Update lugar.php
This commit is contained in:
@@ -78,7 +78,6 @@ $adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user']['
|
||||
.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; }
|
||||
.cola-card.nav-selected { border-color: #3b82f6; background: #eff6ff; box-shadow: 0 0 0 2px #bfdbfe; }
|
||||
.prio-dot {
|
||||
width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
@@ -242,20 +241,6 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
<button class="btn btn-primary w-100 py-2" id="btn-llamar" onclick="llamarSiguiente()">
|
||||
<i class="fas fa-bell me-2"></i>Llamar siguiente
|
||||
</button>
|
||||
<!-- Navegación entre turnos en espera -->
|
||||
<div class="d-flex align-items-center gap-1 mt-2" id="nav-cola" style="display:none!important">
|
||||
<button class="btn btn-outline-secondary btn-sm flex-shrink-0" onclick="navCola(-1)" title="Anterior">
|
||||
<i class="fas fa-chevron-up"></i>
|
||||
</button>
|
||||
<div class="flex-grow-1 text-center py-1 px-2 rounded" id="nav-preview"
|
||||
style="background:#f1f5f9;font-size:.82rem;font-weight:600;min-height:32px;cursor:pointer"
|
||||
onclick="llamarNavActual()" title="Clic para llamar este turno">
|
||||
<span class="text-muted" style="font-weight:400">— ninguno seleccionado —</span>
|
||||
</div>
|
||||
<button class="btn btn-outline-secondary btn-sm flex-shrink-0" onclick="navCola(1)" title="Siguiente">
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cola-items" id="cola-items">
|
||||
<div class="cola-vacia">
|
||||
@@ -489,7 +474,6 @@ function renderCola(snap) {
|
||||
const items = snap.cola || [];
|
||||
const espera = items.filter(t => t.estado === 'en_espera_lugar');
|
||||
document.getElementById('badge-count').textContent = espera.length;
|
||||
_actualizarNavCola(items);
|
||||
|
||||
const lista = document.getElementById('cola-items');
|
||||
if (!items.length) {
|
||||
@@ -500,74 +484,52 @@ function renderCola(snap) {
|
||||
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>`;
|
||||
if (enServicio) {
|
||||
return `
|
||||
<div class="cola-card en-servicio-card ${esActivo ? 'activo' : ''}"
|
||||
style="cursor:pointer" onclick="rellamarDesdeCard(${t.id})"
|
||||
title="Re-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>
|
||||
<div class="ms-auto d-flex flex-column align-items-center" style="gap:1px">
|
||||
<i class="fas fa-bell text-success" style="font-size:.85rem"></i>
|
||||
<span style="font-size:.58rem;color:#16a34a;font-weight:700">RE-LLAMAR</span>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
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="cola-card ${esActivo ? 'activo' : ''}"
|
||||
style="cursor:pointer" onclick="llamarTurnoEspecifico(${t.id})"
|
||||
title="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>
|
||||
${badge}
|
||||
<div class="ms-auto d-flex flex-column align-items-center" style="gap:1px">
|
||||
<i class="fas fa-bell text-primary" style="font-size:.85rem"></i>
|
||||
<span style="font-size:.58rem;color:#1d4ed8;font-weight:700">LLAMAR</span>
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function enfocarFicha() {
|
||||
document.getElementById('ficha-turno')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
}
|
||||
|
||||
// ── Navegación entre turnos en espera ─────────────────────────
|
||||
let _navItems = []; // lista de turnos en_espera_lugar actual
|
||||
let _navIdx = -1; // índice seleccionado
|
||||
|
||||
function _actualizarNavCola(items) {
|
||||
_navItems = items.filter(t => t.estado === 'en_espera_lugar');
|
||||
// Mantener idx si el turno seleccionado sigue en lista
|
||||
if (_navIdx >= _navItems.length) _navIdx = _navItems.length - 1;
|
||||
const nav = document.getElementById('nav-cola');
|
||||
if (_navItems.length > 0) {
|
||||
nav.style.removeProperty('display');
|
||||
if (_navIdx < 0) _navIdx = 0;
|
||||
_renderNavPreview();
|
||||
} else {
|
||||
nav.style.display = 'none';
|
||||
_navIdx = -1;
|
||||
document.getElementById('nav-preview').innerHTML =
|
||||
`<span class="text-muted" style="font-weight:400">— ninguno seleccionado —</span>`;
|
||||
async function rellamarDesdeCard(turnoId) {
|
||||
// Enfocar la ficha si es el activo
|
||||
if (turnoActivo?.id == turnoId) {
|
||||
document.getElementById('ficha-turno')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
}
|
||||
}
|
||||
|
||||
function _renderNavPreview() {
|
||||
const t = _navItems[_navIdx];
|
||||
if (!t) return;
|
||||
document.getElementById('nav-preview').innerHTML =
|
||||
`<span style="color:${t.prioridad_color};font-size:.75rem">${t.prioridad_codigo}</span>
|
||||
<strong class="ms-1">${escHtml(t.codigo)}</strong>
|
||||
<span class="text-muted ms-1" style="font-size:.75rem">${escHtml(t.paciente_nombre || '')}</span>
|
||||
<i class="fas fa-bell ms-1 text-primary" style="font-size:.7rem"></i>`;
|
||||
// Resaltar la card en la lista
|
||||
document.querySelectorAll('.cola-card').forEach(el => el.classList.remove('nav-selected'));
|
||||
const cards = document.querySelectorAll('#cola-items .cola-card');
|
||||
if (cards[_navIdx]) cards[_navIdx].classList.add('nav-selected');
|
||||
}
|
||||
|
||||
function navCola(dir) {
|
||||
if (!_navItems.length) return;
|
||||
_navIdx = (_navIdx + dir + _navItems.length) % _navItems.length;
|
||||
_renderNavPreview();
|
||||
}
|
||||
|
||||
async function llamarNavActual() {
|
||||
if (_navIdx < 0 || !_navItems[_navIdx]) return;
|
||||
await llamarTurnoEspecifico(_navItems[_navIdx].id);
|
||||
// Re-llamar via API para actualizar llamado_at y notificar display
|
||||
const res = await fetch(API + 'llamar_turno.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ area: 'lugar', lugar_id: lugarId, turno_id: turnoId }),
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.ok && json.turno) anunciarTurno(json.turno.codigo);
|
||||
}
|
||||
|
||||
// ── Llamar siguiente ──────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user