{{ __('Team Schedule') }} {{ __('View all employees and their shift schedules') }}
@forelse ($employees as $employee)
{{ strtoupper(substr($employee->name, 0, 1)) }}

{{ $employee->name }}

{{ $employee->email }}

@if ($employee->shifts->isNotEmpty())
@foreach ($employee->shifts->sortBy(fn ($shift) => [$shift->day_of_week, $shift->start_time]) as $shift)
{{ \Carbon\Carbon::parse("next " . $shift->day_of_week)->translatedFormat('D') }} @php $shiftStart = $shift->start_time; $shiftEnd = $shift->end_time; if ($shiftEnd <= $shiftStart) { $isNightShift = true; } else { $isNightShift = false; } @endphp @if ($isNightShift) {{ __('Night') }} @endif

{{ __('Time') }}

{{ $shift->start_time->format('H:i') }} - {{ $shift->end_time->format('H:i') }}

{{ __('Grace Period') }}

{{ $shift->grace_period_minutes }}{{ __('m') }}

{{ __('Break Allowance') }}

{{ $shift->break_allowance_minutes }}{{ __('m') }}

@php $duration = $shift->end_time->diffInMinutes($shift->start_time); if ($duration < 0) $duration += 24 * 60; $hours = intval($duration / 60); $minutes = $duration % 60; @endphp

{{ __('Duration') }}

{{ $hours }}{{ __('h') }} {{ $minutes }}{{ __('m') }}

@endforeach
@php $totalMinutes = $employee->shifts->reduce(function ($carry, $shift) { $duration = $shift->end_time->diffInMinutes($shift->start_time); if ($duration < 0) $duration += 24 * 60; return $carry + $duration; }, 0); $totalHours = intval($totalMinutes / 60); $totalMins = $totalMinutes % 60; @endphp

{{ __('Working Days') }}

{{ $employee->shifts->unique('day_of_week')->count() }}

{{ __('Total Shifts') }}

{{ $employee->shifts->count() }}

{{ __('Weekly Hours') }}

{{ $totalHours }}{{ __('h') }} {{ $totalMins }}{{ __('m') }}

@else

{{ __('No shifts scheduled') }}

@endif
@empty

{{ __('No employees found') }}

@endforelse