@extends('admin.templates.layout') @php $assignedQty = collect($variantAssignment)->sum('assigned'); $remainingQty = collect($variantAssignment)->sum('remaining'); $activeDeliveries = $order->deliveries->filter(fn ($d) => (int) $d->status !== TRANSPORTER_DELIVERY_REJECTED); @endphp @section('head') @endsection @section('content') {{-- ═══════════════════════════════════════════════════════════ HEADER ═══════════════════════════════════════════════════════════ --}}
Assignment
{{ $order->order_reference }}
{!! order_status_badge($order->status) !!} {{ web_date_in_timezone($order->created_at, 'M d, Y h:i A') }}
{{-- Stats strip --}}
Total Units
{{ (int) $totalExpected }}
{{ $order->orderItems->count() }} item(s)
Assigned
{{ (int) $totalAssigned }}
Remaining
{{ (int) $totalRemaining }}
@if($totalRemaining > 0) Not yet assigned @else Fully assigned @endif
Deliveries
{{ $activeDeliveries->count() }}
{{ $order->deliveries->where('is_published', true)->count() }} on marketplace
{{-- Parties --}}
Merchant
@if($order->merchant)
@if($order->merchant->profileImage) @else
{{ strtoupper(substr($order->merchant->company_name ?: $order->merchant->name, 0, 1)) }}
@endif
{{ $order->merchant->company_name ?: $order->merchant->name }}
{{ $order->merchant->user_code }}
@if($order->merchant->email)
{{ $order->merchant->email }}
@endif @if($order->merchant->phone)
+{{ $order->merchant->dial_code }}{{ $order->merchant->phone }}
@endif
@else - @endif
Cargo Company
@if($order->cargoCompany)
@if($order->cargoCompany->profileImage) @else
{{ strtoupper(substr($order->cargoCompany->company_name ?: $order->cargoCompany->name, 0, 1)) }}
@endif
{{ $order->cargoCompany->company_name ?: $order->cargoCompany->name }}
{{ $order->cargoCompany->user_code }}
@if($order->cargoCompany->email)
{{ $order->cargoCompany->email }}
@endif @if($order->cargoCompany->phone)
+{{ $order->cargoCompany->dial_code }}{{ $order->cargoCompany->phone }}
@endif
@else Not assigned @endif
{{-- Right: quick actions --}}
{{-- ═══════════════════════════════════════════════════════════ VARIANT-LEVEL ASSIGNMENT ═══════════════════════════════════════════════════════════ --}}
Assignment Breakdown
{{ $order->orderItems->count() }} item(s) · {{ $totalExpected }} unit(s)
@php $i = 1; @endphp @forelse($order->orderItems as $item) @foreach($item->orderItemVariants as $variant) @php $a = $variantAssignment[$variant->id] ?? ['total'=>0,'assigned'=>0,'remaining'=>0]; $pct = $a['total'] > 0 ? round(($a['assigned'] / $a['total']) * 100) : 0; $barCls = $pct >= 100 ? '' : ($pct > 0 ? 'partial' : 'empty'); $deliveriesForVariant = $variantDeliveryMap[$variant->id] ?? []; @endphp @endforeach @empty @endforelse
# Item / Variant Total Assigned Remaining Progress Assigned To (Deliveries)
{{ $i++ }}
@if($variant->image) @elseif($item->image) @endif
{{ $item->name }}
{{ $variant->variant }}
{{ $a['total'] }} {{ $a['assigned'] }} @if($a['remaining'] > 0) {{ $a['remaining'] }} @else Full @endif
{{ $pct }}% assigned
@if(empty($deliveriesForVariant)) Not assigned @else
@foreach($deliveriesForVariant as $dv) @php $dvInfo = config("global.transporter_delivery_statuses.{$dv['status']}") ?? ['text'=>'—','class'=>'secondary']; @endphp {{ $dv['tracking_number'] }} · ×{{ $dv['quantity'] }} @endforeach
@endif
No items.
{{-- ═══════════════════════════════════════════════════════════ DELIVERIES ═══════════════════════════════════════════════════════════ --}}
Deliveries
{{ $order->deliveries->count() }} total · {{ $activeDeliveries->count() }} active
@if($order->deliveries->count()) @foreach($order->deliveries as $delivery) @php $dvInfo = config("global.transporter_delivery_statuses.{$delivery->status}") ?? ['text'=>'—','class'=>'secondary']; $rejected = (int) $delivery->status === TRANSPORTER_DELIVERY_REJECTED; @endphp
{{ $delivery->tracking_number }}
{{ $delivery->transporter?->user_code ?: '—' }} @if($delivery->transporter?->company_name || $delivery->transporter?->name) · {{ $delivery->transporter->company_name ?: $delivery->transporter->name }} @endif {{ $dvInfo['text'] }} @if($delivery->is_published) Marketplace @endif
@if($delivery->deliveryItems->count())
@foreach($delivery->deliveryItems as $di) {{ $di->variant?->orderItem?->name ?? '—' }} · {{ $di->variant?->variant ?? '—' }} · ×{{ $di->quantity }} @endforeach
@endif
{{ $delivery->quantity }}
units
{{ number_format((float) $delivery->total_charges, 2) }}
AED charges
@endforeach @else
No deliveries created yet — the cargo company hasn't assigned any transporter.
@endif
{{-- ═══════════════════════════════════════════════════════════ STATUS TIMELINE ═══════════════════════════════════════════════════════════ --}} @if($order->histories->count())
Order Status Timeline
{{ $order->histories->count() }} entries
@foreach($order->histories->sortByDesc('created_at') as $history)
{!! order_status_badge($history->status) !!}
{{ web_date_in_timezone($history->created_at, 'M d, Y h:i A') }}
{{ $history->remark ?: '—' }}
@if($history->changer) by {{ $history->changer->name }} @if($history->changed_by_role) ({{ config("global.user_roles.{$history->changed_by_role}") ?? '' }}) @endif @endif
@endforeach
@endif @endsection @section('script') {{-- no page-specific JS --}} @endsection