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>
|
</div>
|
||||||
<?php elseif ($isPro): ?>
|
<?php elseif ($isPro): ?>
|
||||||
<?php
|
<?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 && (
|
$_mostrarCanvasPro = !$yaHayCanvasPro && (
|
||||||
(!$modoTurnero && !$modoPublico) ||
|
(!$modoTurnero && !$modoPublico) ||
|
||||||
($modoTurnero && $embebido && isUserLoggedIn() && $_soloFirmaPro && $modoEditar)
|
($modoTurnero && $embebido && isUserLoggedIn() && $modoEditar)
|
||||||
);
|
);
|
||||||
if ($_mostrarCanvasPro): ?>
|
if ($_mostrarCanvasPro): ?>
|
||||||
<?php if ($firmaProfPreguardada): ?>
|
<?php if ($firmaProfPreguardada): ?>
|
||||||
@@ -745,7 +745,7 @@ function esc2(mixed $v): string {
|
|||||||
?>
|
?>
|
||||||
<div class="firma-pro-widget no-print" id="fpw-<?= htmlspecialchars($cid) ?>"
|
<div class="firma-pro-widget no-print" id="fpw-<?= htmlspecialchars($cid) ?>"
|
||||||
data-envio="<?= (int)$envio['id'] ?>" data-campo="<?= 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-turno="<?= isset($tcRow) ? (int)$tcRow['turno_id'] : '' ?>"
|
||||||
data-formulario="<?= isset($tcRow) ? (int)$tcRow['formulario_id'] : '' ?>"
|
data-formulario="<?= isset($tcRow) ? (int)$tcRow['formulario_id'] : '' ?>"
|
||||||
<?= $_mpBloqueado ? 'style="display:none"' : '' ?>>
|
<?= $_mpBloqueado ? 'style="display:none"' : '' ?>>
|
||||||
@@ -1471,32 +1471,45 @@ document.querySelectorAll('.turnero-firma-item').forEach(function(widget) {
|
|||||||
});
|
});
|
||||||
campos[cid + '_svg'] = png; // identificar qué campo firmó
|
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, {
|
fetch(window.location.href, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
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(r) { return r.json(); })
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
if (data.ok) {
|
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) {
|
document.querySelectorAll('.turnero-firma-item').forEach(function(w) {
|
||||||
w.style.display = 'none';
|
w.style.display = 'none';
|
||||||
});
|
});
|
||||||
var ok = document.createElement('div');
|
if (hayCanvasPro) {
|
||||||
ok.className = 'alert alert-success mt-4 d-flex align-items-start gap-3 no-print';
|
// Mostrar mensaje de éxito parcial y hacer scroll al canvas del profesional
|
||||||
var _enIframe = (function(){ try { return window.self !== window.top; } catch(e){ return true; } })();
|
msgEl.innerHTML = '<span class="text-success"><i class="fas fa-check me-1"></i>Firma del paciente guardada. Ahora firma el profesional.</span>';
|
||||||
ok.innerHTML = '<i class="fas fa-check-circle fs-4 flex-shrink-0 mt-1"></i>'
|
var fpw = document.querySelector('.firma-pro-widget');
|
||||||
+ '<div><strong>Firmado correctamente.</strong><br>'
|
if (fpw) setTimeout(function() { fpw.scrollIntoView({ behavior:'smooth', block:'center' }); }, 150);
|
||||||
+ '<span>El personal de salud ha sido notificado.</span>'
|
} else {
|
||||||
+ '<div class="mt-2 d-flex gap-2 flex-wrap">'
|
var ok = document.createElement('div');
|
||||||
+ '<button onclick="window.print()" class="btn btn-warning btn-sm fw-semibold">'
|
ok.className = 'alert alert-success mt-4 d-flex align-items-start gap-3 no-print';
|
||||||
+ '<i class=\"fas fa-file-pdf me-1\"></i>Descargar PDF</button>'
|
var _enIframe = (function(){ try { return window.self !== window.top; } catch(e){ return true; } })();
|
||||||
+ (!_enIframe ? '<button onclick="window.close()" class="btn btn-outline-secondary btn-sm fw-semibold">'
|
ok.innerHTML = '<i class="fas fa-check-circle fs-4 flex-shrink-0 mt-1"></i>'
|
||||||
+ '<i class=\"fas fa-times me-1\"></i>Cerrar</button>' : '')
|
+ '<div><strong>Firmado correctamente.</strong><br>'
|
||||||
+ '</div></div>';
|
+ '<span>El personal de salud ha sido notificado.</span>'
|
||||||
widget.parentNode.insertBefore(ok, widget.nextSibling);
|
+ '<div class="mt-2 d-flex gap-2 flex-wrap">'
|
||||||
try { window.parent.postMessage({ type: 'turneroFirmado' }, '*'); } catch(e) {}
|
+ '<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 {
|
} else {
|
||||||
msgEl.innerHTML = '<span class="text-danger"><i class="fas fa-times me-1"></i>' + (data.error || 'Error al guardar') + '</span>';
|
msgEl.innerHTML = '<span class="text-danger"><i class="fas fa-times me-1"></i>' + (data.error || 'Error al guardar') + '</span>';
|
||||||
btnFirm.disabled = false;
|
btnFirm.disabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user