@extends('layouts.master') @section('content')
General Information

Reference Number

{{ $report->reference_number ?? 'N/A' }}

Date

{{ $report->date ? \Carbon\Carbon::parse($report->date)->format('d M Y') : 'N/A' }}

Issuer (Inspector) Details

Visiting Time: {{ $report->inspector_visiting_time ?? 'N/A' }}
Leaving Time: {{ $report->inspector_leaving_time ?? 'N/A' }}

Project Details

AMC Type: {{ ucfirst($report->amc_type ?? 'existing') }}
Client: {{ $report->company->name ?? 'N/A' }}
@if(($report->amc_type ?? 'existing') === 'existing')
Project: {{ $report->project->subject ?? 'N/A' }}
Visit Schedule: {{ $report->visitSchedule ? \Carbon\Carbon::parse($report->visitSchedule->visit_date)->format('d M Y') : 'N/A' }}
@endif
Location: {{ $report->site_location ?? 'N/A' }}
Site Name: {{ $report->site_name ?? 'N/A' }}
{{-- Block Information Section with Tabbed System Tables --}} @php use Illuminate\Support\Str; $blockInfo = is_array($report->block_info) ? $report->block_info : json_decode($report->block_info, true); $blockInfo = $blockInfo ?? []; // System labels and types mapping $systemConfig = [ 'fire_alarm' => ['label' => 'Fire Alarm System', 'type' => 'complex'], 'fire_fighting' => ['label' => 'Fire Fighting Equipment', 'type' => 'complex'], 'fm200' => ['label' => 'FM-200 System', 'type' => 'complex'], 'foam_tank' => ['label' => 'Foam Bladder Tank', 'type' => 'complex'], 'voice_evacuation' => ['label' => 'Voice Evacuation', 'type' => 'complex'], 'emergency_lighting' => ['label' => 'Emergency Lighting', 'type' => 'complex'], 'system_interfacing' => ['label' => 'System Interfacing', 'type' => 'simple'], 'exit_route' => ['label' => 'Exit Route & Storage', 'type' => 'simple'], 'storage_conditions' => ['label' => 'Storage Conditions', 'type' => 'simple'], 'pump' => ['label' => 'Pump', 'type' => 'complex'], 'deluge' => ['label' => 'Deluge Valve', 'type' => 'complex'], ]; @endphp @if(!empty($blockInfo) && count($blockInfo) > 0)
Block Information & Inspection Details
{{-- Block Tabs Navigation --}}
@php $blockIdx = 0; @endphp @foreach($blockInfo as $blockId => $block) @php $blockIdx++; @endphp @endforeach
{{-- Block Tab Contents --}} @php $blockIdx = 0; @endphp @foreach($blockInfo as $blockId => $block)
{{-- Print-only block header (hidden on screen, visible when printing) --}}
Block Name: {{ $block['name'] ?? 'N/A' }}
@php $systems = $block['systems'] ?? []; @endphp @if(!empty($systems)) {{-- System Tabs Navigation --}}
@php $sysIdx = 0; $availableSystems = []; foreach ($systemConfig as $sysKey => $sysCfg) { if (isset($systems[$sysKey]) && !empty($systems[$sysKey])) { $availableSystems[$sysKey] = $sysCfg; } } @endphp @foreach($availableSystems as $sysKey => $sysCfg) @php $sysIdx++; @endphp @endforeach
{{-- System Tab Contents --}} @php $sysIdx = 0; @endphp @foreach($availableSystems as $sysKey => $sysCfg)
{{-- Print-only system header (hidden on screen, visible when printing) --}} @php $sysData = $systems[$sysKey]; $sysType = $sysCfg['type']; // Group data by item slug $items = []; foreach ($sysData as $key => $value) { // Match pattern: prefix_itemslug_field if (preg_match('/^[a-z0-9]+_(.+)_(total|defective|urgent|remarks|attachment|status)$/', $key, $matches)) { $itemSlug = $matches[1]; $field = $matches[2]; $items[$itemSlug][$field] = $value; } } // Filter out completely empty rows $filtered = []; foreach ($items as $slug => $fields) { $nonEmpty = false; foreach ($fields as $f => $v) { if (!empty($v)) { $nonEmpty = true; break; } } if ($nonEmpty) $filtered[$slug] = $fields; } @endphp
{{ $sysCfg['label'] }}
@if(count($filtered) > 0) @if($sysType === 'complex') @foreach($filtered as $itemSlug => $itemData) @php $itemName = ucwords(str_replace('_', ' ', $itemSlug)); $total = $itemData['total'] ?? ''; $defective = $itemData['defective'] ?? ''; $urgent = $itemData['urgent'] ?? ''; $remarks = $itemData['remarks'] ?? ''; $attachments = $itemData['attachment'] ?? []; $urgentDisplay = $urgent === 'yes' ? '✓ Yes' : ($urgent === 'no' ? '✓ No' : '-'); $defectiveDisplay = is_numeric($defective) ? $defective : ($defective === 'yes' ? '✓ Yes' : ($defective === 'no' ? '✓ No' : '-')); @endphp @endforeach
Item Total Qty Qty Damaged/Defective Urgent Action Required Remarks Attachments
{{ $itemName }} {{ $total ?: '-' }} {{ $defectiveDisplay }} {{ $urgentDisplay }} {{ $remarks ?: '-' }} @if(is_array($attachments) && count($attachments) > 0) @foreach($attachments as $filePath) @php $fileUrl = asset('storage/' . $filePath); $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); @endphp @if(in_array($ext, ['jpg', 'jpeg', 'png'])) @elseif($ext === 'pdf') View PDF @else Download @endif @endforeach @else - @endif
@else {{-- Simple / status-type table --}} @foreach($filtered as $itemSlug => $itemData) @php $itemName = ucwords(str_replace('_', ' ', $itemSlug)); $total = $itemData['total'] ?? ''; $status = $itemData['status'] ?? ($itemData['defective'] ?? ''); $urgent = $itemData['urgent'] ?? ''; $remarks = $itemData['remarks'] ?? ''; $attachments = $itemData['attachment'] ?? []; $statusDisplay = $status === 'working' ? '✓ Working' : ($status === 'not_working' ? '✗ Not Working' : '-'); $urgentDisplay = $urgent === 'yes' ? '✓ Yes' : ($urgent === 'no' ? '✓ No' : '-'); @endphp @endforeach
Item Total Qty Status Urgent Rectification Remarks Attachments
{{ $itemName }} {{ $total ?: '-' }} {{ $statusDisplay }} {{ $urgentDisplay }} {{ $remarks ?: '-' }} @if(is_array($attachments) && count($attachments) > 0) @foreach($attachments as $filePath) @php $fileUrl = asset('storage/' . $filePath); $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); @endphp @if(in_array($ext, ['jpg', 'jpeg', 'png'])) @elseif($ext === 'pdf') View PDF @else Download @endif @endforeach @else - @endif
@endif @else

No data recorded for this system.

@endif
@php $sysIdx++; @endphp @endforeach @if(count($availableSystems) === 0)

No inspection data recorded for this block.

@endif @else

No inspection data recorded for this block.

@endif
@php $blockIdx++; @endphp @endforeach @else {{-- Fallback: show old column-based data if no block_info (backward compat) --}} @php // Old render functions kept for backward compatibility function renderSystemTable($data, $title, $naChecked = false) { if ($naChecked) return; if (empty($data) || count($data) == 0) return; $items = []; foreach ($data as $key => $value) { if (preg_match('/^[a-z]+_(.+)_(name|total|defective|urgent|remarks|attachment)$/', $key, $matches)) { $itemSlug = $matches[1]; $field = $matches[2]; $items[$itemSlug][$field] = $value; } } $filtered = []; foreach ($items as $slug => $fields) { $nonEmpty = false; foreach (['name','total','defective','urgent','remarks','attachment'] as $f) { if (!empty($fields[$f])) { $nonEmpty = true; break; } } if ($nonEmpty) $filtered[$slug] = $fields; } if (count($filtered) === 0) return; echo '
' . e($title) . '
'; echo ''; foreach ($filtered as $itemSlug => $itemData) { $itemName = $itemData['name'] ?? ucwords(str_replace('_', ' ', $itemSlug)); $total = $itemData['total'] ?? ''; $defective = $itemData['defective'] ?? ''; $urgent = $itemData['urgent'] ?? ''; $remarks = $itemData['remarks'] ?? ''; $attachments = $itemData['attachment'] ?? []; $urgentDisplay = $urgent === 'yes' ? '✓ Yes' : ($urgent === 'no' ? '✓ No' : ''); $defectiveDisplay = is_numeric($defective) ? $defective : ($defective === 'yes' ? '✓ Yes' : ($defective === 'no' ? '✓ No' : '')); echo ''; } echo '
ItemTotal QtyQty Damaged/DefectiveUrgent Action RequiredRemarksAttachments
' . e($itemName) . '' . ($total ?: '-') . '' . ($defectiveDisplay ?: '-') . '' . ($urgentDisplay ?: '-') . '' . ($remarks ?: '-') . ''; if (is_array($attachments) && count($attachments) > 0) { foreach ($attachments as $fp) { $fileUrl = asset('storage/' . $fp); $ext = strtolower(pathinfo($fp, PATHINFO_EXTENSION)); if (in_array($ext, ['jpg','jpeg','png'])) echo ""; elseif ($ext === 'pdf') echo "View PDF"; else echo "Download"; } } else { echo '-'; } echo '
'; } function renderStatusTable($data, $title, $naChecked = false) { if ($naChecked) return; if (empty($data) || count($data) == 0) return; $items = []; foreach ($data as $key => $value) { if (preg_match('/^[a-z]+_(.+)_(name|status|urgent|remarks|attachment)$/', $key, $matches)) { $itemSlug = $matches[1]; $field = $matches[2]; $items[$itemSlug][$field] = $value; } } $filtered = []; foreach ($items as $slug => $fields) { $nonEmpty = false; foreach (['name','status','urgent','remarks','attachment'] as $f) { if (!empty($fields[$f])) { $nonEmpty = true; break; } } if ($nonEmpty) $filtered[$slug] = $fields; } if (count($filtered) === 0) return; echo '
' . e($title) . '
'; echo ''; foreach ($filtered as $itemSlug => $itemData) { $itemName = $itemData['name'] ?? ucwords(str_replace('_', ' ', $itemSlug)); $status = $itemData['status'] ?? ''; $urgent = $itemData['urgent'] ?? ''; $remarks = $itemData['remarks'] ?? ''; $attachments = $itemData['attachment'] ?? []; $statusDisplay = $status === 'working' ? '✓ Working' : ($status === 'not_working' ? '✓ Not Working' : ''); $urgentDisplay = $urgent === 'yes' ? '✓ Yes' : ($urgent === 'no' ? '✓ No' : ''); echo ''; } echo '
ItemStatusUrgent RectificationRemarksAttachments
' . e($itemName) . '' . ($statusDisplay ?: '-') . '' . ($urgentDisplay ?: '-') . '' . ($remarks ?: '-') . ''; if (is_array($attachments) && count($attachments) > 0) { foreach ($attachments as $fp) { $fileUrl = asset('storage/' . $fp); $ext = strtolower(pathinfo($fp, PATHINFO_EXTENSION)); if (in_array($ext, ['jpg','jpeg','png'])) echo ""; elseif ($ext === 'pdf') echo "View PDF"; else echo "Download"; } } else { echo '-'; } echo '
'; } @endphp @php $fireAlarmData = is_array($report->fire_alarm_data) ? $report->fire_alarm_data : json_decode($report->fire_alarm_data, true); renderSystemTable($fireAlarmData ?? [], 'Fire Alarm System', isset($fireAlarmData['fire_alarm_na']) && $fireAlarmData['fire_alarm_na'] == '1'); $fireFightingData = is_array($report->fire_fighting_data) ? $report->fire_fighting_data : json_decode($report->fire_fighting_data, true); renderSystemTable($fireFightingData ?? [], 'Fire Fighting Equipment', isset($fireFightingData['fire_fighting_na']) && $fireFightingData['fire_fighting_na'] == '1'); $fm200Data = is_array($report->fm200_data) ? $report->fm200_data : json_decode($report->fm200_data, true); renderSystemTable($fm200Data ?? [], 'FM-200 System', isset($fm200Data['fm200_na']) && $fm200Data['fm200_na'] == '1'); $foamData = is_array($report->foam_tank_data) ? $report->foam_tank_data : json_decode($report->foam_tank_data, true); renderSystemTable($foamData ?? [], 'Foam Bladder Tank System', isset($foamData['foam_tank_na']) && $foamData['foam_tank_na'] == '1'); $voiceData = is_array($report->voice_evacuation_data) ? $report->voice_evacuation_data : json_decode($report->voice_evacuation_data, true); renderSystemTable($voiceData ?? [], 'Voice Evacuation System', isset($voiceData['voice_evacuation_na']) && $voiceData['voice_evacuation_na'] == '1'); $emergencyData = is_array($report->emergency_lighting_data) ? $report->emergency_lighting_data : json_decode($report->emergency_lighting_data, true); renderSystemTable($emergencyData ?? [], 'Emergency Lighting', isset($emergencyData['emergency_lighting_na']) && $emergencyData['emergency_lighting_na'] == '1'); $siData = is_array($report->system_interfacing_data) ? $report->system_interfacing_data : json_decode($report->system_interfacing_data, true); renderStatusTable($siData ?? [], 'System Interfacing', isset($siData['system_interfacing_na']) && $siData['system_interfacing_na'] == '1'); $exitData = is_array($report->exit_route_data) ? $report->exit_route_data : json_decode($report->exit_route_data, true); renderStatusTable($exitData ?? [], 'Exit Route and Storage Condition', isset($exitData['exit_route_na']) && $exitData['exit_route_na'] == '1'); $storageData = is_array($report->storage_conditions_data) ? $report->storage_conditions_data : json_decode($report->storage_conditions_data, true); renderStatusTable($storageData ?? [], 'Storage Conditions', isset($storageData['storage_conditions_na']) && $storageData['storage_conditions_na'] == '1'); $pumpData = is_array($report->pump_data) ? $report->pump_data : json_decode($report->pump_data, true); renderSystemTable($pumpData ?? [], 'Pump', isset($pumpData['pump_na']) && $pumpData['pump_na'] == '1'); $delugeData = is_array($report->deluge_data) ? $report->deluge_data : json_decode($report->deluge_data, true); renderSystemTable($delugeData ?? [], 'Deluge Valve & Water Spray System', isset($delugeData['deluge_na']) && $delugeData['deluge_na'] == '1'); @endphp @endif
Required Maintenance Work
Used Items
Notes / Used Items

{{ $report->notes_used_items ?? 'No notes provided.' }}

Photos (Equipment-specific)
@php $photosData = is_array($report->photos_data) ? $report->photos_data : json_decode($report->photos_data, true); @endphp @if(!empty($photosData) && count($photosData) > 0) @foreach($photosData as $photo) @endforeach
Reference (Item/Equipment) Photo Attachments Remarks / Label
{{ $photo['reference'] ?? '-' }} @if(!empty($photo['files'])) @else No files @endif {{ $photo['label'] ?? '-' }}
@else

No equipment-specific photos attached.

@endif
Scope of Inspection

All components designated for inspection at the site, standards of practiced person are inspected except as may be noted in the limitations of inspection sections within this report. This inspection is visual only. A representative sample of site components are viewed in areas that are accessible at the time of inspection. No destructive testing or dismantling of site components is performed. Not all improvements will be identified during this inspection. Unexpected repairs should still be anticipated. The inspection should not be considered a guarantee or warranty of any kind.

Client EID Details: {{ $report->client_eid_details ?? 'N/A' }}
Client Phone Number: {{ $report->client_phone ?? 'N/A' }}
Attachments: @php // Decode file_path column safely (handles JSON or array) $attachments = is_array($report->file_path) ? $report->file_path : json_decode($report->file_path, true); $attachments = $attachments ?? []; @endphp @if(!empty($attachments) && count($attachments) > 0)
@foreach($attachments as $index => $path) @endforeach
@else

No attachments uploaded.

@endif

Client Signature:

@if($report->client_signature) Client Signature @else

No signature provided.

@endif
Back to Projects
@section('css') @endsection @endsection