@extends('layouts.app') @section('title', 'Insights') @section('content') @include('partials.flash')

Workforce training health across {{ $summary['services'] }} {{ Str::plural('service', $summary['services']) }}.

@php $insRole = auth()->user()->primaryRole(); @endphp @if(\Illuminate\Support\Facades\Route::has($insRole . '.compliance.report')) picture_as_pdf Print / PDF @endif
{{-- KPI tiles --}}
@php $tiles = [ ['label' => 'Compliance', 'value' => $summary['compliance'].'%', 'icon' => 'verified', 'class' => 'text-primary'], ['label' => 'Care Workers', 'value' => $summary['workers'], 'icon' => 'groups', 'class' => 'text-on-surface-variant'], ['label' => 'Services', 'value' => $summary['services'], 'icon' => 'holiday_village', 'class' => 'text-on-surface-variant'], ['label' => 'Overdue Courses', 'value' => $summary['overdue'], 'icon' => 'error', 'class' => 'text-error'], ]; @endphp @foreach($tiles as $t)
{{ $t['icon'] }}

{{ $t['value'] }}

{{ $t['label'] }}

@endforeach
{{-- Training-status donut --}}

Workforce training status

@if($status['total'] > 0) @php $r = 64; $C = 2 * M_PI * $r; $acc = 0; $segs = [ ['key' => 'completed', 'label' => 'Completed', 'value' => $status['completed'], 'hex' => '#0E7C7B', 'ink' => 'text-primary', 'ic' => 'check_circle'], ['key' => 'in_progress', 'label' => 'Overdue · in progress', 'value' => $status['in_progress'], 'hex' => '#D08A3A', 'ink' => 'text-[#a8641f]', 'ic' => 'timelapse'], ['key' => 'not_started', 'label' => 'Overdue · not started', 'value' => $status['not_started'], 'hex' => '#C1473A', 'ink' => 'text-error', 'ic' => 'error'], ['key' => 'sessions_missing', 'label' => 'Overdue · session not attended', 'value' => $status['sessions_missing'], 'hex' => '#7E2F4F', 'ink' => 'text-[#7E2F4F]', 'ic' => 'event_busy'], ['key' => 'competency_missing', 'label' => 'Overdue · medication competency', 'value' => $status['competency_missing'] ?? 0, 'hex' => '#4B5563', 'ink' => 'text-[#4B5563]', 'ic' => 'medication'], ['key' => 'observations_missing', 'label' => 'Overdue · observation', 'value' => $status['observations_missing'] ?? 0, 'hex' => '#9A3412', 'ink' => 'text-[#9A3412]', 'ic' => 'clinical_notes'], ]; @endphp
@foreach($segs as $s) @php $len = $s['value'] / $status['total'] * $C; @endphp @if($s['value'] > 0) {{ $s['label'] }}: {{ $s['value'] }} @endif @php $acc += $len; @endphp @endforeach
{{ $summary['compliance'] }}% compliant
@foreach($segs as $s)

{{ $s['value'] }}

{{ $s['label'] }}

@endforeach
@else

No enrolments in your services yet.

@endif
{{-- Completions per month --}}

Training completed

Completions per month · last 12 months

@php $W = 520; $H = 180; $pl = 8; $pr = 8; $pt = 14; $pb = 26; $n = count($completions); $xf = fn ($i) => $pl + ($n <= 1 ? 0 : $i * ($W - $pl - $pr) / ($n - 1)); $yf = fn ($v) => $pt + ($H - $pt - $pb) * (1 - $v / $compMax); $pts = collect($completions)->map(fn ($p, $i) => round($xf($i), 1).','.round($yf($p['count']), 1)); $area = 'M '.round($xf(0), 1).','.round($H - $pb, 1).' L '.$pts->implode(' L ').' L '.round($xf($n - 1), 1).','.round($H - $pb, 1).' Z'; @endphp @foreach($completions as $i => $p) {{ $p['full'] }}: {{ $p['count'] }} {{ $p['label'] }} @endforeach
{{-- Compliance by service --}}

Compliance by service

Ranked — where to focus

@forelse($byService as $s)
{{ $s['name'] }} {{ $s['completed'] }}/{{ $s['total'] }}@if($s['overdue']) · {{ $s['overdue'] }} overdue@endif
@include('trainer._rate-meter', ['rate' => $s['compliance']])
@empty

No services in scope.

@endforelse
{{-- Biggest training gaps --}}

Biggest training gaps

Courses with the most overdue renewals

@php $gapMax = max(1, (int) $gaps->max('overdue')); @endphp @forelse($gaps as $g)
{{ $g->title }} {{ $g->rate }}% compliant
{{ $g->overdue }}
@empty

No overdue training — nothing to flag.

@endforelse
@endsection