@php $pageCount = 1; @endphp

Mira-Bhayandar Municipal Corporation

Muster Report for the month of {{ Carbon\Carbon::parse($toDate)->format('F Y') }}

Page: {{ $pageCount }}

Generated On: {{ Carbon\Carbon::now()->toDateTimeString() }}

@foreach ($empList as $emp) @php $shortDays = 0; $weekOffs = 0; $leaveHalfDays = $emp->punches->where('type', '2')->count(); $latemark = 0; $paidLeaves = $emp->punches->where('is_paid', '1')->whereIn('leave_type_id', ['0', '1', '3', '4', '5', '6', '7'])->count(); $outpostLeaves = $emp->punches->where('leave_type_id', '2')->count(); $holidaysArray = $holidays->pluck('date')->toArray(); $absendDays = 0; $holidayCount = 0; $actualPresent = 0; $latemarkGraceTime = $emp->is_divyang == 'y' ? $settings['PERMANENT_LATE_MARK_TIMING_DIVYANG'] : $settings['PERMANENT_LATE_MARK_TIMING']; @endphp
#{{ $emp->emp_code }} {{ Carbon\Carbon::parse($toDate)->format('F') }} NAME : {{ $emp->name }} OFFICE : {{ $emp->ward?->name }} DEPARTMENT : {{ $emp->department?->name }}
DESIGNATION : {{ $emp->designation?->name }} CLASS : {{ $emp->clas?->name }} Contractor : {{ $emp->contractor?->name }} FROM DATE : {{ $fromDate }} TO DATE : {{ $toDate }}
DAY
IN
OUT
WD
@foreach ($dateRanges as $dateRange) @php $isWeekOff = false; $islate = false; $weekNameColumn = strtolower(substr($dateRange->format('D'), 0, 2)); if($weekNameColumn == 'sa' && $emp->{$weekNameColumn.'_duration'} ) $minCompletionHour = $emp->{$weekNameColumn.'_duration'}; else $minCompletionHour = $emp->work_duration ?? $settings['MIN_COMPLETION_HOUR']; $clonedDate = clone($dateRange); $currentDate = $clonedDate->toDateString(); $nextDate = $clonedDate->addDay()->toDateString(); $hasPunch = 0; $hasShift = 0; if($emp->is_rotational == 0 && $dateRange->isWeekend() && !$emp->{$weekNameColumn.'_duration'}){ $isWeekOff = true; } else { $hasShift = $emp->is_rotational == 0 ? 0 : $emp->empShifts->where('from_date', '>=', $currentDate)->where('from_date', '<', $nextDate)->first(); $isWeekOff = $hasShift && $hasShift->in_time == 'wo' ? true : false; } $hasPunch = $emp->punches->where('punch_date', '>=', $currentDate)->where('punch_date', '<', $nextDate)->first(); $hasLeaveApplied = $emp->punches->where('punch_date', '>=', $currentDate)->where('punch_date', '<', $nextDate)->where('leave_type_id', '!=', null)->first(); @endphp
{{ $dateRange->format('d') }}
{{ substr($dateRange->format('D'), 0, 2) }}
@if($hasLeaveApplied)
{{ $leavesArray[$hasLeaveApplied->leave_type_id] }}
@elseif ($isWeekOff) {{-- @if(!$hasShift && $hasPunch && $hasPunch->punch_by == '0' ) --}} @if($hasPunch && $hasPunch->punch_by == '0' ) @php $actualPresent++; @endphp
{{ Carbon\Carbon::parse($hasPunch->check_in)->format('h:i A') }}
{{ $hasPunch->check_out ? ( Carbon\Carbon::parse($hasPunch->check_out)->gt(Carbon\Carbon::parse($hasPunch->check_in)->addMinutes(5)) ? Carbon\Carbon::parse($hasPunch->check_out)->format('h:i A') : '-' ) : '-' }}
{{ $hasPunch->duration_in_minute }}
@else @php $weekOffs++; @endphp
WEEKOFF
@endif @else @if($hasShift && array_key_exists( $hasShift->in_time, $otherLeavesArray ) ) @php $actualPresent++; @endphp
{{ $otherLeavesArray[$hasShift->in_time] }}
@elseif( in_array( $dateRange->format('Y-m-d'), $holidaysArray ) ) @if($hasPunch && $hasPunch->punch_by == '0') @php $actualPresent++; @endphp
{{ Carbon\Carbon::parse($hasPunch->check_in)->format('h:i A') }}
{{ $hasPunch->check_out ? ( Carbon\Carbon::parse($hasPunch->check_out)->gt(Carbon\Carbon::parse($hasPunch->check_in)->addMinutes(5)) ? Carbon\Carbon::parse($hasPunch->check_out)->format('h:i A') : '-' ) : '-' }}
{{ $hasPunch->duration_in_minute }}
@else @php $holidayCount++; @endphp
HOLIDAY
@endif @elseif (!$hasPunch) @php $absendDays++; @endphp
ABSENT
@elseif ( $hasPunch->punch_by == '2' )
{{ $leavesArray[$hasPunch->leave_type_id] }}
@elseif( $hasPunch->check_in ) @php $actualPresent++; $isNightShift = false; if( $hasShift) { if( Carbon\Carbon::today()->startOfDay()->diffInMinutes(substr($hasPunch->check_in, 11)) > Carbon\Carbon::today()->startOfDay()->diffInMinutes( Carbon\Carbon::parse($hasShift->in_time)->addMinutes($latemarkGraceTime) ) ) { $latemark++; $islate = true; } if($hasShift->is_night == 1) $isNightShift = true; } elseif( $emp->is_rotational == 0 && Carbon\Carbon::today()->startOfDay()->diffInMinutes(substr($hasPunch->check_in, 11)) > Carbon\Carbon::today()->startOfDay()->diffInMinutes( Carbon\Carbon::parse($emp->shift?->from_time ?? $defaultShift['from_time'])->addMinutes($latemarkGraceTime) ) ) { $latemark++; $islate = true; } if( !$isNightShift && $hasPunch->duration < $minCompletionHour) {$shortDays++;} @endphp @if ( $isNightShift ) @php $nextDayPunch = $emp->punches->where('punch_date', '>', $nextDate)->first(); $checkIn = $hasPunch->check_out ?? $hasPunch->check_in; $checkOut = $nextDayPunch ? $nextDayPunch->check_in : ''; $duration = $checkOut ? Carbon\Carbon::parse( $checkIn )->diffInSeconds( $checkOut ) : 0; if($duration < $minCompletionHour) {$shortDays++;} @endphp
{{ Carbon\Carbon::parse($checkIn)->format('h:i A') }}
{{ $checkOut ? Carbon\Carbon::parse($checkOut)->format('h:i A') : '-' }}
{{ gmdate("H:i", $duration) }}
@else
{{ Carbon\Carbon::parse($hasPunch->check_in)->format('h:i A') }}
{{ $hasPunch->check_out ? ( Carbon\Carbon::parse($hasPunch->check_out)->gt(Carbon\Carbon::parse($hasPunch->check_in)->addMinutes(5)) ? Carbon\Carbon::parse($hasPunch->check_out)->format('h:i A') : '-' ) : '-' }}
{{ $hasPunch->duration_in_minute }}
@endif @else
-
-
-
@endif @endif
@endforeach
@foreach ($leaveTypes as $leaveType) @endforeach @foreach ($leaveTypes as $leaveType) @if ($leaveType->id == '6') @else @endif @endforeach
TOT DAY PRES DAY ABS DAY LATE MARK LATE MARK CL HALF-DAY{{ strtoupper($leaveType->name) }}TOT PAID LEAVE WO HOLI
{{ $totalDays }} {{ ($actualPresent+$outpostLeaves) + ($leaveHalfDays/2) }} {{ $absendDays }} {{ $latemark }} {{ floor($latemark/3) }} {{ ($shortDays) }}{{ $emp->punches->where('leave_type_id', $leaveType->id)->count()+($leaveHalfDays/2) }}{{ $emp->punches->where('leave_type_id', $leaveType->id)->count() }}{{ ($paidLeaves-($leaveHalfDays/2)) }} {{ $weekOffs }} {{ $holidayCount }}
@if ($loop->iteration % 3 == 0) @php $pageCount++ @endphp
LATEMARK
WORKING ON WO/HOLI
MANUAL ATT
NIGHT SHIFT

Page: {{ $pageCount }}

Generated On: {{ Carbon\Carbon::now()->toDateTimeString() }}

@endif @endforeach