@extends('layouts.dashboard') @section('content') @php /** * Shared add/edit reservation form. * @var bool $editing @var array|null $res @var array $tables @var array $labels * @var string $date @var array $closedDows @var array $blackoutDates * @var int $maxParty @var int $defaultDuration @var int $leadMinutes */ $editing = $editing ?? false; $res = $res ?? null; $tables = $tables ?? []; $labels = $labels ?? []; $maxParty = (int) ($maxParty ?? 50); $defaultDuration = (int) ($defaultDuration ?? 90); $leadMinutes = (int) ($leadMinutes ?? 0); $val = static function (string $key, $fallback = '') use ($res, $__env) { return $res[$key] ?? $fallback; }; // Per-field validation errors stashed by the controller on a failed submit (keyed by // field name). Read raw so we can index it; absent on a clean load. Drives the // aria-invalid / aria-describedby wiring below for accessible, inline error reporting. $fieldErrors = \App\Support\Session::old('__errors', []); $fieldErrors = is_array($fieldErrors) ? $fieldErrors : []; $err = static function (string $field) use ($fieldErrors, $__env): string { return isset($fieldErrors[$field][0]) ? (string) $fieldErrors[$field][0] : ''; }; $resTime = $editing && !empty($res['reserved_at']) ? date('H:i', strtotime((string) $res['reserved_at'])) : '19:00'; $resDur = $editing ? (int) ($res['duration_minutes'] ?? $defaultDuration) : $defaultDuration; $resTable = (int) ($res['table_id'] ?? 0) ?: (int) ($prefillTable ?? 0); $resLabel = (int) ($res['label_id'] ?? 0); $resLabelColor = '#64748b'; foreach ($labels as $lbl) { if ((int) ($lbl['id'] ?? 0) === $resLabel) { $resLabelColor = (string) $lbl['color']; } } $durations = [30, 45, 60, 90, 120, 150, 180, 240]; $closedJson = implode(',', array_map('intval', $closedDows ?? [])); $blackoutJson = implode(',', array_map('strval', $blackoutDates ?? [])); $action = $editing ? '/vendor/reservations/update' : '/vendor/reservations/save'; @endphp @php /* .qm-d2: the dashboard density standard (app.css ยง35) */ @endphp
{{ t_raw('nav.reservations') }}

{!! $editing ? t('vendor.reservations.form_sub_edit') : t('vendor.reservations.form_sub_new') !!}

@csrf @if ($editing) @endif @php /* Identity of THIS rendering of the new-booking form, so the server can tell a repeat of one create (Back-then-Create, a replayed POST, a second tab) from a second booking genuinely taken for the same party. The editing branch above carries a version instead, which settles a resubmitted update on its own. See ReservationController::createdByUid(). */ @endphp @if (($createUid ?? '') !== '') @endif

{{ t_raw('vendor.reservations.section_guest_details') }}

{!! $err('guest_name') !!}

{!! $err('guest_phone') !!}

{!! $err('guest_email') !!}

{{ t_raw('vendor.reservations.party_size_hint', [':max' => $maxParty]) }}

{!! $err('party_size') !!}

{{ t_raw('vendor.reservations.section_booking_details') }}

{!! $err('date') !!}

@if ($leadMinutes > 0){{ t_raw('vendor.reservations.lead_time_hint', [':n' => $leadMinutes]) }}@endif

{!! $err('time') !!}

{{ t_raw('vendor.reservations.table_hint') }}

{{ t_raw('common.notes') }}

{!! $err('special_requests') !!}

{!! $err('staff_notes') !!}

{{ t_raw('common.cancel') }}
@php /* /.qm-d2 */ @endphp @endsection