diff --git a/modules/turnero/api/create_solicitud.php b/modules/turnero/api/create_solicitud.php index 30e3ef9..a703f34 100644 --- a/modules/turnero/api/create_solicitud.php +++ b/modules/turnero/api/create_solicitud.php @@ -393,7 +393,7 @@ try { // Consumir el cache: solo eliminar, no reinsertar, para que no recargue en una segunda visita $pdo->prepare( - "DELETE FROM rips_examenes_pendientes WHERE numero_documento = ?" + "DELETE FROM rips_examenes_pendientes WHERE numero_documento = ? AND DATE(created_at) = CURDATE()" )->execute([$numDoc]); } catch (\Throwable $eRips) { diff --git a/modules/turnero/api/guardar_toma.php b/modules/turnero/api/guardar_toma.php index 8b31d61..2d14afb 100644 --- a/modules/turnero/api/guardar_toma.php +++ b/modules/turnero/api/guardar_toma.php @@ -97,7 +97,7 @@ foreach ($esquema as $campo) { $horaFija = sprintf('%02d:%02d:00', $h, $min); } elseif (stripos($separadorLabel, 'Otro') !== false) { $otroVal = trim((string)($datosMerge['_otro_hora'] ?? '')); - if (is_numeric($otroVal)) $minutos = (int)$otroVal; + $minutos = is_numeric($otroVal) ? (int)$otroVal : PHP_INT_MAX; } } $firmasCampos[] = ['id' => $campo['id'], 'minutos' => $minutos, 'hora_fija' => $horaFija]; diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index e2e4b83..0485620 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -640,7 +640,8 @@ function _addExamWizardHtml(string $cid): string { .mp-chip.active { background:#1e3a5f;border-color:#1e3a5f;color:#fff;font-weight:600; } .mp-chip.signed { background:#f0fdf4;border-color:#86efac;color:#166534;cursor:default; } .mp-chip:not(.signed):not(:disabled):hover { border-color:#1e3a5f; } - .mp-chip-otro-inp { display:none;width:100px;vertical-align:middle;margin-left:.3rem; } + .mp-chip-otro-inp { display:none;width:72px;vertical-align:middle;margin-left:.3rem; } + .mp-chip-otro-unit { vertical-align:middle;margin-left:.2rem;font-size:.8rem;color:#64748b; } .mp-cfg-gtitle { font-weight:700;font-size:.88rem;color:#1e3a5f;margin-bottom:.5rem; border-left:3px solid ;padding-left:.5rem; } .mp-cfg-item { border:1.5px solid #e5e7eb;border-radius:8px;padding:.35rem .6rem; @@ -1344,6 +1345,7 @@ var _mpExamOptions = var _mpTomasConfig = ; var _mpCfgToken = ; var _mpModoTurnero = ; +var _mpOtroHora = ; function _mpGuardarConfig(config, examType, onOk, onErr, extra) { var base = window.location.href.split('/ver_formulario_enviado.php')[0]; @@ -1396,8 +1398,12 @@ function _mpShowCfgPanel(examName, groups, isModify) { + (isSigned ? ' disabled title="Ya firmada"' : '') + '>' + chipLbl + (isSigned ? ' ' : '') + ''; if (isOtro) { - html += ''; + var otroVal = (isActive && _mpOtroHora) ? _mpOtroHora : ''; + html += '' + + 'min'; } } html += ''; @@ -1418,9 +1424,14 @@ document.addEventListener('click', function(e) { chk.checked = !chk.checked; chip.classList.toggle('active', chk.checked); if (chip.dataset.otro) { - var inp = chip.nextElementSibling; - if (inp && inp.classList.contains('mp-chip-otro-inp')) + var inp = chip.nextElementSibling; + var unit = inp && inp.nextElementSibling; + if (inp && inp.classList.contains('mp-chip-otro-inp')) { inp.style.display = chk.checked ? 'inline-block' : 'none'; + if (unit && unit.classList.contains('mp-chip-otro-unit')) + unit.classList.toggle('d-none', !chk.checked); + if (chk.checked) setTimeout(function() { inp.focus(); }, 50); + } } }); @@ -1588,17 +1599,17 @@ document.getElementById('mp-cfg-iniciar').addEventListener('click', function() { return; } } - // Validar que "Otro" tenga hora ingresada + // Validar que "Otro" tenga minutos ingresados var otroHora = ''; var otroBtn = document.querySelector('#mp-cfg-grupos .mp-chip[data-otro="1"]'); if (otroBtn) { var otroChk = document.getElementById(otroBtn.getAttribute('data-target')); if (otroChk && otroChk.checked) { - var otroInp = otroBtn.nextElementSibling; - if (otroInp && otroInp.classList.contains('mp-chip-otro-inp')) otroHora = otroInp.value.trim(); - if (!otroHora) { + var otroInp = otroBtn.parentElement.querySelector('.mp-chip-otro-inp'); + if (otroInp) otroHora = otroInp.value.trim(); + if (!otroHora || isNaN(parseInt(otroHora)) || parseInt(otroHora) < 1) { document.getElementById('mp-cfg-msg').innerHTML = - 'Ingrese la hora para la toma "Otro".'; + 'Ingrese los minutos para la toma "Otro" (ej: 2).'; return; } } @@ -2218,6 +2229,7 @@ function _mpMostrarResumen(examType, segs) { if (el) el.textContent = left; if (left <= 0) clearInterval(tick); }, 1000); + window.addEventListener('unload', function() { clearInterval(tick); }); // Ocultar countdown si queda var cd = document.getElementById('mp-countdown'); if (cd) { clearInterval(cd._mpTick); cd.remove(); }