@php
use App\Enums\PrintMode;
[$paperW, $paperH] = $template->paperDimensions();
$slots = $template->slotList();
$elements = $template->elementList();
$overlay = $template->print_mode === PrintMode::Overlay;
@endphp
@if($template->print_background && $template->backgroundUrl())
 }})
@endif
@foreach($sheet->values() as $index => $ticket)
@php
$slot = $slots[$index] ?? null;
if (! $slot) continue;
$bindings = $ticket->templateBindings();
@endphp
@foreach($elements as $element)
@php
$type = $element['type'] ?? 'text';
// In "QR code only" mode the stock is already printed, so
// everything except the QR is skipped unless opted in.
// PrintMode::prints() is the single source of truth here,
// shared with the designer preview.
if (! $template->print_mode->prints($element)) continue;
@endphp
@if($type === 'qr')
{!! $qr->svg($ticket->qrPayload(), 300, (int) ($element['margin'] ?? 0)) !!}
@elseif($type === 'rect')
@else
@php
$value = ! empty($element['field'])
? ($bindings[$element['field']] ?? '')
: ($element['text'] ?? '');
@endphp
{{ $value }}
@endif
@endforeach
@if($template->show_cut_marks)
{{-- Short rules at each slot corner to guide the guillotine. --}}
@foreach([
['x' => $slot['x'], 'y' => $slot['y']],
['x' => $slot['x'] + $slot['w'], 'y' => $slot['y']],
['x' => $slot['x'], 'y' => $slot['y'] + $slot['h']],
['x' => $slot['x'] + $slot['w'], 'y' => $slot['y'] + $slot['h']],
] as $corner)
@endforeach
@endif
@endforeach
@endforeach