@vite(['resources/css/app.css', 'resources/js/app.js']) @include('admin.partials.styles') @include('admin.partials.sidebar')

Order Details

Typography Settings

@if(session('success'))

{{ session('success') }}

@endif @if(session('error'))

{{ session('error') }}

@endif

Order #{{ $order->order_number }}

Order Details & Management

Invoice
@csrf
@php $steps = [ ['status' => 'pending', 'label' => 'Placed', 'icon' => 'M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z'], ['status' => 'processing', 'label' => 'Processed', 'icon' => 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4'], ['status' => 'shipped', 'label' => 'In Transit', 'icon' => 'M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 011 1v2a1 1 0 01-1 1m0-4h3m-11 0h1m11 0a1 1 0 001-1V7a1 1 0 00-1-1h-3.3a1 1 0 00-1 1v9h3.3z'], ['status' => 'completed', 'label' => 'Delivered', 'icon' => 'M5 13l4 4L19 7'], ]; $histories = $order->statusHistories->keyBy('status'); $isCancelled = $order->status === 'cancelled'; // Handle Returns if ($order->returnRequest) { $ret = $order->returnRequest; // Add Return Requested Step $steps[] = ['status' => 'return_requested', 'label' => 'Return Req.', 'icon' => 'M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6']; $histories->put('return_requested', $ret); if (in_array($ret->status, ['approved', 'received', 'refund_initiated', 'refunded'])) { $steps[] = ['status' => 'return_approved', 'label' => 'Return Appr.', 'icon' => 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z']; $histories->put('return_approved', (object) ['created_at' => $ret->updated_at]); } if ($ret->status == 'rejected') { $steps[] = ['status' => 'return_rejected', 'label' => 'Return Rejected', 'icon' => 'M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z']; $histories->put('return_rejected', (object) ['created_at' => $ret->updated_at]); } if ($ret->status == 'refunded') { $steps[] = ['status' => 'refunded', 'label' => 'Refunded', 'icon' => 'M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z']; $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-600', 'processing' => 'text-blue-600', 'shipped' => 'text-amber-600', 'completed' => 'text-green-600', 'return_requested' => 'text-yellow-600', 'return_approved' => 'text-blue-600', 'return_rejected' => 'text-red-600', 'refunded' => 'text-purple-600', ]; @endphp
@if(!$isCancelled)
@endif
@foreach ($steps as $index => $step) @php $active = $histories->has($step['status']); $isCurrent = $order->status === $step['status']; // Note: For returns, strict equality check on $order->status might not capture "current" properly since status might be 'completed' while return is 'requested'. // But this matches the loop logic. The visual 'active' state is driven by $active (history existence). $labelColor = $active ? ($statusLabelColors[$step['status']] ?? 'text-gray-900') : 'text-gray-400'; $iconClasses = $active ? 'bg-indigo-600 border-indigo-600 text-white shadow-lg scale-110' : 'bg-white border-gray-200 text-gray-300'; // Custom styling for return steps to make them distinct if ($active && str_contains($step['status'], 'return')) { $iconClasses = 'bg-blue-600 border-blue-600 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-600 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 }}

@if($hist = $order->statusHistories->where('status', 'cancelled')->first())

Cancelled on {{ $hist->created_at->format('F d, Y \a\t h:i A') }}

@endif
@endif

Order Items

{{ $order->items->count() }} Items @if(request('role') === 'Reseller') @if($order->status == 'quotation_sent') Quotation Sent @elseif($order->status == 'quotation_accepted') Quotation Accepted @endif @endif
@php $isResellerPending = request('role') === 'Reseller' && $order->status === 'pending'; @endphp @if($isResellerPending)
@csrf @endif
@if($isResellerPending) @endif @foreach($order->items as $index => $item) @if($isResellerPending) @endif @endforeach
Product Price Disc. % Qty Subtotal
@php $imgPath = $item->variation->image_path ?? $item->product->images->first()->image_path ?? null; @endphp
@if($imgPath) @else
N/A
@endif

{{ $item->product->name ?? 'Deleted Product' }}

@if(isset($item->options['attributes']))
@foreach($item->options['attributes'] as $attr) {{ $attr['attribute'] }}: {{ $attr['value'] }} @endforeach
@endif
@if($isResellerPending)
@else ₹{{ number_format($item->price, 2) }} @endif
{{ $item->quantity }}
@if($isResellerPending)

This will update prices and initiate the quotation flow.

@else
@endif
{{-- Subtotal --}}
Subtotal ₹{{ number_format($order->subtotal, 2) }}
{{-- Shipping --}}
Shipping ₹{{ number_format($order->shipping_cost, 2) }}
{{-- Reseller Overall Discount Input --}} @if($isResellerPending)
Overall Discount (%)
@endif {{-- Coupon Discount --}} @if($order->discount > 0 && !$isResellerPending)
Discount @if($order->coupon_code) {{ $order->coupon_code }} @endif
-₹{{ number_format($order->discount, 2) }}
@endif {{-- Points / Wallet --}} @if($order->points_discount > 0)
Wallet Used {{ $order->points_redeemed }} Pts
-₹{{ number_format($order->points_discount, 2) }}
@endif {{-- Gift Card --}} @if($order->gift_card_discount > 0)
Gift Card -₹{{ number_format($order->gift_card_discount, 2) }}
@endif {{-- Final Total --}}
TOTAL ₹{{ number_format($order->total, 2) }}
@if($isResellerPending)
@endif
{{-- Final Ratings Section --}} @if($order->agentRating || $order->productReviews->isNotEmpty())

Customer Feedback & Reviews

@if($order->agentRating)

Delivery Performance

Driver: {{ $order->deliveryAgent->user->name ?? 'N/A' }}

@for($i = 1; $i <= 5; $i++) @endfor
@if($order->agentRating->comment)

"{{ $order->agentRating->comment }}"

@endif
@endif @if($order->productReviews->isNotEmpty())

Product Experience

@foreach($order->productReviews as $review)

{{ $review->product->name }}

@for($i = 1; $i <= 5; $i++) @endfor
@if($review->comment)

"{{ $review->comment }}"

@endif
@endforeach
@endif
@endif
@if(request('role') !== 'Reseller')

Customer Profile

{{ substr($order->name, 0, 1) }}

{{ $order->name }}

{{ $order->email }}

Contact {{ $order->phone }}
Account {{ $order->user_id ? 'Registered' : 'Guest' }}
@endif

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 }}

class="text-indigo-300 font-bold mt-2 inline-block bg-white/5 px-3 py-1 rounded-full text-xs box-shadow ring-1 ring-white/10"> {{ $order->shippingAddress->country }} / {{ $order->shippingAddress->postal_code }}

Phone: {{ $order->shippingAddress->phone }}
@else

No physical address found.

@endif

Payment Summary

Method

{{ $order->payment_method ?? 'Unknown' }}

{{ $order->payment_status }}
@if($order->razorpay_order_id || $order->transaction_id)

{{ $order->razorpay_order_id ?? $order->transaction_id }}

@endif
@if($order->order_scope === 'Local' && request('role') !== 'Reseller')

Fleet Management

@if($order->deliveryAgent)
{{ substr($order->deliveryAgent->user->name ?? 'A', 0, 1) }}

{{ $order->deliveryAgent->user->name ?? 'Unknown' }}

{{ $order->deliveryAgent->phone ?? 'No Phone' }}

@endif
@csrf @if($order->status == 'cancelled' || $order->status == 'completed' || $order->status == 'returned')
Agent Locked (Order {{ ucfirst($order->status) }})
@endif @if($order->order_scope === 'Local' && $order->status === 'pending')
@elseif($order->pickupStore)

Assigned Pickup Store

{{ $order->pickupStore->name }}

{{ $order->pickupStore->city }}, {{ $order->pickupStore->state }}

@endif
@if($order->status !== 'completed' && $order->status !== 'cancelled' && $order->status !== 'returned') @endif
@endif