From 3e110324a8b0a57e5f806d4f98dab9477f28f72a Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 10 Jul 2026 09:44:11 -0500 Subject: [PATCH] feat: auto-fill hora de toma con hora actual en F-LAB-28 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Al activarse cada sección de toma (carga inicial, toma inmediata, fin de countdown), se rellena automáticamente el campo hora con la hora actual del dispositivo. Solo actúa si el campo está vacío, por lo que no sobreescribe valores ya ingresados manualmente. Co-Authored-By: Claude Sonnet 4.6 --- ver_formulario_enviado.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index 63937b4..c26415a 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -1097,11 +1097,24 @@ function esc2(mixed $v): string { window._muestrasMap = ; window._mpSavedFirmas = {}; -// Auto-scroll a la primera firma pendiente al cargar (examen ya seleccionado) + +function _mpAutoFillHora(firmaId) { + var entry = window._muestrasMap && window._muestrasMap[firmaId]; + if (!entry || !entry.hora_campo) return; + var el = document.querySelector('[name="' + entry.hora_campo + '"]'); + if (!el || el.value) return; + var now = new Date(); + el.value = ('0'+now.getHours()).slice(-2) + ':' + ('0'+now.getMinutes()).slice(-2); +} + +// Auto-scroll y auto-fill hora a la primera firma pendiente al cargar document.addEventListener('DOMContentLoaded', function() { setTimeout(function() { var fw = document.querySelector('.firma-pro-widget:not([style*="display:none"])'); - if (fw) fw.scrollIntoView({ behavior: 'smooth', block: 'start' }); + if (fw) { + fw.scrollIntoView({ behavior: 'smooth', block: 'start' }); + _mpAutoFillHora(fw.dataset.campo); + } }, 350); }); @@ -1228,13 +1241,14 @@ function _guardarFirmaMP(widget, svg, msgEl, entry, campoId) { } else if (!entry.is_last) { var nw = entry.next_firma_id ? document.getElementById('fpw-' + entry.next_firma_id) : null; if (!nw) nw = document.querySelector('.firma-pro-widget:not([style*="display:none"])'); - if (nw) { nw.style.display = ''; nw.scrollIntoView({ behavior:'smooth', block:'center' }); } + if (nw) { nw.style.display = ''; nw.scrollIntoView({ behavior:'smooth', block:'center' }); _mpAutoFillHora(nw.dataset.campo); } } else { // Último firma del grupo pero hay más exámenes pendientes; desbloquear siguiente var nw = document.querySelector('.firma-pro-widget[style*="display:none"]'); if (nw) { nw.style.display = ''; nw.scrollIntoView({ behavior:'smooth', block:'center' }); + _mpAutoFillHora(nw.dataset.campo); } else { // Sin más firmas pendientes → cerrar setTimeout(function() { @@ -1296,6 +1310,7 @@ function _mpIniciarCountdown(minutos, nextLabel, nextFirmaId) { nw.style.display = ''; nw.style.outline = '3px solid #dc3545'; nw.style.borderRadius = '8px'; + _mpAutoFillHora(nw.dataset.campo); setTimeout(function() { nw.scrollIntoView({ behavior:'smooth', block:'center' }); }, 120); } return;