@extends('garage.layouts.app') @section('title', 'Thermal Invoice') @section('content') @php $garageName = trim((string) (($garage->name ?? '') ?: 'Garage')); $fareedMotorsLogoPath = public_path('images/fareed-motors-logo.png'); $useFareedMotorsInvoiceLogo = is_file($fareedMotorsLogoPath) && stripos($garageName, 'fareed') !== false; $fareedMotorsLogoUrl = $useFareedMotorsInvoiceLogo ? asset('images/fareed-motors-logo.png') : null; $garageAddressLine1 = '408-Nasheman-e-Iqbal Phase-1,'; $garageAddressLine2 = 'Main Khayaban-e-Jinnah Lahore'; $garagePhoneLine = '0304-4509063 / 0333-8003811'; $customerName = trim((string) ($sale->customer_name ?? 'Walk-in Customer')); $cashier = trim((string) ($sale->cashier_name ?? '')); $disc = (float) ($sale->discount_amount ?? 0); $dt = trim((string) ($sale->sale_date ?? '') . ' ' . substr((string) ($sale->sale_time ?? ''), 0, 5)); $subTotal = (float) ($sale->subtotal ?? 0); $netTotal = (float) ($sale->grand_total ?? 0); $orderAdvance = (float) ($sale->order_advance_amount ?? 0); $orderBalance = (float) ($sale->order_balance_amount ?? $netTotal); $orderNumber = trim((string) ($sale->order_repair_number ?? '')); $packageAmount = (float) ($sale->package_amount_total ?? 0); $lineItems = []; foreach ($items as $row) { $lineItems[] = (object) [ 'name' => $row->product_name ?: ($row->description ?: 'Item'), 'qty' => (int) ($row->quantity ?? 0), 'rate' => (float) ($row->unit_price ?? 0), 'disc' => (float) ($row->discount_amount ?? 0), 'amount' => (float) ($row->line_total ?? 0), ]; } foreach ($services as $svc) { $lineItems[] = (object) [ 'name' => $svc->service_name ?: ($svc->title ?: 'Service'), 'qty' => (int) round((float) ($svc->hours ?? 0)), 'rate' => (float) ($svc->rate ?? 0), 'disc' => 0, 'amount' => (float) ($svc->line_total ?? 0), ]; } if ($packageAmount > 0) { $lineItems[] = (object) [ 'name' => 'Package Services', 'qty' => 1, 'rate' => $packageAmount, 'disc' => 0, 'amount' => $packageAmount, ]; } $warrantyLines = [ '1) ANY TYPE OF LUBRICANT ITEM CAN NOT BE RETURN OR REPLACEABLE.', '2) NOT RESPONSIBLE FOR FILTER FACTORY FAULT OR LEAKAGE.', '3) NO WARRANTY OR GUARANTEE ON TYRE ITEMS.', ]; $softwareFooterUrl = trim((string) ($garage->website ?? '')); if ($softwareFooterUrl === '') { $softwareFooterUrl = 'www.cloudsolutions.com.pk'; } $softwareFooterUrl = preg_replace('#^https?://#i', '', $softwareFooterUrl); @endphp