@extends('admin.master') @section('content') @php $currentIndex = $order->status ?? 0; $nextIndex = $currentIndex + 1; $nextStatus = ($nextIndex < 4) ? ($status[$nextIndex] ?? null) : null; $deliveryCost = $deliveryDetail ? ($deliveryDetail['delivery_cost'] ?? 0) : 0; @endphp

Order

@if(session('success')) @endif @if(session('error')) @endif
@php $remaining_amount = ($order->total_price ?? 0) - ($paidAmount ?? 0); @endphp
Booking Details
@if(!auth('admin')->user()->isWarehouse()) Print / View Label @endif {{-- Already Cancelled --}} @if($order->status == 4) {{-- Can still move forward --}} @elseif ($nextStatus && !auth('admin')->user()->isWarehouse()) {{-- Delivered --}} @elseif(!auth('admin')->user()->isWarehouse()) @endif
@include('partials.warehouse-status-panel', [ 'order' => $order, 'updateUrl' => route('admin.warehouse.orders.status', $order->id), 'deliveryType' => 'catalog', ]) @if($order->logo) @endif @if($order->sample_images && count($order->sample_images)) @endif @if($order->status == 0) @endif
Booking ID UNK-{{ $order->id }}
Total Quantity {{ (int) $productDetail->sum('qty') }}
Total Price {{ number_format((float) $order->total_price,2) }}
Status {{ $status[$order->status] ?? 'N/A' }}
Company Name {{ ucwords($order->user->company_name ?? 'N/A') }}
Vat Number {{ ucwords($order->vat_number ?? 'N/A') }}
Contact Person {{ ucwords($order->user->name ?? 'N/A') }}
Email {{ ucwords($order->user->email ?? 'N/A') }}
Phone {{ $order->user->phone ?? 'N/A' }}
Country {{ ucwords($order->country ?? 'N/A') }}
City {{ ucwords($order->city ?? 'N/A') }}
Address {{ ucfirst($order->address ?? 'N/A') }}
Booking Date {{ $order->created_at->format('d-m-Y @ h:i a') }}
Last Update {{ $order->updated_at->format('d-m-Y @ h:i a') }}
Additional Notes {{ ucfirst($order->notes ?? 'N/A') }}
Image Logo
Sample Images @foreach($order->sample_images as $img) Sample @endforeach
Action {{-- Cancel Button (only status 0) --}} @if($order->status == 0) @php $hasPendingReceipt = $order->payment_method === 'Bank Transfer' && \App\Models\OrderReceipts::where('order_id', $order->id)->where('status', 0)->exists(); @endphp @if($hasPendingReceipt) Bank transfer is still Pending. Go to Payment & Finance tab → Approve or Reject first, then you can cancel. @else @endif @endif
@if($order->status == 4)
Order Cancelled
@if($order->refund_notes) @endif @if($order->refund_receipt) @endif
Cancelled By {{ ucfirst($order->cancelled_by) }}
Cancelled At {{ $order->cancelled_at?->format('d M Y @ h:i A') }}
Reason {{ $order->cancel_reason }}
Refund Status @if($order->refund_status === 'pending') Pending @elseif($order->refund_status === 'processed') Processed
Refunded on: {{ $order->refunded_at?->format('d M Y') }} @else Not Applicable @endif
Refund Notes {{ $order->refund_notes }}
Refund Receipt View
@endif
@if(!auth('admin')->user()->isWarehouse())
@php $remaining_amount = $order->total_price - $paidAmount; $deliveryCost = $deliveryDetail->delivery_cost ?? 0; @endphp @if($order->total_price) {{-- ==================== 1. PAYMENT SUMMARY ==================== --}}
Payment Summary
Download Invoice
@if((float) ($order->discount_amount ?? 0) > 0) @endif
Order Total Price {{ config('constants.currency_symbol') }} {{ number_format((float) $order->sub_total, 2, '.', '') }}
Discount ({{ rtrim(rtrim(number_format((float) $order->discount_percent, 2), '0'), '.') }}%) - {{ config('constants.currency_symbol') }} {{ number_format((float) $order->discount_amount, 2, '.', '') }}
VAT(15%) {{ config('constants.currency_symbol') }} {{ number_format((float) $order->vat_amount, 2, '.', '') }}
Total Price {{ config('constants.currency_symbol') }} {{ number_format((float) $order->total_price, 2, '.', '') }}
Delivery Cost {{ config('constants.currency_symbol') }} {{ number_format((float) $deliveryCost, 2, '.', '') }}
Amount Received {{ config('constants.currency_symbol') }} {{ number_format((float) $paidAmount, 2, '.', '') }}
Remaining Amount {{ config('constants.currency_symbol') }} {{ number_format((float) $remaining_amount, 2, '.', '') }}
Payment Method {{ match($order->payment_method) { 'Cash at Pickup' => 'Cash', 'bank' => 'Bank Transfer', 'card' => 'Card', default => ucfirst((string) ($order->payment_method ?? 'N/A')), } }} @if($order->payment_method === 'Credit') ({{ (int) ($order->user->credit_allowed ?? 0) }} Days) @endif
{{-- ==================== 3. RECORD PAYMENT MANUALLY ==================== --}} @if($remaining_amount > 0 && !(in_array($order->payment_method, ['Cash', 'Cash at Pickup'], true) && (int) $order->status === 4)) @if(in_array($order->payment_method, ['Cash', 'Cash at Pickup'], true))
Receive Cash
@csrf
Amount {{ config('constants.currency_symbol') }} {{ number_format($remaining_amount, 2) }}
Action
@else
Record Payment Received
@csrf
@endif @endif {{-- ==================== 2. PAYMENT RECEIPTS (NEW) ==================== --}}
Payment Receipts
@forelse($orderReceipts as $receipt) @empty @endforelse
Date Receipt Description Status Action
{{ $receipt->created_at->format('d-m-Y') }} @php $url = asset('storage/payment_receipt/' . $receipt->receipt); @endphp View {{ $receipt->description ?? 'N/A' }} @if($receipt->status == 0) Pending @elseif($receipt->status == 1) Accepted @else Rejected @endif @if($receipt->status == 0) @else — @endif
No payment receipts uploaded for this order.
{{-- ==================== 4. PAYMENT HISTORY ==================== --}}
Payment History
@forelse($paidLog as $log) @empty @endforelse
Detail Amount Date
Amount Received {{ config('constants.currency_symbol') }} {{ number_format((float) $log->amount, 2, '.', '') }} {{ date('d-m-Y', strtotime($log->created_at)) }}
No payment records found.
Total Received {{ config('constants.currency_symbol') }} {{ number_format((float) $paidAmount, 2, '.', '') }}
@else
Order total price is not set yet.
@endif
@if(!$deliveryDetail)

Add Delivery Details

@csrf
@endif @if($deliveryDetail)

Delivery Details

Delivery Company {{ ucfirst($deliveryDetail['delivery_company']) }}
Date {{ date('d-m-Y',strtotime($deliveryDetail['d_date'])) }}
Tracking ID {{ $deliveryDetail['tracking_id'] }}
Tracking URL {{ $deliveryDetail['tracking_url'] }}
Delivery Cost {{ number_format($deliveryDetail['delivery_cost']) }}
@endif
No messages yet. Start the conversation.
@csrf
@endif
@include('partials.order-delivery-manage', ['order' => $order, 'deliveryType' => 'catalog'])
{{-- Download / Print Buttons --}} @if(!empty($groupedProducts)) @foreach($groupedProducts as $productName => $productData) @php $colors = $productData['colors'] ?? []; $activeSizes = $productData['active_sizes'] ?? []; @endphp
{{ $productName }} @if(!empty($productData['product_code'])) ({{ $productData['product_code'] }}) @endif
Box Qty: {{ $productData['box_quantity'] ?? '—' }} | Per Pack: {{ $productData['per_pack_quantity'] ?? '—' }} | Packs/Box: {{ $productData['pack_per_box'] ?? '—' }}
@foreach($colors as $colorName => $data) @php $mobileSizeMap = []; foreach (($data['items'] ?? []) as $item) { $mobileSizeMap[$item['size']] = $item['qty']; } @endphp
{{ ucfirst($colorName) }} Total {{ $data['total_qty'] ?? 0 }}
SAR {{ number_format($data['total_price'] ?? 0, 2) }}
SizeQuantity
@foreach($activeSizes as $size)
{{ ucwords($size) }} {{ $mobileSizeMap[$size] ?? 0 }}
@endforeach
@endforeach
@if(count($activeSizes) > 0) @endif @foreach($activeSizes as $size) @endforeach @php $productTotalQty = 0; $productTotalPrice = 0; $sizeTotals = []; foreach ($activeSizes as $s) { $sizeTotals[$s] = 0; } @endphp @foreach($colors as $colorName => $data) @php $colorItems = $data['items'] ?? []; $colorTotalQty = $data['total_qty'] ?? 0; $colorTotalPrice = $data['total_price'] ?? 0; $productTotalQty += $colorTotalQty; $productTotalPrice += $colorTotalPrice; $sizeMap = []; foreach ($colorItems as $item) { $sizeMap[$item['size']] = $item['qty']; } foreach ($activeSizes as $size) { $sizeTotals[$size] += $sizeMap[$size] ?? 0; } @endphp @foreach($activeSizes as $size) @endforeach @endforeach @foreach($activeSizes as $size) @endforeach
Sr. Color SIZES Total Qty Total Price (SAR)
{{ ucwords($size) }}
{{ $loop->iteration }} {{ ucfirst($colorName) }}{{ $sizeMap[$size] ?? 0 }}{{ $colorTotalQty }} {{ number_format($colorTotalPrice, 2) }}
Total{{ $sizeTotals[$size] }}{{ $productTotalQty }} {{ number_format($productTotalPrice, 2) }}
@endforeach @endif
{{-- Accept Payment Modal --}} {{-- Cancel Order Modal (Admin) --}} @endsection @push('css-script') @endpush @push('js-script') @endpush