@php $marginTop = max(0.0, (float) ($margenesPt['top'] ?? 0)); $marginRight = max(0.0, (float) ($margenesPt['right'] ?? 0)); $marginBottom = max(0.0, (float) ($margenesPt['bottom'] ?? 0)); $marginLeft = max(0.0, (float) ($margenesPt['left'] ?? 0)); @endphp @if(($formatoImpresion ?? '4_por_hoja') === '2_por_hoja_reverso_qr') @php $paperWidth = 612.0; $paperHeight = 792.0; $usableWidth = max(1.0, $paperWidth - $marginLeft - $marginRight); $usableHeight = max(1.0, $paperHeight - $marginTop - $marginBottom); // Cada fila es un gafete: mitad izquierda = diseño, mitad derecha = QR $halfWidth = $usableWidth / 2; $rowHeight = $usableHeight / 2; $badgeWidth = (float) ($page['width'] ?? $halfWidth); $badgeHeight = (float) ($page['height'] ?? $rowHeight); $scale = min($halfWidth / max($badgeWidth, 1), $rowHeight / max($badgeHeight, 1)); $renderedWidth = $badgeWidth * $scale; $renderedHeight = $badgeHeight * $scale; $badgeOffsetLeft = max(0, ($halfWidth - $renderedWidth) / 2); $badgeOffsetTop = max(0, ($rowHeight - $renderedHeight) / 2); $qrPct = max(20, min(95, (int) ($qrReversoPct ?? 65))); $qrSize = min($halfWidth, $rowHeight) * ($qrPct / 100); @endphp @foreach($items->chunk(2) as $chunk)
@foreach($chunk->values() as $rowIndex => $item) @php $registro = $item['registro']; $qrImagenDataUri = $item['qrImagenDataUri']; $rowTop = $marginTop + ($rowIndex * $rowHeight); $qrLeft = $marginLeft + $halfWidth + ($halfWidth - $qrSize) / 2; $qrTop = $rowTop + ($rowHeight - $qrSize) / 2; @endphp {{-- Diseño del gafete (mitad izquierda) --}}
@include('pdfs.partials.gafete_page', compact('registro', 'plantilla', 'qrImagenDataUri', 'page'))
{{-- QR en fondo blanco (mitad derecha) --}} QR @endforeach
@endforeach @elseif(($formatoImpresion ?? '4_por_hoja') === '1_por_hoja') @php $paperWidth = (float) ($page['width'] ?? 612); $paperHeight = (float) ($page['height'] ?? 792); $usableWidth = max(1.0, $paperWidth - $marginLeft - $marginRight); $usableHeight = max(1.0, $paperHeight - $marginTop - $marginBottom); $badgeWidth = (float) ($page['width'] ?? $paperWidth); $badgeHeight = (float) ($page['height'] ?? $paperHeight); $scale = min($usableWidth / max($badgeWidth, 1), $usableHeight / max($badgeHeight, 1)); $renderedWidth = $badgeWidth * $scale; $renderedHeight = $badgeHeight * $scale; $offsetLeft = $marginLeft + max(0, ($usableWidth - $renderedWidth) / 2); $offsetTop = $marginTop + max(0, ($usableHeight - $renderedHeight) / 2); @endphp @foreach($items as $item)
@php $registro = $item['registro']; $qrImagenDataUri = $item['qrImagenDataUri']; @endphp
@include('pdfs.partials.gafete_page', compact('registro', 'plantilla', 'qrImagenDataUri', 'page'))
@endforeach @else @php $paperWidth = 612.0; $paperHeight = 792.0; $usableWidth = max(1.0, $paperWidth - $marginLeft - $marginRight); $usableHeight = max(1.0, $paperHeight - $marginTop - $marginBottom); $slotWidth = $usableWidth / 2; $slotHeight = $usableHeight / 2; $badgeWidth = (float) ($page['width'] ?? $slotWidth); $badgeHeight = (float) ($page['height'] ?? $slotHeight); $scale = min($slotWidth / max($badgeWidth, 1), $slotHeight / max($badgeHeight, 1)); $renderedWidth = $badgeWidth * $scale; $renderedHeight = $badgeHeight * $scale; $offsetLeft = max(0, ($slotWidth - $renderedWidth) / 2); $offsetTop = max(0, ($slotHeight - $renderedHeight) / 2); @endphp @foreach($items->chunk(4) as $chunk)
@foreach($chunk->values() as $slotIndex => $item) @php $registro = $item['registro']; $qrImagenDataUri = $item['qrImagenDataUri']; $row = intdiv($slotIndex, 2); $col = $slotIndex % 2; $slotLeft = $marginLeft + ($col * $slotWidth); $slotTop = $marginTop + ($row * $slotHeight); @endphp
@include('pdfs.partials.gafete_page', compact('registro', 'plantilla', 'qrImagenDataUri', 'page'))
@endforeach
@endforeach @endif