{{-- Documento del informe. Se usa en: - la vista previa en vivo del editor ($pdf = false) - el PDF generado con DomPDF ($pdf = true) Recibe: $doc (array), $settings (array), $pdf (bool), $logoSrc (?string) --}} @php use App\Support\DocumentAsset; $pdf = $pdf ?? false; $sections = $doc['sections'] ?? []; $date = $doc['service_date'] ?? null; $dateText = $date ? $date->locale('es')->translatedFormat('d \d\e F \d\e Y') : '—'; $signature = $doc['signature'] ?? null; @endphp
@if ($settings['show_company'] || $settings['show_code']) @if ($settings['show_company']) @if ($logoSrc) @endif @endif @if ($settings['show_code']) @endif
{{ $settings['company_name'] }}
@if (filled($settings['company_ruc'])) RUC: {{ $settings['company_ruc'] }} @endif @if (filled($settings['company_address'])) · {{ $settings['company_address'] }} @endif @if (filled($settings['company_phone']))
Tel.: {{ $settings['company_phone'] }} @endif @if (filled($settings['company_email'])) · {{ $settings['company_email'] }} @endif
{{ $doc['code'] ?? 'INF-XXXX-XXXX' }}
{{ $dateText }}
@endif
{{ filled($doc['title'] ?? null) ? $doc['title'] : 'Título del informe' }}
@if ($settings['show_client'])
{{ $settings['client_label'] }} {{ $doc['client_name'] ?: '—' }} Fecha {{ $dateText }}
{{ $settings['location_label'] }} {{ $doc['client_location'] ?: '—' }}
@endif @forelse ($sections as $index => $section) @php $content = $section['content'] ?? []; @endphp
{{ $index + 1 }}. {{ filled($section['title']) ? $section['title'] : 'Sección sin título' }}
@if (filled($section['description'] ?? null))

{{ $section['description'] }}

@endif @switch($section['type']) @case('richtext') @if (filled($content['html'] ?? null))
{!! DocumentAsset::html($content['html'], $pdf) !!}
@elseif (! $pdf)

Escribe el contenido de esta sección…

@endif @break @case('key_value') @break @case('table') @if (count($content['columns'] ?? [])) @foreach ($content['columns'] as $col) @endforeach @foreach ($content['rows'] ?? [] as $row) @foreach ($row as $ci => $cell) @endforeach @endforeach
{{ $col }}
{{ $cell }}
@endif @break @case('gallery') @php $cols = (int) ($content['columns'] ?? 1); $label = $content['label'] ?? 'Evidencia'; $items = $content['items'] ?? []; $chunks = array_chunk($items, $cols, true); @endphp @foreach ($chunks as $chunk) @foreach ($chunk as $i => $item) @php $src = DocumentAsset::src($item['path'] ?? null, $pdf); @endphp @endforeach @for ($k = count($chunk); $k < $cols; $k++) @endfor @endforeach @break @endswitch
@empty @unless ($pdf)

Agrega secciones para ver aquí la vista previa del informe.

@endunless @endforelse @php // Firmas: técnico (izquierda) y cliente (derecha), en la misma fila. $signatures = []; if (($settings['show_signature'] ?? true) && $signature) { $signatures[] = [ 'label' => $settings['technician_signature_label'] ?? 'Técnico responsable', 'name' => $signature['name'] ?? '', 'position' => $signature['position'] ?? null, 'src' => DocumentAsset::src($signature['path'] ?? null, $pdf), ]; } if ($settings['show_client_signature'] ?? true) { $clientSignature = $doc['client_signature'] ?? []; $signatures[] = [ 'label' => $settings['client_signature_label'] ?? 'Conformidad del cliente', 'name' => ($clientSignature['name'] ?? null) ?: ($doc['client_name'] ?? ''), 'position' => $clientSignature['position'] ?? null, 'src' => DocumentAsset::src($clientSignature['path'] ?? null, $pdf), ]; } @endphp @if (count($signatures)) @foreach ($signatures as $sig) @endforeach
@if ($sig['src']) Firma @endif
{{ $sig['name'] ?: ' ' }}
@if (filled($sig['position']))
{{ $sig['position'] }}
@endif @if (filled($sig['label']))
{{ $sig['label'] }}
@endif
@endif