@php
$total = 0;
$totalPresent = 0;
$totalAbsent = 0;
$totalNotMarked = 0;
@endphp
Attendance Report
| Date |
Present |
Absent |
@foreach ($dateRange as $datenew)
| {{ \Carbon\Carbon::create($datenew)->format('d M Y') }} |
@if(in_array(\Carbon\Carbon::create($datenew)->format('Y-m-d'), $holidays))
Holiday
|
@else
@php
$status = '';
$isWeekend = \Carbon\Carbon::create($datenew)->isWeekend(); // Check if the date is a weekend
$attendanceFound = false;
foreach ($attendances as $attendance) {
if (\Carbon\Carbon::create($datenew)->equalTo(\Carbon\Carbon::create($attendance['date_of_attendance']))) {
$attendanceFound = true; // Attendance found for this date
if ($attendance['is_present'] == 1) {
$status = 'Present';
$totalPresent++;
} else {
$status = 'Absent';
$totalAbsent++;
}
break;
}
}
if (!$attendanceFound) {
if ($isWeekend) {
$status = 'Weekend';
} else {
$status = 'Not Marked';
$totalNotMarked++;
}
}
$total++;
@endphp
@if($status == 'Present')
{{$status}} |
|
@elseif($status == 'Absent')
|
{{$status}} |
@elseif($status == 'Weekend')
{{$status}}
|
@else
{{$status}}
|
@endif
@endif
@endforeach