{{-- One care worker's full training record. From ManagementController@complianceWorker: $worker, $service, $items, $summary --}} @extends('layouts.app') @section('title', $worker->name . ' — Training') @section('content') @include('partials.flash') @php $role = auth()->user()->primaryRole(); @endphp @php $fromStaff = request('from') === 'staff' && \Illuminate\Support\Facades\Route::has($role.'.staff-login'); $backUrl = $fromStaff ? route($role.'.staff-login') : ($backService ? route($role.'.compliance.index', ['service' => $backService->id]) : route($role.'.compliance.index')); $backLabel = $fromStaff ? 'Staff Management' : ($backService?->name ?? 'All services'); @endphp arrow_back {{ $backLabel }} {{-- Worker details --}}
badge{{ $worker->roleLabel() }} @if($service) home_health{{ $service->name }} @endif mail{{ $worker->email }} @if($service && $service->serviceManager) supervisor_accountSM: {{ $service->serviceManager->name }} @endif
@if(($canArchive ?? false)) @if($worker->isArchived()) inventory_2 Archived{{ $worker->archived_until ? ' · due back '.$worker->archived_until->format('j M Y') : '' }}
@csrf
@else @endif @endif
@if(($canArchive ?? false) && ! $worker->isArchived()) @include('management._archive-modal') @endif {{-- Key figures (above the donuts) --}} @php $countTiles = [ ['assignment', 'text-[#8a6d3b]', 'bg-gold/15', 'Required', $summary['total']], ['check_circle', 'text-primary', 'bg-primary/10', 'Completed', $summary['completed']], ['error', 'text-error', 'bg-error/10', 'Overdue', $summary['overdue']], ['percent', 'text-primary', 'bg-primary/10', 'Compliance', $summary['compliance'].'%'], ]; @endphp
@foreach($countTiles as [$icon, $color, $bg, $label, $value])
{{ $icon }}

{{ $value }}

{{ $label }}

@endforeach
{{-- Three donuts: this worker · contribution to house · house compliance --}} @php $mixSegs = fn ($d) => [ ['label' => 'Completed', 'value' => (int) $d['completed'], 'hex' => '#0E7C7B'], ['label' => 'Overdue', 'value' => (int) $d['overdue'], 'hex' => '#C1473A'], ]; $rest = max(0, (int) $house['completed'] - (int) $summary['completed']); @endphp

Compliance overview

{{-- 1. This worker --}}

{{ $worker->name }}

@include('management._donut', ['segs' => $mixSegs($summary), 'total' => (int) $summary['total'], 'centerValue' => $summary['compliance'].'%', 'centerLabel' => ''])

{{ $summary['completed'] }} of {{ $summary['total'] }} complete

@if($service) {{-- 2. Contribution to house --}}

Contribution to house

@include('management._donut', [ 'segs' => [['label' => 'This worker', 'value' => (int) $summary['completed'], 'hex' => '#0E7C7B'], ['label' => 'Other workers', 'value' => $rest, 'hex' => '#C3CBD3']], 'total' => (int) $house['completed'], 'centerValue' => $contribution.'%', 'centerLabel' => '', ])

{{ $summary['completed'] }} of {{ $house['completed'] }} house completions

{{-- 3. House compliance --}}

{{ $service?->name ?? 'House' }}

@include('management._donut', ['segs' => $mixSegs($house), 'total' => (int) $house['total'], 'centerValue' => $house['compliance'].'%', 'centerLabel' => ''])

{{ $house['completed'] }} of {{ $house['total'] }} complete

@endif
{{-- Shared status legend --}}
@foreach([['Completed', '#0E7C7B'], ['Overdue (not completed)', '#C1473A']] as [$lbl, $hex]) {{ $lbl }} @endforeach
{{-- Required sessions (selected for this worker's home(s)) — counted in compliance --}} @if(($summary['sessions_required'] ?? 0) > 0)
event_available

Required sessions

{{ $summary['sessions_attended'] }} of {{ $summary['sessions_required'] }} attended — not attended counts as overdue
@foreach($summary['sessions_missing'] as $title) @php $isBooked = in_array($title, $summary['sessions_booked'], true); @endphp
{{ $title }} @if(! $isBooked && ($canBook ?? false)) @if($dates = $bookable->get($title))
@csrf
@else No upcoming dates @endif @endif @if(($canNa ?? false) && isset($sessionIds[$title]))
@csrf
@endif @if($isBooked) event Overdue · booked @else error Overdue · not booked @endif
@endforeach @if(empty($summary['sessions_missing']))
task_alt All required sessions attended
@endif
@endif {{-- Required observations (Insulin / PEG / Dysphagia) — counted in compliance --}} @if(! empty($summary['observations'])) @php $obsDone = count(array_filter($summary['observations'])); $obsRoute = \Illuminate\Support\Facades\Route::has($role.'.observations.show') ? route($role.'.observations.show', $worker) : null; @endphp
clinical_notes

Required observations

{{ $obsDone }} of {{ count($summary['observations']) }} in date — not in date counts as overdue
@foreach($summary['observations'] as $title => $ok)
{{ $title }} @if(! $ok && $obsRoute) upload_file Upload / assess @endif @if(! $ok && ($canNa ?? false) && isset($sessionIds[$title]))
@csrf
@endif @if($ok) check_circle In date @else error Overdue @endif
@endforeach
@endif {{-- Training marked N/A for this person (not counted in compliance) --}} @if(($naItems ?? collect())->isNotEmpty() || ! empty($summary['sessions_covered']))
block

Not applicable (N/A)

Not counted in compliance and shown as N/A on the matrix
{{-- Automatic: covered by the alternative training --}} @foreach($summary['sessions_covered'] ?? [] as $title => $cov)

{{ $title }} · Face to face Automatic

Covered by {{ $cov['by'] }}, attended {{ $cov['on']->format('j M Y') }} — either one is enough.

@endforeach @foreach($naItems as $na)

{{ $na->title() }} · {{ $na->course_id ? 'E-learning' : 'Face to face' }}

“{{ $na->reason }}” — {{ $na->creator?->name ?? 'unknown' }}, {{ $na->created_at->format('j M Y') }}

@if($canNa ?? false)
@csrf @method('DELETE')
@endif
@endforeach
@endif {{-- Medication Competency Pack --}} @if($medCompetency ?? null) @php [$mcCls, $mcIcon, $mcLabel] = \App\Models\MedicationCompetency::stateBadge($medCompetency['state']); $mcCur = $medCompetency['current']; $mcRoute = auth()->user()->primaryRole().'.medication-competency.create'; @endphp
medication

Medication Competency Pack {{ $mcIcon }} {{ $mcLabel }}

@if($mcCur) {{ $mcCur->typeLabel() }} · assessed {{ $mcCur->assessed_at?->format('j M Y') }}@if($mcCur->expires_at) · renewal due {{ $mcCur->expires_at->format('j M Y') }}@endif @else Not yet assessed as competent to administer medication. @endif @if($medCompetency['open']) · assessment in progress@endif

@if(\Illuminate\Support\Facades\Route::has($mcRoute)) {{ $medCompetency['open'] ? 'play_arrow' : 'medication' }} {{ $medCompetency['open'] ? 'Continue assessment' : 'Open competency' }} @endif
@endif {{-- Record a past completion (SM / RM / Office Manager) — for training done before Segra whose record didn't come across from the original data --}} @if(($canRecord ?? false) && $recordableCourses->isNotEmpty())
history_edu

Record a past completion

Training {{ $worker->name }} completed that didn’t come across from the original records — e-learning or a face-to-face session. Choose it and the date it was completed: e-learning is marked complete from that date with a certificate issued to their Vault; a session is marked attended on that date. Renewal dates are worked out from the refresh cycle, and it’s recorded in the audit log under your name. Insulin / PEG / Dysphagia observations need the PDF — use Upload certificates below.

@csrf
@endif {{-- Upload certificates for this person → Staff Certificates page, person pre-selected --}} @if(($canUpload ?? false) && \Illuminate\Support\Facades\Route::has($approvalsRoute))
upload_file

Completed training elsewhere? Upload {{ $worker->name }}’s certificates (e.g. from a previous employer) — approved straight away.

upload Upload certificates
@endif {{-- This person's uploaded certificates --}} @if(($workerUploads ?? collect())->isNotEmpty()) @php $mgrFile = \Illuminate\Support\Facades\Route::has($role.'.external-certs.file'); @endphp

fact_check Uploaded certificates ({{ $workerUploads->count() }})

@if($workerUploads->where('status', 'pending')->isNotEmpty() && \Illuminate\Support\Facades\Route::has($approvalsRoute)) {{ $workerUploads->where('status', 'pending')->count() }} awaiting your approval chevron_right @endif
@foreach($workerUploads as $u) @endforeach
CourseCompletedUploaded byStatus
{{ $u->course->title ?? 'Course' }} {{ $u->sourceLabel() }}{{ $u->provider ? ' · '.$u->provider : '' }}{{ $u->certificate_number ? ' · No. '.$u->certificate_number : '' }} @if($mgrFile)View certificate file@endif {{ optional($u->completion_date)->format('j M Y') }} {{ (int) $u->submitted_by === (int) $u->user_id || ! $u->submitter ? $worker->name.' (self)' : $u->submitter->name }} {{ $u->created_at->format('j M Y') }} @if($u->isApproved()) check_circle Approved @if($u->reviewer)by {{ $u->reviewer->name }}@endif @elseif($u->isRejected()) error Not approved {{ $u->review_note }} @else hourglass_top Awaiting approval @endif
@endif {{-- All trainings --}}

All training ({{ $items->count() }})

Overdue and outstanding first

@php $badge = [ 'completed' => ['bg-primary/10 text-primary', 'check_circle', 'Completed'], 'overdue' => ['bg-error-container text-error', 'error', 'Overdue'], 'in_progress' => ['bg-gold/20 text-[#8a6d3b]', 'timelapse', 'In progress'], 'not_started' => ['bg-surface-container-high text-on-surface-variant', 'radio_button_unchecked', 'Not started'], ]; @endphp @forelse($items as $it) @php $b = $it['na'] ? ['bg-surface-container-high text-outline', 'block', 'N/A — not counted'] : ($badge[$it['status']] ?? $badge['not_started']); @endphp @empty @endforelse
Course Status Enrolled Completed Due / Renewal Actions
{{ $it['course']->title }} {{ $b[1] }} {{ $b[2] }} @if($it['status'] !== 'completed' && $it['progress'] > 0) {{ $it['progress'] }}% @endif {{ $it['assigned_at'] ? \Carbon\Carbon::parse($it['assigned_at'])->format('j M Y') : '—' }} {{ $it['completed_at'] ? \Carbon\Carbon::parse($it['completed_at'])->format('j M Y') : '—' }} @if($it['due_at']) @php $past = \Carbon\Carbon::parse($it['due_at'])->isPast(); @endphp {{ \Carbon\Carbon::parse($it['due_at'])->format('j M Y') }} @else — @endif @if($it['status'] === 'completed' && \Illuminate\Support\Facades\Route::has($role.'.worker.certificate')) workspace_premium View @elseif($canRecord ?? false) @elseif(! ($canReassign ?? false)) — @endif @if(($canNa ?? false) && ! $it['na'])
@csrf
@endif @if(($canReassign ?? false) && ($it['status'] !== 'not_started' || $it['progress'] > 0 || $it['completed_at'])) @endif
No training assigned.
{{-- Reassign for retake (SM / RM / Office Manager) — opened from a course row's "Retake" button --}} @if($canReassign ?? false) @endif {{-- Time spent per module (active on-screen time) --}} @php $fmtTime = function ($s) { $s = (int) $s; if ($s < 60) return $s.'s'; $m = intdiv($s, 60); $sec = $s % 60; if ($m < 60) return $m.'m'.($sec ? ' '.$sec.'s' : ''); $h = intdiv($m, 60); $mm = $m % 60; return $h.'h'.($mm ? ' '.$mm.'m' : ''); }; @endphp
schedule

Time spent per module

Total {{ $fmtTime($totalTime) }}
@forelse($moduleTimes as $courseTitle => $mods) @php $courseTotal = collect($mods)->sum('time_spent_seconds'); @endphp

{{ $courseTitle }}

{{ $fmtTime($courseTotal) }}
@empty
No active time recorded on any module yet.
@endforelse
{{-- Instructor-led training sessions --}}
co_present

Training sessions ({{ $sessions->count() }})

@if($sessions->isEmpty())
No training sessions booked yet.
@else
@foreach($sessions as $s) @php $badge = match($s['status']) { 'attended' => ['Attended', 'bg-primary/10 text-primary', 'check_circle'], 'no_show' => ['Missed', 'bg-error-container text-error', 'cancel'], 'on_leave' => ['On leave', 'bg-gold/20 text-on-surface', 'event_busy'], default => [$s['upcoming'] ? 'Booked' : 'Registered', 'bg-surface-container-high text-on-surface-variant', 'event_available'], }; $when = $s['status'] === 'attended' && $s['attended_at'] ? \Illuminate\Support\Carbon::parse($s['attended_at']) : $s['date']; @endphp @endforeach
Session Date Trainer Outcome
{{ $s['title'] }} @if($s['certificate_url'])workspace_premiumCertificate @endif· {{ $s['format'] === 'online' ? 'Online' : 'In-person' }} {{ $when ? \Illuminate\Support\Carbon::parse($when)->format('j M Y') : '—' }} {{ $s['trainer'] ?? '—' }} {{ $badge[2] }} {{ $badge[0] }}
@endif
@endsection