{{-- Role-scoped compliance dashboard (Team Lead → CEO). From ManagementController@dashboard: $serviceRows, $summary, $attention --}} @extends('layouts.app') @section('title', 'Compliance Overview') @section('content') @include('partials.flash') {{-- "Where would you like to start?" — CEO/COO, once per login --}} @if($showQuickStart ?? false) @php $qsRole = auth()->user()->primaryRole(); $qsOptions = [ ['insights', 'monitoring', 'Insights', 'Training health, gaps & completion trends'], ['compliance.index', 'verified_user', 'Compliance', 'Org-wide compliance status by service'], ['training-risk', 'warning', 'Training Risk', 'Who has expiring or overdue training'], ['organogram', 'account_tree', 'Organogram', 'Compliance across the whole org chart'], ]; @endphp
waving_hand

Welcome, {{ auth()->user()->name }}

Where would you like to start?

@foreach($qsOptions as [$suffix, $icon, $title, $desc]) @if(\Illuminate\Support\Facades\Route::has($qsRole . '.' . $suffix)) {{ $icon }}

{{ $title }}

{!! $desc !!}

@endif @endforeach
@if(\Illuminate\Support\Facades\Route::has($qsRole . '.non-compliance')) gpp_bad

Non-Compliance

Failing services & workers — and who's responsible (SM · RM · HOD)

arrow_forward
@endif
@endif {{-- Summary tiles --}}
@php $dashRole = auth()->user()->primaryRole(); $overdueHref = \Illuminate\Support\Facades\Route::has($dashRole.'.compliance.overdue') ? route($dashRole.'.compliance.overdue') : null; $tiles = [ ['label' => 'Services', 'value' => $summary['homes'], 'icon' => 'home_health', 'class' => 'text-primary', 'href' => null], ['label' => 'Care Workers', 'value' => $summary['workers'], 'icon' => 'groups', 'class' => 'text-secondary', 'href' => null], ['label' => 'Compliance %', 'value' => $summary['avg_compliance'] . '%', 'icon' => 'donut_large', 'class' => 'text-on-secondary-container', 'href' => null], ['label' => ($summary['overdue_sessions'] ?? 0) > 0 ? 'Overdue · incl. '.$summary['overdue_sessions'].' sessions' : 'Overdue Training', 'value' => $summary['overdue_courses'], 'icon' => 'warning', 'class' => 'text-error', 'href' => $overdueHref], ['label' => 'Staff Fully Compliant · '.$summary['fully_compliant'].'/'.$summary['workers'], 'value' => $summary['fully_compliant_pct'].'%', 'icon' => 'verified_user', 'class' => 'text-gold', 'href' => null], ]; @endphp @foreach($tiles as $tile) <{{ $tile['href'] ? 'a' : 'div' }} @if($tile['href']) href="{{ $tile['href'] }}" @endif class="surface-card rounded-xl p-5 flex items-center gap-4 {{ $tile['href'] ? 'group cursor-pointer' : '' }}"> {{ $tile['icon'] }}

{{ $tile['value'] }}

{{ $tile['label'] }}

@if($tile['href'])chevron_right@endif @endforeach
@include('management._services-glance') {{-- 12-month compliance trend --}} @if(!empty($trend)) @php $current = end($trend); $trend = array_values($trend); $prev = count($trend) > 1 ? $trend[count($trend) - 2] : null; $delta = $prev ? $current['compliance'] - $prev['compliance'] : 0; $peak = collect($trend)->max('compliance'); // Left donut geometry $cur = $current['compliance']; $dR = 82; $dC = 2 * M_PI * $dR; // Right line-chart geometry (wide viewBox → fills width, no letterboxing) $n = count($trend); $W = 960; $H = 250; $pl = 40; $pr = 18; $pt = 16; $pb = 30; $pw = $W - $pl - $pr; $ph = $H - $pt - $pb; $xf = fn ($i) => $pl + ($n > 1 ? ($i / ($n - 1)) * $pw : $pw / 2); $yf = fn ($v) => $pt + (1 - $v / 100) * $ph; $linePts = collect($trend)->map(fn ($p, $i) => round($xf($i), 1) . ',' . round($yf($p['compliance']), 1))->implode(' '); $areaPath = 'M ' . round($xf(0), 1) . ',' . round($yf(0), 1) . ' ' . collect($trend)->map(fn ($p, $i) => 'L ' . round($xf($i), 1) . ',' . round($yf($p['compliance']), 1))->implode(' ') . ' L ' . round($xf($n - 1), 1) . ',' . round($yf(0), 1) . ' Z'; @endphp
trending_up

Compliance Trend

Last 12 months · E-learning and face to face · {{ $trendHomeName ?? 'All services' }}

{{-- Big circular compliance chart (LEFT) --}}
{{ $cur }}% Compliant

@if($delta > 0)▲ {{ $delta }}% this month @elseif($delta < 0)▼ {{ abs($delta) }}% this month @else No change this month @endif

{{ number_format($current['completed']) }} / {{ number_format($current['assigned']) }} training items complete

{{-- Trend line (RIGHT, fills remaining width) --}}
{{-- Gridlines + Y labels --}} @foreach([0, 25, 50, 75, 100] as $g) {{ $g }}% @endforeach {{-- Area + line --}} {{-- Points + X labels --}} @foreach($trend as $i => $p) @php $isLast = $i === $n - 1; @endphp {{ $p['label'] }}: {{ $p['compliance'] }}% ({{ $p['completed'] }}/{{ $p['assigned'] }}){{ $p['measured'] ? '' : ' — rebuilt from today’s records' }} {{ $p['label'] }} @endforeach

E-learning completed plus required face-to-face sessions in date, at each month-end, for current staff. Solid points are saved at the time; hollow points are rebuilt from today’s records, and e-learning from before Segra comes from imported records, so those months may look better than they really were. Peak: {{ $peak }}%.

@endif @include('management._yearly-compliance')
{{-- Homes compliance --}}
priority_high

Services Needing Attention

All services →
@if($serviceRows->isEmpty())
home_health

No services assigned to you yet

Once services are assigned to you, their compliance appears here.

@else
@foreach($serviceRows as $row) @php $pct = $row['compliance']; $bar = $row['overdue'] > 0 ? 'bg-error' : ($pct >= 100 ? 'bg-primary' : 'bg-gold'); @endphp @endforeach
Service Workers Overdue Compliance
{{ $row['service']->name }}

{{ $row['service']->code }}{{ $row['service']->region ? ' · ' . $row['service']->region : '' }}

{{ $row['workers'] }} @if($row['overdue'] > 0) {{ $row['overdue'] }} @else 0 @endif
{{ $pct }}%
@endif {{-- Available Sessions — book your team (SM / RM / Office Manager) --}} @php $tsRole = auth()->user()->primaryRole(); @endphp @if(\Illuminate\Support\Facades\Route::has($tsRole.'.team.sessions') && auth()->user()->can('sessions.assign'))
event_available

Available Sessions

All sessions →
@if($availableSessions->isEmpty())
event_busy

No upcoming training sessions right now.

@else
@foreach($availableSessions as $s) @endforeach
Session Date Format Team booked Action
{{ $s->title }} {{ $s->session_date->format('j M Y') }} · {{ \Carbon\Carbon::parse($s->start_time)->format('H:i') }} {{ $s->format === 'in_person' ? 'In-Person' : 'Online' }} {{ $s->team_registered_count }} / {{ $eligibleWorkers }} Assign team

{{ $eligibleWorkers }} eligible care {{ \Illuminate\Support\Str::plural('worker', $eligibleWorkers) }} on your team.

@endif @endif
{{-- Workforce status + personal compliance + needs attention --}}
@isset($statusMix) @include('management._status-donut', ['mix' => $statusMix, 'overdueHref' => $overdueHref ?? null]) @endisset @if($personal['total'] > 0)
school

Your Training

{{ $personal['compliance'] }}%

{{ $personal['completed'] }} of {{ $personal['total'] }} courses complete

@if($personal['overdue'] > 0)

{{ $personal['overdue'] }} overdue

@else

Personal compliance

@endif @if(\Illuminate\Support\Facades\Route::has(auth()->user()->primaryRole().'.courses')) Go to my courses → @endif
@endif
notification_important

Needs Attention

@forelse($attention as $row)
{{ strtoupper(collect(explode(' ', $row['user']->name))->map(fn($n) => $n[0] ?? '')->take(2)->implode('')) }}

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

{{ $row['home'] ?? 'Unassigned service' }}

{{ $row['overdue'] }} overdue
@empty
task_alt

All on track

No overdue training across your services.

@endforelse
{{-- Compliance Organogram reference (CEO/COO) --}} @if(!empty($organogram))
account_tree

Compliance Organogram

Open full view →
@include('management._org-node', ['node' => $organogram, 'depth' => 0])
@endif @endsection