enable disable whatsapp

This commit is contained in:
Flatlogic Bot 2026-03-08 10:29:50 +00:00
parent d424fc2360
commit 3ef2b853c6
2 changed files with 17 additions and 4 deletions

View File

@ -16,6 +16,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
'wablas_domain' => trim($_POST['wablas_domain'] ?? ''),
'wablas_api_token' => trim($_POST['wablas_api_token'] ?? ''),
'wablas_secret_key' => trim($_POST['wablas_secret_key'] ?? ''),
'whatsapp_enabled' => isset($_POST['whatsapp_enabled']) ? '1' : '0',
'smtp_host' => trim($_POST['smtp_host'] ?? ''),
'smtp_port' => trim($_POST['smtp_port'] ?? ''),
'smtp_secure' => trim($_POST['smtp_secure'] ?? ''),
@ -42,6 +43,7 @@ $thawaniEnv = $settings['thawani_environment'] ?? 'test';
$wablasDomain = $settings['wablas_domain'] ?? '';
$wablasToken = $settings['wablas_api_token'] ?? '';
$wablasSecret = $settings['wablas_secret_key'] ?? '';
$whatsappEnabled = $settings['whatsapp_enabled'] ?? '0';
$smtpHost = $settings['smtp_host'] ?? '';
$smtpPort = $settings['smtp_port'] ?? '587';
$smtpSecure = $settings['smtp_secure'] ?? 'tls';
@ -115,6 +117,13 @@ render_header('Integrations', 'admin', true);
<p class="text-muted small mb-4">Connect Wablas to automatically send WhatsApp notifications to Shippers and Truck Owners.</p>
<div class="row g-0">
<div class="col-12 mb-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="whatsapp_enabled" id="whatsapp_enabled" value="1" <?= $whatsappEnabled === '1' ? 'checked' : '' ?>>
<label class="form-check-label fw-bold" for="whatsapp_enabled">Enable WhatsApp Notifications</label>
</div>
</div>
<div class="col-md-6">
<label class="form-label fw-bold">Wablas Server Domain</label>
<input type="text" name="wablas_domain" class="form-control" value="<?= e($wablasDomain) ?>" placeholder="e.g. https://solo.wablas.com">

View File

@ -1,6 +1,7 @@
<?php
require_once __DIR__ . '/../db/config.php';
require_once __DIR__ . '/../mail/MailService.php';
require_once __DIR__ . '/app.php';
class NotificationService
{
@ -66,8 +67,11 @@ class NotificationService
MailService::sendMail($user['email'], $subject, $htmlBody, $body);
}
// Log WhatsApp (Mock)
// In a real app, this would call Twilio/Meta API
error_log("WHATSAPP Notification to {$user['email']} (Phone N/A): $whatsapp");
// Send WhatsApp if enabled
if (get_setting('whatsapp_enabled') === '1') {
// Log WhatsApp (Mock)
// In a real app, this would call Twilio/Meta API
error_log("WHATSAPP Notification to {$user['email']} (Phone N/A): $whatsapp");
}
}
}
}