This commit is contained in:
Lizandro Guarnizo
2026-06-13 13:19:02 -05:00
parent 0e51165108
commit f34d19b3df
4 changed files with 43 additions and 4 deletions
+1 -2
View File
@@ -183,10 +183,9 @@ function siguienteNumeroPorPrioridad(int $sesionId, int $prioridadId): int
'SELECT COALESCE(MAX(numero), 0) + 1 AS siguiente
FROM turnero_turnos
WHERE sesion_id = ?
AND prioridad_id = ?
FOR UPDATE'
);
$stmt->execute([$sesionId, $prioridadId]);
$stmt->execute([$sesionId]);
return (int) $stmt->fetchColumn();
}
+14
View File
@@ -105,6 +105,20 @@ try {
// ── Enviar notificación WhatsApp con la plantilla configurada ──
if ($pacienteTel) {
try {
$stmtCfg = $pdo->prepare(
"SELECT clave, valor FROM lab_config WHERE clave IN ('turnero_wa_template','turnero_wa_lang','turnero_wa_kiosko_enabled')"
);
$stmtCfg->execute();
$cfgWA = $stmtCfg->fetchAll(PDO::FETCH_KEY_PAIR);
$waKioskoEnabled = ($cfgWA['turnero_wa_kiosko_enabled'] ?? '0') === '1';
} catch (\Throwable $e) {
$waKioskoEnabled = true;
}
}
if ($pacienteTel && $waKioskoEnabled) {
try {
$cfgWA = [];
$stmtCfg = $pdo->prepare(
"SELECT clave, valor FROM lab_config WHERE clave IN ('turnero_wa_template','turnero_wa_lang')"
);
+4
View File
@@ -82,6 +82,8 @@ if ($accion === 'reabrir') {
if ($accion === 'config_wa') {
$template = trim($input['template'] ?? '');
$lang = trim($input['lang'] ?? 'es_CO');
$waKiosko = (int)($input['wa_kiosko'] ?? 0);
$waConsent = (int)($input['wa_consent'] ?? 0);
if ($template === '') jsonError('El nombre de plantilla es requerido');
if (!preg_match('/^[a-z0-9_]{1,64}$/i', $template)) {
@@ -98,6 +100,8 @@ if ($accion === 'config_wa') {
);
$upsert->execute(['turnero_wa_template', $template]);
$upsert->execute(['turnero_wa_lang', $lang]);
$upsert->execute(['turnero_wa_kiosko_enabled', (string)$waKiosko]);
$upsert->execute(['turnero_wa_consent_enabled', (string)$waConsent]);
jsonOk([], 'Configuración WhatsApp guardada');
}