feat: auto-fill hora de toma con hora actual en F-LAB-28

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 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-10 09:44:11 -05:00
co-authored by Claude Sonnet 4.6
parent 55bccae0ad
commit 3e110324a8
+18 -3
View File
@@ -1097,11 +1097,24 @@ function esc2(mixed $v): string {
<?php if (!empty($_mpMap)): ?>
window._muestrasMap = <?= json_encode($_mpMap, JSON_UNESCAPED_UNICODE) ?>;
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);
});
<?php endif; ?>
@@ -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;