up
This commit is contained in:
@@ -320,6 +320,9 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
<button class="btn btn-outline-warning d-none" id="btn-regresar" onclick="regresarCola()">
|
||||
<i class="fas fa-undo me-1"></i>Regresar a cola
|
||||
</button>
|
||||
<button class="btn btn-outline-info d-none" id="btn-rellamar" onclick="rellamarTurno()">
|
||||
<i class="fas fa-bullhorn me-1"></i>Re-llamar
|
||||
</button>
|
||||
<button class="btn btn-secondary ms-auto" id="btn-ausente" onclick="marcarAusente()">
|
||||
<i class="fas fa-user-slash me-1"></i>Ausente
|
||||
</button>
|
||||
@@ -364,10 +367,22 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
function iniciarPuesto() {
|
||||
recuperarTurnoActivo(); // ver si ya hay un turno en_servicio en esta estación
|
||||
cargarCola();
|
||||
pollingColaId = setInterval(cargarCola, 7000);
|
||||
}
|
||||
|
||||
// Recupera el turno en_servicio de ESTA estación (si existe) al cargar la página
|
||||
async function recuperarTurnoActivo() {
|
||||
try {
|
||||
const res = await fetch(`${API}get_cola.php?area=lugar&lugar_id=${lugarId}`);
|
||||
const json = await res.json();
|
||||
if (json.ok && json.activo) {
|
||||
await abrirFicha(json.activo);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// ── Selector de lugar ─────────────────────────────────────────
|
||||
function confirmarLugar() {
|
||||
const sel = document.getElementById('sel-lugar-init');
|
||||
@@ -771,17 +786,39 @@ function actualizarEstadoBadge(estado) {
|
||||
el.textContent = lbl;
|
||||
|
||||
// Sincronizar botones según estado
|
||||
const btnIni = document.getElementById('btn-iniciar');
|
||||
const btnFin = document.getElementById('btn-finalizar');
|
||||
const btnReg = document.getElementById('btn-regresar');
|
||||
const btnIni = document.getElementById('btn-iniciar');
|
||||
const btnFin = document.getElementById('btn-finalizar');
|
||||
const btnReg = document.getElementById('btn-regresar');
|
||||
const btnRellamar = document.getElementById('btn-rellamar');
|
||||
if (estado === 'en_espera_lugar') {
|
||||
btnIni.classList.remove('d-none'); btnIni.disabled = hayPendientes;
|
||||
btnFin.classList.add('d-none');
|
||||
btnReg.classList.add('d-none');
|
||||
btnRellamar.classList.add('d-none');
|
||||
} else if (estado === 'en_servicio') {
|
||||
btnIni.classList.add('d-none');
|
||||
btnFin.classList.remove('d-none');
|
||||
btnReg.classList.remove('d-none');
|
||||
btnRellamar.classList.remove('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
async function rellamarTurno() {
|
||||
if (!turnoActivo) return;
|
||||
const btn = document.getElementById('btn-rellamar');
|
||||
btn.disabled = true;
|
||||
try {
|
||||
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: turnoActivo.id }),
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.ok) alert('Error: ' + json.error);
|
||||
} catch (err) {
|
||||
alert('Error: ' + err.message);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user