{{-- resources/views/probation/cases/_cso_work.blade.php CSO Quantification: hours ordered vs worked (progress), value of work in KSh at the area rate, daily work record (CS 5), placements & agency matching, skills transferred, employment linkage. --}} @php $placements = $case->placements->sortByDesc('id'); $current = $placements->first(); $hoursOrd = (float) optional($case->cso)->hours_required; $hoursDone = \App\Support\ReportFormData::hoursWorked($case); $value = \App\Support\ReportFormData::value($case); $pct = $hoursOrd > 0 ? min(100, round(100 * $hoursDone / $hoursOrd)) : 0; $rate = optional($current)->wage_rate; $logs = $case->workLogs->sortByDesc('work_date'); // matching: agencies whose skills / work available mention words from the client's skills or offence-free text $needle = strtolower(trim(($current->skills_transferred ?? '') . ' ' . optional($case->supervisionProfile)->occupation)); $match = $agencies->map(function ($a) use ($needle) { $hay = strtolower($a->skills_offered . ' ' . $a->work_available . ' ' . $a->work_profile); $score = 0; foreach (preg_split('/[\s,;]+/', $needle) as $w) if (strlen($w) > 3 && str_contains($hay, $w)) $score++; return (object) ['agency' => $a, 'score' => $score]; })->sortByDesc('score'); @endphp
{{-- quantification --}}
CSO Quantification
Hours completed{{ rtrim(rtrim(number_format($hoursDone, 1), '0'), '.') }} / {{ $hoursOrd ? rtrim(rtrim(number_format($hoursOrd, 1), '0'), '.') : '—' }}
{{ $pct }}%
Balance of hours
{{ $hoursOrd ? max(0, $hoursOrd - $hoursDone) : '—' }}
Rate for the area
{{ $rate !== null ? 'KSh ' . number_format($rate, 2) . '/hr' : '—' }}
Value of work done
KSh {{ number_format($value, 2) }}
Full order value
{{ ($hoursOrd && $rate) ? 'KSh ' . number_format($hoursOrd * $rate, 2) : '—' }}
Days worked
{{ $logs->count() }}
Value = hours worked × prevailing rate for the work area.
{{-- daily work record (CS 5) --}}
Work record (CS 5)
@if($current)
@csrf
@else
Place the offender with a work agency first (below).
@endif
@forelse($logs as $l) @empty@endforelse
DateTaskHoursKShAgency comment
{{ $l->work_date->format('d M Y') }}{{ $l->task }}{{ $l->hours + 0 }} {{ number_format($l->hours * ($l->wage_rate ?? 0), 2) }}{{ $l->agency_comment }}
@csrf @method('DELETE')
No days recorded yet.
The CS 5 form (Reports → CS 5) is filled from this record month by month.
{{-- placements --}}
Work agency placement
@forelse($placements as $p) @empty@endforelse
AgencyAreaAssignedArrivalRate/hrStatus
{{ optional($p->agency)->name ?? '—' }}{{ $p->area ?? optional($p->agency)->area ?? '—' }} {{ optional($p->assigned_on)->format('d M Y') }} {{ $p->arrival_confirmed ? optional($p->arrival_date)->format('d M Y') : 'Pending' }} {{ $p->wage_rate !== null ? number_format($p->wage_rate, 2) : '—' }} {{ $p->ended_on ? 'Ended ' . \Carbon\Carbon::parse($p->ended_on)->format('d M Y') : 'Current' }}
No placement yet.
@if($current && !$current->arrival_confirmed)
@csrf
@endif @unless($current)
@csrf
@else
To move the offender to another agency use Overview → Transfer → To another work agency.
@endunless @if($match->where('score', '>', 0)->count())
Agencies matching the skills on record: {{ $match->where('score', '>', 0)->take(5)->map(fn ($m) => $m->agency->name . ($m->agency->skills_offered ? ' (' . $m->agency->skills_offered . ')' : ''))->implode(' · ') }}
@endif @can('probation.cso.view')@endcan
{{-- skills transfer & employment linkage --}}
Skills transferred & employment linkage
@if($current)
@csrf
@csrf
@endif
Tools / equipment provided: {{ $case->empowerments->whereIn('type', ['tools', 'startup_capital', 'vocational_training'])->map(fn ($e) => $e->description ?: (config('probation_workflow.empowerment_types')[$e->type] ?? $e->type))->implode(', ') ?: 'none yet' }} — record them in the Empowerment tab.