fix: firma del paciente aparecía duplicada en consentimiento y desistimiento
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c91900ef14
commit
9b4cdcc817
+16
-11
@@ -453,9 +453,10 @@ function esc2(mixed $v): string {
|
|||||||
$firmaSharedPaciente = $envio['firma_svg'] ?? null;
|
$firmaSharedPaciente = $envio['firma_svg'] ?? null;
|
||||||
|
|
||||||
// Rastrear si ya se renderizó la firma inline (para no duplicarla al pie)
|
// Rastrear si ya se renderizó la firma inline (para no duplicarla al pie)
|
||||||
$_renderedFirmaProfesional = false;
|
$_renderedFirmaProfesional = false;
|
||||||
$_renderedFirmaPaciente = false;
|
$_renderedFirmaPaciente = false;
|
||||||
$_esquemaTieneFirmaPaciente = false; // el esquema tiene campo tipo=firma
|
$_esquemaTieneFirmaPaciente = false;
|
||||||
|
$_firmaGlobalPacienteUsada = false; // la firma global solo va al primer campo firma
|
||||||
|
|
||||||
foreach ($esquema as $campo):
|
foreach ($esquema as $campo):
|
||||||
$tipo = $campo['tipo'] ?? '';
|
$tipo = $campo['tipo'] ?? '';
|
||||||
@@ -473,25 +474,29 @@ function esc2(mixed $v): string {
|
|||||||
// Campos posteriores (ej. desistimiento) solo muestran su propia firma por campo.
|
// Campos posteriores (ej. desistimiento) solo muestran su propia firma por campo.
|
||||||
$fSvg = $isPro
|
$fSvg = $isPro
|
||||||
? (!$_renderedFirmaProfesional ? ($firmaSharedProfesional ?? $datosCliente[$cid . '_svg'] ?? null) : ($datosCliente[$cid . '_svg'] ?? null))
|
? (!$_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;
|
$fFoto = $datosCliente[$cid . '_foto'] ?? null;
|
||||||
$fIcon = $isPro ? 'fa-user-md' : 'fa-signature';
|
$fIcon = $isPro ? 'fa-user-md' : 'fa-signature';
|
||||||
$fColor = $isPro ? '#198754' : '#1565c0';
|
$fColor = $isPro ? '#198754' : '#1565c0';
|
||||||
$fLabel = htmlspecialchars($campo['label'] ?? ($isPro ? 'Firma profesional' : 'Firma paciente'));
|
$fLabel = htmlspecialchars($campo['label'] ?? ($isPro ? 'Firma profesional' : 'Firma paciente'));
|
||||||
|
|
||||||
// Campo paciente sin firma: omitir en vista normal.
|
// Campo paciente sin firma:
|
||||||
// En turnero pendiente se muestra el canvas en su posición del esquema.
|
// - 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 (!$fSvg && !$fFoto && !$isPro) {
|
||||||
if ($modoTurnero && $modoEditar) {
|
if ($modoTurnero && $modoEditar && !$_esquemaTieneFirmaPaciente) {
|
||||||
$_esquemaTieneFirmaPaciente = true;
|
$_esquemaTieneFirmaPaciente = true; // solo el primero muestra canvas
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue; // campos firma adicionales (desistimiento) sin firma → omitir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$yaHayCanvasPro = $isPro && $_renderedFirmaProfesional;
|
$yaHayCanvasPro = $isPro && $_renderedFirmaProfesional;
|
||||||
if ($isPro) $_renderedFirmaProfesional = true;
|
if ($isPro) $_renderedFirmaProfesional = true;
|
||||||
if (!$isPro && $fSvg) $_renderedFirmaPaciente = true;
|
if (!$isPro && $fSvg) {
|
||||||
|
$_renderedFirmaPaciente = true;
|
||||||
|
$_firmaGlobalPacienteUsada = true;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="section-title mt-3" style="color:<?= $fColor ?>">
|
<div class="section-title mt-3" style="color:<?= $fColor ?>">
|
||||||
<i class="fas <?= $fIcon ?> me-1"></i><?= $fLabel ?>
|
<i class="fas <?= $fIcon ?> me-1"></i><?= $fLabel ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user