@extends('layout.master') @push('styles') @endpush @section('content')
Equipment Details
Model {{ $crane->model ?? 'N/A' }}
Serial No {{ $crane->serial_no ?? 'N/A' }}
Location {{ $crane->platform ?? 'N/A' }}
Manufacture Date {{ $ppm->date_manufacturer ? $ppm->date_manufacturer->format('d M Y') : 'N/A' }}
Boom Length {{ $ppm->boom_length ? $ppm->boom_length.' m' : 'N/A' }}
SWL {{ $ppm->main_swl ? $ppm->main_swl.' ton' : 'N/A' }}
Inspection Details
PPM ID PPM-{{ str_pad($ppm->id, 5, '0', STR_PAD_LEFT) }}
Inspection Date {{ $ppm->date_inspection ? $ppm->date_inspection->format('d M Y') : 'N/A' }}
Technician {{ $ppm->site_technician ?? 'N/A' }}
Time {{ $ppm->time_in ? date('H:i', strtotime($ppm->time_in)) : 'N/A' }} - {{ $ppm->time_out ? date('H:i', strtotime($ppm->time_out)) : 'N/A' }}
Status {{ ucfirst($ppm->status ?? 'pending') }}
Duration @if($ppm->time_in && $ppm->time_out) @php $start = new DateTime($ppm->time_in); $end = new DateTime($ppm->time_out); $diff = $start->diff($end); @endphp {{ $diff->h }}h {{ $diff->i }}m @else N/A @endif
@forelse($components as $component)
{{ ucwords($component->component_name) }} @if($component->details->whereNotNull('sub_component')->count()) {{ $component->details->whereNotNull('sub_component')->count() }} sub-components @endif
{{ $component->details->whereNull('sub_component')->count() }} checks
@php $hasSubComponents = $component->details->whereNotNull('sub_component')->count() > 0; @endphp @if(!$hasSubComponents && $component->details->whereNull('sub_component')->count() > 0)
Inspection Checklist
@foreach($component->details->whereNull('sub_component') as $detail) @endforeach
Description Pre Condition Post Condition Priority Remarks Image
{{ $detail->description ?? 'N/A' }} {{ $detail->pre_condition ?? 'N/A' }} {{ $detail->post_condition ?? 'N/A' }} {{ $detail->priority ?? 'N/A' }} {{ $detail->remark ?: '—' }} @if($detail->hasMedia('component_images'))
Component Images
@foreach($detail->getMedia('component_images') as $media) @if($media->getCustomProperty('component_id') == $detail->id) @endif @endforeach
@endif
@endif @php $subComponents = $component->details ->filter(function($item) { return !empty($item->sub_component); }) ->groupBy('sub_component'); @endphp @if($subComponents->count() > 0)
Sub-Components
@foreach($subComponents as $subName => $items)
{{ $subName }}
{{ $items->count() }} items
@foreach($items as $item) @endforeach
Description Pre Condition Post Condition Priority
{{ $item->description }} {{ $item->pre_condition }} {{ $item->post_condition }} {{ $item->priority }}
@endforeach
@endif @if($component->otherData->count() > 0)
Component Specifications
@foreach($component->otherData->groupBy('name_component') as $groupName => $items) @php // Calculate total rows needed for this component $rowCount = 0; foreach ($items as $item) { $value = $item->value; if (is_array($value)) { $specData = $value; } elseif (is_string($value)) { $specData = json_decode($value, true) ?? ['value' => $value]; } elseif (is_object($value)) { $specData = (array)$value; } else { $specData = ['value' => $value]; } $specData = is_iterable($specData) ? $specData : ['value' => $specData]; $rowCount += count(array_filter($specData, function($v) { return !empty($v) || $v === 0 || $v === '0'; })); } $isFirstRow = true; @endphp @foreach($items as $item) @php // Convert value to consistent array format $value = $item->value; if (is_array($value)) { $specData = $value; } elseif (is_string($value)) { $specData = json_decode($value, true) ?? ['value' => $value]; } elseif (is_object($value)) { $specData = (array)$value; } else { $specData = ['value' => $value]; } // Ensure we have an iterable array $specData = is_iterable($specData) ? $specData : ['value' => $specData]; @endphp @foreach($specData as $key => $value) @if(!empty($value) || $value === 0 || $value === '0') @if($isFirstRow) @php $isFirstRow = false; @endphp @endif @endif @endforeach @endforeach @endforeach
Component Specification Value
{{ $groupName }} @php $fieldLabels = [ 'construction' => 'Construction', 'diameter_length' => 'Diameter Length', 'date_installed' => 'Installation Date', 'first_layer_size' => 'First Layer Size', 'second_layer_size' => 'Second Layer Size', ]; $displayKey = is_int($key) ? 'value' : $key; @endphp {{ $fieldLabels[$displayKey] ?? ucwords(str_replace('_', ' ', $displayKey)) }} @if($displayKey == 'date_installed') {{ date('d M Y', strtotime($value)) }} @elseif(is_numeric($value)) {{ number_format($value, 2) }} @else {{ $value }} @endif
@endif @if($component->otherDetails->count() > 0)
Additional Findings
@foreach($component->otherDetails as $detail) @endforeach
Description Condition Priority Remarks Value
{{ $detail->description ?? 'N/A' }} {{ $detail->condition ?? 'N/A' }} {{ $detail->priority ?? 'N/A' }} {{ $detail->remark ?: '—' }} {{ $detail->volt ?: '—' }}
@endif
@empty
No components found for this inspection.
@endforelse
Verification
@if($ppm->technician_signature) Technician Signature @endif

{{ $ppm->site_technician ?? 'Technician Name' }}

Inspected By

{{ $ppm->date_inspection ? $ppm->date_inspection->format('d M Y') : '' }}

@if($ppm->supervisor_signature) Supervisor Signature @endif

{{ $ppm->approvedBy->name ?? 'Supervisor Name' }}

Approved By

{{ $ppm->date_approved ? $ppm->date_approved->format('d M Y') : '' }}

Report generated on {{ now()->format('d M Y H:i') }}

PPM Inspection System v1.0

@endsection