up
This commit is contained in:
@@ -66,23 +66,34 @@ if ($area === 'recepcion') {
|
||||
);
|
||||
$stmt->execute($bindsCola);
|
||||
} 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);
|
||||
$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(
|
||||
"SELECT 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
|
||||
FROM turnero_turnos t
|
||||
JOIN turnero_prioridades p ON p.id = t.prioridad_id
|
||||
WHERE t.sesion_id = ?
|
||||
AND t.estado = 'en_espera_lugar'
|
||||
AND t.lugar_destino_id IN ($inLugares)
|
||||
ORDER BY p.orden_peso ASC, t.creado_at ASC"
|
||||
"SELECT * FROM (
|
||||
(SELECT $cols
|
||||
FROM turnero_turnos t
|
||||
JOIN turnero_prioridades p ON p.id = t.prioridad_id
|
||||
WHERE t.sesion_id = ?
|
||||
AND t.estado = 'en_espera_lugar'
|
||||
AND t.lugar_destino_id IN ($inLugares))
|
||||
UNION ALL
|
||||
(SELECT $cols
|
||||
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);
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ $adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user']['
|
||||
display: flex; align-items: center; gap: .55rem;
|
||||
}
|
||||
.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 {
|
||||
width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
@@ -469,28 +471,41 @@ async function cargarCola() {
|
||||
}
|
||||
|
||||
function renderCola(snap) {
|
||||
const espera = (snap.cola || []).filter(t =>
|
||||
t.estado === 'en_espera_lugar'
|
||||
);
|
||||
const items = snap.cola || [];
|
||||
const espera = items.filter(t => t.estado === 'en_espera_lugar');
|
||||
document.getElementById('badge-count').textContent = espera.length;
|
||||
|
||||
const lista = document.getElementById('cola-items');
|
||||
if (!espera.length) {
|
||||
if (!items.length) {
|
||||
lista.innerHTML = `<div class="cola-vacia">
|
||||
<i class="fas fa-hourglass-start fa-2x mb-2 d-block"></i>Cola vacía</div>`;
|
||||
return;
|
||||
}
|
||||
lista.innerHTML = espera.map(t => `
|
||||
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}"
|
||||
style="cursor:pointer" onclick="llamarTurnoEspecifico(${t.id})"
|
||||
title="Llamar turno ${escHtml(t.codigo)}">
|
||||
lista.innerHTML = items.map(t => {
|
||||
const enServicio = t.estado === 'en_servicio';
|
||||
const esActivo = turnoActivo?.id == t.id;
|
||||
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="turno-info">
|
||||
<div class="cod">${escHtml(t.codigo)}</div>
|
||||
<div class="pac">${escHtml(t.paciente_nombre || 'Paciente')}</div>
|
||||
</div>
|
||||
<i class="fas fa-chevron-right text-muted ms-auto" style="font-size:.7rem"></i>
|
||||
</div>`).join('');
|
||||
${badge}
|
||||
</div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function enfocarFicha() {
|
||||
document.getElementById('ficha-turno')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
}
|
||||
|
||||
// ── Llamar siguiente ──────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user