From 9b4cdcc817bde462ae5eb2657c38995336771fc4 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 24 Jun 2026 01:21:26 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20firma=20del=20paciente=20aparec=C3=ADa?= =?UTF-8?q?=20duplicada=20en=20consentimiento=20y=20desistimiento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La firma global (firma_svg) se aplicaba a todos los campos tipo=firma. Ahora la firma global solo se asigna al primer campo firma del esquema. Los campos firma adicionales (ej. desistimiento) solo muestran su propia firma por campo; si no tienen, se omiten sin mostrar el canvas extra. Co-Authored-By: Claude Sonnet 4.6 --- ver_formulario_enviado.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index 98aa0d0..bc49d10 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -453,9 +453,10 @@ function esc2(mixed $v): string { $firmaSharedPaciente = $envio['firma_svg'] ?? null; // Rastrear si ya se renderizó la firma inline (para no duplicarla al pie) - $_renderedFirmaProfesional = false; - $_renderedFirmaPaciente = false; - $_esquemaTieneFirmaPaciente = false; // el esquema tiene campo tipo=firma + $_renderedFirmaProfesional = false; + $_renderedFirmaPaciente = false; + $_esquemaTieneFirmaPaciente = false; + $_firmaGlobalPacienteUsada = false; // la firma global solo va al primer campo firma foreach ($esquema as $campo): $tipo = $campo['tipo'] ?? ''; @@ -473,25 +474,29 @@ function esc2(mixed $v): string { // Campos posteriores (ej. desistimiento) solo muestran su propia firma por campo. $fSvg = $isPro ? (!$_renderedFirmaProfesional ? ($firmaSharedProfesional ?? $datosCliente[$cid . '_svg'] ?? null) : ($datosCliente[$cid . '_svg'] ?? null)) - : ($datosCliente[$cid . '_svg'] ?? $firmaSharedPaciente ?? null); + : ($datosCliente[$cid . '_svg'] ?? (!$_firmaGlobalPacienteUsada ? $firmaSharedPaciente : null) ?? null); $fFoto = $datosCliente[$cid . '_foto'] ?? null; $fIcon = $isPro ? 'fa-user-md' : 'fa-signature'; $fColor = $isPro ? '#198754' : '#1565c0'; $fLabel = htmlspecialchars($campo['label'] ?? ($isPro ? 'Firma profesional' : 'Firma paciente')); - // Campo paciente sin firma: omitir en vista normal. - // En turnero pendiente se muestra el canvas en su posición del esquema. + // Campo paciente sin firma: + // - En turnero pendiente: el PRIMER campo firma muestra el canvas, los demás se omiten. + // - En vista normal: omitir campos sin firma. if (!$fSvg && !$fFoto && !$isPro) { - if ($modoTurnero && $modoEditar) { - $_esquemaTieneFirmaPaciente = true; + if ($modoTurnero && $modoEditar && !$_esquemaTieneFirmaPaciente) { + $_esquemaTieneFirmaPaciente = true; // solo el primero muestra canvas } else { - continue; + continue; // campos firma adicionales (desistimiento) sin firma → omitir } } $yaHayCanvasPro = $isPro && $_renderedFirmaProfesional; - if ($isPro) $_renderedFirmaProfesional = true; - if (!$isPro && $fSvg) $_renderedFirmaPaciente = true; + if ($isPro) $_renderedFirmaProfesional = true; + if (!$isPro && $fSvg) { + $_renderedFirmaPaciente = true; + $_firmaGlobalPacienteUsada = true; + } ?>