diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php
index 27a9f25..086f392 100644
--- a/ver_formulario_enviado.php
+++ b/ver_formulario_enviado.php
@@ -481,13 +481,13 @@ function esc2(mixed $v): string {
$fLabel = htmlspecialchars($campo['label'] ?? ($isPro ? 'Firma profesional' : 'Firma paciente'));
// Campo paciente sin firma:
- // - En turnero pendiente: el PRIMER campo firma muestra el canvas, los demás se omiten.
+ // - En turnero pendiente: todos los campos firma muestran canvas (consentimiento + desistimiento).
// - En vista normal: omitir campos sin firma.
if (!$fSvg && !$fFoto && !$isPro) {
- if ($modoTurnero && $modoEditar && !$_esquemaTieneFirmaPaciente) {
- $_esquemaTieneFirmaPaciente = true; // solo el primero muestra canvas
+ if ($modoTurnero && $modoEditar) {
+ $_esquemaTieneFirmaPaciente = true;
} else {
- continue; // campos firma adicionales (desistimiento) sin firma → omitir
+ continue; // no-turnero: omitir campos sin firma
}
}
@@ -510,20 +510,20 @@ function esc2(mixed $v): string {
-
+
He leído el documento. Dibuje su firma:
-
-
-
+
@@ -736,7 +736,7 @@ function esc2(mixed $v): string {
-
+
Firma del paciente / responsable
@@ -744,19 +744,19 @@ function esc2(mixed $v): string {
He leído y comprendido el contenido de este documento.
Por favor dibuje su firma en el recuadro:
-
-
+
Limpiar
-
- Confirmar y firmar consentimiento
+
+ Confirmar y firmar
-
+
@@ -888,16 +888,17 @@ function esc2(mixed $v): string {
});
})();
-/* ── Firma de consentimiento turnero ────────────────────────────────── */
-(function () {
- var canvas = document.getElementById('turneroCv');
- var widget = document.getElementById('turneroFirmaWidget');
+/* ── Firma de consentimiento turnero (soporta múltiples campos firma) ── */
+document.querySelectorAll('.turnero-firma-item').forEach(function(widget) {
+ var canvas = widget.querySelector('.turnero-cv');
if (!canvas) return;
+ var cid = widget.dataset.cid || '__firma';
var ctx = canvas.getContext('2d');
- var btnLimp = document.getElementById('turneroLimpiar');
- var btnFirm = document.getElementById('turneroFirmar');
- var msgEl = document.getElementById('turneroMsg');
+ var btnLimp = widget.querySelector('.turnero-limpiar');
+ var btnFirm = widget.querySelector('.turnero-firmar');
+ var msgEl = widget.querySelector('.turnero-msg');
var drawing = false;
+ var btnLabel = btnFirm ? btnFirm.innerHTML : '';
(function scaleCanvas() {
var ratio = window.devicePixelRatio || 1;
@@ -928,12 +929,12 @@ function esc2(mixed $v): string {
canvas.addEventListener('touchmove', function(e){ e.preventDefault(); if(!drawing) return; var p=getPos(e); ctx.lineTo(p.x,p.y); ctx.stroke(); }, {passive:false});
canvas.addEventListener('touchend', function(){ drawing=false; });
- btnLimp.addEventListener('click', function() {
+ if (btnLimp) btnLimp.addEventListener('click', function() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
msgEl.textContent = '';
});
- btnFirm.addEventListener('click', function() {
+ if (btnFirm) btnFirm.addEventListener('click', function() {
var png = canvas.toDataURL('image/png');
if (png.length < 1500) {
msgEl.innerHTML = 'Por favor dibuje su firma antes de confirmar.';
@@ -943,23 +944,20 @@ function esc2(mixed $v): string {
btnFirm.innerHTML = 'Guardando...';
msgEl.textContent = '';
- // Recopilar respuestas de campos interactivos
var campos = {};
document.querySelectorAll('[name]').forEach(function(el) {
var rawName = el.name;
var isArr = rawName.slice(-2) === '[]';
var name = isArr ? rawName.slice(0, -2) : rawName;
if (el.type === 'checkbox') {
- if (el.checked) {
- if (!Array.isArray(campos[name])) campos[name] = [];
- campos[name].push(el.value);
- }
+ if (el.checked) { if (!Array.isArray(campos[name])) campos[name] = []; campos[name].push(el.value); }
} else if (el.type === 'radio') {
if (el.checked) campos[name] = el.value;
} else if (el.value !== '') {
campos[name] = el.value;
}
});
+ campos[cid + '_svg'] = png; // identificar qué campo firmó
fetch(window.location.href, {
method: 'POST',
@@ -969,26 +967,28 @@ function esc2(mixed $v): string {
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.ok) {
- widget.outerHTML =
- '
' +
- '' +
- '
Consentimiento firmado correctamente. ' +
- 'Puede cerrar esta ventana.
';
- // Notificar ventana padre si está en iframe/modal
+ // Ocultar todos los demás widgets de firma (ya no se puede firmar dos veces)
+ 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-center gap-2 no-print';
+ ok.innerHTML = '