@extends('layouts.dashboard') @section('content') @php /** * Vendor dine-in QR page (/vendor/tables/qr): the restaurant's DESIGNED QR cards, in two clearly * separated entries so a vendor never confuses one for the other: * * 1. Table ordering QR — one card per table (a FRONT and a BACK), each carrying that table's own * scan-to-order code. There is ONE design for the whole restaurant; only the QR is per-table. * 2. Payment QR — MANY named "scan to pay" cards, each its own design + static payment link * (PayPal.Me / a Stripe link / a upi:// link), for stalls and trucks that take payment with no * table. Managed add / click-to-edit / delete, like TV screens. * * On screen both render through the shared studio-grid (object mode) so the QR page matches the TV * Screens + Printable-menu managers 1:1; the 3D flip preview + the hidden per-card print blocks are * unchanged. On paper the print flows are independent — the table button prints every table's card; * each payment card carries its own @page rule so a landscape card prints landscape. * * @var array $rows per-table [id, label, zone, path, table] * @var array $card the table-card design (front/back + settings) * @var array $logo the restaurant brand mark [src, initials, color] * @var array|null $frontProduct resolved featured dish for the table front (or null) * @var array|null $backProduct resolved featured dish for the table back (or null) * @var array $payCards named payment cards, each [id, name, card, payUrl, frontProduct, backProduct] */ $rows = $rows ?? []; $card = $card ?? \App\Models\QrCard::defaultConfig(); $logo = $logo ?? []; $payCards = $payCards ?? []; /** The @page rule for a card's paper size + orientation (cards differ; JS swaps it per print run). */ $pageRule = static function (array $c): string { $o = ($c['orientation'] ?? 'portrait') === 'landscape' ? 'landscape' : 'portrait'; $p = \App\Models\QrCard::PAPERS[$c['paper'] ?? 'a5']['css'] ?? 'A5'; return '@page { size: ' . $p . ' ' . $o . '; margin: 6mm; }'; }; $tableRule = $pageRule($card); $emptyTable = ['label' => '', 'zone' => '']; // a payment card isn't tied to a table @endphp @php /* ============================ 1 · Table ordering QR ============================ */ @endphp

{{ t_raw('vendor.qr_card.section_table_title') }}

{{ t_raw('vendor.qr_print.page_subtitle') }}

{{ t_raw('vendor.qr_print.back_to_floor_plan_btn') }} {{ t_raw('vendor.qr_card.design_btn') }} @if ($rows) @partial('print-actions', ['target' => '.qrc-print[data-print="table"]', 'name' => 'table-qr-cards', 'nup' => true, 'page' => $tableRule]) @endif
@if (!$rows)

{{ t_raw('vendor.qr_print.empty_no_tables') }}

{{ t_raw('vendor.qr_print.go_to_floor_plan_btn') }}
@else
@php $tableCards = []; @endphp @foreach ($rows as $r) @php ob_start(); @endphp
@partial('qr-card-side', ['side' => $card['front'], 'card' => $card, 'product' => $frontProduct ?? null, 'qrPath' => $r['path'], 'logo' => $logo, 'table' => $r['table']])
@partial('qr-card-side', ['side' => $card['back'], 'card' => $card, 'product' => $backProduct ?? null, 'qrPath' => $r['path'], 'logo' => $logo, 'table' => $r['table']])
@php $media = ob_get_clean(); ob_start(); @endphp @php /* Icon-row actions (the screens-page convention): full labels made each button wrap onto its own line inside the narrow card column, stacking three deep. */ @endphp @if ($r['path'] !== '') @endif
@csrf
@php $tableCards[] = ['media' => $media, 'actions' => ob_get_clean()]; @endphp @endforeach @php echo partial('studio-grid', ['cards' => $tableCards, 'mode' => 'object', 'align' => 'center', 'min' => '210px']); @endphp
@foreach ($rows as $r)
@partial('qr-card-side', ['side' => $card['front'], 'card' => $card, 'product' => $frontProduct ?? null, 'qrPath' => $r['path'], 'logo' => $logo, 'table' => $r['table']])
@partial('qr-card-side', ['side' => $card['back'], 'card' => $card, 'product' => $backProduct ?? null, 'qrPath' => $r['path'], 'logo' => $logo, 'table' => $r['table']])
@endforeach
@endif @php /* ===================== 2 · Payment QR (many named cards) ===================== */ @endphp

{{ t_raw('vendor.qr_card.section_pay_title') }}

{{ t_raw('vendor.qr_card.section_pay_sub') }}

{{ t_raw('vendor.qr_card.pay_add_btn') }}
@if (!$payCards)

{{ t_raw('vendor.qr_card.pay_empty') }}

{{ t_raw('vendor.qr_card.pay_add_btn') }}
@else
@php $payTiles = []; @endphp @foreach ($payCards as $pc) @php $pcard = $pc['card']; $purl = (string) $pc['payUrl']; $editUrl = url('/vendor/tables/qr/pay/' . $pc['id']); ob_start(); @endphp
@partial('qr-card-side', ['side' => $pcard['front'], 'card' => $pcard, 'product' => $pc['frontProduct'], 'qrPath' => $purl, 'logo' => $logo, 'table' => $emptyTable])
@partial('qr-card-side', ['side' => $pcard['back'], 'card' => $pcard, 'product' => $pc['backProduct'], 'qrPath' => $purl, 'logo' => $logo, 'table' => $emptyTable])
@php $media = ob_get_clean(); ob_start(); @endphp @php /* Same icon-row treatment as the table cards; everything but the Print/Export dropdown compacts to an icon so the four controls share one line. */ @endphp @if ($purl !== '') @partial('print-actions', ['target' => '.qrc-print[data-pay-id="' . (int) $pc['id'] . '"]', 'name' => 'payment-qr-' . (int) $pc['id'], 'nup' => true, 'compact' => true, 'page' => $pageRule($pcard)]) @endif
@csrf
@php $payTiles[] = ['media' => $media, 'name' => $pc['name'], 'actions' => ob_get_clean()]; @endphp @endforeach @php /* 280px min: Edit + open-link + Print/Export + delete must share one row. */ echo partial('studio-grid', ['cards' => $payTiles, 'mode' => 'object', 'align' => 'center', 'min' => '280px']); @endphp
@foreach ($payCards as $pc) @php if ((string) $pc['payUrl'] === '') { continue; } $pcard = $pc['card']; $purl = (string) $pc['payUrl']; @endphp
@partial('qr-card-side', ['side' => $pcard['front'], 'card' => $pcard, 'product' => $pc['frontProduct'], 'qrPath' => $purl, 'logo' => $logo, 'table' => $emptyTable])
@partial('qr-card-side', ['side' => $pcard['back'], 'card' => $pcard, 'product' => $pc['backProduct'], 'qrPath' => $purl, 'logo' => $logo, 'table' => $emptyTable])
@endforeach @endif @endsection