{{-- resources/views/probation/cases/_pr2.blade.php PR 2 — Supervision record ("Order for supervision" sheet). Blank fields are pre-filled from what the case already holds; the officer completes the rest. Name, serial, officer and breaches are always live. --}} @php $pf = $case->supervisionProfile; $order = $case->supervisionOrders->sortBy('start_date')->first(); $latest = $case->supervisionOrders->sortByDesc('created_at')->first(); $from = optional($pf)->order_from ?? optional($order)->start_date; $to = optional($pf)->order_to ?? optional($latest)->extension_to ?? optional($latest)->end_date; $months = ($from && $to) ? \Carbon\Carbon::parse($from)->diffInMonths(\Carbon\Carbon::parse($to)) : null; $autoDuration = $months !== null ? ($months >= 12 && $months % 12 === 0 ? ($months / 12) . ' year(s)' : $months . ' month(s)') : ''; $autoVariation = $case->supervisionOrders->filter(fn ($o) => $o->extension_to) ->map(fn ($o) => 'Extended to ' . $o->extension_to->format('d M Y'))->implode('; '); $v = fn ($k, $auto = '') => old($k, optional($pf)->{$k} ?? $auto); // contacts: saved list, else next of kin $contacts = optional($pf)->contacts ?: collect(optional($case->prisoner)->nextOfKin ?? [])->map(fn ($k) => [ 'name' => $k->name, 'relationship' => $k->relationship, 'phone' => $k->phone, 'address' => '', ])->values()->all() ?: []; while (count($contacts) < 4) $contacts[] = ['name' => '', 'relationship' => '', 'phone' => '', 'address' => '']; $jobs = optional($pf)->employment_record ?: []; while (count($jobs) < 3) $jobs[] = ['record' => '', 'duration_wages' => '', 'reason_for_leaving' => '']; @endphp
PR 2 — Supervision Record
@if($pf) Last saved {{ $pf->updated_at->format('d M Y H:i') }} @else Pre-filled from the case — review and save @endif
{{-- always-live details --}}
Serial No.
{{ $case->serial_number }}
Name
{{ optional($case->prisoner)->name }}
Probation Officer
{{ optional($case->officer)->name ?? 'Unassigned' }}
Breaches
@if($case->breaches->count()) {{ $case->breaches->count() }} — latest {{ optional($case->breaches->sortByDesc('reported_on')->first()->reported_on)->format('d M Y') }} @else None @endif
@csrf
Order for supervision
School particulars
Persons interested and who to contact in case need arises
@if(!$pf && collect(optional($case->prisoner)->nextOfKin ?? [])->count())
Filled from the client's next of kin.
@endif
@foreach($contacts as $i => $c) @endforeach
NameRelationshipPhoneAddress
{{ ['i','ii','iii','iv','v','vi','vii','viii'][$i] ?? $i + 1 }}.
Employment
@foreach($jobs as $i => $j) @endforeach
Employment recordDuration / wagesReasons for leaving