@php $format = request('format', 'invoice'); @endphp @if($format === 'delivery_docket') @include('backend.sales.delivery_docket_print_preview') @elseif($format === 'freight') @include('backend.sales.freight_print_preview') @else {{-- Default Invoice Format --}}
{{--

TAX INVOICE

Tyres Planet PTY LTD

209 Mcroyle St, Wacol 4076

CALL: 07 3144 3131

E-mail: Sales@tyresplanet.com.au

Website: https://tyresplanet.com.au/

--}}
@php $base64Image = base64_encode(file_get_contents(public_path('assets/images/tyres_logo.png'))); @endphp Logo

Sales@tyresplanet.com.au

www.tyresplanet.com.au

ABN. 95 633 998 624

TAX INVOICE

Tyres Planet PTY LTD

209 Mcroyle St, Wacol 4076

CALL: 07 3144 3131

@if ($orderData['user_id'] === 104)

Ship To:

Cash Sale

Email: {{ $orderData['cash_sale_email'] ?? '' }}

Company Name: {{ $orderData['cash_sale_company_name'] ?? 'Cash Sale' }}

@else

Bill To:


@php // 1) Choose source (billing → shipping → JSON) $billSource = $billingAddress ?: $shippingAddress ?: null; // 2) JSON Address fallback ONLY if no saved billing $billJson = !$billingAddress && $shippingJson ? $shippingJson : []; // 3) Build full address if ($billSource) { // Address from DB $billFullAddress = $billSource->address; $billFullAddress .= $billSource->locationCity ? ', ' . $billSource->locationCity->name : ''; $billFullAddress .= $billSource->locationState ? ', ' . $billSource->locationState->name : ''; $billFullAddress .= $billSource->locationCountry ? ', ' . $billSource->locationCountry->name : ''; $billFullAddress .= $billSource->zip_code ? ', ' . $billSource->zip_code : ''; } else { // Address from JSON // Convert IDs to names $jsonCity = !empty($billJson['city']) ? \Botble\Location\Models\City::find($billJson['city']) : null; $jsonState = !empty($billJson['state']) ? \Botble\Location\Models\State::find($billJson['state']) : null; $jsonCountry = !empty($billJson['country']) ? \Botble\Location\Models\Country::find($billJson['country']) : null; $billFullAddress = $billJson['address'] ?? ''; $billFullAddress .= $jsonCity ? ', ' . $jsonCity->name : ''; $billFullAddress .= $jsonState ? ', ' . $jsonState->name : ''; $billFullAddress .= $jsonCountry ? ', ' . $jsonCountry->name : ''; $billFullAddress .= !empty($billJson['postal_code']) ? ', ' . $billJson['postal_code'] : ''; } @endphp @if ($customer['company_name']) Name: {{ $customer['company_name'] ?? '-' }}
@else {{-- BILL TO DETAILS --}} Name: {{ $billSource->name ?? ($billJson['name'] ?? '-') }}
@endif Address: {!! nl2br(e($billFullAddress)) !!}
Phone: {{ $billSource->phone ?? ($billJson['phone'] ?? '-') }}
Email: {{ $billSource->email ?? ($billJson['email'] ?? '-') }}

Shipp To:


@if ($shippingAddress) @php $shippingFullAddress = $shippingAddress->address; if ($shippingAddress->locationCity) { $shippingFullAddress .= ', ' . $shippingAddress->locationCity->name; } if ($shippingAddress->locationState) { $shippingFullAddress .= ', ' . $shippingAddress->locationState->name; } if ($shippingAddress->locationCountry) { $shippingFullAddress .= ', ' . $shippingAddress->locationCountry->name; } if ($shippingAddress->zip_code) { $shippingFullAddress .= ', ' . $shippingAddress->zip_code; } @endphp Name: {{ $shippingAddress->name ?? '-' }}
Address: {!! nl2br(e($shippingFullAddress)) !!}
Phone: {{ $shippingAddress->phone ?? '-' }}
Email: {{ $shippingAddress->email ?? '-' }}
@else Name: {{ $orderData['shipping_first_name'] ?? '-' }} {{ $orderData['shipping_last_name'] ?? '' }}
Address: {{ $orderData['shipping_address_1'] ?? '' }}
Phone: {{ $orderData['shipping_phone'] ?? '-' }}
Email: {{ $orderData['shipping_email'] ?? '-' }}
@endif
@endif

Invoice:

Invoice No: {{ $orderData['order_number'] }}

Date: {{ $orderData['order_date'] }}

Payment Status: {{ ucwords(str_replace('_', ' ', $orderData['payment_status'])) }}

Payment: {{ strtoupper(str_replace('_', ' ', $orderData['payment_method'])) }}

Shipping: @if($orderData['shipping_method'] === 'pickup') Pick-up @else Delivery @endif

@php $totalQty = 0; $totalAmount = 0; $totalTaxAmount = 0; $finalTotal = 0; @endphp @foreach ($products as $index => $product) @php $totalQty += $product['quantity']; $subtotal = $product['amount']; $totalAmount += $subtotal; $taxPercent = $product['tax_percent'] ?? 0; $taxAmount = $product['tax_amount'] ?? 0; $totalTaxAmount += $taxAmount; $lineTotal = $subtotal + $taxAmount; $finalTotal += $lineTotal; @endphp @endforeach @for ($i = count($products); $i < 8; $i++) @endfor {{-- --}}
No Product Description Price Qty Subtotal Tax(%) Tax($) Total
{{ $index + 1 }} {{ $product['name'] }} ${{ number_format($product['price'], 2) }} {{ $product['quantity'] }} ${{ number_format($subtotal, 2) }} {{ $taxPercent > 0 ? $taxPercent . '%' : '0%' }} ${{ number_format($taxAmount, 2) }} ${{ number_format($lineTotal, 2) }}
               
Sub-Total {{ $totalQty }} - ${{ number_format($totalAmount, 2) }} - ${{ number_format($finalTotal, 2) }}
{{-- LEFT SIDE --}} {{--
Thank You For Your Business

Tyres Planet PTY LTD

209 Mcroyle St, Wacol 4076

07 3144 3131

cst@tyresplanet.com.au

--}} {{-- RIGHT SIDE --}}
@if (!empty($terms))
Terms & Conditions
@foreach ($terms as $term) @if (!empty($term['description'])) @php $description = html_entity_decode(strip_tags($term['description'])); $lines = array_values( array_filter(array_map('trim', preg_split("/\r\n|\n|\r/", $description))), ); @endphp @foreach ($lines as $line)
• {{ ltrim($line, '-• ') }}
@endforeach @endif @endforeach

@endif
Return Policy

• Free return within 48 hours. Return within 7 days will incur a 10% restocking fee. No Return accepted after 7 days.

Customer Name
Customer Signature
Our Business Terms & Conditions Available on Our Website
@endif @php function numberToWords($number) { $ones = [ 0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', ]; $tens = [ 20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', ]; if ($number < 20) { return $ones[$number]; } elseif ($number < 100) { return $tens[10 * floor($number / 10)] . ($number % 10 ? ' ' . $ones[$number % 10] : ''); } elseif ($number < 1000) { return $ones[floor($number / 100)] . ' hundred' . ($number % 100 ? ' ' . numberToWords($number % 100) : ''); } elseif ($number < 100000) { return numberToWords(floor($number / 1000)) . ' thousand' . ($number % 1000 ? ' ' . numberToWords($number % 1000) : ''); } else { return numberToWords(floor($number / 100000)) . ' lakh' . ($number % 100000 ? ' ' . numberToWords($number % 100000) : ''); } } @endphp