From 7a08e63e448203c1f352ba4645a9e9a6deeba494 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 21 Jul 2026 17:18:24 -0500 Subject: [PATCH] send_consentimiento: read wa template from lab_config instead of hardcoding Was sending 'consentimiento_turno' (plain text fallback) while the configured template is 'consentimiento_turno_v2'. Now reads turnero_wa_template and turnero_wa_lang from lab_config, matching the same logic used in create_turno.php (kiosk). Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/send_consentimiento.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/turnero/api/send_consentimiento.php b/modules/turnero/api/send_consentimiento.php index 96ba9cb..f6cd547 100644 --- a/modules/turnero/api/send_consentimiento.php +++ b/modules/turnero/api/send_consentimiento.php @@ -84,6 +84,15 @@ function generarUuid(): string ); } +// ── Leer config de WhatsApp (igual que create_turno.php) ───── +$stmtCfg = $pdo->prepare( + "SELECT clave, valor FROM lab_config WHERE clave IN ('turnero_wa_template','turnero_wa_lang')" +); +$stmtCfg->execute(); +$cfgWA = $stmtCfg->fetchAll(PDO::FETCH_KEY_PAIR); +$waTemplateName = $cfgWA['turnero_wa_template'] ?? 'consentimiento_turno'; +$waLangFallback = $cfgWA['turnero_wa_lang'] ?? 'es'; + $pdo->beginTransaction(); $consentimientosResultado = []; $erroresEnvio = []; @@ -105,10 +114,10 @@ try { $wa = new WhatsAppService('turnero'); $waMeta = ['canal' => 'turnero']; - $waTemplate = 'consentimiento_turno'; + $waTemplate = $waTemplateName; $stmtLang = $pdo->prepare("SELECT language_code FROM message_templates WHERE template_name = ? LIMIT 1"); $stmtLang->execute([$waTemplate]); - $waLang = $stmtLang->fetchColumn() ?: 'es'; + $waLang = $stmtLang->fetchColumn() ?: $waLangFallback; $baseUrl = defined('BASE_URL') ? rtrim(BASE_URL, '/') : ( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')