@php $statusBadge = [ 'draft' => 'slate', 'dispatched' => 'sky', 'received' => 'emerald', 'cancelled' => 'rose', ]; $statusLabel = [ 'draft' => __('Draft'), 'dispatched' => __('Dispatched'), 'received' => __('Received'), 'cancelled' => __('Cancelled'), ]; $kpiIcon = [ 'indigo' => 'bg-indigo-50 text-indigo-600', 'amber' => 'bg-amber-50 text-amber-600', 'emerald' => 'bg-emerald-50 text-emerald-600', 'sky' => 'bg-sky-50 text-sky-600', ]; $avatarColors = [ 'bg-indigo-100 text-indigo-700', 'bg-emerald-100 text-emerald-700', 'bg-amber-100 text-amber-700', 'bg-sky-100 text-sky-700', 'bg-rose-100 text-rose-700', 'bg-violet-100 text-violet-700', ]; $initials = function (?string $name): string { $parts = collect(preg_split('/\s+/', trim((string) $name)))->filter(); return $parts->isEmpty() ? '—' : $parts->take(2)->map(fn ($w) => mb_strtoupper(mb_substr($w, 0, 1)))->implode(''); }; $avatarColor = fn (?string $name): string => $avatarColors[abs(crc32((string) $name)) % count($avatarColors)]; @endphp
{{ __('New Delivery Note') }} {{-- Order context: cumulative fulfilment for the invoice/job you arrived from. --}} @if ($orderContext) @php $fmt = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); @endphp
{{ __('Deliveries for') }} {{ $orderContext['type'] === 'invoice' ? __('Invoice') : __('Job') }} {{ $orderContext['ref'] }}
{{ __('Ordered') }}: {{ $fmt($orderContext['ordered']) }} {{ __('Delivered') }}: {{ $fmt($orderContext['delivered']) }} {{ __('Outstanding') }}: {{ $fmt($orderContext['outstanding']) }}
{{ __('View all notes') }} @if ($orderContext['outstanding'] > 0) {{ __('New delivery note') }} · {{ __('remaining') }} {{ $fmt($orderContext['outstanding']) }} @else {{ __('Fully delivered') }} @endif
@endif
@foreach ($kpis as $kpi)

{{ $kpi['label'] }}

{{ $kpi['value'] }}

{{ $kpi['sub'] }}

@endforeach
@forelse ($deliveryNotes as $note)

{{ $note->customer?->name ?: '—' }}

@if ($note->project_name)

{{ $note->project_name }}

@endif
{{ $statusLabel[$note->status] ?? ucfirst($note->status) }}

{{ __('Delivered') }}: {{ rtrim(rtrim(number_format($note->total_delivered, 2), '0'), '.') }} @if ($note->total_outstanding > 0) · {{ __('Out') }} {{ rtrim(rtrim(number_format($note->total_outstanding, 2), '0'), '.') }} @endif

@empty
{{ __('No delivery notes yet.') }}
@endforelse
{{ $deliveryNotes->links() }}
{{ $editingId ? __('Edit Delivery Note') : __('New Delivery Note') }} @if ($delivery_number) {{ $delivery_number }} @endif
@foreach ($lines as $i => $line) @php $ordered = (float) ($line['ordered_qty'] ?? 0); $delivered = (float) ($line['delivered_qty'] ?? 0); $rowOutstanding = max(0, $ordered - $delivered); @endphp
{{ __('Item description') }}
{{ __('Colour') }}
{{ __('Ordered') }}
{{ __('Delivered') }}
{{ __('Size breakdown') }}
{{ __('Outstanding') }} {{ rtrim(rtrim(number_format($rowOutstanding, 2), '0'), '.') }}
{{ __('Description / specification') }}
@endforeach
{{-- Signed copy: upload the physically signed delivery note back into the system. --}}
{{ __('Signed copy') }} @if ($existingSignedUrl) {{ __('View signed copy') }} @endif
@if ($existingSignedUrl)

{{ __('Uploaded :when. Choose a file to replace it.', ['when' => $existingSignedAt]) }}

@else

{{ __('Upload the returned, signed delivery note (PDF, JPG or PNG).') }}

@endif
{{ __('Cancel') }} {{ __('Save') }}