feat(formulario): firma profesional directa en modal embebido (formularios solo-pro)
- ver_formulario_enviado.php: pre-scan $_soloFirmaPro; muestra canvas pro cuando modoTurnero+embebido+sesión activa+sin firma paciente - fpw-save JS: recopila campos del form y envía solo_profesional=true; al guardar muestra éxito y postMessage turneroFirmado - firmar_profesional_consentimiento.php: si solo_profesional=true guarda datos_respuestas y marca estado=firmado Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1e2cfbaa0b
commit
3dbf40e4fa
@@ -16,6 +16,9 @@ $body = inputJson();
|
||||
$turnoId = (int)($body['turno_id'] ?? 0);
|
||||
$formularioId = (int)($body['formulario_id'] ?? 0);
|
||||
$svg = $body['svg'] ?? '';
|
||||
$soloPro = !empty($body['solo_profesional']);
|
||||
$datosResp = (isset($body['datos_respuestas']) && is_array($body['datos_respuestas']))
|
||||
? json_encode($body['datos_respuestas'], JSON_UNESCAPED_UNICODE) : null;
|
||||
|
||||
if (!$turnoId) jsonError('turno_id requerido.');
|
||||
if (!$formularioId) jsonError('formulario_id requerido.');
|
||||
@@ -37,12 +40,22 @@ $tc = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$tc) jsonError('Consentimiento no encontrado.', 404);
|
||||
|
||||
$stmt = $pdo->prepare(
|
||||
"UPDATE turnero_consentimientos
|
||||
SET firma_profesional_svg = ?, firmado_profesional_at = NOW()
|
||||
WHERE turno_id = ? AND formulario_id = ?"
|
||||
);
|
||||
$stmt->execute([$svg, $turnoId, $formularioId]);
|
||||
if ($soloPro) {
|
||||
// El profesional es el firmante final: guardar datos + marcar como firmado
|
||||
$pdo->prepare(
|
||||
"UPDATE turnero_consentimientos
|
||||
SET firma_profesional_svg = ?, firmado_profesional_at = NOW(),
|
||||
estado = 'firmado', firmado_at = NOW(),
|
||||
datos_respuestas = COALESCE(?, datos_respuestas)
|
||||
WHERE turno_id = ? AND formulario_id = ?"
|
||||
)->execute([$svg, $datosResp, $turnoId, $formularioId]);
|
||||
} else {
|
||||
$pdo->prepare(
|
||||
"UPDATE turnero_consentimientos
|
||||
SET firma_profesional_svg = ?, firmado_profesional_at = NOW()
|
||||
WHERE turno_id = ? AND formulario_id = ?"
|
||||
)->execute([$svg, $turnoId, $formularioId]);
|
||||
}
|
||||
|
||||
notificarSSE((int)$tc['sesion_id']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user