@if(!empty($vehicle_image_url))
{{ $display_vehicle_no }}
@endif

{{ $display_vehicle_no }} @if(!empty($vehicle_make_model)) {{ $vehicle_make_model }} @endif

@if(!empty($prefill['customer_name']))

{{ $prefill['customer_name'] }}

@endif
@if(!$found)
@lang('repair::lang.no_vehicle_history_found', ['vehicle' => $display_vehicle_no])
@else
{{ $job_sheets->count() }}
@lang('repair::lang.service_history')
{{ $invoices->count() }}
@lang('repair::lang.invoices')
{{ $appointments->count() }}
@lang('repair::lang.appointments')
@if($appointments->count() > 0)

@lang('repair::lang.appointments')

@foreach($appointments as $apt) @php $stMeta = $statuses[$apt->status] ?? ['label' => ucfirst($apt->status), 'color' => '#64748b']; @endphp @endforeach
@lang('repair::lang.appointment_no') @lang('messages.date') @lang('repair::lang.preferred_time_slot') @lang('repair::lang.service_type') @lang('sale.status')
{{ $apt->appointment_no }} {{ $apt->appointment_date ? $apt->appointment_date->format('Y-m-d') : '-' }} {{ $apt->time_slot ?: '-' }} {{ $apt->service_type ?: '-' }} {{ $stMeta['label'] }}
@endif

@lang('repair::lang.invoices') ({{ $invoices->count() }}) @if($invoices->count() > 0) Click an invoice to view full details @endif

@if($invoices->count() > 0) @foreach($invoices as $idx => $inv) @php $pStatus = $inv->payment_status ?: 'due'; $pStatusColor = '#f39c12'; if ($pStatus === 'paid') { $pStatusColor = '#00a65a'; } elseif ($pStatus === 'due') { $pStatusColor = '#dd4b39'; } $linkedJs = $inv->linked_job_sheet; $invInsp = ($linkedJs && is_array($linkedJs->inspection_details)) ? $linkedJs->inspection_details : []; $invWork = ($linkedJs && is_array($linkedJs->service_checklist)) ? $linkedJs->service_checklist : []; $goodCount = count(array_filter($invInsp, fn($v) => $v === 'good')); $attCount = count(array_filter($invInsp, fn($v) => $v === 'attention')); $repCount = count(array_filter($invInsp, fn($v) => $v === 'replace')); $totalInsp = $goodCount + $attCount + $repCount; $balanceDue = max(0, (float) $inv->final_total - (float) $inv->total_paid); $paidByText = !empty($inv->payment_methods) ? 'Paid by ' . implode(', ', $inv->payment_methods) : ''; $invNotes = trim((string) (($linkedJs->comment_by_ss ?? '') ?: ($inv->additional_notes ?? ''))); @endphp
{{ \Carbon\Carbon::parse($inv->transaction_date)->format('Y-m-d') }} · {{ $inv->invoice_no }} · {{ $currency_symbol }} {{ number_format((float) $inv->final_total, 2) }} @if(!empty($inv->job_sheet_no)) {{ $inv->job_sheet_no }} @endif
{{ __('lang_v1.' . $pStatus) }} Details
Invoice no: {{ $inv->invoice_no }} @if($paidByText) · {{ $paidByText }} @endif
{{ $inv->repair_serial_no ?: $display_vehicle_no }} {{ \Carbon\Carbon::parse($inv->transaction_date)->format('Y-m-d') }} @if(!empty($inv->job_sheet_no)) {{ $inv->job_sheet_no }} @endif @if(!empty($inv->location_name)) {{ $inv->location_name }} @endif
@if($totalInsp > 0)
Vehicle Health Check
@if($goodCount > 0)
{{ $goodCount }}
@endif @if($attCount > 0)
{{ $attCount }}
@endif @if($repCount > 0)
{{ $repCount }}
@endif
{{ $goodCount }} Good {{ $attCount }} Needs attention {{ $repCount }} Replace
@foreach($inspection_items as $iKey => $iLabel) @if(!empty($invInsp[$iKey])) @php $st = $invInsp[$iKey]; $stLabel = $inspection_statuses[$st]['label'] ?? ucfirst($st); @endphp
{{ $iLabel }}
{{ $stLabel }}
@endif @endforeach
@endif @if(!empty($invWork))
Work done {{ count($invWork) }}
@foreach($invWork as $code) @php $rawLabel = $service_checklist_items[$code] ?? $code; $cleanLabel = preg_replace('/^\d+\s*-\s*/', '', $rawLabel); @endphp
{{ $cleanLabel }}
@endforeach
@endif
Invoice {{ strtoupper(__('lang_v1.' . $pStatus)) }}
@if($inv->line_items && $inv->line_items->count() > 0) @foreach($inv->line_items as $line)
{{ $line->product_name ?: 'Service Charge' }} @if((float) $line->quantity != 1) × {{ rtrim(rtrim(number_format((float) $line->quantity, 2), '0'), '.') }} @endif {{ $currency_symbol }} {{ number_format((float) $line->quantity * (float) $line->unit_price_inc_tax, 2) }}
@endforeach @else
Service charge {{ $currency_symbol }} {{ number_format((float) $inv->final_total, 2) }}
@endif
Total {{ $currency_symbol }} {{ number_format((float) $inv->final_total, 2) }}
@if($balanceDue > 0)
Paid: {{ $currency_symbol }} {{ number_format((float) $inv->total_paid, 2) }} Balance Due: {{ $currency_symbol }} {{ number_format($balanceDue, 2) }}
@endif
{{ $paidByText }} @lang('repair::lang.view_invoice')
@if($invNotes !== '')
{{ $invNotes }}
@endif
@endforeach @else

@lang('repair::lang.no_invoices_for_vehicle')

@endif

@lang('repair::lang.service_history') ({{ $job_sheets->count() }})

@if($job_sheets->count() > 0) @foreach($job_sheets as $js) @php $jsInsp = is_array($js->inspection_details) ? $js->inspection_details : []; $jsWork = is_array($js->service_checklist) ? $js->service_checklist : []; $jsGood = count(array_filter($jsInsp, fn($v) => $v === 'good')); $jsAtt = count(array_filter($jsInsp, fn($v) => $v === 'attention')); $jsRep = count(array_filter($jsInsp, fn($v) => $v === 'replace')); $jsTotalInsp = $jsGood + $jsAtt + $jsRep; @endphp
{{ $js->job_sheet_no }} {{ \Carbon\Carbon::parse($js->created_at)->format('Y-m-d H:i') }}
@if(!empty($js->repair_status)) {{ $js->repair_status }} @endif
@lang('product.brand'): {{ $js->brand_name ?: '-' }}
@lang('repair::lang.model'): {{ $js->model_name ?: '-' }}
@lang('repair::lang.service_type'): {{ !empty($js->service_type) ? __('repair::lang.' . $js->service_type) : '-' }}
@lang('repair::lang.expected_delivery_date'): {{ !empty($js->delivery_date) ? \Carbon\Carbon::parse($js->delivery_date)->format('Y-m-d H:i') : '-' }}
@lang('repair::lang.estimated_cost'): {{ !is_null($js->estimated_cost) ? $currency_symbol . ' ' . number_format((float) $js->estimated_cost, 2) : '-' }}
@lang('business.business_location'): {{ $js->location_name ?: '-' }}
@if($jsTotalInsp > 0 || !empty($jsWork))
@if($jsTotalInsp > 0)
Vehicle Health Check
@if($jsGood > 0)
{{ $jsGood }}
@endif @if($jsAtt > 0)
{{ $jsAtt }}
@endif @if($jsRep > 0)
{{ $jsRep }}
@endif
{{ $jsGood }} Good {{ $jsAtt }} Needs attention {{ $jsRep }} Replace
@foreach($inspection_items as $iKey => $iLabel) @if(!empty($jsInsp[$iKey])) @php $st = $jsInsp[$iKey]; $stLabel = $inspection_statuses[$st]['label'] ?? ucfirst($st); @endphp
{{ $iLabel }}
{{ $stLabel }}
@endif @endforeach
@endif @if(!empty($jsWork))
Work done {{ count($jsWork) }}
@foreach($jsWork as $code) @php $rawLabel = $service_checklist_items[$code] ?? $code; $cleanLabel = preg_replace('/^\d+\s*-\s*/', '', $rawLabel); @endphp
{{ $cleanLabel }}
@endforeach
@endif
@endif @if(!empty($js->defects))
@lang('repair::lang.problem_reported_by_customer'): @php $defects = json_decode($js->defects, true); @endphp @if(is_array($defects)) {{ collect($defects)->pluck('value')->implode(', ') }} @else {{ $js->defects }} @endif
@endif @if(!empty($js->comment_by_ss))
@lang('repair::lang.comment_by_ss'): {{ $js->comment_by_ss }}
@endif @if(!empty($js->activities) && $js->activities->count() > 0)
@lang('repair::lang.activities'): @includeIf('repair::customer_repair.repair_activities', ['activities' => $js->activities])
@endif
@endforeach @else

@lang('repair::lang.no_job_sheets_for_vehicle')

@endif @endif