@extends('cargo_company.templates.layout') @php $quote = $order->activeQuote; $quoteInfo = $quote ? (config("global.quote_statuses.{$quote->status}") ?? ['text'=>'—','class'=>'secondary']) : null; $totalExpected = collect($variantAssignment)->sum('total'); $totalAssigned = collect($variantAssignment)->sum('assigned'); $totalRemaining = collect($variantAssignment)->sum('remaining'); $progressPct = $totalExpected > 0 ? round(($totalAssigned / $totalExpected) * 100) : 0; @endphp @section('head') @endsection @section('content') {{-- ═══════════════════════════════════════════════════════════ CREATE DELIVERY CTA (inline, above the header card) ═══════════════════════════════════════════════════════════ --}} @if($canCreateDelivery)
Ready to ship

{{ $totalAssigned }} of {{ $totalExpected }} units assigned. @if($totalRemaining > 0) {{ $totalRemaining }} remaining — assign them to a transporter. @endif

Create Delivery
@endif {{-- ═══════════════════════════════════════════════════════════ HEADER ROW — Info card + Quote panel ═══════════════════════════════════════════════════════════ --}}
Shipment
{{ $order->order_reference }}
{!! order_status_badge($order->status) !!} {{ web_date_in_timezone($order->created_at, 'M d, Y h:i A') }}
{{-- Stats --}}
Total Units
{{ (int) $totalExpected }}
{{ $order->orderItems->count() }} item(s)
Assigned
{{ (int) $totalAssigned }}
Remaining
{{ (int) $totalRemaining }}
@if($totalRemaining > 0) Not yet assigned @else Full @endif
Deliveries
{{ $order->deliveries->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 }}
@if($order->merchant->user_code)
{{ $order->merchant->user_code }}
@endif @if($order->merchant->email)
{{ $order->merchant->email }}
@endif @if($order->merchant->phone)
+{{ $order->merchant->dial_code }}{{ $order->merchant->phone }}
@endif
@else — @endif
Transporter(s)
@php $transporters = $order->deliveries ->map(fn ($d) => $d->transporter) ->filter() ->unique('id') ->values(); @endphp @forelse($transporters as $t)
{{ $t->company_name ?: $t->name }} @if($t->phone) · +{{ $t->dial_code }}{{ $t->phone }} @endif
@empty
Not assigned
@endforelse
Destination
{{ $order->destination_city ?: '—' }} @if($order->destination_country), {{ $order->destination_country }}@endif
Items Amount
{{ number_format((float) ($order->total_items_amount ?: 0), 2) }} {{ $order->currency ?: 'AED' }}
Weight
{{ $order->total_weight ?: 0 }} kg
{{-- ═══════════════════════════════════════════════════════════ QUOTE PANEL (right column — replaces admin's "Change Status") ═══════════════════════════════════════════════════════════ --}}
Shipping Quote
@if($quoteInfo) {{ $quoteInfo['text'] }} @endif
{{-- REQUESTED → form --}} @if($quote && $quote->status == QUOTE_REQUESTED)

Submit your price per variant. The sum becomes your total quote.

@csrf
@foreach($order->orderItems as $item) @foreach($item->orderItemVariants as $variant) @endforeach @endforeach
Variant Qty Price
{{ $item->name }}
{{ $variant->variant }}
{{ $variant->quantity }}
{{-- SUBMITTED → waiting + breakdown --}} @elseif($quote && $quote->status == QUOTE_SUBMITTED)
Waiting for merchant review.
Your total {{ number_format((float) $quote->total_amount, 2) }} AED
@if($quote->items->isNotEmpty())
Breakdown
@foreach($quote->items as $qi)
{{ $qi->orderItemVariant?->orderItem?->name ?? '—' }} · {{ $qi->orderItemVariant?->variant ?? '' }} {{ number_format((float) $qi->price, 2) }} AED
@endforeach
@endif {{-- ACCEPTED → accept shipment flow / create delivery --}} @elseif($quote && $quote->status == QUOTE_ACCEPTED)
Merchant accepted your quote.
@if((int) $order->status === ORDER_PENDING)
@elseif(in_array((int) $order->status, [ORDER_ACCEPTED, ORDER_ASSIGNED, ORDER_IN_TRANSIT]))
You accepted this shipment.
@if($canCreateDelivery) Create Delivery @else
All items assigned.
@endif @else
Shipment is now in {{ config("global.order_statuses.{$order->status}.text") ?? 'progress' }}.
@endif {{-- REJECTED --}} @elseif($quote && $quote->status == QUOTE_REJECTED)
Your quote was rejected.
{{-- CANCELLED --}} @elseif($quote && $quote->status == QUOTE_CANCELLED)
This quote was cancelled.
{{-- NO QUOTE --}} @else
No active quote for this shipment.
@endif
{{-- ═══════════════════════════════════════════════════════════ ITEMS ═══════════════════════════════════════════════════════════ --}}
Items
{{ $order->orderItems->count() }} item(s) · {{ $totalExpected }} unit(s)
@forelse($order->orderItems as $i => $item) @foreach($item->orderItemVariants as $vIdx => $variant) @php $a = $variantAssignment[$variant->id] ?? ['total'=>0,'assigned'=>0,'remaining'=>0]; $pct = $a['total'] > 0 ? round(($a['assigned'] / $a['total']) * 100) : 0; @endphp @if($vIdx === 0) @endif @if($vIdx === 0) @endif @endforeach @empty @endforelse
# Item Variants Total Assigned Remaining Amount
{{ $i + 1 }}
@if($item->image) @endif
{{ $item->name ?: '—' }}
@if($item->min_variant_price)
min {{ number_format((float) $item->min_variant_price, 2) }} AED
@endif
@if($variant->image) @elseif($item->image) @endif
{{ $variant->variant }}
{{ number_format((float) $variant->price, 2) }} AED
{{ $a['total'] }}
{{ $a['assigned'] }}
@if($a['remaining'] > 0) {{ $a['remaining'] }} @else Full @endif {{ number_format((float) ($item->total_items_amount ?: 0), 2) }}
AED
No items.
{{-- ═══════════════════════════════════════════════════════════ DELIVERIES ═══════════════════════════════════════════════════════════ --}}
Deliveries
{{ $order->deliveries->count() }} total @if($canCreateDelivery && $order->deliveries->count()) New Delivery @endif
@forelse($order->deliveries as $delivery) @php $dInfo = config("global.transporter_delivery_statuses.{$delivery->status}") ?? ['text' => 'Unknown', 'class' => 'secondary']; @endphp @if($delivery->statusHistories->isNotEmpty()) @endif @empty @endforelse
Tracking # Transporter Qty Charges Status Published Arrival Estimate Delivered At History
{{ $delivery->tracking_number }} {{ $delivery->transporter?->company_name ?: ($delivery->transporter?->name ?: '—') }} {{ $delivery->quantity }} {{ number_format((float) $delivery->total_charges, 2) }} AED {{ $dInfo['text'] }} @if($delivery->is_published) Yes @else No @endif {{ $delivery->arrival_estimate ? web_date_in_timezone($delivery->arrival_estimate, 'M d, Y h:i A') : '—' }} {{ $delivery->delivered_at ? web_date_in_timezone($delivery->delivered_at, 'M d, Y h:i A') : '—' }} @if($delivery->statusHistories->isEmpty()) — @else @endif
Delivery Status History — {{ $delivery->tracking_number }}
@foreach($delivery->statusHistories->sortByDesc('created_at') as $sh) @php $shInfo = config("global.transporter_delivery_statuses.{$sh->status}") ?? ['text' => 'Unknown', 'class' => 'secondary']; @endphp
{{ $shInfo['text'] }} {{ web_date_in_timezone($sh->created_at, 'M d, Y h:i A') }}
@endforeach
No deliveries yet.
@if($canCreateDelivery) Create First Delivery @endif
{{-- ═══════════════════════════════════════════════════════════ ORDER STATUS TIMELINE ═══════════════════════════════════════════════════════════ --}}
Status Timeline
{{ $order->histories->count() }} entries
@forelse($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
@empty
No status history yet.
@endforelse
{{-- Reject modal --}} @endsection @section('script') @endsection