@php
/* A customer's signature, inked darker and thicker so it reads clearly: contrast turns faint
strokes black and keeps paper white; two copies half a point apart, multiplied, thicken each
stroke without drawing a box around a photographed one. */
$ink = fn (?string $src, string $alt = '') => $src
? ''
: '';
$date = fn ($value) => $value ? \Illuminate\Support\Carbon::parse($value) : null;
$compoundDate = $date($compound->compound_date);
$complianceFrom = $date($compound->compliance_from);
$officerDate = $date($compound->officer_signed_at) ?? $compoundDate;
$customerDate = $compound->customer_signed_at;
$accepted = $compound->customer_acceptance === 'accepted';
$declined = $compound->customer_acceptance === 'declined';
$answered = $compound->customer_acceptance !== null;
$amount = $compound->compound_amount === null ? null : (float) $compound->compound_amount;
/* A ruled answer line with the answer written on it, as the form is filled in by hand. */
$answer = fn ($value) => filled($value) ? e($value) : ' ';
$days = fn ($value) => $value ? e((string) $value) : ' ';
$dmy = fn ($value) => $value ? $value->format('d/m/Y') : str_repeat(' ', 10);
/* A blank of the paper form's width when nothing has been written on it yet. */
$fill = fn ($value, int $width = 18) => filled($value) ? e((string) $value) : str_repeat(' ', $width);
/* The form prints in the language it was filled in - Kiswahili unless the officer chose English. */
$lang = \Modules\Compounding\Support\FormLanguage::normalise($compound->language);
$t = \Modules\Compounding\Support\FormLanguage::text($lang);
/* A phrase that follows a filled-in name: English joins it with a comma, Kiswahili with a space. */
$after = fn (string $text) => (str_starts_with($text, ',') ? '' : ' ').e($text);
@endphp
{{--
FOMU YA UFIFILISHAJI - the official compounding form under section 46 of the Weights and
Measures Act, Cap. 340, printed.
The wording, the order of the sections, the numbered particulars, the declarations, the
signature lines and the office-use box are the official form's; nothing here is a redesign.
It is two pages because the official form is two pages: the offender's particulars, the
offence and their agreement on the first; their disagreement, the compounding officer's
declaration, the order or warning, the signatures and the office-use box on the second.
Where the paper form has a blank the officer fills by hand - a name, a number of days, a sum,
the sum in words - the printed form shows the recorded value on the same ruled line. Where the
paper offers two alternatives - nakuamuru/nakuonya, Bwana/Bibi - both are printed as they are
on the form, so a filled sheet reads exactly like a hand-filled one.
Long text flows: the offence and the order wrap and continue onto the next page rather than
being cut, and a section heading never sits alone at the foot of a page.
--}}
{{ $t['uf_decl_i'] }} {!! $fill($compound->offender_name, 18) !!}{!! $after($t['uf_decl_body']) !!}
{{ $t['uf_accept_body'] }} {!! $days($compound->compliance_days) !!} {{ $t['uf_accept_from'] }} {!! $dmy($complianceFrom) !!} {{ $t['uf_accept_end'] }}
{{ $t['uf_decline'] }}
@if ($declined && filled($compound->disagreement_reason)){{ $t['uf_officer_i'] }} {!! $fill($officerName, 18) !!}{!! $after($t['uf_officer_body']) !!} {!! $offenceCount > 0 ? e((string) $offenceCount) : str_repeat(' ', 6) !!} {{ $t['uf_officer_offences'] }} {!! $fill($compound->offender_name, 18) !!} {{ $t['uf_officer_pay'] }} {!! ($amount !== null) ? e(number_format($amount, 0).'/=') : str_repeat(' ', 12) !!} {{ $t['uf_in_words'] }} {!! $fill($compound->amount_in_words, 24) !!} {{ $t['uf_appeal'] }}
{{-- The officer signs on the left; the office's rubber stamp is set on the right. --}}{{ $t['uf_order_i'] }} {!! $fill($officerName, 18) !!}{!! $after($t['uf_order_body']) !!} {!! $fill($compound->offender_name, 18) !!} {{ $t['uf_order_that'] }}
@if (filled($compound->order_text)){{ $t['uf_order_fail'] }} {!! $days($compound->order_days ?: $compound->compliance_days) !!} {{ $t['uf_order_action'] }}
{{ $t['uf_office_paid'] }} {!! ($officeUse['amountPaid'] !== null) ? e(number_format($officeUse['amountPaid'], 0).'/=') : str_repeat(' ', 12) !!} @if (filled($officeUse['amountWords'] ?? null)) ({{ $officeUse['amountWords'] }}) @else {!! str_repeat(' ', 30) !!} {{ $t['uf_office_words'] }} @endif {{ $t['uf_office_receipt'] }} {!! $fill($officeUse['receiptNumber'], 12) !!} {{ $t['uf_office_dated'] }} {!! $dmy($date($officeUse['receiptDate'])) !!}, {{ $t['uf_office_issued'] }}
{{-- The receiving officer - the region's accountant - signs; the Regional Manager's stamp is struck over it. --}}