IMMREX7
<!DOCTYPE html>
<html>
<head>
<!-- <meta charset="utf-8"> -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>School MIS</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
<style type="text/css">
@page {
header: page-header;
footer: page-footer;
margin-top: 20pt;
margin-bottom: 10px;
}
section{
}
td.border_bottom{
border-bottom: 1pt solid black;
}
td {
padding-top: .5em;
white-space: nowrap;
padding-bottom: .5em;
}
body {
font-family: 'examplefont', sans-serif;
}
.page-break {
page-break-after: always;
}
table {
border-collapse: collapse;
}
</style>
</head>
<?php
$weekMap = [
0 => 'Sun',
1 => 'Mon',
2 => 'Tue',
3 => 'Wed',
4 => 'Thu',
5 => 'Fri',
6 => 'Sat',
];
?>
<body>
<!--<htmlpageheader name="page-header" >-->
<table class="table" style="width:100%;">
<tbody>
<tr>
<th style="padding: 0px;text-align: center; "><?php echo e($school->schoolName); ?> <br> <span style="font-size:12px;text-decoration:underline;"> Monthly Attendence Record for the month of <?php echo e($month->monthName); ?>-<?php echo e($y); ?> </span></th>
</tr>
</tbody>
</table>
<!--</htmlpageheader>-->
<section>
<?php $page = 1; ?>
<?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php
$total_present = 0;
$total_absent = 0;
$total_holiday = 0;
$incomplete = 0;
$total = 0;
$week_off = 0;
$service = [];
$status = [];
$presentWeek = [];
$isIncomplete = [];
$data["half_day"] = 0;
$data["late_in"] = 0;
$data["early"] = 0;
$data["present"] = 0;
$data["holiday"] = 0;
$data["week"] = 0;
$data["leave"] = 0;
$data["absent"] = 0;
$data["incomplete"] = 0;
$data["paid_leave"] = 0;
$data["salary"] = 0;
$data["idEmployee"] = $emp->idEmployee;
$data["loan"] = 0;
$data["prev"] = 0;//previous month leave
$data["current"] = 0; //current month leave
$data["total"] = 0; //total leave taken
$data["balance"] = 0; //balance leave available
$data["leave_count"] = 0; //no of leave taken and leave marked
$data["deduction"] = 0; // deduction based on leave
$data["salary_deduction"] = 0; //salary deduction
$data["gross_salary"] = 0; //salary to be paid
$totalLateDays = 0;
$totalEarlyDays = 0;
$allowedLateMinutes = 0;
$allowedEarlyMinutes = 0;
$totalLateDays = 0;
$totalEarlyDays = 0;
$empDays = [];
$chDays = [];
$school = \App\School::where('idSchool',$emp->idSchool)->first();
//check total leave
$designationYearWise = \App\LeaveMaster::where('idSchool', '=', $emp->idSchool)
->where('idDesignation', $emp->idDesignation)
->where('idFinancialYear', $fy)
->where('leaveType', "yearly")
->whereNull('idEmployee')
->sum('paidLeaves');
$paidYearLeaves = \App\LeaveMaster::where('idSchool', '=', $emp->idSchool)
->where('idDesignation', $emp->idDesignation)
->where('idEmployee', $emp->idEmployee)
->where('idFinancialYear', $fy)
->where('leaveType', "yearly")
->sum('paidLeaves');
$designationMonthWise = \App\LeaveMaster::where('idSchool', '=', $emp->idSchool)
->where('idDesignation', $emp->idDesignation)
->where('idFinancialYear', $fy)
->where('leaveType', "monthly")
->whereNull('idEmployee')
->sum('paidLeaves') * 12;
$paidMonthLeaves = \App\LeaveMaster::where('idSchool', '=', $emp->idSchool)
->where('idDesignation', $emp->idDesignation)
->where('idEmployee', $emp->idEmployee)
->where('idFinancialYear', $fy)
->where('leaveType', "monthly")
->sum('paidLeaves') * 12;
//calculate allowed leave in a finanacial year
$totalLeave = $designationYearWise + $paidYearLeaves + $designationMonthWise + $paidMonthLeaves;
//check for total leave taken added in master
$leaveBalance = DB::table('leave_balance_master')->where('idSchool', '=', $emp->idSchool)
->where('idDesignation', $emp->idDesignation)
->where('idFinancialYear', $fy)
->whereNull('idEmployee')->sum('balance') + DB::table('leave_balance_master')->where('idSchool', '=', $emp->idSchool)
->where('idEmployee', $emp->idEmployee)
->where('idFinancialYear', $fy)->sum('balance');
$leaveMaster = fetchLeaveMaster($emp,$fy);
for ($i = 1; $i <= $noOfdays; $i++) {
$dt = $i . '-' . $m . '-' . $y;
$tdate = \Carbon\Carbon::parse($dt);
$now = \Carbon\Carbon::now();
$jdate = $tdate->format('Y-m-d');
$cdate = intval($tdate->format('d'));
$length = $tdate->diffInDays($now);
$otHr = 0;
$otAmount = 0;
//check for holiday
$holiday = getHoliday($emp,$jdate);
$shifts = fetchShift($emp,$jdate);
$dayNight = "AM";
$nightDay = "AM";
$isPaidLeaveMaster = "N";
$isLeaveMaster = "N";
$empDays[$cdate] = "A";
$status[$cdate] = "A";
$delay[$cdate] = "";
if($shifts != null && $holiday == null){
$dayNight = strtoupper($shifts->shift_from);
$nightDay = strtoupper($shifts->shift_to);
$arrival = checkArrival($emp,$jdate,$shifts,$school,$dayNight,$fy,$allowedLateMinutes,$totalLateDays);
$departure = checkDeparture($emp,$jdate,$shifts,$school,$nightDay,$fy,$allowedEarlyMinutes,$totalEarlyDays);
$overtime = fetchOvertime($emp,$shifts,$dayNight,$nightDay,$school,$jdate,$fy);
$totalEarlyDays = $departure['days'];
$totalLateDays = $arrival['days'];
$aintime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $tdate)
->where('status', '=', 'IN')
->where('idType', '=', 'A')
->first();
$aouttime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $tdate)
->where('status', '=', 'OUT')
->where('idType', '=', 'A')
->first();
if($aintime != null && $aouttime != null){
$arrivalTime = Carbon\Carbon::parse(explode(" ",$aintime->TimeStamp)[1]);
$departureTime = Carbon\Carbon::parse(explode(" ",$aouttime->TimeStamp)[1]);
$total = $total + $arrivalTime->diffInSeconds($departureTime);
}
if(fetchPaidLeave($jdate,$emp) == 1){
$isPaidLeaveMaster = "Y";
}else
if($leaveMaster != null){
if($leaveMaster->leave_allocation == "A"){
$monthV = \App\Month::where('monthName', '=', $tdate->format('F'))->first();
if($cdate > 1 && $cdate < $noOfdays){
if(isset($leaveMaster->exclude_month)){
$monthV = \App\Month::where('monthName',$tdate->format('F'))->whereIn('idMonth',json_decode($leaveMaster->exclude_month,true))->get();
if(count($monthV) == 0){
//check for sandwich leave
if($holiday != null){
if(checkForSandwich($emp,$leaveMaster->sandwich,$empDays,$tdate,$cdate,$school) == 1){
$isLeaveMaster = "Y";
}
}
if($shifts->weekOff == "Y"){
if(checkForSandwich($emp,$leaveMaster->sandwich,$empDays,$tdate,$cdate,$school) == 1){
$isLeaveMaster = "Y";
}
}
}
}else{
//check for sandwich leave
}
}
}
}
}
$nonPaidLeave = DB::table('employee_leave')
->whereDate('leave_from', '<=', $jdate)
->whereDate('leave_to', '>=', $jdate)
->where('idEmployee', $emp->idEmployee)
->where('status' ,'!=', 'Approve with PL(Paid Leave)')
->first();
if($nonPaidLeave != null){
$data["leave"]++;
$empDays[$cdate] = "A";
}else if($isPaidLeaveMaster == "Y"){
$data["current"]++;
$data["paid_leave"]++;
$empDays[$cdate] = "P";
$status[$cdate] = "P";
}else{
if($isLeaveMaster == "Y" && $shifts != null){
$data["absent"]++;
$empDays[$cdate] = "A";
}else{
if($holiday != null){
$data["holiday"]++;
$empDays[$cdate] = "H";
$status[$cdate] = "H";
}else{
if($shifts != null){
if($shifts->weekOff == "Y"){
$data["week"]++;
$empDays[$cdate] = "H";
$status[$cdate] = "W";
}else{
$empDays[$cdate] = "P";
$status[$cdate] = "P";
if(isset($shifts->fromTime) && isset($shifts->toTime)){
if($arrival['status'] == "A"){
$data["absent"]++;
$empDays[$cdate] = "A";
$status[$cdate] = "A";
}else if($departure['status'] == "A"){
$data["absent"]++;
$empDays[$cdate] = "A";
$status[$cdate] = "A";
}else if($arrival['status'] == "I" && $departure['status'] == "I"){
$data["absent"]++;
$empDays[$cdate] = "A";
$status[$cdate] = "A";
}else if($arrival['status'] == "I" || $departure['status'] == "I"){
$data["incomplete"]++;
$status[$cdate] = "I";
if($departure['status'] == "HF" || $arrival['status'] == "HF"){
$data["half_day"]++;
}
}else if($departure['status'] == "P" && $arrival['status'] == "P"){
$data["present"]++;
$status[$cdate] = "P";
}else if( ( $departure['status'] == "LT" || $departure['status'] == "P") && ( $arrival['status'] == "LT" || $arrival['status'] == "P")){
$data["present"]++;
$status[$cdate] = "P";
}else if($departure['status'] == "HF" || $arrival['status'] == "HF"){
$data["half_day"]++;
$status[$cdate] = "HF";;
}
if($arrival['status'] == "LT" || $departure['status'] == "LT") {
$data["late_in"]++;
if($departure['status'] == "LT")
$status[$cdate] = "EG";
else
$status[$cdate] = "LT";
if(array_key_exists("before",$departure))
$delay[$cdate] = $departure["before"];
elseif(array_key_exists("time",$arrival))
$delay[$cdate] = $arrival["time"];
}
if($departure['status'] == "HF" || $arrival['status'] == "HF") {
$data["early"]++;
$status[$cdate] = "HF";
if(array_key_exists("before",$departure))
$delay[$cdate] = $departure["before"];
elseif(array_key_exists("time",$arrival))
$delay[$cdate] = $arrival["time"];
}
if($overtime['status'] == "Y"){
$otHr = $otHr + $overtime['otHour'];
$otAmount = $otAmount + $overtime['otEarning'];
}
}
}
}
}
}
}
}
$adjustAbsent = 0;
if($leaveMaster != null){
if($leaveMaster->leave_allocation == "A"){
if(isset($leaveMaster->max_allowed)){
if($data["paid_leave"] < $leaveMaster->max_allowed){
$balnceLeave = $leaveMaster->max_allowed - $data["paid_leave"];
if( $balnceLeave > 0 && $balnceLeave < $data["absent"]){
$adjustAbsent = $balnceLeave;
$data["paid_leave"] = $data["paid_leave"] + $balnceLeave;
}else{
$adjustAbsent = $data["absent"];
$data["paid_leave"] = $data["paid_leave"] + $data["absent"];
}
}
}
}
}
$data["absent"] = $data["absent"] - $adjustAbsent;
?>
<div class="content">
<table cellpadding="5" style="width:100% ;font-size:12px;text-align: left;border:1px solid;">
<tbody>
<tr>
<td colspan="2">Employee: (<?php echo e($emp->enrollmentNo); ?>) <?php echo e($emp->firstName); ?> <?php echo e($emp->middleName); ?> <?php echo e($emp->lastName); ?></td>
<td></td>
</tr>
<tr>
<?php $department = \App\Department::where('idDepartment',$emp->idDepartment)->first(); ?>
<td>Department : <?php if($department != null): ?><?php echo e($department->departmentName); ?> <?php endif; ?></td>
<td>Category : </td>
<td>Gender : <?php echo e($emp->gender); ?></td>
</tr>
<tr>
<?php $designation = \App\Designation::where('idDesignation',$emp->idDesignation)->first(); ?>
<td>Designation: <?php if($designation != null): ?> <?php echo e($designation->designationName); ?> <?php endif; ?> </td>
<td>Grade</td>
<td></td>
</tr>
<tr>
<td>Location: </td>
<td>Group</td>
<td></td>
</tr>
<tr>
<td>Location: </td>
<td>Group</td>
<td></td>
</tr>
</tbody>
</table>
<table cellpadding="5" style="width:100%;font-size:10px;">
<tbody>
<tr>
<td style="border:1px solid;text-align: center;">CARD ID <br> <?php echo e(ltrim($emp->enrollmentNo, '0')); ?></td>
<td style="border:1px solid;text-align: center;">
<table cellpadding="5" >
<tr>
<td>Present <br> Days</td>
<td>Holiday <br> Off</td>
<td>Leave</td>
<td>Week <br> Off</td>
<td>Absent</td>
<td>*</td>
<td>Total <br> Days</td>
<td>Paid <br> Days</td>
</tr>
<tr>
<td><?php echo e($data["present"] + ($data["half_day"]/2)); ?></td>
<td><?php echo e($data["holiday"]); ?></td>
<td><?php echo e($data["paid_leave"]); ?></td>
<td><?php echo e($data["week"]); ?></td>
<td><?php echo e($data["absent"]); ?></td>
<td>0</td>
<td><?php echo e($noOfdays); ?></td>
<td><?php echo e($data["present"] +$data["holiday"] + $data["week"] + $data["paid_leave"] + ($data["half_day"]/2)); ?></td>
</tr>
</table>
</td>
<?php
$hours = floor($total / 3600);
$minutes = floor(($total / 60) % 60);
?>
<td><span>O.T. 0.00 </span><br> Work Hour: <?php echo e($hours.':'.$minutes); ?></td>
<td style="border:1px solid;text-align: left;">Late In/Early Out: <?php echo e($data["early"]); ?><br> Miss Punches: <?php echo e($data["incomplete"]); ?><br>Late Coming: <?php echo e($data["late_in"]); ?></td>
</tr>
</tbody>
</table>
<table cellpadding="5" style="width:100%;font-size:10px;text-align: left;border:1px solid;">
<tbody>
<tr>
<td class="border_bottom">Day</td>
<td class="border_bottom">Shift</td>
<td class="border_bottom">System <br> <span> IN </span> <span style="margin-left:2px;"> OUT </span></td>
<td class="border_bottom">Manual <br> <span> IN </span> <span style="margin-left:2px;"> OUT </span></td>
<td class="border_bottom">Less <br>Hr</td>
<td class="border_bottom">Extra <br>Hr</td>
<td class="border_bottom">LC /EG</td>
<td class="border_bottom">OUT Door</td>
<td class="border_bottom">Approved</td>
<td class="border_bottom">Present</td>
<td class="border_bottom">Status</td>
<td class="border_bottom">Error<br>Message</td>
<td class="border_bottom">Reason</td>
<td class="border_bottom">Leave</td>
<td class="border_bottom">Allow.</td>
</tr>
<?php for($i = 1; $i <= $noOfdays; $i++): ?>
<tr >
<?php $dt = $i . '-' . $m . '-' . $y;
$tdate = \Carbon\Carbon::parse($dt);
$cdate = intval($tdate->format('d'));
$emp_shift = \App\AssignShift::where('idEmployee', '=', $emp->idEmployee)->first();
$shifts = null;
$dayNight = "AM";
$nightDay = "AM";
$doSpecialShiftExisits = DB::table('special_shifts')->where('idEmployee', '=', $emp->idEmployee)->where('shift_date',$tdate->format('Y-m-d'))->where('type','S')->first();
if(isset($emp_shift->idShift)){
$shifts = DB::table('shift_details')
->where('idShift', '=', $emp_shift->idShift)
->where('idWeekday', '=', $tdate->dayOfWeek)
->first();
if($doSpecialShiftExisits != null){
if($shifts != null){
$specialShift = explode("-",$doSpecialShiftExisits->shift_time);//shift_time
$shifts->fromTime = explode(" ",$specialShift[0])[0];
$shifts->shift_from = explode(" ",$specialShift[0])[1];
$shifts->toTime = explode(" ",$specialShift[1])[0];
$shifts->shift_to = explode(" ",$specialShift[1])[1];
$presentWeek[$tdate->format('Y-m-d')] = 1;
}
}
}
if($shifts == null && $doSpecialShiftExisits != null){
$shifts = new \App\ShiftDetail();
$specialShift = explode("-",$doSpecialShiftExisits->shift_time);//shift_time
$shifts->fromTime = explode(" ",$specialShift[0])[0];
$shifts->shift_from = explode(" ",$specialShift[0])[1];
$shifts->toTime = explode(" ",$specialShift[1])[0];
$shifts->shift_to = explode(" ",$specialShift[1])[1];
$presentWeek[$tdate->format('Y-m-d')] = 1;
}
if($shifts != null){
if($shifts->shift_from == "pm")
$dayNight = "PM";
if($shifts->shift_to == "pm")
$nightDay = "PM";
}
$aintime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $tdate)
->where('status', '=', 'IN')
->where('idType', '=', 'A')
->first();
$aouttime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $tdate)
->where('status', '=', 'OUT')
->where('idType', '=', 'A')
->first();
$a_mat = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('idSchool', '=', $school->idSchool)
->whereDate('date', '=', $tdate)
->where('idType', '=', 'M')
->first();
if($doSpecialShiftExisits != null){
if($doSpecialShiftExisits->is_night == "Y"){
$nextDay = \Carbon\Carbon::parse($tdate->format('Y-m-d'))->addDays(1)->format('Y-m-d');
$aintime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $tdate)
->where('status', '=', 'OUT')
->where('idType', '=', 'A')
->first();
$aouttime = \App\EmpAttendance::where('Enrollment_Number', '=', $emp->enrollmentNo)
->where('Device_ID', '=', $school->Device_ID)
->whereDate('date', '=', $nextDay)
->where('status', '=', 'IN')
->where('idType', '=', 'A')
->first();
}
}
?>
<td class="border_bottom"><?php echo e($i); ?> <?php echo e($weekMap[\Carbon\Carbon::parse($dt)->dayOfWeek]); ?></td>
<td class="border_bottom">
<?php if($shifts != null): ?>
<?php if($shifts->fromTime != "" && $shifts->toTime != ""): ?>
<?php echo e(\Carbon\Carbon::parse($shifts->fromTime.' '.$dayNight)->format('H:i')); ?> - <?php echo e(\Carbon\Carbon::parse($shifts->toTime.' '.$nightDay)->format('H:i')); ?>
<?php else: ?>
-
<?php endif; ?>
<?php else: ?> -
<?php endif; ?></td>
<td class="border_bottom">
<?php if($aintime): ?>
<?php echo e(\Carbon\Carbon::parse(explode(" ",$aintime->TimeStamp)[1])->format('H:i')); ?>
<?php endif; ?>
<?php if($aouttime): ?>
<?php echo e(\Carbon\Carbon::parse(explode(" ",$aouttime->TimeStamp)[1])->format('H:i')); ?>
<?php endif; ?>
</td>
<td class="border_bottom"></td>
<td class="border_bottom"></td>
<td class="border_bottom">-</td>
<td class="border_bottom"><?php if($delay[$cdate] != ""): ?><?php echo e(gmdate('H:i', $delay[$cdate])); ?> <?php endif; ?></td>
<td class="border_bottom">No</td>
<td class="border_bottom">No</td>
<td class="border_bottom">
<?php if($status[$cdate] == "A"): ?>
0.0
<?php else: ?>
<?php if($status[$cdate] == "P" || $status[$cdate] == "W" || $status[$cdate] == "H" || $status[$cdate] == "LT"): ?>
1.0
<?php else: ?>
<?php if($status[$cdate] == "HF"): ?>
0.5
<?php else: ?>
0.0
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</td>
<td class="border_bottom">
<?php if($status[$cdate] == "W"): ?>
WO
<?php else: ?>
<?php if($status[$cdate] == "H"): ?>
HO
<?php else: ?>
<?php if($status[$cdate] == "A"): ?>
AB
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</td>
<td class="border_bottom">
<?php if($status[$cdate] == "I"): ?>
MP
<?php else: ?>
<?php if($status[$cdate] == "HF"): ?>
LC/EG
<?php endif; ?>
<?php if($status[$cdate] == "LT"): ?>
LC
<?php endif; ?>
<?php if($status[$cdate] == "EG"): ?>
EG
<?php endif; ?>
<?php endif; ?>
</td>
<td class="border_bottom"></td>
<td class="border_bottom"></td>
<td class="border_bottom"></td>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
<?php if($page == 1): ?>
<p style="font-size:10px;text-align: left;">Note : * Late Coming, STATUS : EG: Early Going , LC: Late Coming , AB: Absent , WO: Weekly Off , HO: Holiday</p>
<?php else: ?>
<p style="font-size:10px;text-align: left;">Note : * Late Coming</p>
<p style="font-size:10px;text-align: left;">STATUS : EG: Early Going , LC: Late Coming , AB: Absent , WO: Weekly Off , HO: Holiday</p>
<?php endif; ?>
<?php if($page < count($employees)): ?>
<div class="page-break"></div>
<?php endif; ?>
<?php $page++;?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</section>
<htmlpagefooter name="page-footer" >
</htmlpagefooter>
</body>
</html>
Copyright © 2021 -