@extends('layouts.app') @section('title', $employee->full_name . ' — Attendance History') @section('breadcrumbs') @endsection @section('content')
{{-- Employee Header --}}
@if($employee->profile_photo) @else {{ strtoupper(substr($employee->first_name, 0, 1) . substr($employee->last_name, 0, 1)) }} @endif

{{ $employee->full_name }}

{{ $employee->employee_code }} · {{ $employee->department?->name ?? 'No Department' }} · {{ $employee->designation?->name ?? '' }}

{{-- Month/Year Selector --}}
Export
{{-- Summary Cards --}}
{{ $summary['present'] }}
Present
{{ $summary['absent'] }}
Absent
{{ $summary['half_day'] }}
Half Day
{{ $summary['leave'] }}
Leave
{{ $summary['late_days'] }}
Late Days
{{ $summary['total_hours'] }}h
Total Hours
{{ $summary['total_overtime'] }}h
Overtime
{{-- Calendar Grid --}}

{{ \Carbon\Carbon::createFromDate($year, $month, 1)->format('F Y') }} Calendar

Present Absent Leave/Half Weekend Late
{{-- Day headers --}} @foreach(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] as $dayName)
{{ $dayName }}
@endforeach {{-- Empty cells for start of month --}} @for($i = 0; $i < $startOfMonth->dayOfWeek; $i++)
@endfor {{-- Day cells --}} @for($day = 1; $day <= $daysInMonth; $day++) @php $dateKey = \Carbon\Carbon::createFromDate($year, $month, $day)->format('Y-m-d'); $record = $records->get($dateKey); $bgClass = 'bg-gray-50'; $textClass = 'text-gray-600'; $dotClass = ''; if ($record) { switch ($record->status) { case 'present': $bgClass = $record->is_late ? 'bg-orange-100 border border-orange-300' : 'bg-success-100 border border-success-500/30'; $textClass = $record->is_late ? 'text-orange-700' : 'text-success-700'; break; case 'absent': $bgClass = 'bg-danger-100 border border-danger-500/30'; $textClass = 'text-danger-600'; break; case 'half_day': $bgClass = 'bg-warning-100 border border-warning-500/30'; $textClass = 'text-warning-700'; break; case 'leave': $bgClass = 'bg-primary-100 border border-primary-500/30'; $textClass = 'text-primary-700'; break; case 'weekend': case 'holiday': $bgClass = 'bg-gray-100'; $textClass = 'text-gray-400'; break; } } @endphp
{{ $day }}
@endfor
{{-- Detailed Records Table --}}

Daily Records

@for($day = 1; $day <= $daysInMonth; $day++) @php $dateObj = \Carbon\Carbon::createFromDate($year, $month, $day); $dateKey = $dateObj->format('Y-m-d'); $record = $records->get($dateKey); if ($dateObj->isFuture()) continue; @endphp @endfor
Date Clock In Clock Out Hours Overtime Status Late Source
{{ $dateObj->format('d M, D') }} @if($record && $record->clock_in) {{ $record->formatted_clock_in }} @else @endif {{ $record ? $record->formatted_clock_out : '—' }} {{ $record ? $record->formatted_total_hours : '—' }} {{ $record && $record->overtime_hours > 0 ? $record->overtime_hours . 'h' : '—' }} @if($record) {{ $record->status_label }} @else @endif @if($record && $record->is_late) {{ $record->late_minutes }}m @else @endif {{ $record ? $record->source_label : '—' }}
@endsection