@extends($layout ?? 'backend.layouts.app') @section('content')
{{ translate('POS Invoice') }} #{{ $order->code }}
{{ translate('Customer') }}
@php $address = json_decode($order->shipping_address); @endphp
{{ $address->name ?? translate('Walk-in Customer') }}
{{ $address->phone ?? '' }}
{{ $address->address ?? '' }}
{{ translate('Order Info') }}
{{ translate('Date') }}: {{ date('d M Y H:i', $order->date) }}
{{ translate('Payment') }}: {{ ucfirst($order->payment_status) }}
{{ translate('Payment Method') }}: {{ ucfirst($order->payment_type) }}
@foreach ($order->orderDetails as $detail) @endforeach
{{ translate('Item') }} {{ translate('Qty') }} {{ translate('Price') }} {{ translate('Total') }}
{{ $detail->product->getTranslation('name') }}
{{ $detail->variation }}
{{ $detail->quantity }} {{ single_price($detail->price / max(1, $detail->quantity)) }} {{ single_price($detail->price) }}
@php // Check if any order detail has prescription data $hasPrescription = $order->orderDetails->first(function ($detail) { return $detail->product_lens_id && $detail->cartLens; }); @endphp @if (($hasPrescription->cartLens->prescription_image || $hasPrescription->cartLens->eyesight_description) && env('ENABLE_LENSES', false))
{{ translate('Prescription Details') }}
@if ($hasPrescription->cartLens->prescription_image)
{{ translate('Prescription Image') }}:
Prescription
@endif @if ($hasPrescription->cartLens->eyesight_description)
{{ translate('Additional Notes') }}:

{{ $hasPrescription->cartLens->eyesight_description }}

@endif
@endif
@php // Calculate lens price and collect lens details from order details $lensPrice = 0; $productSubtotal = 0; $lensDetails = []; foreach ($order->orderDetails as $detail) { $productSubtotal += $detail->price; // Check if selected_lenses exists in order detail if (!empty($detail->selected_lenses)) { $selectedLenses = is_array($detail->selected_lenses) ? $detail->selected_lenses : json_decode($detail->selected_lenses, true); if (!empty($selectedLenses)) { foreach ($selectedLenses as $lensData) { $lensId = $lensData['id'] ?? null; $lensPrice += floatval($lensData['price'] ?? 0); // Get lens details if ($lensId) { $lens = \App\Models\Lens::find($lensId); if ($lens) { $lensDetails[] = [ 'name' => $lens->name, 'price' => floatval($lensData['price'] ?? 0), 'color' => $lensData['color'] ?? null, ]; } } } } } } @endphp @if ($lensPrice > 0 && env('ENABLE_LENSES', false)) @foreach ($lensDetails as $lensDetail)
{{ translate('Lens') }}: {{ $lensDetail['name'] }} @if ($lensDetail['color']) @endif {{ single_price($lensDetail['price']) }}
@endforeach @endif
{{ translate('Subtotal') }} {{ single_price($productSubtotal) }}
@if ($order->tax > 0)
{{ translate('Tax') }} {{ single_price($order->orderDetails->sum('tax')) }}
@endif @if ($order->coupon_discount > 0)
{{ translate('Discount') }} -{{ single_price($order->coupon_discount) }}
@endif
{{ translate('Grand Total') }} {{ single_price($order->grand_total) }}
@endsection