@php $isPdf = $isPdf ?? false; @endphp
{{-- Header --}}
Homeowner Checklist
Action items from your home evaluation
@php $tenantLogoUrl = is_array($tenantLogo ?? null) ? ($tenantLogo['original'] ?? null) : null; @endphp Logo
@php $primaryCustomer = $customers->first(); $evaluatorNames = $inspectors->pluck('name')->filter()->implode(', '); @endphp
Homeowner: {{ $primaryCustomer['name'] ?? 'N/A' }} Eval Date: {{ $scheduledDateTime ?: 'N/A' }}
Address: {{ $propertyAddress ?: 'N/A' }} File #: {{ $schedule->appointment_id ?? 'N/A' }}
Evaluator: {{ $evaluatorNames ?: 'N/A' }}
{{-- Sections --}} @if($sections->isEmpty())
No inspection data available.
@else @foreach($sections as $section) @php $sectionQuestions = $questionsBySection->get($section->id, collect()); $categoryGroups = $sectionQuestions->groupBy(function ($question) { return data_get($question, 'item_type.type_name', 'General'); }); @endphp
{{ $section->title }}
@forelse($categoryGroups as $categoryName => $groupQuestions)
{{ $categoryName }}
@php $groupQuestions = collect($groupQuestions)->sortBy(function ($question) { $categoryOrder = data_get($question, 'question_category.sort_order', 0); $questionOrder = data_get($question, 'question.sort_order', 0); return sprintf('%05d-%05d', $categoryOrder, $questionOrder); })->values(); $questionGroups = collect($groupQuestions)->groupBy(function ($q) { return $q['question_id'] ?? 'no_id_' . spl_object_id((object)$q); }); @endphp @foreach($questionGroups as $questionId => $variants) @php // Collect recommendations & comments across all variants (deduplicated) $groupedRecommendations = []; $groupedComments = []; $hasNonCompliance = false; $hasCompliance = false; foreach ($variants as $v) { $vOptionType = $v['option']['option_type'] ?? null; $vOptionLower = strtolower($v['option']['option_title'] ?? ''); $vIsNonCompliance = $vOptionType !== null ? (int)$vOptionType === 0 : $vOptionLower === 'non-compliance'; $vIsCompliance = $vOptionType !== null ? (int)$vOptionType === 1 : $vOptionLower === 'compliance'; if ($vIsNonCompliance) $hasNonCompliance = true; if ($vIsCompliance) $hasCompliance = true; if (!empty($v['recommendations'])) { foreach ($v['recommendations'] as $rec) { $recText = is_array($rec) ? ($rec['recommendation_text'] ?? ($rec['recommendation']['recomendation_text'] ?? '')) : ($rec->recommendation_text ?? ($rec->recommendation->recomendation_text ?? '')); if (!empty($recText) && !in_array($recText, $groupedRecommendations)) { $groupedRecommendations[] = $recText; } } } if (!empty($v['comments'])) { foreach ($v['comments'] as $comment) { $commentText = is_array($comment) ? ($comment['comment'] ?? '') : ($comment->comment ?? ''); if (!empty($commentText) && !in_array($commentText, $groupedComments)) { $groupedComments[] = $commentText; } } } } // Determine checkbox state $checkboxClass = ''; if ($hasNonCompliance) { $checkboxClass = 'non-compliant'; } elseif ($hasCompliance) { $checkboxClass = 'checked'; } // Build question label with all side names $firstVariant = $variants->first(); $questionName = $firstVariant['question']['type_name'] ?? 'Question'; $allSideNames = []; foreach ($variants as $v) { if (!empty($v['side_ids'])) { foreach ($v['side_ids'] as $sideId) { if (!empty($sideMap[$sideId]) && !in_array($sideMap[$sideId], $allSideNames)) { $allSideNames[] = $sideMap[$sideId]; } } } } $questionCategory = ''; if (!empty($firstVariant['question_category_id']) && !empty($firstVariant['question_category']['category_name'])) { $questionCategory = $firstVariant['question_category']['category_name']; } @endphp
{{-- Question row with checkbox --}}
@if($checkboxClass === 'non-compliant') fail @elseif($checkboxClass === 'checked') pass @else - @endif
{{ $questionName }} @if(!empty($allSideNames)) ({{ implode(', ', $allSideNames) }}) @endif @if(!empty($questionCategory)) - {{ $questionCategory }} @endif
{{-- Status summary for each variant --}} @foreach($variants as $v) @php $vOption = $v['option']['option_title'] ?? 'N/A'; $vOptionType = $v['option']['option_type'] ?? null; $vOptionLower = strtolower($vOption); $vIsNonCompliance = $vOptionType !== null ? (int)$vOptionType === 0 : $vOptionLower === 'non-compliance'; $vIsCompliance = $vOptionType !== null ? (int)$vOptionType === 1 : $vOptionLower === 'compliance'; $vSideNames = []; if (!empty($v['side_ids'])) { foreach ($v['side_ids'] as $sId) { if (!empty($sideMap[$sId])) $vSideNames[] = $sideMap[$sId]; } } $optionCat = data_get($v, 'option.option_category.category_name', ''); @endphp
@if(count($variants) > 1 && !empty($vSideNames)) {{ implode(', ', $vSideNames) }}: @endif @if($vIsNonCompliance) fail @elseif($vIsCompliance) pass @else - @endif {{ $vOption }} @if(!empty($optionCat)) ({{ $optionCat }}) @endif
@endforeach {{-- Recommendations --}} @if(!empty($groupedRecommendations))
Recommendations:
@foreach($groupedRecommendations as $recText)
{{ $recText }}
@endforeach
@endif {{-- Special Notes --}} @if(!empty($groupedComments))
Special Notes:
@foreach($groupedComments as $noteText)
{{ $noteText }}
@endforeach
@endif
@endforeach
@empty
No items for this section.
@endforelse
@endforeach @endif {{-- Legend --}}
Legend
pass Compliant fail Non-Compliant (action needed) - Not Applicable / Other
{{-- Footer --}}
Generated on {{ now()->format('M j, Y') }} · {{ $schedule->appointment_id ?? '' }}
{{-- Print button (web only) --}} @if(!$isPdf)
@endif