Attendance Report
{{ $employee->name ?? 'Employee' }} (Primary ID: {{ $employee->primary_id ?? '-' }}, Emp ID: {{ $employee->e_id ?? '-' }})
{{-- ========================================== Attendance Statistics Summary Cards ========================================== --}}
Total Days
{{ $totalDays }}
Present
{{ $presentDays }}
Absent
{{ $absentDays }}
Late / Partial
{{ $partialDays }}
Leave
{{ $leaveDays }}
Off Day
{{ $offDays }}
Total Worked Hours: @php $workH = floor($totalWorkedMinutes / 60); $workM = $totalWorkedMinutes % 60; @endphp {{ $workH }}h {{ $workM }}m
Attendance Rate: {{ $attendanceRate }}%
{{-- ========================================== Filter Form (Auto-Filtering Enabled) ========================================== --}}
{{-- Date Preset Filter --}}
{{-- From Date --}}
{{-- To Date --}}
{{-- Status Filter --}}
{{-- Dynamic Records Per Page --}}
{{-- Reset Filter Button --}}
{{-- ========================================== Attendance Detailed Table (Shift-Wise In/Out) ========================================== --}}
@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 {{-- Morning In, Out, Late --}} {{-- Day In, Out, Late --}} {{-- Total Worked Hours --}} {{-- Status --}} @empty @endforelse
SL Date Day Morning Shift Day Shift Worked Status
In Out Late In Out Late
{{ $attendances->firstItem() + $index }} {{ $attDate ? $attDate->format('d M, Y') : '-' }} {{ $attDate ? $attDate->format('l') : '-' }} {{ $mIn ?? '-' }} {{ $mOut ?? '-' }} @if($mLate > 0) {{ $mLate }}m @else - @endif {{ $dIn ?? '-' }} {{ $dOut ?? '-' }} @if($dLate > 0) {{ $dLate }}m @else - @endif @if($workedDisplay !== '-') {{ $workedDisplay }} @else - @endif @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
No attendance records found for this period.
{{-- Pagination & Records Info --}}
Showing {{ $attendances->firstItem() ?? 0 }} to {{ $attendances->lastItem() ?? 0 }} of {{ $attendances->total() }} records
@if($attendances->hasPages())
{{ $attendances->withQueryString()->links() }}
@endif
{{-- Tab-specific Auto Filter Event Script --}}