This commit is contained in:
Lizandro Guarnizo
2026-06-16 13:35:03 -05:00
parent 1b9c8efaad
commit fc14360e2e
2 changed files with 48 additions and 22 deletions
+23 -12
View File
@@ -66,23 +66,34 @@ if ($area === 'recepcion') {
); );
$stmt->execute($bindsCola); $stmt->execute($bindsCola);
} else { } else {
// Lugar: cola compartida (grupo) solo en_espera_lugar // Lugar: cola = en_espera_lugar del grupo + en_servicio en ESTA estación
$grupoIds = lugarIdsDeGrupo($lugarId); $grupoIds = lugarIdsDeGrupo($lugarId);
$inLugares = implode(',', array_map('intval', $grupoIds)); $inLugares = implode(',', array_map('intval', $grupoIds));
$cols = "t.id, t.codigo, t.numero, t.estado, t.paciente_nombre,
t.recepcion_desk_id, t.creado_at, t.llamado_recepcion_at, t.llamado_lugar_at,
p.codigo AS prioridad_codigo, p.nombre AS prioridad_nombre,
p.color AS prioridad_color, p.orden_peso";
$stmt = $pdo->prepare( $stmt = $pdo->prepare(
"SELECT t.id, t.codigo, t.numero, t.estado, t.paciente_nombre, "SELECT * FROM (
t.recepcion_desk_id, t.creado_at, t.llamado_recepcion_at, t.llamado_lugar_at, (SELECT $cols
p.codigo AS prioridad_codigo, p.nombre AS prioridad_nombre, FROM turnero_turnos t
p.color AS prioridad_color, p.orden_peso JOIN turnero_prioridades p ON p.id = t.prioridad_id
FROM turnero_turnos t WHERE t.sesion_id = ?
JOIN turnero_prioridades p ON p.id = t.prioridad_id AND t.estado = 'en_espera_lugar'
WHERE t.sesion_id = ? AND t.lugar_destino_id IN ($inLugares))
AND t.estado = 'en_espera_lugar' UNION ALL
AND t.lugar_destino_id IN ($inLugares) (SELECT $cols
ORDER BY p.orden_peso ASC, t.creado_at ASC" FROM turnero_turnos t
JOIN turnero_prioridades p ON p.id = t.prioridad_id
WHERE t.sesion_id = ?
AND t.estado = 'en_servicio'
AND t.lugar_destino_id = ?)
) AS cola_union
ORDER BY orden_peso ASC, creado_at ASC"
); );
$stmt->execute([$sesionId]); $stmt->execute([$sesionId, $sesionId, $lugarId]);
} }
$cola = $stmt->fetchAll(PDO::FETCH_ASSOC); $cola = $stmt->fetchAll(PDO::FETCH_ASSOC);
+25 -10
View File
@@ -76,6 +76,8 @@ $adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user']['
display: flex; align-items: center; gap: .55rem; display: flex; align-items: center; gap: .55rem;
} }
.cola-card.activo { border-color: #6366f1; box-shadow: 0 0 0 2px #c7d2fe; } .cola-card.activo { border-color: #6366f1; box-shadow: 0 0 0 2px #c7d2fe; }
.cola-card.en-servicio-card { border-color: #16a34a; background: #f0fdf4; }
.cola-card.en-servicio-card.activo { border-color: #16a34a; box-shadow: 0 0 0 2px #bbf7d0; }
.prio-dot { .prio-dot {
width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
display: flex; align-items: center; justify-content: center; display: flex; align-items: center; justify-content: center;
@@ -469,28 +471,41 @@ async function cargarCola() {
} }
function renderCola(snap) { function renderCola(snap) {
const espera = (snap.cola || []).filter(t => const items = snap.cola || [];
t.estado === 'en_espera_lugar' const espera = items.filter(t => t.estado === 'en_espera_lugar');
);
document.getElementById('badge-count').textContent = espera.length; document.getElementById('badge-count').textContent = espera.length;
const lista = document.getElementById('cola-items'); const lista = document.getElementById('cola-items');
if (!espera.length) { if (!items.length) {
lista.innerHTML = `<div class="cola-vacia"> lista.innerHTML = `<div class="cola-vacia">
<i class="fas fa-hourglass-start fa-2x mb-2 d-block"></i>Cola vacía</div>`; <i class="fas fa-hourglass-start fa-2x mb-2 d-block"></i>Cola vacía</div>`;
return; return;
} }
lista.innerHTML = espera.map(t => ` lista.innerHTML = items.map(t => {
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}" const enServicio = t.estado === 'en_servicio';
style="cursor:pointer" onclick="llamarTurnoEspecifico(${t.id})" const esActivo = turnoActivo?.id == t.id;
title="Llamar turno ${escHtml(t.codigo)}"> const onclick = enServicio
? `enfocarFicha()`
: `llamarTurnoEspecifico(${t.id})`;
const badge = enServicio
? `<span class="badge bg-success ms-auto" style="font-size:.6rem;white-space:nowrap">En servicio</span>`
: `<i class="fas fa-chevron-right text-muted ms-auto" style="font-size:.7rem"></i>`;
return `
<div class="cola-card ${esActivo ? 'activo' : ''} ${enServicio ? 'en-servicio-card' : ''}"
style="cursor:pointer" onclick="${onclick}"
title="${enServicio ? 'Turno en atención — clic para ver ficha' : `Llamar turno ${escHtml(t.codigo)}`}">
<div class="prio-dot" style="background:${t.prioridad_color}">${t.prioridad_codigo}</div> <div class="prio-dot" style="background:${t.prioridad_color}">${t.prioridad_codigo}</div>
<div class="turno-info"> <div class="turno-info">
<div class="cod">${escHtml(t.codigo)}</div> <div class="cod">${escHtml(t.codigo)}</div>
<div class="pac">${escHtml(t.paciente_nombre || 'Paciente')}</div> <div class="pac">${escHtml(t.paciente_nombre || 'Paciente')}</div>
</div> </div>
<i class="fas fa-chevron-right text-muted ms-auto" style="font-size:.7rem"></i> ${badge}
</div>`).join(''); </div>`;
}).join('');
}
function enfocarFicha() {
document.getElementById('ficha-turno')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
} }
// ── Llamar siguiente ────────────────────────────────────────── // ── Llamar siguiente ──────────────────────────────────────────