{{ auth()->user()->tenant_name }} - Month Wise Report
{{-- --}}
{{-- --}} {{-- @foreach ($leaveTypes as $leaveType) @endforeach --}} {{-- --}} {{-- --}} @forelse ($empList as $emp) @php $leaveDaysCount = array_fill_keys($leavesArray, []); $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 @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(); $hasLeaveApplied = $emp->punches->where('punch_date', '>=', $currentDate)->where('punch_date', '<', $nextDate)->where('leave_type_id', '!=', null)->first(); if($hasLeaveApplied) { array_push($leaveDaysCount[$leavesArray[$hasLeaveApplied->leave_type_id]], Carbon\Carbon::parse($hasLeaveApplied->punch_date)->toDateString()); } 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 ) ) { $actualPresent++; } elseif (!$hasPunch) { $absendDays++; } elseif ( $hasPunch->punch_by == '2' ){ } elseif( $hasPunch->check_in ) { $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++;} 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) @if ($leaveType->id == '6') @else @endif @endforeach --}} {{-- --}} @if( (($actualPresent+$paidLeaves+$outpostLeaves+($leaveHalfDays/2)) > 0) ) @else @endif {{-- --}} @empty {{-- @foreach ($leaveTypes as $leaveType) @endforeach --}} {{-- --}} @endforelse
Sr No Emp Code Emp Name Department Total Working Days Present Days Late MarksLate Mark CLHalf Day{{ ucfirst($leaveType->name) }}Paid LeavesWeek Offs Holidays Total Present Days Total Absent DaysLeave Dates
{{ $loop->iteration }} {{ $emp->emp_code }} {{ $emp->name }} {{ $emp->department?->name }} {{ $totalDays }} {{ $actualPresent+$outpostLeaves+($leaveHalfDays/2) }} {{ $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 }}{{ ($actualPresent + $weekOffs + $holidayCount + $paidLeaves + $outpostLeaves) }} {{ $absendDays }}0 {{ $totalDays }} @foreach ($leavesArray as $larr) @if ( count($leaveDaysCount[$larr]) > 0 ) {{$larr}} => @foreach ($leaveDaysCount[$larr] as $ld) {{ $ld }}, @endforeach
@endif @endforeach
{{-- Show More Info Modal --}}
{{-- --}} {{-- Get month wise date --}} {{-- --}}