From 019d2f4fb00a41ca154716109ba212e4162c4960 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:36:23 -0500 Subject: [PATCH] =?UTF-8?q?turnero:=20notificaci=C3=B3n=20del=20sistema=20?= =?UTF-8?q?cuando=20vence=20el=20countdown=20de=20toma=20progresiva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usa Web Notifications API via postMessage iframe→parent para alertar incluso cuando el tab está en segundo plano o la pantalla ocupada. Pide permiso al iniciar el protocolo (primer gesto del usuario). Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/views/lugar.php | 8 +++++++- ver_formulario_enviado.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index b0fc2a7..a368801 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -1541,7 +1541,13 @@ function cerrarModalConsentimiento(forzar) { window.addEventListener('message', function(e) { if (e.data && e.data.type === 'tomaProgresivaIniciada') { _tomaProgresivaActiva = true; - // Botón cerrar permanece habilitado; el operador puede cerrar en cualquier momento + if ('Notification' in window && Notification.permission === 'default') Notification.requestPermission(); + } + if (e.data && e.data.type === 'tomaProgresivaAlerta') { + var lbl = (e.data.label || '¡Siguiente muestra!'); + if ('Notification' in window && Notification.permission === 'granted') { + new Notification('⏰ Toma de muestras', { body: lbl, icon: '/favicon.ico', requireInteraction: true }); + } } if (e.data && e.data.type === 'turneroFirmado') { _tomaProgresivaActiva = false; diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index bb5204a..bf42f6f 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -2196,6 +2196,7 @@ function _mpIniciarCountdown(targetMsOrMins, nextLabel, nextFirmaId) { + (nextLabel ? '
' + nextLabel + '
' : ''); if (navigator.vibrate) navigator.vibrate([900,150,900,150,900,150,900,150,900]); _mpPlayBeep(); + try { window.parent.postMessage({ type: 'tomaProgresivaAlerta', label: nextLabel || '¡Siguiente muestra!' }, '*'); } catch(e) {} // Desbloquear y mostrar siguiente canvas var nw = nextFirmaId ? document.getElementById('fpw-' + nextFirmaId) : null; if (!nw) nw = document.querySelector('.firma-pro-widget[style*="display:none"]');