@extends('admin.layouts.app') @section('title', 'Order #' . $order->order_number) @section('content')
@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' => '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)
@csrf @endif
@if($isResellerPending) @endif @foreach($order->items as $index => $item) @if($isResellerPending) @endif @endforeach
Product Price Disc. % Qty Subtotal
@php $name = 'Unknown Item'; $imgPath = null; $subtext = null; if ($item->astrologer_pooja_service_id && $item->poojaService) { $name = ($item->poojaService->poojaService->name ?? ($item->poojaService->custom_name ?? 'Ritual Service')) . ' by ' . ($item->poojaService->user->name ?? 'Astrologer'); $imgPath = $item->poojaService->poojaService && $item->poojaService->poojaService->image ? asset('storage/' . $item->poojaService->poojaService->image) : null; $subtext = 'Ritual Service'; } elseif ($item->product) { $name = $item->product->name; $imgPath = $item->variation->image_path ?? $item->product->images->first()->image_path ?? null; } @endphp

{{ $name }}

@if($subtext)

{{ $subtext }}

@elseif(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)
@else
@endif
Subtotal ₹{{ number_format($order->subtotal, 2) }}
Shipping ₹{{ number_format($order->shipping_cost, 2) }}
@if($isResellerPending)
Overall Discount (%)
@endif @if($order->discount > 0 && !$isResellerPending)
Discount -₹{{ number_format($order->discount, 2) }}
@endif
TOTAL ₹{{ number_format($order->total, 2) }}
@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