@php $payload = $report->data ?? []; $header = is_array($payload['header'] ?? null) ? $payload['header'] : []; $body = is_array($payload['body'] ?? null) ? $payload['body'] : []; $footer = is_array($payload['footer'] ?? null) ? $payload['footer'] : []; $technicianContact = null; $technicianStampUrl = null; if (!empty($header['technician_contact_id'])) { $technicianContact = \App\Models\Contact::find($header['technician_contact_id']); } if (!$technicianContact && !empty($header['technician_name'])) { $parts = preg_split('/\s+/', trim((string) $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 && method_exists($technicianContact, 'getFirstMedia')) { $stampMedia = $technicianContact->getFirstMedia('technician_stamp'); if (!$stampMedia) { $stampMedia = $technicianContact->getFirstMedia('contact_images'); } if ($stampMedia) { $technicianStampUrl = $stampMedia->getPath(); } } $fireExtinguishers = is_array($body['fire_extinguishers'] ?? null) ? $body['fire_extinguishers'] : []; $emergencyLights = is_array($body['emergency_lights'] ?? null) ? $body['emergency_lights'] : []; $accountName = $report->account ? trim($report->account->company_name . ($report->account->suffix ? ' (' . $report->account->suffix . ')' : '')) : ''; $primaryAddress = optional($report->account)->primaryAddress; $primaryPhone = optional($report->account)->primaryPhone; $addressLine1 = trim((string) ($primaryAddress->line_1 ?? '')); $city = trim((string) ($primaryAddress->city ?? '')); $province = trim((string) ($primaryAddress->state ?? '')); $postalCode = trim((string) ($primaryAddress->zip ?? '')); $phone = trim((string) ($primaryPhone->number ?? '')); $accountSite = $accountName ?: '—'; $addressLine1 = $addressLine1 !== '' ? $addressLine1 : '—'; $city = $city !== '' ? $city : '—'; $province = $province !== '' ? $province : '—'; $postalCode = $postalCode !== '' ? $postalCode : '—'; $phone = $phone !== '' ? $phone : '—'; $serviceDate = $header['service_date'] ?? ''; $startTime = $header['start_time'] ?? ''; $endTime = $header['end_time'] ?? ''; $technician = $header['technician_name'] ?? ''; $contact = $header['contact_name'] ?? ''; $owner = $header['owner_authorized_agent_name'] ?? ''; $ahj = $header['ahj_name'] ?? ''; $frequency = $header['frequency'] ?? ''; $lastServiceDate = $header['last_service_date'] ?? ''; $signedDate = $footer['signed_date'] ?? $serviceDate; $comments = $footer['comments'] ?? ''; $additionalNotes = $footer['additional_notes'] ?? ''; $yesNoMark = function ($value, $target) { return strtolower((string) $value) === strtolower((string) $target) ? '✔' : ''; }; @endphp
@include('pdfs.service-reports.partials.header', [ 'report' => $report, 'title' => 'Portable Extinguishers & Emergency Lighting', ])
Site {{ $accountSite }} Date of Service {{ $serviceDate ?: '—' }}
Contact {{ $contact ?: '—' }} Start Time {{ $startTime ?: '—' }}
Address {{ $addressLine1 }} End Time {{ $endTime ?: '—' }}
City {{ $city }} Service Technician {{ $technician ?: '—' }}
Province {{ $province }} Frequency {{ $frequency ?: '—' }}
Postal Code {{ $postalCode }} Last Service Date {{ $lastServiceDate ?: '—' }}
Phone {{ $phone }} Report No. {{ $report->report_number }}
Mark appropriate: “✔” Pass, or “X” Fail.
Fire Extinguishers
@php $extRows = count($fireExtinguishers) ? $fireExtinguishers : array_fill(0, 13, []); @endphp @foreach($extRows as $row) @php $sizeType = $row['size_type'] ?? ''; if (($row['size_type'] ?? '') === 'other' && !empty($row['size_type_other'])) { $sizeType = $row['size_type_other']; } $val = strtolower(trim((string) ($row['inspection'] ?? ''))); @endphp @endforeach
Location Size / Type Hst Date Serial No. ✔ / X Comments
{{ $row['location'] ?? '' }} {{ $sizeType }} {{ $row['installation_year'] ?? '' }} {{ $row['serial_no'] ?? '' }} @if(in_array($val, ['pass', 'check', 'checked', 'yes', 'ok', '1', '?'])) ✔ @elseif(in_array($val, ['fail', 'x', 'no', '0'])) X @endif {{ $row['comments'] ?? '' }}
Comments
{{ $comments ?: ' ' }}
I state that the information on this service report stood correct at the time and place of my inspection. All equipment was tested and serviced where possible in conformance with the applicable code and left in operational condition upon completion of this inspection. Any equipment not operable after service will be detailed in the notes section.
{{ $owner ?: '—' }}
Owner / Authorized Agent
Date: {{ $signedDate ?: '—' }}
@if(!empty($technicianStampUrl) && file_exists($technicianStampUrl)) Technician Stamp @else
@endif
@include('pdfs.service-reports.partials.footer')
@include('pdfs.service-reports.partials.header', [ 'report' => $report, 'title' => 'Portable Extinguishers & Emergency Lighting', ])
Emergency Lights
@php $lightRows = count($emergencyLights) ? $emergencyLights : array_fill(0, 28, []); @endphp @foreach($lightRows as $row) @php $val = strtolower(trim((string) ($row['inspection'] ?? ''))); $rowComment = trim((string) ($row['comments'] ?? '')); @endphp @endforeach
Location V-in Unit Size Batt Size # Batts Date Bulbs P F
{{ $row['location'] ?? '' }} {{ $row['vin'] ?? '' }} {{ $row['unit_size'] ?? '' }} {{ $row['num_batts'] ?? '' }} {{ $row['battery_size'] ?? '' }} {{ $row['installation_year'] ?? '' }} {{ $row['bulbs'] ?? '' }} @if(in_array($val, ['pass', 'check', 'checked', 'yes', 'ok', '1', '?'])) ✔ @endif @if(in_array($val, ['fail', 'x', 'no', '0'])) X @endif
Comments: {{ $rowComment !== '' ? $rowComment : ' ' }}
@include('pdfs.service-reports.partials.footer')
@include('pdfs.service-reports.partials.header', [ 'report' => $report, 'title' => 'Portable Extinguishers & Emergency Lighting', ])
Notes
@php $notesLines = []; if (!empty($additionalNotes)) { $notesLines = preg_split("/\r\n|\n|\r/", (string) $additionalNotes); } @endphp @for($i = 0; $i < 34; $i++)
{{ $notesLines[$i] ?? '' }}
@endfor
@include('pdfs.service-reports.partials.footer')