diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index e0bbf90..ef6942e 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -1363,13 +1363,18 @@ function renderConsentimientos(lista) { sinEl.classList.add('d-none'); banner.classList.toggle('d-none', !hayPendientes); - // Actualizar mapa de timers para tomas progresivas + // Actualizar mapa de timers para tomas progresivas (preservar alertado si ya sonó) + const _prevTimers = _tomaTimers; _tomaTimers = {}; lista.forEach(c => { if (c.es_toma_progresiva && c.estado === 'en_progreso') { + const prev = _prevTimers[c.id]; + const newAt = c.siguiente_toma_at ? new Date(c.siguiente_toma_at.replace(' ', 'T')).getTime() : null; + // Si la siguiente_toma_at cambió (firmó una toma), resetear alertado para el nuevo tiempo + const sameTime = prev && prev.siguiente_toma_at === newAt; _tomaTimers[c.id] = { - siguiente_toma_at: c.siguiente_toma_at ? new Date(c.siguiente_toma_at.replace(' ', 'T')).getTime() : null, - alertado: false, + siguiente_toma_at: newAt, + alertado: sameTime ? (prev.alertado || false) : false, }; } }); @@ -1497,6 +1502,8 @@ function abrirModalConsentimientoPorToken(token) { // ── Toma progresiva: abre el modal con modo especial ────────── function abrirTomaProgresiva(token, turnoId, formularioId) { + cerrarBannerToma(); + _tomaAlertados.delete(turnoId); const modal = document.getElementById('modal-consentimiento'); const iframe = document.getElementById('modal-consent-iframe'); const load = document.getElementById('modal-consent-loading');