diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php
index 2665718..aaa351a 100644
--- a/modules/turnero/views/lugar.php
+++ b/modules/turnero/views/lugar.php
@@ -321,14 +321,7 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
-
-
-
Consentimientos informados
@@ -753,29 +746,40 @@ function renderConsentimientos(lista) {
const idJs = parseInt(c.id) || 0;
const tId = parseInt(c.turno_id) || (turnoActivo?.id) || 0;
- // Firmar aquí: solo si no completado y hay token
- const btnFirmar = (!ya && c.token)
- ? `
` : '';
+ // Botón ver (firmado)
+ const btnVer = (ya && c.token)
+ ? `
+ Ver
+ ` : '';
- // WA / Ver: según estado
- const btnWa = ya
- ? (c.token ? `
- Ver
- ` : '')
- : `
`;
+ // Acción principal según modo y estado
+ let btnAccion = '';
+ if (!ya && c.token) {
+ if (LUGAR_FORM_MODO === 'embebido') {
+ // Modo embebido: abrir modal directamente
+ btnAccion = `
`;
+ } else {
+ // Modo link: firmar presencial o reenviar WA
+ btnAccion = `
+
`;
+ }
+ }
return `
${escHtml(c.formulario_nombre || 'Consentimiento')}
${label}
-
${btnFirmar}${btnWa}
+
${btnAccion}${btnVer}
`;
}).join('');
}
@@ -889,27 +893,10 @@ async function cambiarEstadoTurno(nuevoEstado) {
// ── Embebido como modal ───────────────────────────────────────
let _consentTokenCache = null; // { turnoId, token }
-async function cargarFormEmbebido(turnoId) {
- const sec = document.getElementById('sec-form-embebido');
- if (sec) sec.classList.remove('d-none');
- // Pre-cargar token para que el modal abra rápido
- try {
- const res = await fetch(`${API}get_consent_token.php?turno_id=${turnoId}&lugar_id=${lugarId}`);
- const json = await res.json();
- if (json.ok && json.token) {
- _consentTokenCache = { turnoId, token: json.token };
- } else {
- _consentTokenCache = null;
- if (sec) sec.innerHTML = `
Consentimiento informado
-
${json.error || 'Sin formulario configurado'}
`;
- }
- } catch (e) {
- _consentTokenCache = null;
- }
-}
+// cargarFormEmbebido ya no necesita hacer nada (el token viene de la fila de consentimiento)
+async function cargarFormEmbebido(turnoId) { /* token llega vía renderConsentimientos */ }
-function abrirModalConsentimiento() {
- if (!_consentTokenCache) { mostrarError('Token de consentimiento no disponible.'); return; }
+function _abrirModalConToken(token) {
const modal = document.getElementById('modal-consentimiento');
const iframe = document.getElementById('modal-consent-iframe');
const load = document.getElementById('modal-consent-loading');
@@ -917,12 +904,20 @@ function abrirModalConsentimiento() {
iframe.src = '';
load.style.display = '';
modal.style.display = 'flex';
- // Pequeño delay para que el modal sea visible antes de cargar el iframe
setTimeout(() => {
- iframe.src = `${BASE_WA}ver_formulario_enviado.php?token=${encodeURIComponent(_consentTokenCache.token)}&embed=1`;
+ iframe.src = `${BASE_WA}ver_formulario_enviado.php?token=${encodeURIComponent(token)}&embed=1`;
}, 80);
}
+function abrirModalConsentimiento() {
+ if (!_consentTokenCache?.token) { mostrarError('Token de consentimiento no disponible.'); return; }
+ _abrirModalConToken(_consentTokenCache.token);
+}
+
+function abrirModalConsentimientoPorToken(token) {
+ _abrirModalConToken(token);
+}
+
function cerrarModalConsentimiento() {
const modal = document.getElementById('modal-consentimiento');
const iframe = document.getElementById('modal-consent-iframe');
@@ -952,17 +947,7 @@ function resetFicha() {
tieneConsent = false;
hayPendientes = false;
_consentTokenCache = null;
-
- // Limpiar modal embebido
cerrarModalConsentimiento();
- const sec = document.getElementById('sec-form-embebido');
- if (sec) {
- sec.classList.add('d-none');
- sec.innerHTML = `
Consentimiento informado
-
`;
- }
document.getElementById('ficha-turno').classList.add('d-none');
document.getElementById('ficha-placeholder').classList.remove('d-none');