@extends('admin.layout') @section('title', 'Jadwal Harian') @section('subtitle', 'Atur shift aktif untuk setiap hari') @section('content') @php $monthNames = ['Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember']; $dayNames = ['Sen','Sel','Rab','Kam','Jum','Sab','Min']; $prevMonth = $month == 1 ? 12 : $month - 1; $prevYear = $month == 1 ? $year - 1 : $year; $nextMonth = $month == 12 ? 1 : $month + 1; $nextYear = $month == 12 ? $year + 1 : $year; $daysInMonth = $startOfMonth->daysInMonth; $startDayOfWeek = ($startOfMonth->dayOfWeek + 6) % 7; // Monday = 0 @endphp {{-- Month Navigation --}}

{{ $monthNames[$month - 1] }} {{ $year }}

{{-- Shift Legend --}}
@foreach ($shifts as $shift) @php $colors = ['bg-sky-100 text-sky-700', 'bg-emerald-100 text-emerald-700', 'bg-amber-100 text-amber-700', 'bg-purple-100 text-purple-700', 'bg-rose-100 text-rose-700']; $colorClass = $colors[$loop->index % count($colors)]; @endphp {{ $shift->name }} @endforeach
{{-- Calendar Grid --}}
{{-- Day Headers --}}
@foreach ($dayNames as $dayName)
{{ $dayName }}
@endforeach
{{-- Calendar Days --}}
@for ($i = 0; $i < $startDayOfWeek; $i++)
@endfor @for ($day = 1; $day <= $daysInMonth; $day++) @php $dateStr = sprintf('%04d-%02d-%02d', $year, $month, $day); $schedule = $schedules[$dateStr] ?? null; $isToday = $dateStr === now()->format('Y-m-d'); @endphp
{{ $day }}
@if ($schedule) @php $shiftIdx = $shifts->search(fn($s) => $s->id === $schedule->shift_id); $colorClass = $colors[$shiftIdx % count($colors)] ?? $colors[0]; @endphp
{{ $schedule->shift->name }}
@endif {{-- Quick assign popup trigger --}}
@endfor @php $remaining = (7 - (($startDayOfWeek + $daysInMonth) % 7)) % 7; @endphp @for ($i = 0; $i < $remaining; $i++)
@endfor
{{-- Assign Modal --}} @push('scripts') @endpush @endsection