diff --git a/modules/turnero/api/cambiar_estado.php b/modules/turnero/api/cambiar_estado.php index 2f78efb..656fdc6 100644 --- a/modules/turnero/api/cambiar_estado.php +++ b/modules/turnero/api/cambiar_estado.php @@ -29,6 +29,7 @@ $datos = inputJson(); $turnoId = isset($datos['turno_id']) ? (int) $datos['turno_id'] : 0; $nuevoEstado = isset($datos['nuevo_estado']) ? trim((string) $datos['nuevo_estado']) : ''; $lugarId = isset($datos['lugar_id']) ? (int) $datos['lugar_id'] : null; +$deskId = isset($datos['desk_id']) ? (int) $datos['desk_id'] : null; // ── Validación básica ───────────────────────────────────────── if ($turnoId <= 0) jsonError('turno_id inválido.'); @@ -107,10 +108,14 @@ try { switch ($nuevoEstado) { 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[] = 'atendido_recepcion_por = COALESCE(atendido_recepcion_por, ?)'; $binds[] = adminId(); + if ($deskId) { + $sets[] = 'recepcion_desk_id = ?'; + $binds[] = $deskId; + } break; case 'en_espera_lugar': diff --git a/modules/turnero/views/recepcion.php b/modules/turnero/views/recepcion.php index 299e2ed..874e134 100644 --- a/modules/turnero/views/recepcion.php +++ b/modules/turnero/views/recepcion.php @@ -1192,7 +1192,7 @@ async function llamarTurnoEspecifico(turnoId, estadoActual) { const res = await fetch(API + 'cambiar_estado.php', { method: 'POST', 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(); if (!json.ok) { mostrarError(json.error); return; }