{{-- 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') {{-- Summary tiles --}}
@php $tiles = [ ['label' => 'Services', 'value' => $summary['homes'], 'icon' => 'home_health', 'class' => 'text-primary'], ['label' => 'Care Workers', 'value' => $summary['workers'], 'icon' => 'groups', 'class' => 'text-secondary'], ['label' => 'Avg. Compliance', 'value' => $summary['avg_compliance'] . '%', 'icon' => 'donut_large', 'class' => 'text-on-secondary-container'], ['label' => 'Overdue Courses', 'value' => $summary['overdue_courses'], 'icon' => 'warning', 'class' => 'text-error'], ]; @endphp @foreach($tiles as $tile)
{{ $tile['icon'] }}

{{ $tile['value'] }}

{{ $tile['label'] }}

@endforeach
{{-- 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 · {{ $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

{{ $current['completed'] }} / {{ $current['assigned'] }} courses 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['label'] }} @endforeach

Cumulative completion rate at each month-end (courses completed ÷ courses assigned). Peak: {{ $peak }}%.

@endif
{{-- 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
{{-- Personal compliance + needs attention --}}
@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 Go to my courses →
@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