Compare commits
2
Commits
3d26700e16
...
7b599b28ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b599b28ef | ||
|
|
8472c916b0 |
@@ -23,7 +23,7 @@ if ($_indexRole === 'recepcionista') {
|
|||||||
header('Location: erp.php?m=turnero&v=recepcion'); exit;
|
header('Location: erp.php?m=turnero&v=recepcion'); exit;
|
||||||
}
|
}
|
||||||
if (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) {
|
if (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) {
|
||||||
$_indexAdminRoles = ['superadmin', 'admin', 'supervisor'];
|
$_indexAdminRoles = ['superadmin', 'admin', 'supervisor', 'bacteriologo'];
|
||||||
$url = in_array($_indexRole, $_indexAdminRoles, true)
|
$url = in_array($_indexRole, $_indexAdminRoles, true)
|
||||||
? 'erp.php?m=turnero&v=dashboard'
|
? 'erp.php?m=turnero&v=dashboard'
|
||||||
: 'erp.php?m=turnero&v=recepcion';
|
: 'erp.php?m=turnero&v=recepcion';
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ if ($_POST && !$loginBlocked) {
|
|||||||
header('Location: enfermero_portal.php');
|
header('Location: enfermero_portal.php');
|
||||||
} elseif (in_array('turnero', $modules, true)) {
|
} elseif (in_array('turnero', $modules, true)) {
|
||||||
if ($roleSlug === 'bacteriologo') {
|
if ($roleSlug === 'bacteriologo') {
|
||||||
header('Location: erp.php?m=turnero&v=lugar&lugar_id=1');
|
header('Location: erp.php?m=turnero&v=dashboard');
|
||||||
} elseif (in_array($roleSlug, ['superadmin', 'admin', 'supervisor'], true)) {
|
} elseif (in_array($roleSlug, ['superadmin', 'admin', 'supervisor'], true)) {
|
||||||
header('Location: erp.php?m=turnero&v=dashboard');
|
header('Location: erp.php?m=turnero&v=dashboard');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* POST llamar_desde_espera.php
|
* POST llamar_desde_espera.php
|
||||||
* {turno_id} → devuelve el paciente a la cola activa para la siguiente muestra.
|
* {turno_id, lugar_id} → regresa el paciente a cola, actualiza lugar y dispara display.
|
||||||
* SET muestra_espera_at = NULL.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/_helpers.php';
|
require_once __DIR__ . '/_helpers.php';
|
||||||
requireTurnero();
|
requireTurnero();
|
||||||
@@ -10,10 +9,31 @@ requireMethod('POST');
|
|||||||
|
|
||||||
$input = inputJson();
|
$input = inputJson();
|
||||||
$turnoId = (int)($input['turno_id'] ?? 0);
|
$turnoId = (int)($input['turno_id'] ?? 0);
|
||||||
|
$lugarId = (int)($input['lugar_id'] ?? 0);
|
||||||
if (!$turnoId) jsonError('turno_id requerido');
|
if (!$turnoId) jsonError('turno_id requerido');
|
||||||
|
if (!$lugarId) jsonError('lugar_id requerido');
|
||||||
|
|
||||||
db()->prepare(
|
$pdo = db();
|
||||||
"UPDATE turnero_turnos SET muestra_espera_at = NULL WHERE id = ? AND muestra_espera_at IS NOT NULL"
|
$pdo->prepare(
|
||||||
)->execute([$turnoId]);
|
'UPDATE turnero_turnos
|
||||||
|
SET muestra_espera_at = NULL,
|
||||||
|
lugar_destino_id = ?,
|
||||||
|
llamado_lugar_at = NOW(),
|
||||||
|
atendido_lugar_por = ?
|
||||||
|
WHERE id = ? AND muestra_espera_at IS NOT NULL'
|
||||||
|
)->execute([$lugarId, adminId(), $turnoId]);
|
||||||
|
|
||||||
jsonOk([], 'Paciente de vuelta en cola');
|
$stmt = $pdo->prepare(
|
||||||
|
'SELECT t.*, p.codigo AS prioridad_codigo, p.nombre AS prioridad_nombre, p.color AS prioridad_color,
|
||||||
|
COALESCE(ts.solo_muestras, 0) AS solo_muestras
|
||||||
|
FROM turnero_turnos t
|
||||||
|
JOIN turnero_prioridades p ON p.id = t.prioridad_id
|
||||||
|
LEFT JOIN turnero_solicitudes ts ON ts.turno_id = t.id
|
||||||
|
WHERE t.id = ?'
|
||||||
|
);
|
||||||
|
$stmt->execute([$turnoId]);
|
||||||
|
$turno = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($turno) notificarSSE((int)$turno['sesion_id']);
|
||||||
|
|
||||||
|
jsonOk(['turno' => $turno], 'Paciente llamado');
|
||||||
|
|||||||
@@ -2589,11 +2589,13 @@ async function _llamarDesdeEspera(turnoId) {
|
|||||||
try {
|
try {
|
||||||
const res = await fetch(API + 'llamar_desde_espera.php', {
|
const res = await fetch(API + 'llamar_desde_espera.php', {
|
||||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ turno_id: turnoId }),
|
body: JSON.stringify({ turno_id: turnoId, lugar_id: lugarId }),
|
||||||
});
|
});
|
||||||
const j = await res.json();
|
const j = await res.json();
|
||||||
if (!j.ok) mostrarError(j.error);
|
if (!j.ok) { mostrarError(j.error); return; }
|
||||||
else cargarCola();
|
mostrarLlamando(j.turno.codigo);
|
||||||
|
await abrirFicha(j.turno);
|
||||||
|
cargarCola();
|
||||||
} catch (e) { mostrarError(e.message); }
|
} catch (e) { mostrarError(e.message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user