@php $hasCompliances = $instance->actSections && $instance->actSections->count() > 0; @endphp {{-- ===== HEADER ===== --}}

{{ 'Establishment Compliance Report - ' . ($instance->template->state_master?->name ?? '-') }}

Generated: {{ now()->format('d M Y H:i') }}
VHR Logo
{{-- ===== CLIENT DETAILS ===== --}}

Client Details

@php $branchName = $instance->client_branch->branch_name ?? ''; $branchAddress = $instance->client_branch->address ?? ''; $branchCity = $instance->client_branch->city_master?->name ?? ''; $branchState = $instance->client_branch->state_master?->name ?? ''; $fullAddress = collect([$branchAddress, $branchCity, $branchState]) ->filter(fn ($v) => filled($v)) ->join(', '); @endphp
Branch Name {{ $branchName ?: '—' }}
Address {{ $fullAddress ?: '—' }}
{{-- ===== FORM DETAILS ===== --}}

Form Details

@foreach($instance->template->fields as $field) @php $value = $instance->values->firstWhere('form_field_id', $field->id); @endphp @endforeach
{{ $field->field_label }} {{ $value?->field_value ?? '—' }}
{{-- ===== COMPLIANCE TABLE ===== --}} @if($hasCompliances)

Statutory Compliance Details

@foreach($instance->actSections as $row) @endforeach
Act Section / Rule Form Nature of Compliance Status Remarks
{{ $row->statutoryAct?->act_name ?? '-' }} {{ $row->statutorySection?->section ?? '-' }} {{ $row->statutorySection?->form ?? '-' }} {{ $row->statutorySection?->nature_of_compliance ?? '-' }} {{ $row->status }} {{ $row->remarks ?? '—' }}
@endif {{-- ===== OVERALL STATUS ===== --}} @if($hasCompliances) @php $statuses = [ 'COMPLIED', 'NOT COMPLIED', 'OUT OF SCOPE', 'YET TO ASCERTAIN', 'NOT APPLICABLE', ]; $total = max($instance->actSections->count(), 1); @endphp

Overall Compliance Status

@foreach($statuses as $status) @php $count = $instance->actSections->where('status', $status)->count(); $percent = round(($count / $total) * 100); @endphp
{{ str_replace('_', ' ', $status) }} {{ $percent }}%
@endforeach
@endif