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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
26bb9e1844
commit
7a08e63e44
@@ -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();
|
$pdo->beginTransaction();
|
||||||
$consentimientosResultado = [];
|
$consentimientosResultado = [];
|
||||||
$erroresEnvio = [];
|
$erroresEnvio = [];
|
||||||
@@ -105,10 +114,10 @@ try {
|
|||||||
|
|
||||||
$wa = new WhatsAppService('turnero');
|
$wa = new WhatsAppService('turnero');
|
||||||
$waMeta = ['canal' => 'turnero'];
|
$waMeta = ['canal' => 'turnero'];
|
||||||
$waTemplate = 'consentimiento_turno';
|
$waTemplate = $waTemplateName;
|
||||||
$stmtLang = $pdo->prepare("SELECT language_code FROM message_templates WHERE template_name = ? LIMIT 1");
|
$stmtLang = $pdo->prepare("SELECT language_code FROM message_templates WHERE template_name = ? LIMIT 1");
|
||||||
$stmtLang->execute([$waTemplate]);
|
$stmtLang->execute([$waTemplate]);
|
||||||
$waLang = $stmtLang->fetchColumn() ?: 'es';
|
$waLang = $stmtLang->fetchColumn() ?: $waLangFallback;
|
||||||
|
|
||||||
$baseUrl = defined('BASE_URL') ? rtrim(BASE_URL, '/') : (
|
$baseUrl = defined('BASE_URL') ? rtrim(BASE_URL, '/') : (
|
||||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')
|
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')
|
||||||
|
|||||||
Reference in New Issue
Block a user