@php
$totalDays = 0;
$workingDays = 0;
$sundays = 0;
$holidays = 0;
$present = 0; $absent = 0; $lop = 0; $cl = 0; $sl = 0; $pl = 0;
foreach($attendanceMap as $day => $status) {
$totalDays++;
if($status === 'Sunday') {
$sundays++;
} elseif($status === 'Holiday') {
$holidays++;
} else {
$workingDays++;
if($status === 'Present') $present++;
elseif($status === 'Absent') $absent++;
elseif(strtoupper($status) === 'LOP') $lop++;
elseif(strtoupper($status) === 'CL') $cl++;
elseif(strtoupper($status) === 'SL') $sl++;
elseif(strtoupper($status) === 'PL') $pl++;
}
}
// Use pre-calculated OT and Shortage hours from database (passed from controller)
// $otHours and $shortageHours are already calculated in the controller
$totalOt = $otHours ?? 0;
$totalShortage = $shortageHours ?? 0;
// Calculate attendance rate based on working days (excluding Sundays and Holidays)
$attendanceRate = $workingDays > 0 ? round(($present / $workingDays) * 100, 1) : 0;
@endphp
@if(request('employee_id'))
{{ $attendanceRate }}%
Attendance Rate
Present
{{ $present }}
CL (Casual Leave)
{{ $cl }}
SL (Sick Leave)
{{ $sl }}
PL (Privilege Leave)
{{ $pl }}
LOP
{{ $lop }}
Absent
{{ $absent }}
OT Hours
{{ number_format($totalOt, 2) }}
Shortage Hours
{{ number_format($totalShortage, 2) }}
Total Days
{{ $totalDays }}
Sundays (W/OFF)
{{ $sundays }}
Holidays
{{ $holidays }}
Working Days
{{ $workingDays }}
@else
Select an employee to view their monthly summary
@endif