@php $data = is_array($report->data) ? $report->data : json_decode($report->data, true); $header = $data['header'] ?? []; $body = $data['body'] ?? []; $footer = $data['footer'] ?? []; $ownerAuthorizedAgentDisplay = trim((string) ($header['owner_authorized_agent_name'] ?? $footer['owner_authorized_agent_name'] ?? '')); $ownerAuthorizedAgentDisplay = $ownerAuthorizedAgentDisplay !== '' ? $ownerAuthorizedAgentDisplay : '—'; $returnVisitDisplay = '—'; if (($header['return_visit_required'] ?? '') === 'yes') { $returnVisitDisplay = 'Yes'; } elseif (($header['return_visit_required'] ?? '') === 'no') { $returnVisitDisplay = 'No'; } // SERVICE $reportDate = $header['service_date'] ?? optional($report->service_date)->format('m/d/Y') ?? '—'; $startTime = $header['start_time'] ?? '—'; $endTime = $header['end_time'] ?? '—'; $totalHours = $header['total_hours'] ?? '—'; $technician = $header['technician_name'] ?? '—'; $technicianContact = null; $technicianStampUrl = null; if (!empty($header['technician_name'])) { $parts = preg_split('/\s+/', trim($header['technician_name'])); $firstName = $parts[0] ?? null; $lastName = count($parts) ? $parts[count($parts) - 1] : null; if ($firstName && $lastName) { $technicianContact = \App\Models\Contact::query() ->where('first_name', 'like', $firstName . '%') ->where('last_name', 'like', $lastName . '%') ->first(); } if ($technicianContact) { $stampMedia = $technicianContact->getFirstMedia('technician_stamp'); if ($stampMedia) { $technicianStampUrl = $stampMedia->getPath(); } } } $contact = $header['contact_name'] ?? '—'; $returnVisit = $header['return_visit_required'] ?? '—'; // ACCOUNT $accountName = trim((string) optional($report->account)->company_name); $accountSuffix = trim((string) optional($report->account)->suffix); $accountDisplay = trim($accountName . ($accountSuffix ? ' (' . $accountSuffix . ')' : '')); // ADDRESS $primaryAddress = optional($report->account)->primaryAddress; $primaryPhone = optional($report->account)->primaryPhone; $addressLine1 = $primaryAddress->line_1 ?? '—'; $addressLine2 = $primaryAddress->line_2 ?? '—'; $city = $primaryAddress->city ?? ''; $province = $primaryAddress->state ?? ''; $postalCode = $primaryAddress->zip ?? ''; $cityProvPostal = trim(implode(' ', array_filter([$city, $province, $postalCode]))) ?: '—'; $phone = $primaryPhone->number ?? '—'; $mobilePhone = '—'; // EQUIPMENT $equipment = $body['equipment_details'] ?? []; $canopyManufacturer = $equipment['canopy_manufacturer'] ?? '—'; $modelNo = $equipment['model_no'] ?? '—'; $serialNo = $equipment['serial_no'] ?? '—'; $fuelValues = !empty($equipment['fuel']) && is_array($equipment['fuel']) ? $equipment['fuel'] : []; $cookingVolume = $equipment['cooking_volume'] ?? ''; $cookingEquipmentValues = !empty($equipment['cooking_equipment']) && is_array($equipment['cooking_equipment']) ? $equipment['cooking_equipment'] : []; $fuelOther = $equipment['fuel_other'] ?? ''; $cookingEquipmentOther = $equipment['cooking_equipment_other'] ?? ''; $fuelLabels = [ 'natural_gas' => 'Natural Gas', 'electric' => 'Electric', 'solid_fuel' => 'Solid Fuel', 'other' => 'Other', ]; $cookingEquipmentLabels = [ 'griddles' => 'Griddles', 'deep_fat_fryers' => 'Deep Fat Fryers', 'woks' => 'Woks', 'stoves' => 'Stoves', 'other' => 'Other', ]; $cleanFuelValues = array_values(array_filter($fuelValues, function ($value) { return !in_array(trim((string) $value), ['', 'fuel'], true); })); $fuelDisplay = !empty($cleanFuelValues) ? implode(', ', array_map(fn ($value) => $fuelLabels[$value] ?? $value, $cleanFuelValues)) : '—'; $cookingEquipmentDisplay = !empty($cookingEquipmentValues) ? implode(', ', array_map(fn ($value) => $cookingEquipmentLabels[$value] ?? $value, $cookingEquipmentValues)) : '—'; $cookingVolumeLabels = [ 'high' => 'High', 'medium' => 'Medium', 'low' => 'Low', ]; $cookingVolume = $cookingVolumeLabels[$cookingVolume] ?? ($cookingVolume ?: '—'); $fuelOther = trim((string) $fuelOther) !== '' ? $fuelOther : '—'; $cookingEquipmentOther = trim((string) $cookingEquipmentOther) !== '' ? $cookingEquipmentOther : '—'; // FILTERS $filters = $body['filters_replaced'] ?? []; $pleat = $filters['pleat_filters'] ?? []; $hepa = $filters['hepa_filters'] ?? []; $finalStage = $filters['final_stage_filters'] ?? []; $otherFilters = $filters['other_filters'] ?? []; $belt = $filters['belt_replaced'] ?? []; // SERVICE DETAILS $serviceDetails = $body['service_details'] ?? []; $leaksFound = $serviceDetails['leaks_found'] ?? '—'; $leakLocation = $serviceDetails['leak_location'] ?? '—'; // NOTES / FOOTER $comments = $footer['comments'] ?? '—'; $additionalNotes = $footer['additional_notes'] ?? '—'; $scheduledCycle = $footer['scheduled_cycle'] ?? '—'; $recommendedCycle = $footer['recommended_cycle'] ?? '—'; $ownerAuthorizedAgent = $footer['owner_authorized_agent_name'] ?? '—'; $signedDate = $footer['signed_date'] ?? '—'; // CHECKLIST $checklist = $body['inspection_checklist'] ?? []; $checkbox = function ($checked) { return '' . ($checked ? 'X' : ' ') . ''; }; $statusMark = function ($answer, $expected) { return strtolower((string) $answer) === strtolower((string) $expected) ? 'X' : ''; }; $beltReplaced = '—'; if (!empty($filters['belt_replaced']['yes'])) { $beltReplaced = 'Yes'; } elseif (!empty($filters['belt_replaced']['no'])) { $beltReplaced = 'No'; } $beltSize = $filters['belt_replaced']['belt_size'] ?? '—'; $leaksFoundDisplay = '—'; if ($leaksFound === 'yes') { $leaksFoundDisplay = 'Yes'; } elseif ($leaksFound === 'no') { $leaksFoundDisplay = 'No'; } $leakLocationDisplay = trim((string) $leakLocation) !== '' ? $leakLocation : '—'; $comments = trim((string) $comments) !== '' ? $comments : '—'; $additionalNotes = trim((string) $additionalNotes) !== '' ? $additionalNotes : '—'; $scheduledCycle = trim((string) $scheduledCycle) !== '' ? $scheduledCycle : '—'; $recommendedCycle = trim((string) $recommendedCycle) !== '' ? $recommendedCycle : '—'; $signedDate = trim((string) $signedDate) !== '' ? $signedDate : '—'; $defaultChecklistRows = [ ['key' => 'fan_operational', 'label' => 'Exhaust fan operational before and after service'], ['key' => 'appliances_operational', 'label' => 'Appliances operational before and after service'], ['key' => 'filters_spacers', 'label' => 'Adequate number of filters and spacers (no gaps)'], ['key' => 'filters_ulc', 'label' => 'Filters UL/C Listed and undamaged'], ['key' => 'no_holes_canopy', 'label' => 'There are no holes in the canopy'], ['key' => 'safe_access', 'label' => 'Exhaust fan and access panels safe to access'], ['key' => 'gaskets_condition', 'label' => 'Gaskets on cleanouts in good condition'], ['key' => 'hinge_kit', 'label' => 'Exhaust fan has proper hinge kit'], ['key' => 'interior_accessible', 'label' => 'Entire system interior accessible for cleaning'], ['key' => 'suppression_compliance', 'label' => 'Fire suppression system in compliance'], ['key' => 'nozzles_clear', 'label' => 'Fire suppression nozzles clear'], ['key' => 'k_class_present', 'label' => 'K-Class fire extinguisher present'], ['key' => 'pilots_lit', 'label' => 'Appliance gas pilots lit on service completion'], ['key' => 'final_inspection_tag', 'label' => 'Final inspection inspection, service tag attached'], ['key' => 'before_after_photos', 'label' => 'Before and after photos taken'], ]; $savedChecklist = []; foreach ($checklist as $row) { if (!empty($row['key'])) { $savedChecklist[$row['key']] = $row; } } $rows = []; foreach ($defaultChecklistRows as $row) { $saved = $savedChecklist[$row['key']] ?? null; $rows[] = [ 'label' => $saved['label'] ?? $row['label'], 'answer' => $saved['answer'] ?? '', 'repaired' => !empty($saved['repaired']), ]; }; $uvSystemRows = []; $savedUvRows = is_array($body['uv_system'] ?? null) ? $body['uv_system'] : []; foreach ($savedUvRows as $row) { $uvSystemRows[] = [ 'label' => $row['label'] ?? '—', 'answer' => $row['answer'] ?? '', 'repaired' => !empty($row['repaired']), ]; } $uvDetails = $body['uv_details'] ?? []; $uvLampsAction = $uvDetails['lamps_action'] ?? '—'; $uvLampsQty = $uvDetails['lamps_qty'] ?? '—'; $uvHoursRecorded = $uvDetails['hours_recorded'] ?? '—'; $uvLampsActionDisplay = $uvLampsAction !== '' ? ucfirst($uvLampsAction) : '—'; $uvLampsQty = trim((string) $uvLampsQty) !== '' ? $uvLampsQty : '—'; $uvHoursRecorded = trim((string) $uvHoursRecorded) !== '' ? $uvHoursRecorded : '—'; @endphp
@include('pdfs.service-reports.partials.header', [ 'report' => $report, 'title' => 'Kitchen Ventilation System Report', ])
Account
Name {{ $accountDisplay }}
Contact {{ $contact }}
Technician(s) {{ $technician }}
Address Line 1 {{ $addressLine1 }}
Address Line 2 {{ $addressLine2 }}
City / Prov / PC {{ $cityProvPostal }}
Phone {{ $phone }}
Mobile Phone {{ $mobilePhone }}
Service / Equipment
Service Date {{ $reportDate }}
Start Time {{ $startTime }}
End Time {{ $endTime }}
Total Hours {{ $totalHours }}
Return Visit {{ $returnVisitDisplay }}
Manufacturer {{ $canopyManufacturer }}
Model No {{ $modelNo }}
Serial No {{ $serialNo }}
Fuel {{ $fuelDisplay }}
Fuel (Other) {{ $fuelOther }}
Cooking Equip {{ $cookingEquipmentDisplay }}
Equip (Other) {{ $cookingEquipmentOther }}
Cooking Volume {{ $cookingVolume }}
Inspection Checklist
@foreach($rows as $row) @endforeach
Item Pass Fail N/A Repaired
{{ $row['label'] }} {{ $statusMark($row['answer'], 'pass') }} {{ $statusMark($row['answer'], 'fail') }} {{ $statusMark($row['answer'], 'na') }} {{ !empty($row['repaired']) ? 'X' : '' }}
Filters Replaced
Pleat Filters{{ $pleat['fq'] ?? 'FQ' }}
Full Size {!! $checkbox(!empty($pleat['full_size_yes'])) !!}Yes {!! $checkbox(!empty($pleat['full_size_no'])) !!}No Qty {{ !empty($pleat['full_size_qty']) ? $pleat['full_size_qty'] : '—' }}
Half Size {!! $checkbox(!empty($pleat['half_size_yes'])) !!}Yes {!! $checkbox(!empty($pleat['half_size_no'])) !!}No Qty {{ !empty($pleat['half_size_qty']) ? $pleat['half_size_qty'] : '—' }}
Depth{{ !empty($pleat['depth']) ? $pleat['depth'] : '—' }}
Hepa (Bag) Filters{{ $hepa['fq'] ?? 'FQ' }}
Full Size {!! $checkbox(!empty($hepa['full_size_yes'])) !!}Yes {!! $checkbox(!empty($hepa['full_size_no'])) !!}No Qty {{ !empty($hepa['full_size_qty']) ? $hepa['full_size_qty'] : '—' }}
Half Size {!! $checkbox(!empty($hepa['half_size_yes'])) !!}Yes {!! $checkbox(!empty($hepa['half_size_no'])) !!}No Qty {{ !empty($hepa['half_size_qty']) ? $hepa['half_size_qty'] : '—' }}
Length{{ !empty($hepa['length']) ? $hepa['length'] : '—' }}
Final Stage Filters{{ $finalStage['fq'] ?? 'FQ' }}
Full Size {!! $checkbox(!empty($finalStage['full_size_yes'])) !!}Yes {!! $checkbox(!empty($finalStage['full_size_no'])) !!}No Qty {{ !empty($finalStage['full_size_qty']) ? $finalStage['full_size_qty'] : '—' }}
Half Size {!! $checkbox(!empty($finalStage['half_size_yes'])) !!}Yes {!! $checkbox(!empty($finalStage['half_size_no'])) !!}No Qty {{ !empty($finalStage['half_size_qty']) ? $finalStage['half_size_qty'] : '—' }}
Other Filters{{ $otherFilters['fq'] ?? 'FQ' }}
Size{{ !empty($otherFilters['size_1']) ? $otherFilters['size_1'] : '—' }}
Qty{{ !empty($otherFilters['qty_1']) ? $otherFilters['qty_1'] : '—' }}
Size{{ !empty($otherFilters['size_2']) ? $otherFilters['size_2'] : '—' }}
Qty{{ !empty($otherFilters['qty_2']) ? $otherFilters['qty_2'] : '—' }}
Exhaust Fan Belt Replaced {!! $checkbox(!empty($belt['yes'])) !!}Yes {!! $checkbox(!empty($belt['no'])) !!}No
Belt size {{ !empty($belt['belt_size']) ? $belt['belt_size'] : '—' }}
Leaks Found in Duct Work {{ $leaksFoundDisplay }}
Leak Location {{ $leakLocationDisplay }}
PCU / Ecologizer / Ultra Violet Exhaust System
@forelse($uvSystemRows as $row) @empty @endforelse
Item Pass Fail N/A Repaired
{{ $row['label'] }} {{ $statusMark($row['answer'], 'pass') }} {{ $statusMark($row['answer'], 'fail') }} {{ $statusMark($row['answer'], 'na') }} {{ !empty($row['repaired']) ? 'X' : '' }}
UV (Ultra Violet) Lamps Cleaned or Replaced {{ $uvLampsActionDisplay }}     Qty {{ $uvLampsQty }}
UV (Ultra Violet) Hours of Service Recorded {{ $uvHoursRecorded }}
@include('pdfs.service-reports.partials.footer')
@include('pdfs.service-reports.partials.header', [ 'report' => $report, 'title' => 'Kitchen Ventilation System Report', ])
Additional Notes
{{ $additionalNotes !== '' ? $additionalNotes : '—' }}
@include('pdfs.service-reports.partials.footer')