{{-- Training Sessions — calendar (this month / next month / year) + agenda. From EmployeeSessionController@index: $filter, $anchor, $periodLabel, $sessions, $byDate, $weeks, $myStatuses --}} @extends('layouts.app') @section('title', 'Training Sessions') @section('content') @include('employee._flash') @php $myBookedCount = $sessions->filter(function ($s) use ($myStatuses) { $st = $myStatuses[$s->id] ?? null; return $st && $st !== 'cancelled'; })->count(); @endphp {{-- Toolbar: filter segmented control + period label --}}
@php $filters = ['this_month' => 'This Month', 'next_month' => 'Next Month', 'year' => 'This Year']; @endphp @foreach($filters as $key => $label) {{ $label }} @endforeach
{{-- Booked filter — governs both the calendar and the agenda list below --}}
bookmark My bookings {{ $myBookedCount }}
@if($locations->isNotEmpty()) {{-- Face-to-face location, so managers can focus on sessions in their area. --}}
location_on
@endif
@if($prevMonth) chevron_left @endif calendar_month {{ $periodLabel }} @if($nextMonth) chevron_right @endif
{{-- Calendar grid (month views only) --}} @if($weeks)
{{-- Weekday header --}}
@foreach(['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] as $dow)
{{ $dow }}
@endforeach
{{-- Weeks --}}
@foreach($weeks as $week)
@foreach($week as $day)
{{ $day['date']->format('j') }}
@php // Booked-first so a booked session never gets hidden behind "+N more". $dayOrdered = $day['sessions']->sortByDesc(function ($s) use ($myStatuses) { $st = $myStatuses[$s->id] ?? null; return $st && $st !== 'cancelled' ? 1 : 0; })->values(); @endphp @foreach($dayOrdered->take(3) as $s) @php $st = $myStatuses[$s->id] ?? null; $booked = $st && $st !== 'cancelled'; // Booked sessions get a bold primary treatment + left accent bar so // the eye catches them instantly among the muted others. $pill = $booked ? 'bg-primary/15 text-primary ring-1 ring-inset ring-primary/50 border-l-[3px] border-primary font-bold' : ($s->format === 'in_person' ? 'bg-secondary-container text-on-secondary-container border-l-[3px] border-transparent' : 'bg-surface-container-high text-secondary border-l-[3px] border-transparent'); @endphp @php $venue = $s->format === 'in_person' ? ($s->location ?: 'In-person · venue TBC') : 'Online'; @endphp @php $capN = (int) ($s->capacity ?? 0); $bk = (int) ($s->booked_count ?? 0); $full = $capN > 0 && $bk >= $capN; $capLabel = $capN > 0 ? $bk.'/'.$capN : $bk.' booked'; @endphp @if($booked)check_circle@endif {{ \Carbon\Carbon::parse($s->start_time)->format('H:i') }} {{ $s->title }} {{ $s->format === 'in_person' ? 'location_on' : 'videocam' }}{{ $venue }} {{ $full ? 'event_busy' : 'group' }}{{ $full ? 'Full · '.$capLabel : $capLabel }} @endforeach @if($day['sessions']->count() > 3) +{{ $day['sessions']->count() - 3 }} more @endif
@endforeach
@endforeach
{{-- Legend --}}
check_circle You're booked In-Person Online
@endif {{-- Agenda --}}
event_note

{{ $filter === 'year' ? 'Sessions This Year' : 'Sessions in ' . $periodLabel }}

({{ $sessions->count() }})
@if($sessions->isEmpty())
calendar_today

No sessions in this period

Try another range, or check back once new dates are scheduled.

@elseif($filter === 'year') {{-- Year view: group agenda by month --}} @foreach($sessions->groupBy(fn ($s) => $s->session_date->format('Y-m')) as $monthKey => $monthSessions)

{{ \Carbon\Carbon::createFromFormat('Y-m', $monthKey)->format('F Y') }} · {{ $monthSessions->count() }}

@foreach($monthSessions as $session) @include('employee._session-agenda-item') @endforeach
@endforeach @else
@foreach($sessions as $session) @include('employee._session-agenda-item') @endforeach
@endif {{-- Shown by JS when "Only my bookings" is on but nothing in this period is booked. --}} @endsection