@extends('transporter.templates.layout') @php $ds = config('global.transporter_delivery_statuses')[$delivery->status] ?? ['text'=>'—','class'=>'secondary']; $canScan = ! in_array((int) $delivery->status, [TRANSPORTER_DELIVERY_COLLECTED, TRANSPORTER_DELIVERY_COMPLETED], true); $canConfirm = ! in_array((int) $delivery->status, [TRANSPORTER_DELIVERY_COLLECTED, TRANSPORTER_DELIVERY_COMPLETED], true); // Summary computations $totalVariants = $delivery->deliveryItems->count(); $totalSKUs = $delivery->deliveryItems->sum(fn ($i) => $i->products->count()); $progressPct = $expectedCount > 0 ? round(($scannedCount / $expectedCount) * 100) : 0; $allCollected = $delivery->deliveryItems->every(fn ($i) => (bool) $i->is_collected); @endphp @section('head') @endsection @section('content') {{-- ═══════════════════════════════════════════════════════════ HEADER ═══════════════════════════════════════════════════════════ --}}
{{ $delivery->tracking_number }}
{{ $ds['text'] }} · {{ web_date_in_timezone($delivery->created_at, 'M d, Y h:i A') }} @if($allCollected) · All items collected @endif
Back
{{-- ═══════════════════════════════════════════════════════════ SUMMARY TILES ═══════════════════════════════════════════════════════════ --}}
Summary
Expected Units
{{ (int) $expectedCount }}
{{ $totalVariants }} variant(s)
Scanned
{{ (int) $scannedCount }}
Remaining
{{ (int) max(0, $expectedCount - $scannedCount) }}
@if($expectedCount - $scannedCount > 0) still to scan @else ready to confirm @endif
Charges
{{ number_format((float) $delivery->total_charges, 2) }}
AED
{{-- ═══════════════════════════════════════════════════════════ LEFT — Info + Items + Scanned products ═══════════════════════════════════════════════════════════ --}}
{{-- Delivery Information --}}
Delivery Information
Order
{{ $delivery->order?->order_reference ?? '—' }}
Destination
{{ $delivery->order?->destination_city ?: '—' }}
Cargo Company
{{ $delivery->order?->cargoCompany?->company_name ?: ($delivery->order?->cargoCompany?->name ?: '—') }}
Merchant
{{ $delivery->order?->merchant?->company_name ?: ($delivery->order?->merchant?->name ?: '—') }}
Quantity
{{ number_format((int) $delivery->quantity) }}
Total Charges
{{ number_format((float) $delivery->total_charges, 2) }} AED
@if($delivery->delivered_at) Delivered @elseif($delivery->arrival_estimate) ETA @else Created @endif
@if($delivery->delivered_at) {{ web_date_in_timezone($delivery->delivered_at, 'M d, Y') }} @elseif($delivery->arrival_estimate) {{ web_date_in_timezone($delivery->arrival_estimate, 'M d, Y') }} @else {{ web_date_in_timezone($delivery->created_at, 'M d, Y') }} @endif
{{-- Items to Collect --}}
Items to Collect
{{ $totalVariants }} variant(s)
@forelse($delivery->deliveryItems as $di) @php $variant = $di->variant; $orderItem = $variant?->orderItem; $scannedQ = $di->products->count(); $expectedQ = (int) $di->quantity; $isDone = $di->is_collected; $amount = (float) ($di->amount ?? 0); $hasAmount = $amount > 0; // all reference IDs for this variant + which are scanned $allRefs = $variant?->orderItemVariantProducts?->pluck('reference_id') ?? collect(); $scannedRefs = $di->products->pluck('reference_id')->all(); @endphp @empty @endforelse
Item / Variant Expected Scanned Amount Status Reference IDs Action
@if($variant?->image) @elseif($orderItem?->image) @endif
{{ $orderItem?->name ?? '—' }}
{{ $variant?->variant ?? '—' }}
{{ $expectedQ }} {{ $scannedQ }} @if($hasAmount) {{ number_format($amount, 2) }} @else — @endif @if($isDone) Collected @elseif($scannedQ >= $expectedQ) Ready @else Pending @endif @if($allRefs->isEmpty()) — @else
@foreach($allRefs as $ref) {{ $ref }} @endforeach
@endif
@if(! $isDone && $canConfirm) @else — @endif
No items in this delivery
{{-- Scanned Products --}}
Scanned Products
{{ $scannedCount }} scanned
@php $collected = collect(); foreach ($delivery->deliveryItems as $di) { foreach ($di->products as $p) { $collected->push([ 'ref' => $p->reference_id, 'item' => $di->variant?->orderItem?->name, 'vname' => $di->variant?->variant, 'at' => $p->pivot?->created_at, ]); } } $collected = $collected->sortByDesc('at')->values(); @endphp @forelse($collected as $row) @empty @endforelse
Reference ID Item / Variant Scanned At
{{ $row['ref'] }}
{{ $row['item'] ?? '—' }}
{{ $row['vname'] ?? '—' }}
{{ $row['at'] ? web_date_in_timezone($row['at'], 'M d, Y h:i A') : '—' }}
No products scanned yet
{{-- ═══════════════════════════════════════════════════════════ RIGHT — Scanner + Confirm + Update + Timeline ═══════════════════════════════════════════════════════════ --}}
{{-- Scanner --}} @if($canScan)
Scan Products
Scan QR Codes

Scan each product to mark it as received.

{{ $scannedCount }} / {{ $expectedCount }} scanned
Each reference ID can only be scanned once.
No scans yet
@endif {{-- Confirm Collection --}} @if($canConfirm)
Confirm Collection
@if($allCollected)
Collection already confirmed. Use Update Status below to move to the next stage.
@else

Once all items are scanned, confirm collection. This sends a "picked up" notification to the merchant and cargo company.

@endif
@endif {{-- Update Status --}} @if(! in_array((int) $delivery->status, [TRANSPORTER_DELIVERY_COMPLETED, TRANSPORTER_DELIVERY_REJECTED], true))
Update Status
@endif {{-- Status Timeline --}} @if($delivery->statusHistories->count())
Status Timeline
@foreach($delivery->statusHistories->sortByDesc('created_at') as $h) @php $hs = config('global.transporter_delivery_statuses')[$h->status] ?? ['text'=>'—','class'=>'secondary']; @endphp
{{ $hs['text'] }}
{{ web_date_in_timezone($h->created_at, 'M d, Y h:i A') }}
@endforeach
@endif
@endsection @section('script') @endsection