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;