@extends('admin.layouts.app')
@section('title', 'Order #' . $order->order_number)
@section('content')
@if(session('success'))
@endif
@if(session('error'))
@endif
Order #{{ $order->order_number }}
Order Details &
Management
@php
$steps = [
['status' => 'pending', 'label' => 'Placed', 'icon' => 'shopping-cart'],
['status' => 'processing', 'label' => 'Processed', 'icon' => 'package'],
['status' => 'shipped', 'label' => 'In Transit', 'icon' => 'truck'],
['status' => 'completed', 'label' => 'Delivered', 'icon' => 'check-circle'],
];
$histories = $order->statusHistories->keyBy('status');
$isCancelled = $order->status === 'cancelled';
// Handle Returns
if ($order->returnRequest) {
$ret = $order->returnRequest;
$steps[] = ['status' => 'return_requested', 'label' => 'Return Req.', 'icon' => 'rotate-ccw'];
$histories->put('return_requested', $ret);
if (in_array($ret->status, ['approved', 'received', 'refund_initiated', 'refunded'])) {
$steps[] = ['status' => 'return_approved', 'label' => 'Return Appr.', 'icon' => 'thumbs-up'];
$histories->put('return_approved', (object) ['created_at' => $ret->updated_at]);
}
if ($ret->status == 'rejected') {
$steps[] = ['status' => 'return_rejected', 'label' => 'Return Rejected', 'icon' => 'x-circle'];
$histories->put('return_rejected', (object) ['created_at' => $ret->updated_at]);
}
if ($ret->status == 'refunded') {
$steps[] = ['status' => 'refunded', 'label' => 'Refunded', 'icon' => 'banknote'];
$histories->put('refunded', (object) ['created_at' => $ret->refunded_at]);
}
}
$furthestStep = -1;
foreach ($steps as $index => $step) {
if ($histories->has($step['status']))
$furthestStep = $index;
}
$totalShownSteps = count($steps) + ($isCancelled ? 1 : 0);
$progressPercentage = ($totalShownSteps > 1) ? ($furthestStep / ($totalShownSteps - 1)) : 0;
$progressWidth = $progressPercentage * 100;
$statusLabelColors = [
'pending' => 'text-indigo-400',
'processing' => 'text-blue-400',
'shipped' => 'text-amber-400',
'completed' => 'text-green-400',
'return_requested' => 'text-yellow-400',
'return_approved' => 'text-blue-400',
'return_rejected' => 'text-red-400',
'refunded' => 'text-purple-400',
];
@endphp
@if(!$isCancelled)
@endif
@foreach ($steps as $index => $step)
@php
$active = $histories->has($step['status']);
$labelColor = $active ? ($statusLabelColors[$step['status']] ?? 'text-white') : 'text-slate-500';
$iconClasses = $active
? 'bg-blue-600 border-blue-500 text-white shadow-lg scale-110'
: 'bg-slate-800 border-slate-600 text-slate-500';
if ($active && str_contains($step['status'], 'return'))
$iconClasses = 'bg-indigo-600 border-indigo-500 text-white shadow-lg scale-110';
if ($active && $step['status'] == 'return_rejected')
$iconClasses = 'bg-red-500 border-red-500 text-white shadow-lg scale-110';
if ($active && $step['status'] == 'refunded')
$iconClasses = 'bg-purple-600 border-purple-500 text-white shadow-lg scale-110';
@endphp
{{ $step['label'] }}
@if($active && ($hist = $histories->get($step['status'])))
{{ $hist->created_at->format('M d • h:i A') }}
@endif
@endforeach
@if($isCancelled)
Cancelled
@if($hist = $histories->get('cancelled'))
{{ $hist->created_at->format('M d • h:i A') }}
@endif
@endif
@if($order->status === 'cancelled' && $order->cancellation_reason)
Cancellation Reason
{{ $order->cancellation_reason }}
@endif
Order Items
{{ $order->items->count() }}
Items
@php $isResellerPending = request('role') === 'Reseller' && $order->status === 'pending'; @endphp
@if($isResellerPending)
@endif
Customer Profile
{{ substr($order->name, 0, 1) }}
{{ $order->name }}
{{ $order->email }}
Contact
{{ $order->phone }}
Delivery Location
@if($order->shippingAddress)
{{ $order->shippingAddress->name }}
{{ $order->shippingAddress->address_line1 }}
@if($order->shippingAddress->address_line2)
{{ $order->shippingAddress->address_line2 }}
@endif
{{ $order->shippingAddress->city }}, {{ $order->shippingAddress->state }}
{{ $order->shippingAddress->country }} / {{ $order->shippingAddress->postal_code }}
@else
No physical address found.
@endif
@endsection