up
This commit is contained in:
@@ -27,11 +27,26 @@ try {
|
||||
$cat = $ex['categoria'] ?: 'General';
|
||||
$examenesAgrupados[$cat][] = $ex;
|
||||
}
|
||||
|
||||
// Escritorio de recepción (opcional, vía ?desk_id=X)
|
||||
$deskId = (int)($_GET['desk_id'] ?? 0);
|
||||
$desk = null;
|
||||
if ($deskId) {
|
||||
$stmtDesk = $pdo->prepare(
|
||||
"SELECT id, nombre FROM turnero_lugares WHERE id = ? AND tipo = 'recepcion' AND activo = 1"
|
||||
);
|
||||
$stmtDesk->execute([$deskId]);
|
||||
$desk = $stmtDesk->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||
if (!$desk) { $deskId = 0; } // ID inválido → sin desk
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$lugares = [];
|
||||
$examenesAgrupados = [];
|
||||
$deskId = 0;
|
||||
$desk = null;
|
||||
}
|
||||
|
||||
$deskNombre = $desk['nombre'] ?? null; // null = vista genérica
|
||||
$adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user']['username'] ?? 'Operador';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -39,7 +54,7 @@ $adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user']['
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Recepción — Turnero</title>
|
||||
<title><?= htmlspecialchars($deskNombre ?? 'Recepción') ?> — Turnero</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||
<link href="<?= BASE_URL ?>assets/css/styles.css?v=12" rel="stylesheet">
|
||||
@@ -169,17 +184,19 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
<div class="d-flex align-items-center justify-content-between px-3 py-2 border-bottom bg-white"
|
||||
style="position:sticky;top:0;z-index:100">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<i class="fas fa-ticket-alt text-primary"></i>
|
||||
<strong>Recepción</strong>
|
||||
<i class="fas fa-concierge-bell text-primary"></i>
|
||||
<strong><?= htmlspecialchars($deskNombre ?? 'Recepción') ?></strong>
|
||||
<span id="badge-turno-activo" class="badge-turno-activo d-none">
|
||||
Turno: <span id="badge-codigo">—</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="text-muted small"><?= htmlspecialchars($adminNombre) ?></span>
|
||||
<a href="<?= BASE_URL ?>erp.php?m=turnero&v=lugar" class="btn btn-outline-secondary btn-sm" target="_blank">
|
||||
<i class="fas fa-flask me-1"></i>Ver Lugar
|
||||
<?php if ($deskId): ?>
|
||||
<a href="<?= BASE_URL ?>erp.php?m=turnero&v=display_recepcion&desk_id=<?= $deskId ?>" class="btn btn-outline-info btn-sm" target="_blank">
|
||||
<i class="fas fa-tv me-1"></i>Ver Pantalla
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<button class="btn btn-primary btn-sm" id="btn-llamar" onclick="llamarSiguiente()">
|
||||
<i class="fas fa-bell me-1"></i>Llamar siguiente
|
||||
</button>
|
||||
@@ -364,8 +381,9 @@ let solicitudActiva = null;
|
||||
let consentimientos = [];
|
||||
let pollingColaId = null;
|
||||
|
||||
const API = '<?= BASE_URL ?>modules/turnero/api/';
|
||||
const API = '<?= BASE_URL ?>modules/turnero/api/';
|
||||
const API_PAC = '<?= BASE_URL ?>api/lab/get_pacientes.php';
|
||||
const DESK_ID = <?= $deskId ?: 'null' ?>;
|
||||
|
||||
// ── Arranque ──────────────────────────────────────────────────
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
@@ -421,7 +439,7 @@ async function llamarSiguiente() {
|
||||
const res = await fetch(API + 'llamar_turno.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ area: 'recepcion' }),
|
||||
body: JSON.stringify({ area: 'recepcion', desk_id: DESK_ID }),
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.ok) { mostrarError(json.error); return; }
|
||||
@@ -454,8 +472,18 @@ async function seleccionarTurno(turnoId) {
|
||||
|
||||
// ── Llamar turno específico (cambia estado → en_recepcion) ─────────
|
||||
async function llamarTurnoEspecifico(turnoId, estadoActual) {
|
||||
// Si ya está en recepción, solo abrir ficha sin intentar re-transicionar
|
||||
// Si ya está en recepción: re-llamar (actualiza llamado_at para que la pantalla TV reactive)
|
||||
if (estadoActual === 'en_recepcion') {
|
||||
try {
|
||||
const res = await fetch(API + 'rellamar.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ turno_id: turnoId, desk_id: DESK_ID }),
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.ok && json.turno) { abrirFicha(json.turno); return; }
|
||||
} catch (_) {}
|
||||
// Fallback: solo abrir ficha
|
||||
seleccionarTurno(turnoId);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user