{{-- Session Analytics (trainer). Attendance by session / service / manager / worker, scoped to "My sessions" or "All trainers". From TrainerSessionAnalyticsController@index: $rows, $by, $scope, $summary --}} @extends('layouts.app') @section('title', 'Session Analytics') @section('content') @include('partials.flash') @php $dimensions = [ 'session' => ['label' => 'Session-wise', 'icon' => 'event_note'], 'service' => ['label' => 'Service-wise', 'icon' => 'home_health'], 'manager' => ['label' => 'Service Manager-wise', 'icon' => 'badge'], 'worker' => ['label' => 'Care Worker-wise', 'icon' => 'person'], 'coverage' => ['label' => 'Service Coverage', 'icon' => 'grid_view'], ]; $rateColor = $summary['rate'] >= 75 ? 'text-primary' : ($summary['rate'] >= 50 ? 'text-gold' : 'text-error'); $tiles = [ ['label' => 'Sessions', 'value' => number_format($summary['sessions']), 'icon' => 'event_available', 'class' => 'text-primary'], ['label' => 'Attendances', 'value' => number_format($summary['attendances']), 'icon' => 'how_to_reg', 'class' => 'text-primary'], ['label' => 'Attendance Rate', 'value' => $summary['rate'].'%', 'icon' => 'insights', 'class' => $rateColor], ['label' => 'Care Workers Reached', 'value' => number_format($summary['workers']), 'icon' => 'groups', 'class' => 'text-on-surface-variant'], ]; if ($scope === 'all') { $tiles[] = ['label' => 'Trainers', 'value' => number_format($summary['trainers']), 'icon' => 'school', 'class' => 'text-on-surface-variant']; } $gridCols = $scope === 'all' ? 'lg:grid-cols-5' : 'lg:grid-cols-4'; @endphp {{-- Scope: my sessions vs the whole company --}}
@foreach(['me' => ['My Sessions', 'person'], 'all' => ['All Trainers', 'groups']] as $sv => $meta) {{ $meta[1] }} {{ $meta[0] }} @endforeach
{{-- Engagement filter: surface who is NOT attending / is disengaged --}}
filter_alt
download Export CSV
{{-- KPI tiles (dashboard UI) --}}
@foreach($tiles as $tile)
{{ $tile['icon'] }}

{{ $tile['value'] }}

{{ $tile['label'] }}

@endforeach
{{-- Dimension tabs (Session-wise exits the engagement filter) --}}
@foreach($dimensions as $key => $dim) @php $tabParams = ['scope' => $scope, 'by' => $key]; if ($engagement !== 'all' && ! in_array($key, ['session', 'coverage'])) { $tabParams['engagement'] = $engagement; } @endphp {{ $dim['icon'] }} {{ $dim['label'] }} @endforeach
@if($by === 'coverage') {{-- Which service has taken which training (session), and which has not --}}
Taken (attended) Booked, not attended Not taken Each row is a service; each column a training added by trainers. Coverage = trainings the service has attended.
@if($trainings->isEmpty())
grid_view

No trainings yet

Add and schedule sessions and they’ll appear here as columns.

@else
@foreach($trainings as $t) @endforeach @foreach($coverageRows as $row) @foreach($row['cells'] as $cell) @endforeach @endforeach
Service
{{ \Illuminate\Support\Str::limit($t, 26) }}
Coverage

{{ $row['service']->name }}

{{ $row['service']->code }}

@if($cell->state === 'taken') check_circle @elseif($cell->state === 'booked') schedule @else – @endif @php $cr = $row['rate']; $crTone = $cr >= 75 ? 'text-primary' : ($cr >= 40 ? 'text-gold' : 'text-error'); @endphp
{{ $cr }}%
@endif @elseif($engagement !== 'all') @php $entityLabel = ['service' => 'Service', 'manager' => 'Service Manager', 'worker' => 'Care Worker'][$by] ?? 'Service'; $scopeNote = $scope === 'me' ? 'your sessions' : 'any trainer’s sessions'; $filterNote = $engagement === 'disengaged' ? 'Not attending '.$scopeNote.' AND no e-learning completed' : 'Not attending '.$scopeNote; @endphp
{{ $engagement === 'disengaged' ? 'report' : 'event_busy' }}

{{ $rows->count() }} {{ Str::plural(strtolower($entityLabel), $rows->count()) }} flagged

· {{ $filterNote }}
@if($rows->isEmpty())
check_circle

Nothing to flag

Every {{ strtolower($entityLabel) }} in scope is engaging with training.

@else
@if($by !== 'worker')@endif @foreach($rows as $r) @if($by !== 'worker')@endif @endforeach
{{ $entityLabel }}Care WorkersSessions (att / booked) E-learning (done / assigned) Status

{{ $r->title }}

{{ $r->subtitle }}

{{ $r->workers }} {{ $r->attended }}/{{ $r->booked }} {{ $r->completed }}/{{ $r->assigned }} @if($r->status === 'disengaged') report Disengaged @else event_busy No sessions @endif
@endif @elseif($rows->isEmpty())
bar_chart

No attendance data yet

Once sessions are delivered and attendance is marked, the breakdown appears here.

@else
@switch($by) @case('service') @break @case('manager') @break @case('worker') @break @default @if($scope === 'all')@endif @endswitch {{-- ── Session-wise ── --}} @if($by === 'session') @foreach($rows as $s) @php $past = $s->session_date && $s->hasEnded(); @endphp @if($scope === 'all')@endif @endforeach {{-- ── Service-wise ── --}} @elseif($by === 'service') @foreach($rows as $r) @endforeach {{-- ── Service Manager-wise ── --}} @elseif($by === 'manager') @foreach($rows as $r) @endforeach {{-- ── Care Worker-wise ── --}} @else @foreach($rows as $r) @endforeach @endif
Service Service Manager Sessions Workers Attendances Attendance rateService Manager Services Sessions Workers Attendances Attendance rateCare Worker Service Sessions Attended No-show Attendance rateSessionTrainerExpected Attended No-show Attendance rate
{{ $s->format === 'online' ? 'videocam' : 'location_on' }}
@if($scope === 'me') {{ $s->title }} @else

{{ $s->title }}

@endif

{{ $s->session_date?->format('D, d M Y') }} · {{ \Carbon\Carbon::parse($s->start_time)->format('H:i') }}{{ $s->training_code ? ' · ' . $s->training_code : '' }}

{{ $s->trainerName() ?? '—' }}{{ $s->expected }} {{ $s->attended }} {{ $s->no_show }} @if($past) @include('trainer._rate-meter', ['rate' => $s->rate]) @else Upcoming @endif

{{ $r->name }}

{{ $r->code }}

{{ $r->sm_name ?? '—' }} {{ $r->sessions }} {{ $r->workers_attended }}/{{ $r->workers_total }} {{ $r->attended }} @include('trainer._rate-meter', ['rate' => $r->rate])
badge

{{ $r->name }}

{{ $r->services }} {{ $r->sessions }} {{ $r->workers_attended }}/{{ $r->workers_total }} {{ $r->attended }} @include('trainer._rate-meter', ['rate' => $r->rate])

{{ $r->name }}

{{ $r->email }}

{{ $r->service_name ?? '—' }} {{ $r->sessions }} {{ $r->attended }} {{ $r->no_show }} @include('trainer._rate-meter', ['rate' => $r->rate])
@endif @endsection