Fix queue handoff so tickets keep their number across services.
Deploy Ladill Queue / deploy (push) Successful in 40s

Handoff now frees the counter, ends the service session, and requeues
the same ticket for the next department — critical for hospital flows
like doctor → lab.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-14 21:22:01 +00:00
co-authored by Cursor
parent d938acf909
commit d2f5ff11d2
12 changed files with 333 additions and 74 deletions
+29 -15
View File
@@ -14,6 +14,13 @@
</div>
</div>
@if (session('success'))
<p class="mt-4 rounded-lg bg-emerald-50 px-3 py-2 text-sm text-emerald-800">{{ session('success') }}</p>
@endif
@if (session('error'))
<p class="mt-4 rounded-lg bg-rose-50 px-3 py-2 text-sm text-rose-800">{{ session('error') }}</p>
@endif
@if ($currentTicket)
<section class="mt-6 overflow-hidden rounded-2xl border border-indigo-200 bg-gradient-to-br from-indigo-50 via-white to-white shadow-sm">
<div class="border-b border-indigo-100 px-6 py-4">
@@ -47,26 +54,33 @@
@endforeach
</div>
@if ($allQueues->count() > 1)
<form method="POST" action="{{ route('qms.console.action', $counter) }}" class="mt-4 flex flex-wrap items-end gap-2 border-t border-indigo-100 pt-4">
@php
$handoffQueues = $allQueues->where('id', '!=', $currentTicket->service_queue_id)->values();
@endphp
@if ($handoffQueues->isNotEmpty())
<form method="POST" action="{{ route('qms.console.action', $counter) }}" class="mt-4 border-t border-indigo-100 pt-4">
@csrf
<input type="hidden" name="action" value="transfer">
<input type="hidden" name="ticket_id" value="{{ $currentTicket->id }}">
<div class="min-w-[12rem] flex-1">
<label class="block text-xs font-medium text-slate-500">Transfer to queue</label>
<select name="to_queue_id" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
@foreach ($allQueues as $q)
@if ($q->id !== $currentTicket->service_queue_id)
<option value="{{ $q->id }}">{{ $q->name }}</option>
@endif
@endforeach
</select>
<div class="mb-3">
<p class="text-sm font-medium text-slate-800">Hand off to another queue</p>
<p class="mt-1 text-xs text-slate-500">Sends this customer to the next service while keeping ticket <span class="font-mono font-semibold text-slate-700">{{ $currentTicket->ticket_number }}</span>.</p>
</div>
<div class="min-w-[12rem] flex-1">
<label class="block text-xs font-medium text-slate-500">Reason (optional)</label>
<input type="text" name="reason" placeholder="e.g. Specialist required" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
<div class="flex flex-wrap items-end gap-2">
<div class="min-w-[12rem] flex-1">
<label class="block text-xs font-medium text-slate-500">Next queue</label>
<select name="to_queue_id" required class="mt-1 w-full rounded-lg border-slate-300 text-sm">
@foreach ($handoffQueues as $q)
<option value="{{ $q->id }}">{{ $q->name }} ({{ $q->prefix }})</option>
@endforeach
</select>
</div>
<div class="min-w-[12rem] flex-1">
<label class="block text-xs font-medium text-slate-500">Reason (optional)</label>
<input type="text" name="reason" placeholder="e.g. Lab tests needed" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
</div>
<button type="submit" class="btn-primary text-sm">Hand off</button>
</div>
<button type="submit" class="btn-secondary text-sm">Transfer ticket</button>
</form>
@endif
</div>
@@ -17,5 +17,29 @@
<a href="{{ route('qms.tickets.index') }}" class="btn-primary">All tickets</a>
</div>
</div>
@if ($ticket->transfers->isNotEmpty())
<div class="mt-4 rounded-2xl bg-white p-6 shadow-sm">
<h2 class="text-sm font-semibold text-slate-900">Hand-off history</h2>
<p class="mt-1 text-xs text-slate-500">Ticket number stays {{ $ticket->ticket_number }} across each hand-off.</p>
<ul class="mt-4 divide-y divide-slate-100">
@foreach ($ticket->transfers as $transfer)
<li class="py-3 text-sm">
<p class="font-medium text-slate-800">
{{ $transfer->fromQueue?->name ?? 'Queue' }}
{{ $transfer->toQueue?->name ?? 'Queue' }}
</p>
<p class="mt-1 text-xs text-slate-500">
{{ $transfer->transferred_at?->format('M j, Y H:i') }}
@if ($transfer->reason)
· {{ $transfer->reason }}
@endif
</p>
</li>
@endforeach
</ul>
</div>
@endif
</div>
</x-app-layout>