Refactor SMS and notification logic; add email template.

Updated the SMS sending logic to improve validation and handling of recipients in `gatewayapi.php`. Refactored notification conditions in `bookings_o.php` to ensure proper fallback mechanisms. Additionally, included a new booking notification email template in `email.php`.
This commit is contained in:
Jepp9350
2025-04-14 09:58:25 +02:00
parent e0b2e5dade
commit 6efa414251
3 changed files with 9 additions and 5 deletions
+1
View File
@@ -8,6 +8,7 @@ require_once WD . '/modules/email/templates/email_template_footer.php';
require_once WD . '/modules/email/templates/email_template_head.php';
require_once WD . '/modules/email/templates/email_template_stripe_invoice.php';
require_once WD . '/modules/email/templates/email_template_booking_confirmation.php';
require_once WD . '/modules/email/templates/email_template_booking_notification.php';
require_once WD . '/modules/email/templates/email_template_wash_certificate.php';
use email\email_c;
+1 -1
View File
@@ -36,7 +36,7 @@ class gatewayapi implements gatewayapi_i
$data = [
"recipients" => array_map(function ($recipient) {
return [
'msisdn' => (int)$recipient,
'msisdn' => $recipient,
];
}, $to),
'message' => $message,
+7 -4
View File
@@ -303,11 +303,11 @@ class bookings_o extends db
$department_array = $department->asArray();
$customer_array = $customer->asArray();
// Define delivery methods
$deliverSlack = !empty($department->slack_webhook->value());
$deliverSlack = (boolean)!empty($department->slack_webhook->value());
$deliverSMS = (
!empty($branding->phone_country_code->value()) &&
!empty($branding->phone->value()) &&
!$deliverSlack // Only send SMS if slack is not available
((int)$branding->phone->value() > 0)
);
$deliverEmail = (
!empty($this->contact_email->value()) &&
@@ -336,11 +336,14 @@ class bookings_o extends db
));
}
if (!$deliverSMS) {
if ($deliverSMS) {
// Send an SMS notification to the department
$gatewayapi = new gatewayapi();
$phone = '' . $branding->phone_country_code->value() . $branding->phone->value();
$gatewayapi->send(
[$branding->phone_country_code->value() . $branding->phone->value()],
[
$phone,
],
'New booking from ' . $customer->getCustomerName($customer_array['customer_number']) . ' (' . $this->id . ')',
);
}