@php use App\Enums\AttendanceStatus; use Carbon\Carbon; @endphp
{{-- Attendance Statistics Cards --}}
@php // Calculate present count (checked_in, checked_out, or half_day) $presentStatuses = [ AttendanceStatus::CHECKED_IN->value, AttendanceStatus::CHECKED_OUT->value, AttendanceStatus::HALF_DAY->value ]; $presentCount = $attendanceLogs->whereIn('status', $presentStatuses)->count(); $absentCount = $attendanceLogs->where('status', AttendanceStatus::ABSENT->value)->count(); $lateCount = $attendanceLogs->filter(function($log) { return isset($log->late_hours) && $log->late_hours > 0; })->count(); $halfDayCount = $attendanceLogs->where('status', AttendanceStatus::HALF_DAY->value)->count(); $totalDays = $attendanceLogs->count(); $attendancePercentage = $totalDays > 0 ? (($presentCount + ($halfDayCount * 0.5)) / $totalDays) * 100 : 0; @endphp
{{ __('Attendance Rate') }}

{{ number_format($attendancePercentage, 1) }}%

{{ __('Last 30 days') }}
{{ __('Present Days') }}

{{ $presentCount }}

{{ __('Out of') }} {{ $totalDays }}
{{ __('Late Arrivals') }}

{{ $lateCount }}

{{ __('Last 30 days') }}
{{ __('Absent Days') }}

{{ $absentCount }}

{{ __('Last 30 days') }}
{{-- Attendance Log Table --}}
{{ __('Attendance Log') }}
@forelse ($attendanceLogs as $log) @empty @endforelse
{{ __('Date') }} {{ __('Day') }} {{ __('Shift') }} {{ __('Check In') }} {{ __('Check Out') }} {{ __('Work Hours') }} {{ __('Status') }} {{ __('Remarks') }}
{{ $log->date ? Carbon::parse($log->date)->format('d M Y') : __('N/A') }} {{ $log->date ? Carbon::parse($log->date)->format('l') : __('N/A') }} {{ $log->shift->name ?? __('N/A') }} @if ($log->check_in_time) {{ Carbon::parse($log->check_in_time)->format('h:i A') }} @else {{ __('N/A') }} @endif @if ($log->check_out_time) {{ Carbon::parse($log->check_out_time)->format('h:i A') }} @else {{ __('N/A') }} @endif @if ($log->working_hours) @php $hours = floor($log->working_hours); $minutes = round(($log->working_hours - $hours) * 60); @endphp @if($hours > 0) {{ $hours }}h {{ $minutes }}m @else {{ $minutes }}m @endif @else {{ __('N/A') }} @endif @php $statusEnum = is_string($log->status) ? AttendanceStatus::tryFrom($log->status) : $log->status; @endphp @if($statusEnum) {{ __($statusEnum->label()) }} @if(isset($log->late_hours) && $log->late_hours > 0) @endif @else {{ ucfirst($log->status ?? 'N/A') }} @endif {{ $log->remarks ?? __('N/A') }}
{{ __('No attendance records found') }}
@push('page-scripts') @endpush