{{ __('Attendance Log') }}

@if (session()->has('message'))
{{ session('message') }}
@endif @if (session()->has('error'))
{{ session('error') }}
@endif
{{ $status ?: __('All Statuses') }} {{ __('All Statuses') }} {{ __('Present') }} {{ __('Late') }} {{ __('On Break') }} {{ __('Absent') }} {{ __('Left Early') }} {{ __('Clear All') }}
@forelse ($attendances as $attendance)
{{ substr($attendance->user->first_name, 0, 1) }}{{ substr($attendance->user->last_name, 0, 1) }}
{{ $attendance->user->first_name }} {{ $attendance->user->last_name }}
{{ $attendance->user->email }}
{{ __('Date') }} {{ $attendance->date->translatedFormat('M d, Y') }}
{{ __('Check In') }} {{ $attendance->check_in->format('H:i') }}
{{ __('Check Out') }} {{ $attendance->check_out ? $attendance->check_out->format('H:i') : '--:--' }}
{{ __('Break Time') }} @if($attendance->total_break_duration > 0) {{ intdiv($attendance->total_break_duration, 60) }}{{ __('h') }} {{ $attendance->total_break_duration % 60 }}{{ __('m') }} @else -- @endif
{{ __('Duration') }} @if($attendance->check_out && $attendance->check_in) @php $workDuration = $attendance->actual_work_duration; $totalMinutes = $attendance->check_out->diffInMinutes($attendance->check_in); @endphp @if($workDuration > 0) {{ intdiv($workDuration, 60) }}{{ __('h') }} {{ $workDuration % 60 }}{{ __('m') }} @else {{ intdiv($totalMinutes, 60) }}{{ __('h') }} {{ $totalMinutes % 60 }}{{ __('m') }} @endif @else -- @endif
@if($isAdmin)
@if($attendance->status === 'absent') {{ __('Recuperate') }} @endif {{ __('Edit') }} {{ __('History') }}
@endif
@empty
{{ __('No attendance records found.') }}
@endforelse
{{ $attendances->links() }}
{{-- Edit Attendance Modal --}}
@if($editingAttendance) {{-- Header --}}
{{ __('Edit Attendance Record') }}

{{ $editingAttendance->user->first_name }} {{ $editingAttendance->user->last_name }} — {{ $editingAttendance->date->translatedFormat('M d, Y') }}

{{-- Body --}}
{{-- Flash message --}} @if (session()->has('message'))
{{ session('message') }}
@endif {{-- Time Fields --}}
{{ __('Check In') }} @error('editCheckIn') {{ $message }} @enderror {{ __('Check Out') }} @error('editCheckOut') {{ $message }} @enderror
{{-- Status and Work Duration --}}
{{ __('Status') }} {{ __('Present') }} {{ __('Absent') }} {{ __('Congé') }} {{ __('Maladie') }} {{ __('Recupuration') }} @error('editStatus') {{ $message }} @enderror
{{ __('Work Duration') }}
{{ __('Hours : Minutes') }}
@error('editWorkHours') {{ $message }} @enderror @error('editWorkMinutes') {{ $message }} @enderror
{{ __('Break Duration') }}
{{ __('Hours : Minutes') }}
@error('editBreakHours') {{ $message }} @enderror @error('editBreakMinutes') {{ $message }} @enderror
{{-- Edit Reason --}} {{ __('Reason for Edit') }} * @error('editReason') {{ $message }} @enderror
{{-- Footer --}}
{{ __('Cancel') }} {{ __('Save Changes') }}
@endif
{{-- View History Modal --}}
@if($historyAttendance) {{-- Header --}}
{{ __('Edit History') }}

{{ $historyAttendance->user->first_name }} {{ $historyAttendance->user->last_name }} — {{ $historyAttendance->date->translatedFormat('M d, Y') }}

{{-- Body --}}
@if($historyAttendance->edits->count() > 0)
@foreach($historyAttendance->edits as $edit)
{{-- Edit Header --}}
{{ substr($edit->editor->first_name ?? $edit->editor->name, 0, 1) }}{{ substr($edit->editor->last_name ?? '', 0, 1) }}
{{ $edit->editor->first_name ?? $edit->editor->name }} {{ $edit->editor->last_name ?? '' }}
{{ $edit->created_at->diffForHumans() }}
{{ $edit->created_at->translatedFormat('M d, Y H:i') }}
{{-- Edit Reason --}}
"{{ $edit->edit_reason }}"
{{-- Changes --}}
@php $changes = $edit->changes; @endphp @if(isset($changes['check_in']))
{{ __('Check In') }} {{ $changes['check_in']['old'] ?? __('Not set') }} {{ $changes['check_in']['new'] ?? __('Not set') }}
@endif @if(isset($changes['check_out']))
{{ __('Check Out') }} {{ $changes['check_out']['old'] ?? __('Not set') }} {{ $changes['check_out']['new'] ?? __('Not set') }}
@endif @if(isset($changes['status']))
{{ __('Status') }} {{ __($changes['status']['old']) }} {{ __($changes['status']['new']) }}
@endif @if(isset($changes['work_duration']))
{{ __('Work Duration') }} {{ $changes['work_duration']['old'] ?? __('Not set') }} {{ __('min') }} {{ $changes['work_duration']['new'] ?? __('Not set') }} {{ __('min') }}
@endif @if(isset($changes['breaks_added']) && count($changes['breaks_added']) > 0)
{{ __('Breaks Added') }}
@foreach($changes['breaks_added'] as $break)
{{ $break['started_at'] }} - {{ $break['ended_at'] }} ({{ __($break['type']) }})
@endforeach
@endif @if(isset($changes['breaks_removed']) && count($changes['breaks_removed']) > 0)
{{ __('Breaks Removed') }}
@foreach($changes['breaks_removed'] as $break)
{{ $break['started_at'] }} - {{ $break['ended_at'] ?? '?' }} ({{ __($break['type']) }})
@endforeach
@endif @if(isset($changes['breaks_modified']) && count($changes['breaks_modified']) > 0)
{{ __('Breaks Modified') }}
@foreach($changes['breaks_modified'] as $mod)
{{ $mod['old']['started_at'] }} - {{ $mod['old']['ended_at'] ?? '?' }} {{ $mod['new']['started_at'] }} - {{ $mod['new']['ended_at'] }}
@endforeach
@endif
@endforeach
@else

{{ __('No edit history for this attendance record.') }}

@endif
{{-- Footer --}}
{{ __('Close') }}
@endif