Update recepcion.php
This commit is contained in:
@@ -177,6 +177,9 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
</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
|
||||
</a>
|
||||
<button class="btn btn-primary btn-sm" id="btn-llamar" onclick="llamarSiguiente()">
|
||||
<i class="fas fa-bell me-1"></i>Llamar siguiente
|
||||
</button>
|
||||
@@ -208,7 +211,7 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
<div class="ficha-placeholder" id="ficha-placeholder">
|
||||
<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 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>
|
||||
|
||||
<!-- Ficha de turno (oculta hasta llamar) -->
|
||||
@@ -395,13 +398,18 @@ function renderCola(snap) {
|
||||
return;
|
||||
}
|
||||
lista.innerHTML = espera.map(t => `
|
||||
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}"
|
||||
onclick="seleccionarTurno(${t.id})">
|
||||
<div class="prio-dot" style="background:${t.prioridad_color}">${t.prioridad_codigo}</div>
|
||||
<div class="turno-info">
|
||||
<div class="cola-card ${turnoActivo?.id === t.id ? 'activo' : ''}">
|
||||
<div class="prio-dot" style="background:${t.prioridad_color};cursor:pointer" onclick="seleccionarTurno(${t.id})">${t.prioridad_codigo}</div>
|
||||
<div class="turno-info" style="cursor:pointer" onclick="seleccionarTurno(${t.id})">
|
||||
<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>
|
||||
<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('');
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
// No abrir si ya hay uno activo en recepción
|
||||
if (turnoActivo && turnoActivo.estado === 'en_recepcion') return;
|
||||
try {
|
||||
const res = await fetch(API + 'get_turno.php?id=' + turnoId);
|
||||
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 ───────────────────────────────────────────────
|
||||
function abrirFicha(turno) {
|
||||
turnoActivo = turno;
|
||||
@@ -659,13 +682,27 @@ async function pasarALugar() {
|
||||
if (!json.ok) { mostrarError(json.error); btn.disabled = false; return; }
|
||||
|
||||
// Reiniciar ficha
|
||||
turnoActivo = null;
|
||||
turnoActivo = null;
|
||||
solicitudActiva = null;
|
||||
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');
|
||||
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) {
|
||||
mostrarError(err.message);
|
||||
btn.disabled = false;
|
||||
@@ -705,6 +742,14 @@ function escHtml(str) {
|
||||
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) {
|
||||
alert('Error: ' + msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user