diff --git a/api/lab/firmar_profesional.php b/api/lab/firmar_profesional.php index 3deacd8..b8ad3d1 100644 --- a/api/lab/firmar_profesional.php +++ b/api/lab/firmar_profesional.php @@ -69,9 +69,13 @@ if (!$campoDef || ($campoDef['tipo'] ?? '') !== 'firma_profesional') { err('El campo no es una firma_profesional'); } -// ── Actualizar datos_cliente ───────────────────────────────────────── +// ── Actualizar datos_cliente: guardar en TODOS los campos firma_profesional ── $datos = json_decode($envio['datos_cliente'] ?? '{}', true) ?? []; -$datos[$campoId . '_svg'] = $svg; +foreach ($esquema as $c) { + if (($c['tipo'] ?? '') === 'firma_profesional' && !empty($c['id'])) { + $datos[$c['id'] . '_svg'] = $svg; + } +} $nuevosDatos = json_encode($datos, JSON_UNESCAPED_UNICODE); $nuevoEstado = $envio['estado'] === 'firmado' ? 'firmado' : 'firmado'; diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index 4713c8a..16b0946 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -421,6 +421,22 @@ function esc2(mixed $v): string { @@ -431,13 +447,21 @@ function esc2(mixed $v): string { if ($tipo === 'firma' || $tipo === 'firma_profesional'): $cid = $campo['id'] ?? null; if (!$cid) continue; - $fSvg = $datosCliente[$cid . '_svg'] ?? null; - $fFoto = $datosCliente[$cid . '_foto'] ?? null; $isPro = ($tipo === 'firma_profesional'); + // Usar firma compartida del tipo correspondiente + $fSvg = $isPro ? $firmaSharedProfesional : $firmaSharedPaciente; + $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')); - // Firma paciente sin contenido: omitir + + // Si ya renderizamos la firma de este tipo, omitir duplicado + if (!$isPro && $_renderedFirmaPaciente) { continue; } + if ($isPro && $_renderedFirmaProfesional) { continue; } + if (!$isPro) $_renderedFirmaPaciente = true; + if ($isPro) $_renderedFirmaProfesional = true; + + // Firma paciente sin contenido y sin widget turnero: omitir if (!$isPro && !$fSvg && !$fFoto) continue; ?>
@@ -453,7 +477,7 @@ function esc2(mixed $v): string {
- +

Dibuje su firma en el recuadro: