@extends('layouts.admin') @section('content')
{ const el = document.getElementById(id); if (el) { const valStr = (value !== undefined && value !== null && value.toString().trim() !== '') ? value.toString() : ' '; el.value = valStr; if (window.HSSelect) { const inst = window.HSSelect.getInstance(el); if (inst) inst.setValue(valStr); } } }); }, validateAndSubmit(e) { if (!this.selectedMachine) { window.showToast('{{ __('Please select a machine') }}', 'error'); return; } if (!this.passCodeName.trim()) { window.showToast('{{ __('Please enter a description') }}', 'error'); return; } if (parseInt(this.quantity) <= 1 && !this.customCode.trim()) { window.showToast('{{ __('Please enter or generate a pass code') }}', 'error'); return; } e.target.submit(); }, copyQrCode() { if (!this.activeQrCode) return; navigator.clipboard.writeText(this.activeQrCode).then(() => { window.showToast('{{ __('Code Copied') }}', 'success'); }); }, copyQrLink() { if (!this.activeTicketUrl) return; navigator.clipboard.writeText(this.activeTicketUrl).then(() => { window.showToast('{{ __('Link Copied') }}', 'success'); }); }, async downloadQrCode() { const url = '{{ route('admin.basic-settings.qr-code') }}?size=500&data=' + encodeURIComponent(this.activeQrCode); fetch(url) .then(response => response.blob()) .then(blob => { const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = `pass-code-${this.activeQrCode}.png`; link.click(); URL.revokeObjectURL(link.href); }); }, init() { this.$watch('activeTab', (newTab) => { const url = new URL(window.location.origin + window.location.pathname); url.searchParams.set('tab', newTab); window.history.pushState({}, '', url); this.$nextTick(() => { if (window.HSStaticMethods) window.HSStaticMethods.autoInit(); }); }); this.$watch('showCreateModal', (val) => { if (val) { this.selectedMachine = ''; this.passCodeName = ''; this.expiresDays = 7; this.quantity = 1; this.generateRandomCode(); this.syncSelect('modal-pass-machine', ''); } }); } } " @ajax:navigate.window.prevent="fetchTabData(activeTab, $event.detail.url)"> @include('admin.sales.partials.batch-result-banner') {{-- Page Header --}} {{-- Tabs --}} {{-- Main Content --}}
{{-- List Tab --}}
@include('admin.sales.pass-codes.partials.tab-list')
{{-- Logs Tab --}}
{{-- Create Modal --}}

{{ __('Add Pass Code') }}

@csrf
@foreach($machines as $machine) @endforeach
{{-- Quantity (Batch Generate) --}}

{{ __('Batch mode: codes are auto-generated and the custom code is ignored.') }}

{{ __('Days') }}
{{ __('Estimated Expiry') }}
{{-- 只能使用一次:勾選 → usage_limit=1;不勾 → 無限次(維持原行為) --}}
{{-- Edit Modal --}}

{{ __('Edit Pass Code') }}

@csrf @method('PATCH')
{{-- QR Modal --}}

{{ __('QR Code') }}

{{ __('Pass Code') }}:

{{ __('Scan this code at the machine or share the link with the maintenance staff.') }}

{{-- Copy Link Button --}} {{-- Copy Code Button --}} {{-- Download Image Button --}}
{{-- Delete Modal --}}
@endsection