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; + } ?>