From 590795c199d48dd27ee88c90914cbef0b21f9d55 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:08:47 -0500 Subject: [PATCH] fix: permitir firma en consentimientos con firma paciente + profesional (H.pylori) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formularios con ambos tipos de firma (paciente + profesional) en modo embebido quedaban bloqueados porque $_mostrarCanvasPro exigía $_soloFirmaPro. Flujo corregido: - Canvas profesional ahora se muestra en cualquier form con firma_profesional cuando el operador está logueado en modo turnero embebido. - El botón "Confirmar" del paciente detecta si hay canvas del profesional: si hay, guarda como borrador (sin marcar firmado) y hace scroll al canvas pro. - El profesional firma último con solo_profesional=true, marcando firmado y cerrando el modal. Co-Authored-By: Claude Sonnet 4.6 --- ver_formulario_enviado.php | 51 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index eedea51..3b3e47e 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -727,10 +727,10 @@ function esc2(mixed $v): string { @@ -745,7 +745,7 @@ function esc2(mixed $v): string { ?>
> @@ -1471,32 +1471,45 @@ document.querySelectorAll('.turnero-firma-item').forEach(function(widget) { }); campos[cid + '_svg'] = png; // identificar qué campo firmó + // Si hay canvas del profesional en el form, guardar como borrador (el profesional finaliza) + var hayCanvasPro = !!document.querySelector('.firma-pro-widget'); + var payload = hayCanvasPro + ? { datos_respuestas: campos } + : { firma_svg: png, datos_respuestas: campos }; + fetch(window.location.href, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ firma_svg: png, datos_respuestas: campos }) + body: JSON.stringify(payload) }) .then(function(r) { return r.json(); }) .then(function(data) { if (data.ok) { - // Ocultar todos los demás widgets de firma (ya no se puede firmar dos veces) + // Ocultar todos los canvas de firma del paciente (ya firmó) document.querySelectorAll('.turnero-firma-item').forEach(function(w) { w.style.display = 'none'; }); - var ok = document.createElement('div'); - ok.className = 'alert alert-success mt-4 d-flex align-items-start gap-3 no-print'; - var _enIframe = (function(){ try { return window.self !== window.top; } catch(e){ return true; } })(); - ok.innerHTML = '' - + '
Firmado correctamente.
' - + 'El personal de salud ha sido notificado.' - + '
' - + '' - + (!_enIframe ? '' : '') - + '
'; - widget.parentNode.insertBefore(ok, widget.nextSibling); - try { window.parent.postMessage({ type: 'turneroFirmado' }, '*'); } catch(e) {} + if (hayCanvasPro) { + // Mostrar mensaje de éxito parcial y hacer scroll al canvas del profesional + msgEl.innerHTML = 'Firma del paciente guardada. Ahora firma el profesional.'; + var fpw = document.querySelector('.firma-pro-widget'); + if (fpw) setTimeout(function() { fpw.scrollIntoView({ behavior:'smooth', block:'center' }); }, 150); + } else { + var ok = document.createElement('div'); + ok.className = 'alert alert-success mt-4 d-flex align-items-start gap-3 no-print'; + var _enIframe = (function(){ try { return window.self !== window.top; } catch(e){ return true; } })(); + ok.innerHTML = '' + + '
Firmado correctamente.
' + + 'El personal de salud ha sido notificado.' + + '
' + + '' + + (!_enIframe ? '' : '') + + '
'; + widget.parentNode.insertBefore(ok, widget.nextSibling); + try { window.parent.postMessage({ type: 'turneroFirmado' }, '*'); } catch(e) {} + } } else { msgEl.innerHTML = '' + (data.error || 'Error al guardar') + ''; btnFirm.disabled = false;