{{-- ==========================================
Attendance Statistics Summary Cards
========================================== --}}
Total Days
{{ $totalDays }}
Present
{{ $presentDays }}
Late / Partial
{{ $partialDays }}
Total Worked Hours:
@php
$workH = floor($totalWorkedMinutes / 60);
$workM = $totalWorkedMinutes % 60;
@endphp
{{ $workH }}h {{ $workM }}m
Attendance Rate:
{{ $attendanceRate }}%
{{-- ==========================================
Filter Form (Auto-Filtering Enabled)
========================================== --}}
{{-- ==========================================
Attendance Detailed Table (Shift-Wise In/Out)
========================================== --}}
| SL |
Date |
Day |
Morning Shift |
Day Shift |
Worked |
Status |
| In |
Out |
Late |
In |
Out |
Late |
@forelse($attendances as $index => $attendance)
@php
$dateStr = $attendance->date ? \Carbon\Carbon::parse($attendance->date)->toDateString() : null;
$attDate = $attendance->date ? \Carbon\Carbon::parse($attendance->date) : null;
$dateShifts = isset($shiftSummariesByDate) ? ($shiftSummariesByDate->get($dateStr) ?? collect()) : collect();
$morningShift = $dateShifts->first(fn($s) => str_contains(strtolower($s->shift->name ?? ''), 'morning'));
$dayShift = $dateShifts->first(fn($s) => str_contains(strtolower($s->shift->name ?? ''), 'day'));
// Morning Times
$mIn = $morningShift?->in_time ? \Carbon\Carbon::parse($morningShift->in_time)->format('h:i A') : null;
$mOut = $morningShift?->out_time ? \Carbon\Carbon::parse($morningShift->out_time)->format('h:i A') : null;
$mLate = (int) ($morningShift?->late_minutes ?? 0);
// Day Times
$dIn = $dayShift?->in_time ? \Carbon\Carbon::parse($dayShift->in_time)->format('h:i A') : null;
$dOut = $dayShift?->out_time ? \Carbon\Carbon::parse($dayShift->out_time)->format('h:i A') : null;
$dLate = (int) ($dayShift?->late_minutes ?? 0);
// Fallback if ShiftSummary table was not generated for this day but daily in/out exists
if (!$morningShift && !$dayShift && ($attendance->in_time || $attendance->out_time)) {
$empShiftName = strtolower($employee->shift->name ?? '');
$genIn = $attendance->in_time ? \Carbon\Carbon::parse($attendance->in_time)->format('h:i A') : '-';
$genOut = $attendance->out_time ? \Carbon\Carbon::parse($attendance->out_time)->format('h:i A') : '-';
$genLate = (int) ($attendance->late_minutes ?? 0);
if (str_contains($empShiftName, 'morning')) {
$mIn = $genIn;
$mOut = $genOut;
$mLate = $genLate;
} else {
$dIn = $genIn;
$dOut = $genOut;
$dLate = $genLate;
}
}
$workedM = (int) ($attendance->worked_minutes ?? (($morningShift?->worked_minutes ?? 0) + ($dayShift?->worked_minutes ?? 0)));
$workedDisplay = $workedM > 0 ? (floor($workedM / 60) . 'h ' . ($workedM % 60) . 'm') : '-';
$attStatus = strtolower((string) ($attendance->attendance_status ?? ''));
@endphp
| {{ $attendances->firstItem() + $index }} |
{{ $attDate ? $attDate->format('d M, Y') : '-' }}
|
{{ $attDate ? $attDate->format('l') : '-' }}
|
{{-- Morning In, Out, Late --}}
{{ $mIn ?? '-' }} |
{{ $mOut ?? '-' }} |
@if($mLate > 0)
{{ $mLate }}m
@else
-
@endif
|
{{-- Day In, Out, Late --}}
{{ $dIn ?? '-' }} |
{{ $dOut ?? '-' }} |
@if($dLate > 0)
{{ $dLate }}m
@else
-
@endif
|
{{-- Total Worked Hours --}}
@if($workedDisplay !== '-')
{{ $workedDisplay }}
@else
-
@endif
|
{{-- Status --}}
@if($attStatus === 'present')
Present
@elseif($attStatus === 'absent')
Absent
@elseif($attStatus === 'partial')
Late / Partial
@elseif($attStatus === 'leave')
Leave
@elseif(in_array($attStatus, ['off_day', 'holiday', 'weeklyoff'], true))
Off Day
@else
{{ ucfirst($attStatus ?: 'N/A') }}
@endif
|
@empty
|
No attendance records found for this period.
|
@endforelse
{{-- Pagination & Records Info --}}
Showing {{ $attendances->firstItem() ?? 0 }} to {{ $attendances->lastItem() ?? 0 }} of {{ $attendances->total() }} records
@if($attendances->hasPages())
{{ $attendances->withQueryString()->links() }}
@endif