@extends('layouts.app') @section('title', 'My Attendance') @section('page-title', 'My Attendance') @section('content')
{{-- Month Selector --}}
{{-- Stats Cards --}}

Attendance Rate

{{ $stats['percentage'] }}%

Present

{{ $stats['present'] }}

of {{ $stats['total'] }} days

Absent

{{ $stats['absent'] }}

Late / Half Day

{{ $stats['late'] + $stats['half_day'] }}

{{-- Calendar View --}}

{{ \Carbon\Carbon::parse($month)->format('F Y') }}

{{-- Day headers --}}
@foreach(['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] as $day)
{{ $day }}
@endforeach
{{-- Calendar grid --}}
@php $firstDay = $startDate->copy()->startOfMonth(); $lastDay = $startDate->copy()->endOfMonth(); $startPadding = $firstDay->dayOfWeek; // 0=Sun @endphp {{-- Empty cells for padding --}} @for($i = 0; $i < $startPadding; $i++)
@endfor {{-- Day cells --}} @for($day = 1; $day <= $lastDay->day; $day++) @php $dateStr = $startDate->format('Y-m') . '-' . str_pad($day, 2, '0', STR_PAD_LEFT); $dateObj = \Carbon\Carbon::parse($dateStr); $attendance = $attendances->get($dateStr); $isSunday = $dateObj->isSunday(); $isFuture = $dateObj->isFuture(); $isToday = $dateObj->isToday(); $bgClass = 'bg-gray-50 text-gray-400'; // default (no data) $icon = ''; if ($isSunday) { $bgClass = 'bg-gray-100 text-gray-300'; } elseif ($isFuture) { $bgClass = 'bg-gray-50 text-gray-300'; } elseif ($attendance) { $bgClass = match($attendance->status) { 'present' => 'bg-green-50 text-green-700 ring-1 ring-green-200', 'absent' => 'bg-red-50 text-red-700 ring-1 ring-red-200', 'late' => 'bg-yellow-50 text-yellow-700 ring-1 ring-yellow-200', 'half_day' => 'bg-orange-50 text-orange-700 ring-1 ring-orange-200', 'excused' => 'bg-blue-50 text-blue-700 ring-1 ring-blue-200', default => 'bg-gray-50 text-gray-400', }; $icon = match($attendance->status) { 'present' => '✅', 'absent' => '❌', 'late' => '⏰', 'half_day' => '🕐', 'excused' => '📋', default => '', }; } @endphp
{{ $day }} @if($icon) {{ $icon }} @endif @if($isSunday && !$isFuture) OFF @endif
@endfor
{{-- Legend --}}
✅ Present ❌ Absent ⏰ Late 🕐 Half Day 📋 Excused
{{-- Daily Log --}} @if($attendances->isNotEmpty())

Daily Log

@foreach($attendances->sortByDesc(fn($a) => $a->date) as $a) @php $statusColors = [ 'present' => 'bg-green-100 text-green-700', 'absent' => 'bg-red-100 text-red-700', 'late' => 'bg-yellow-100 text-yellow-700', 'half_day' => 'bg-orange-100 text-orange-700', 'excused' => 'bg-blue-100 text-blue-700', ]; @endphp
{{ $a->date->format('D, d M') }} {{ ucfirst($a->status) }}
@if($a->remarks) {{ $a->remarks }} @endif
@endforeach
@endif
@endsection