@extends('layouts.app') @section('title', $pageTitle ?? 'Training Calendar') @section('content') @include('partials.flash') @php // Reused read-only for HR (HrCalendarController): own route names, no create / list / "my calendar". $calRoute = $calRoute ?? 'trainer.sessions.calendar'; $showRoute = $showRoute ?? 'trainer.sessions.show'; $readOnly = $readOnly ?? false; @endphp {{-- Toolbar: view toggle + navigation --}}
{{-- Week / Month / Year toggle --}}
@foreach(['week' => 'Week', 'month' => 'Month', 'year' => 'Year'] as $v => $vl) {{ $vl }} @endforeach
{{-- Whose calendar: master (all trainers) / personal / a specific trainer --}} @php $selectedTrainer = ctype_digit($trainerFilter) ? $trainers->firstWhere('id', (int) $trainerFilter) : null; $currentLabel = $trainerFilter === 'all' ? 'All trainers' : ($trainerFilter === 'me' ? 'My calendar' : ($selectedTrainer?->name ?? 'All trainers')); $calBase = route($calRoute); @endphp
{{-- Prev / label / next --}}
{{ $sessions->count() }} {{ Str::plural('session', $sessions->count()) }} @unless($readOnly) list List add New training @endunless
@php $pill = function ($s) { $role = $s->trainerRoleFor(auth()->id()); return $role === 'support' ? ['bg-gold/15 hover:bg-gold/25', 'text-[#8a6d3b]', true] : ['bg-primary/10 hover:bg-primary/20', 'text-primary', false]; }; // Capacity badge: "booked / capacity", "Full" at capacity, or just "N booked" when no cap set. $cap = function ($s) { $booked = (int) ($s->booked_count ?? 0); $capacity = (int) ($s->capacity ?? 0); if ($capacity <= 0) { return ['label' => $booked.' booked', 'full' => false, 'almost' => false]; } $full = $booked >= $capacity; return [ 'label' => $booked.'/'.$capacity, 'full' => $full, 'almost' => ! $full && ($capacity - $booked) <= max(1, (int) floor($capacity * 0.1)), ]; }; @endphp {{-- ══ WEEK ══ --}} @if($view === 'week')
{{-- ══ YEAR ══ --}} @elseif($view === 'year')
@foreach($months as $m)

{{ $m['label'] }}

{{ $m['count'] ? $m['count'].' '.Str::plural('session', $m['count']) : 'No sessions' }}

{{ $m['count'] }}
@endforeach
{{-- ══ MONTH ══ --}} @else
@foreach(['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] as $dow)
{{ $dow }}
@endforeach
@endif @endsection