Update recepcion.php
This commit is contained in:
@@ -177,6 +177,9 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
<span class="text-muted small"><?= htmlspecialchars($adminNombre) ?></span>
|
<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
|
||||||
|
</a>
|
||||||
<button class="btn btn-primary btn-sm" id="btn-llamar" onclick="llamarSiguiente()">
|
<button class="btn btn-primary btn-sm" id="btn-llamar" onclick="llamarSiguiente()">
|
||||||
<i class="fas fa-bell me-1"></i>Llamar siguiente
|
<i class="fas fa-bell me-1"></i>Llamar siguiente
|
||||||
</button>
|
</button>
|
||||||
@@ -208,7 +211,7 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
|||||||
<div class="ficha-placeholder" id="ficha-placeholder">
|
<div class="ficha-placeholder" id="ficha-placeholder">
|
||||||
<i class="fas fa-ticket-alt fa-3x mb-3" style="color:#cbd5e1"></i>
|
<i class="fas fa-ticket-alt fa-3x mb-3" style="color:#cbd5e1"></i>
|
||||||
<p class="mb-0 fw-semibold">Sin turno activo</p>
|
<p class="mb-0 fw-semibold">Sin turno activo</p>
|
||||||
<small class="text-muted">Haga clic en "Llamar siguiente" o seleccione un turno de la cola</small>
|
<small class="text-muted">Haga clic en <i class="fas fa-bell"></i> de un turno para llamarlo, o use "Llamar siguiente"</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Ficha de turno (oculta hasta llamar) -->
|
<!-- Ficha de turno (oculta hasta llamar) -->
|
||||||
@@ -395,13 +398,18 @@ function renderCola(snap) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lista.innerHTML = espera.map(t => `
|
lista.innerHTML = espera.map(t => `
|
||||||
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}"
|
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}">
|
||||||
onclick="seleccionarTurno(${t.id})">
|
<div class="prio-dot" style="background:${t.prioridad_color};cursor:pointer" onclick="seleccionarTurno(${t.id})">${t.prioridad_codigo}</div>
|
||||||
<div class="prio-dot" style="background:${t.prioridad_color}">${t.prioridad_codigo}</div>
|
<div class="turno-info" style="cursor:pointer" onclick="seleccionarTurno(${t.id})">
|
||||||
<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 || 'Sin nombre')}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button onclick="llamarTurnoEspecifico(${t.id})"
|
||||||
|
title="Llamar este turno ahora"
|
||||||
|
style="flex-shrink:0;background:#2563eb;border:none;color:#fff;
|
||||||
|
border-radius:7px;padding:5px 9px;font-size:.78rem;cursor:pointer">
|
||||||
|
<i class="fas fa-bell"></i>
|
||||||
|
</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,10 +440,8 @@ async function llamarSiguiente() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Seleccionar turno de la cola (para ver ficha de uno ya llamado) ─
|
// ── Seleccionar turno de la cola (ver ficha sin cambiar estado) ─────
|
||||||
async function seleccionarTurno(turnoId) {
|
async function seleccionarTurno(turnoId) {
|
||||||
// No abrir si ya hay uno activo en recepción
|
|
||||||
if (turnoActivo && turnoActivo.estado === 'en_recepcion') return;
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(API + 'get_turno.php?id=' + turnoId);
|
const res = await fetch(API + 'get_turno.php?id=' + turnoId);
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
@@ -446,6 +452,23 @@ async function seleccionarTurno(turnoId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Llamar turno específico (cambia estado → en_recepcion) ─────────
|
||||||
|
async function llamarTurnoEspecifico(turnoId) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(API + 'cambiar_estado.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ turno_id: turnoId, nuevo_estado: 'en_recepcion' }),
|
||||||
|
});
|
||||||
|
const json = await res.json();
|
||||||
|
if (!json.ok) { mostrarError(json.error); return; }
|
||||||
|
abrirFicha(json.turno);
|
||||||
|
cargarCola();
|
||||||
|
} catch (err) {
|
||||||
|
mostrarError('Error al llamar turno: ' + err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Abrir ficha ───────────────────────────────────────────────
|
// ── Abrir ficha ───────────────────────────────────────────────
|
||||||
function abrirFicha(turno) {
|
function abrirFicha(turno) {
|
||||||
turnoActivo = turno;
|
turnoActivo = turno;
|
||||||
@@ -662,10 +685,24 @@ async function pasarALugar() {
|
|||||||
turnoActivo = null;
|
turnoActivo = null;
|
||||||
solicitudActiva = null;
|
solicitudActiva = null;
|
||||||
document.getElementById('ficha-turno').classList.add('d-none');
|
document.getElementById('ficha-turno').classList.add('d-none');
|
||||||
document.getElementById('ficha-placeholder').classList.remove('d-none');
|
|
||||||
document.getElementById('badge-turno-activo').classList.add('d-none');
|
document.getElementById('badge-turno-activo').classList.add('d-none');
|
||||||
cargarCola();
|
cargarCola();
|
||||||
|
|
||||||
|
// Mostrar aviso con link al lugar
|
||||||
|
const ph = document.getElementById('ficha-placeholder');
|
||||||
|
ph.classList.remove('d-none');
|
||||||
|
ph.innerHTML = `
|
||||||
|
<i class="fas fa-check-circle fa-3x mb-3" style="color:#22c55e"></i>
|
||||||
|
<p class="fw-semibold mb-1">Turno pasado al lugar correctamente</p>
|
||||||
|
<small class="text-muted d-block mb-3">El paciente aparece en la cola del puesto de toma de muestras</small>
|
||||||
|
<a href="<?= BASE_URL ?>erp.php?m=turnero&v=lugar" target="_blank"
|
||||||
|
class="btn btn-primary btn-sm">
|
||||||
|
<i class="fas fa-flask me-1"></i>Ir a Vista Lugar
|
||||||
|
</a>
|
||||||
|
<button class="btn btn-outline-secondary btn-sm ms-2" onclick="resetPlaceholder()">
|
||||||
|
Siguiente turno
|
||||||
|
</button>`;
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
mostrarError(err.message);
|
mostrarError(err.message);
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
@@ -705,6 +742,14 @@ function escHtml(str) {
|
|||||||
return d.innerHTML;
|
return d.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetPlaceholder() {
|
||||||
|
const ph = document.getElementById('ficha-placeholder');
|
||||||
|
ph.innerHTML = `
|
||||||
|
<i class="fas fa-ticket-alt fa-3x mb-3" style="color:#cbd5e1"></i>
|
||||||
|
<p class="mb-0 fw-semibold">Sin turno activo</p>
|
||||||
|
<small class="text-muted">Haga clic en "Llamar siguiente" o en <i class="fas fa-bell"></i> de un turno de la cola</small>`;
|
||||||
|
}
|
||||||
|
|
||||||
function mostrarError(msg) {
|
function mostrarError(msg) {
|
||||||
alert('Error: ' + msg);
|
alert('Error: ' + msg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user