@php /** * Standalone printable MENU document (no dashboard chrome). Two modes: * - preview: the fold-builder's live iframe (fits the frame; shows the side being edited); * - print: a toolbar + the sheet(s), printed true to the design's paper size / orientation. A * double-sided design prints its FRONT then its BACK, one page each (duplex → one sheet). * Renders partials/print-menu-sheet.php from a structure PrintMenuRenderer already resolved (against a * RestaurantContext for a vendor, a SampleContext for an admin template preview), so the preview is true * to paper. The order/pay QR is drawn client-side into [data-qr-url] by the shared QR drawer. * * @var array $resolved ['sheet'=>,'front'=>,'back'=>,'sample'=>] from PrintMenuRenderer::resolve() * @var string $mode 'preview' | 'print' * @var string $side preview only: 'front' | 'back' (which side to show) * @var string $back the URL the toolbar's back button points to * @var string $title */ use App\Models\QrCard; $mode = ($mode ?? 'print') === 'preview' ? 'preview' : 'print'; $resolved = $resolved ?? []; $sheet = $resolved['sheet'] ?? []; $backUrl = (string) ($back ?? route('vendor.menu.print')); $frontPanels = $resolved['front'] ?? []; $backPanels = $resolved['back'] ?? []; $double = !empty($sheet['doubleSided']) && $backPanels; $sample = !empty($resolved['sample']); // The printed page rule: the design's real paper size + the fold's orientation (horizontal fold ⇒ // a landscape sheet), so what prints matches the chosen paper exactly. $paperCss = QrCard::PAPERS[$sheet['paper'] ?? 'a4']['css'] ?? 'A4'; $pageOrient = ($sheet['orientation'] ?? 'horizontal') === 'horizontal' ? 'landscape' : 'portrait'; $dir = is_rtl() ? 'rtl' : 'ltr'; // Which side(s) to lay out. Preview can show one side (front|back) OR BOTH (a double-sided sheet renders // front + back side by side, so the two-sided design is obvious in the editor + the gallery thumbnail); // print always lays out both sides of a double-sided design. $sideParam = in_array($side ?? 'front', ['front', 'back', 'both'], true) ? ($side ?? 'front') : 'front'; if ($mode === 'preview') { if ($sideParam === 'both' && $backPanels) { $sides = [$frontPanels, $backPanels]; } elseif ($sideParam === 'back' && $backPanels) { $sides = [$backPanels]; } else { $sides = [$frontPanels]; } } else { $sides = $double ? [$frontPanels, $backPanels] : [$frontPanels]; } @endphp {{ $title ?? t_raw('vendor.print_menu.doc_title') }} @if ($mode === 'print')
{{ t_raw('vendor.print_menu.back') }}
{{ t_raw('vendor.print_menu.export') }}
@endif
@foreach ($sides as $panels)
@partial('print-menu-sheet', [ 'sheet' => $sheet, 'panels' => $panels, 'sample' => $sample, ])
@endforeach
@if ($mode === 'print') @endif