{{ auth()->user()->tenant_name }} - Emp Leaves Count Report
{{-- --}}
@foreach ($leaveTypes as $leaveType) @endforeach @forelse ($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['LATE_MARK_TIMING_DIVYANG'] : $settings['LATE_MARK_TIMING']; @endphp @foreach ($dateRanges as $dateRange) @php $isWeekOff = 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(); if($hasPunch && $hasPunch->punch_by == '2') { } elseif ($isWeekOff) { if(!$hasShift && $hasPunch && $hasPunch->punch_by == '0') { $actualPresent++; } else { $weekOffs++; } } else { if ( in_array( $dateRange->format('Y-m-d'), $holidaysArray ) ) { if($hasPunch && $hasPunch->punch_by == '0'){ $actualPresent++; } else { $holidayCount++; } } elseif($hasShift && array_key_exists( $hasShift->in_time, $otherLeavesArray ) ) { } elseif (!$hasPunch) { } elseif ( $hasPunch->punch_by == '2' ){ } elseif( $hasPunch->check_in ) { $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++;} if( $isNightShift ) { $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 @endforeach @foreach ($leaveTypes as $leaveType) @endforeach @empty @foreach ($leaveTypes as $leaveType) @endforeach @endforelse
Sr No Emp Code Emp Name Department Late Marks Late Mark CL Short Day{{ ucfirst($leaveType->name) }} Applied {{ ucfirst($leaveType->name) }} Approved {{ ucfirst($leaveType->name) }} RejectedWeek Offs Holidays
{{ $loop->iteration }} {{ $emp->emp_code }} {{ $emp->name }} {{ $emp->department?->name }} {{ $latemark }} {{ floor($latemark/3) }} {{ ($shortDays) }}{{ $emp->leaveRequests->where('leave_type_id', $leaveType->id)->whereIn('is_approved', ['0','1','2'])->sum('no_of_days') }} {{ $emp->leaveRequests->where('leave_type_id', $leaveType->id)->where('is_approved', '1')->sum('no_of_days') }} {{ $emp->leaveRequests->where('leave_type_id', $leaveType->id)->where('is_approved', '2')->sum('no_of_days') }}{{ $weekOffs }} {{ $holidayCount }}
{{-- Show More Info Modal --}}
{{-- Get month wise date --}} {{-- --}}