{{-- Search Bar - 對齊取貨碼風格 --}}
@foreach($machines as $m) @endforeach
{{-- 付款狀態 --}}
{{-- 出貨狀態 --}}
{{-- 開始時間 --}}
{{ __('Start Time') }}
{{-- 結束時間 --}}
{{ __('End Time') }}
@if(auth()->user()->isSystemAdmin()) {{-- 手動補單:機台斷線/漏報時人工補登銷售紀錄(僅系統管理員) --}} @endif
@if($isImplicitFilter)
{{ __('Showing last 6 months by default when no date range is selected') }}
@endif {{-- Table (Desktop) --}} {{-- Mobile Cards (xl:hidden) --}}
@forelse($orders as $order)
@php $statusMap = [ 'pending' => ['label' => __('Pending'), 'color' => 'amber'], 'paid' => ['label' => __('Paid'), 'color' => 'emerald'], 'completed' => ['label' => __('Completed'), 'color' => 'emerald'], 'failed' => ['label' => __('Failed'), 'color' => 'rose'], 'abandoned' => ['label' => __('Unpaid'), 'color' => 'slate'], 'cancelled' => ['label' => __('Cancelled'), 'color' => 'slate'], 'refunded' => ['label' => __('Refunded'), 'color' => 'rose'], ]; $s = $statusMap[$order->status] ?? ['label' => $order->status, 'color' => 'slate']; $invoiceSearchValue = $order->invoice ? $order->invoice->invoice_no : $order->order_no; $targetUrl = route('admin.sales.index', ['tab' => 'invoices', 'search' => $invoiceSearchValue]); @endphp {{-- Card Header --}}

{{ $order->order_no }} @if($order->is_manual) {{ __('Manual') }} @endif

{{ $order->machine->name ?? 'Unknown' }}

{{-- Info Grid --}}

{{ __('Order Items') }}

@if($order->items->count() > 0) {{ $order->items->first()->product_name }} @if($order->items->count() > 1) {{ __('and :count other items', ['count' => $order->items->count()]) }} @endif @else {{ __('No product record found') }} @endif

{{ __('Amount / Payment') }}

${{ number_format($order->total_amount, 0) }} {{ $paymentTypes[$order->payment_type] ?? '??' }}

@if($order->payment_type == 41 && $order->staffCardLog && $order->staffCardLog->staffCard)
{{ $order->staffCardLog->staffCard->name }} ({{ $order->staffCardLog->staffCard->employee_id }})
@endif @if($order->payment_type == 42 && !empty($order->member_barcode))
{{ $order->masked_pickup_recipient }}
@endif

{{ __('Order Time') }}

{{ $order->created_at->format('m-d H:i') }} {{ $order->created_at->diffForHumans() }}

{{ __('Invoice Number') }}

@php $invVoided = $order->invoice && $order->invoice->status === 'void'; @endphp

{{ $order->invoice->invoice_no ?? '---' }} @if($invVoided) {{ __('Voided') }} @endif

{{ __('Dispense Status') }}

{{-- 非付款成功(未完成/支付失敗/未支付)的單從未出貨,出貨狀態無意義 → 顯示 '--' --}} @if(! $order->hasDeliveryOutcome()) -- @else @php $deliveryStatusMap = [ 0 => ['label' => __('Dispense Failed'), 'color' => 'rose'], 1 => ['label' => __('Dispense Success'), 'color' => 'emerald'], 2 => ['label' => __('Partial Dispense Success'), 'color' => 'amber'], ]; $ds = $deliveryStatusMap[$order->delivery_status] ?? ['label' => __('Unknown'), 'color' => 'slate']; @endphp @endif
{{-- Remark --}}

{{ __('Remark') }}

{{-- Action Buttons --}}
@empty
@endforelse
{{-- Pagination --}}
{{ $orders->links('vendor.pagination.luxury', ['page_param' => 'orders_page']) }}