fix(turnero): asignar recepcion_desk_id al llamar turno específico
llamarTurnoEspecifico usaba cambiar_estado.php sin pasar desk_id, por lo que recepcion_desk_id quedaba NULL. El display TV filtra por recepcion_desk_id = ?, así el turno llamado no aparecía en pantalla. También se corrige llamado_recepcion_at: era COALESCE (no actualizaba si ya tenía valor), ahora es NOW() para que el display reaccione al re-llamar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bfab8418b6
commit
71e97f2d95
@@ -29,6 +29,7 @@ $datos = inputJson();
|
|||||||
$turnoId = isset($datos['turno_id']) ? (int) $datos['turno_id'] : 0;
|
$turnoId = isset($datos['turno_id']) ? (int) $datos['turno_id'] : 0;
|
||||||
$nuevoEstado = isset($datos['nuevo_estado']) ? trim((string) $datos['nuevo_estado']) : '';
|
$nuevoEstado = isset($datos['nuevo_estado']) ? trim((string) $datos['nuevo_estado']) : '';
|
||||||
$lugarId = isset($datos['lugar_id']) ? (int) $datos['lugar_id'] : null;
|
$lugarId = isset($datos['lugar_id']) ? (int) $datos['lugar_id'] : null;
|
||||||
|
$deskId = isset($datos['desk_id']) ? (int) $datos['desk_id'] : null;
|
||||||
|
|
||||||
// ── Validación básica ─────────────────────────────────────────
|
// ── Validación básica ─────────────────────────────────────────
|
||||||
if ($turnoId <= 0) jsonError('turno_id inválido.');
|
if ($turnoId <= 0) jsonError('turno_id inválido.');
|
||||||
@@ -107,10 +108,14 @@ try {
|
|||||||
|
|
||||||
switch ($nuevoEstado) {
|
switch ($nuevoEstado) {
|
||||||
case 'en_recepcion':
|
case 'en_recepcion':
|
||||||
$sets[] = 'llamado_recepcion_at = COALESCE(llamado_recepcion_at, NOW())';
|
$sets[] = 'llamado_recepcion_at = NOW()';
|
||||||
$sets[] = 'inicio_recepcion_at = COALESCE(inicio_recepcion_at, NOW())';
|
$sets[] = 'inicio_recepcion_at = COALESCE(inicio_recepcion_at, NOW())';
|
||||||
$sets[] = 'atendido_recepcion_por = COALESCE(atendido_recepcion_por, ?)';
|
$sets[] = 'atendido_recepcion_por = COALESCE(atendido_recepcion_por, ?)';
|
||||||
$binds[] = adminId();
|
$binds[] = adminId();
|
||||||
|
if ($deskId) {
|
||||||
|
$sets[] = 'recepcion_desk_id = ?';
|
||||||
|
$binds[] = $deskId;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'en_espera_lugar':
|
case 'en_espera_lugar':
|
||||||
|
|||||||
@@ -1192,7 +1192,7 @@ async function llamarTurnoEspecifico(turnoId, estadoActual) {
|
|||||||
const res = await fetch(API + 'cambiar_estado.php', {
|
const res = await fetch(API + 'cambiar_estado.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ turno_id: turnoId, nuevo_estado: 'en_recepcion' }),
|
body: JSON.stringify({ turno_id: turnoId, nuevo_estado: 'en_recepcion', desk_id: DESK_ID }),
|
||||||
});
|
});
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
if (!json.ok) { mostrarError(json.error); return; }
|
if (!json.ok) { mostrarError(json.error); return; }
|
||||||
|
|||||||
Reference in New Issue
Block a user