fix: permitir firma en consentimientos con firma paciente + profesional (H.pylori)
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f4807e41ae
commit
590795c199
+32
-19
@@ -727,10 +727,10 @@ function esc2(mixed $v): string {
|
||||
</div>
|
||||
<?php elseif ($isPro): ?>
|
||||
<?php
|
||||
// Mostrar canvas pro si: admin normal, O turnero+embebido+sesión activa+solo firma pro
|
||||
// Mostrar canvas pro si: admin normal, O turnero+embebido+sesión activa (sin importar si también hay firma paciente)
|
||||
$_mostrarCanvasPro = !$yaHayCanvasPro && (
|
||||
(!$modoTurnero && !$modoPublico) ||
|
||||
($modoTurnero && $embebido && isUserLoggedIn() && $_soloFirmaPro && $modoEditar)
|
||||
($modoTurnero && $embebido && isUserLoggedIn() && $modoEditar)
|
||||
);
|
||||
if ($_mostrarCanvasPro): ?>
|
||||
<?php if ($firmaProfPreguardada): ?>
|
||||
@@ -745,7 +745,7 @@ function esc2(mixed $v): string {
|
||||
?>
|
||||
<div class="firma-pro-widget no-print" id="fpw-<?= htmlspecialchars($cid) ?>"
|
||||
data-envio="<?= (int)$envio['id'] ?>" data-campo="<?= htmlspecialchars($cid) ?>"
|
||||
data-solo-pro="<?= ($modoTurnero && $_soloFirmaPro) ? '1' : '0' ?>"
|
||||
data-solo-pro="<?= $modoTurnero ? '1' : '0' ?>"
|
||||
data-turno="<?= isset($tcRow) ? (int)$tcRow['turno_id'] : '' ?>"
|
||||
data-formulario="<?= isset($tcRow) ? (int)$tcRow['formulario_id'] : '' ?>"
|
||||
<?= $_mpBloqueado ? 'style="display:none"' : '' ?>>
|
||||
@@ -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 = '<i class="fas fa-check-circle fs-4 flex-shrink-0 mt-1"></i>'
|
||||
+ '<div><strong>Firmado correctamente.</strong><br>'
|
||||
+ '<span>El personal de salud ha sido notificado.</span>'
|
||||
+ '<div class="mt-2 d-flex gap-2 flex-wrap">'
|
||||
+ '<button onclick="window.print()" class="btn btn-warning btn-sm fw-semibold">'
|
||||
+ '<i class=\"fas fa-file-pdf me-1\"></i>Descargar PDF</button>'
|
||||
+ (!_enIframe ? '<button onclick="window.close()" class="btn btn-outline-secondary btn-sm fw-semibold">'
|
||||
+ '<i class=\"fas fa-times me-1\"></i>Cerrar</button>' : '')
|
||||
+ '</div></div>';
|
||||
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 = '<span class="text-success"><i class="fas fa-check me-1"></i>Firma del paciente guardada. Ahora firma el profesional.</span>';
|
||||
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 = '<i class="fas fa-check-circle fs-4 flex-shrink-0 mt-1"></i>'
|
||||
+ '<div><strong>Firmado correctamente.</strong><br>'
|
||||
+ '<span>El personal de salud ha sido notificado.</span>'
|
||||
+ '<div class="mt-2 d-flex gap-2 flex-wrap">'
|
||||
+ '<button onclick="window.print()" class="btn btn-warning btn-sm fw-semibold">'
|
||||
+ '<i class=\"fas fa-file-pdf me-1\"></i>Descargar PDF</button>'
|
||||
+ (!_enIframe ? '<button onclick="window.close()" class="btn btn-outline-secondary btn-sm fw-semibold">'
|
||||
+ '<i class=\"fas fa-times me-1\"></i>Cerrar</button>' : '')
|
||||
+ '</div></div>';
|
||||
widget.parentNode.insertBefore(ok, widget.nextSibling);
|
||||
try { window.parent.postMessage({ type: 'turneroFirmado' }, '*'); } catch(e) {}
|
||||
}
|
||||
} else {
|
||||
msgEl.innerHTML = '<span class="text-danger"><i class="fas fa-times me-1"></i>' + (data.error || 'Error al guardar') + '</span>';
|
||||
btnFirm.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user