{{-- Book team members onto a session. From TeamSessionController@manage: $session, $team, $registeredIds, $needsThis, $requiredHere … The team list is a DataTable with search / home / status filters and a sticky booking bar. --}} @extends('layouts.app') @section('title', 'Book Team onto Session') @section('content') @php $tsRole = auth()->user()->primaryRole(); @endphp arrow_back Back to Assign Sessions @include('partials.flash')

{{ $session->title }}

@if($session->training_code) sell{{ $session->training_code }} @endif
calendar_month{{ $session->session_date->format('l, j F Y') }} schedule{{ \Carbon\Carbon::parse($session->start_time)->format('H:i') }} · {{ $session->duration_minutes }} min {{ $session->format === 'online' ? 'videocam' : 'location_on' }}{{ $session->format === 'online' ? 'Online' : ($session->location ?? 'Venue TBC') }}
@if($capacity > 0) @php $full = $spacesLeft === 0; @endphp {{ $full ? 'event_busy' : 'event_available' }} {{ $bookedTotal }} / {{ $capacity }} booked · {{ $full ? 'Full' : $spacesLeft.' '.\Illuminate\Support\Str::plural('space', (int) $spacesLeft).' left' }} @else {{ $bookedTotal }} booked · no capacity limit set @endif
@php $homes = $team->map(fn ($m) => in_array($m->id, $smIds ?? [], true) ? ($smHomes[$m->id] ?? 'Service Manager') : ($m->location?->name ?? '—')) ->flatMap(fn ($h) => array_map('trim', explode(',', $h)))->unique()->sort()->values(); $needCount = $team->filter(fn ($m) => ($needsThis[$m->id] ?? false) && ! in_array($m->id, $registeredIds) && ! isset($alreadyTaken[$m->id]))->count(); @endphp
@csrf {{-- Filter toolbar --}}
groups

Book your team

{{ $team->count() }} {{ Str::plural('person', $team->count()) }}@if($needCount) · {{ $needCount }} still need this training@endif
search
Show: @if(!empty($smIds))@endif
@foreach($team as $member) @php $isBooked = in_array($member->id, $registeredIds); $tookOn = $alreadyTaken[$member->id] ?? null; $past = $history[$member->id] ?? collect(); $locked = $isBooked || $tookOn; $isSM = in_array($member->id, $smIds ?? [], true); $home = $isSM ? ($smHomes[$member->id] ?? 'Service Manager') : ($member->location?->name ?? '—'); $needs = (bool) ($needsThis[$member->id] ?? false); $reqHere = isset($requiredHere[$member->id]); $state = $tookOn ? 'done' : ($isBooked ? 'booked' : 'available'); $rank = $tookOn ? 3 : ($isBooked ? 2 : ($needs ? 0 : 1)); @endphp @endforeach
Staff member Home This training Training history
{{ strtoupper(collect(explode(' ', $member->name))->filter()->map(fn($n) => mb_substr($n, 0, 1))->take(2)->implode('')) }}

{{ $member->name }}

@if($isSM)Service Manager@endif
{{ $home }} @if($tookOn) verified Completed {{ \Carbon\Carbon::parse($tookOn)->format('j M Y') }} @elseif($isBooked) check_circle Booked on this session @elseif($needs) assignment_late Needs it — required at their home @elseif($reqHere) Required at their home @else Not required at their home @endif
@forelse($past->take(3) as $h) check_circle{{ $h->title }} @empty None yet @endforelse @if($past->count() > 3)+{{ $past->count() - 3 }} more@endif {{-- hidden text so the search also matches every training taken --}}
{{-- Sticky booking bar --}}

0 selected to book @if($capacity > 0) · {{ $spacesLeft }} {{ Str::plural('space', (int) $spacesLeft) }} left @endif

{{-- Team attendance report --}} @if($roster->isNotEmpty())
fact_check

Your team's attendance

{{ $summary['attended'] }} attended @if($summary['no_show']){{ $summary['no_show'] }} no-show@endif @if($summary['on_leave']){{ $summary['on_leave'] }} on leave@endif @if($summary['booked']){{ $summary['booked'] }} booked@endif

Attendance is recorded by the trainer. Before the training runs you can mark someone on leave (e.g. sick), swap in cover, or remove them from the session.

@endif {{-- Everyone booked on this whole session (all teams) + who booked them --}}

Who’s booked on this session

{{ $bookedTotal }}{{ $capacity ? ' / '.$capacity : '' }} booked@if($spacesLeft !== null) · {{ $spacesLeft }} {{ \Illuminate\Support\Str::plural('space', (int) $spacesLeft) }} left@endif
@if($allAttendees->isNotEmpty())
search
@endif
@if($allAttendees->isEmpty())

No one is booked on this session yet.

@else
@foreach($allAttendees as $a) @php $b = match($a['status']) { 'attended' => ['Attended', 'bg-primary/10 text-primary'], 'no_show' => ['No-show', 'bg-error-container text-error'], 'on_leave' => ['On leave', 'bg-gold/20 text-on-surface'], default => ['Booked', 'bg-surface-container-high text-on-surface-variant'], }; @endphp @endforeach
Staff member Status Booked by Booked on
{{ $a['name'] }} @if($a['mine'])Your team@endif {{ $b[0] }} {{ $a['booked_by'] }} {{ $a['booked_at'] ? \Illuminate\Support\Carbon::parse($a['booked_at'])->format('j M Y, H:i') : '—' }}
@endif
@include('management._datatables') @endsection