diff --git a/system/controllers/customers.php b/system/controllers/customers.php index ca95cce5..8328c7b9 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -432,6 +432,47 @@ switch ($action) { } } } + + // Send welcome message + if (isset($_POST['send_welcome_message']) && $_POST['send_welcome_message'] == true) { + $welcomeMessage = Lang::getNotifText('welcome_message'); + $welcomeMessage = str_replace('[[company_name]]', $config['CompanyName'], $welcomeMessage); + $welcomeMessage = str_replace('[[name]]', $d['fullname'], $welcomeMessage); + $welcomeMessage = str_replace('[[username]]', $d['username'], $welcomeMessage); + $welcomeMessage = str_replace('[[password]]', $d['password'], $welcomeMessage); + $welcomeMessage = str_replace('[[url]]', APP_URL . '/index.php?_route=login', $welcomeMessage); + + $emailSubject = "Welcome to " . $config['CompanyName']; + + $channels = [ + 'sms' => [ + 'enabled' => isset($_POST['sms']), + 'method' => 'sendSMS', + 'args' => [$d['phonenumber'], $welcomeMessage] + ], + 'whatsapp' => [ + 'enabled' => isset($_POST['wa']) && $_POST['wa'] == 'wa', + 'method' => 'sendWhatsapp', + 'args' => [$d['phonenumber'], $welcomeMessage] + ], + 'email' => [ + 'enabled' => isset($_POST['email']), + 'method' => 'Message::sendEmail', + 'args' => [$d['email'], $emailSubject, $welcomeMessage, $d['email']] + ] + ]; + + foreach ($channels as $channel => $message) { + if ($message['enabled']) { + try { + call_user_func_array($message['method'], $message['args']); + } catch (Exception $e) { + // Log the error and handle the failure + _log("Failed to send welcome message via $channel: " . $e->getMessage()); + } + } + } + } r2(U . 'customers/list', 's', Lang::T('Account Created Successfully')); } else { r2(U . 'customers/add', 'e', $msg); diff --git a/system/uploads/notifications.default.json b/system/uploads/notifications.default.json index a1485439..e6843cca 100644 --- a/system/uploads/notifications.default.json +++ b/system/uploads/notifications.default.json @@ -6,5 +6,7 @@ "reminder_3_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 3 days.", "reminder_1_day": "Hello *[[name]]*,\r\n your internet package *[[package]]* will be expired tomorrow.", "invoice_paid": "*[[company_name]]*\r\n[[address]]\r\n[[phone]]\r\n\r\n\r\nINVOICE: *[[invoice]]*\r\nDate : [[date]]\r\n[[payment_gateway]] [[payment_channel]]\r\n\r\n\r\nType : *[[type]]*\r\nPackage : *[[plan_name]]*\r\nPrice : *[[plan_price]]*\r\n\r\nUsername : *[[user_name]]*\r\nPassword : ***********\r\n\r\nExpired : *[[expired_date]]*\r\n\r\n====================\r\n[[footer]]", - "invoice_balance": "*[[company_name]]*\r\n[[address]]\r\n[[phone]]\r\n\r\n\r\nINVOICE: *[[invoice]]*\r\nDate : [[date]]\r\n[[payment_gateway]] [[payment_channel]]\r\n\r\n\r\nType : *[[type]]*\r\nPackage : *[[plan_name]]*\r\nPrice : *[[plan_price]]*\r\n\r\n====================\r\n[[footer]]" + "invoice_balance": "*[[company_name]]*\r\n[[address]]\r\n[[phone]]\r\n\r\n\r\nINVOICE: *[[invoice]]*\r\nDate : [[date]]\r\n[[payment_gateway]] [[payment_channel]]\r\n\r\n\r\nType : *[[type]]*\r\nPackage : *[[plan_name]]*\r\nPrice : *[[plan_price]]*\r\n\r\n====================\r\n[[footer]]", + "welcome_message": "Welcome aboard, [[name]]! \r\nWe're excited to have you as a new [[company]] customer. \r\nYour account is all set up and ready to go.\r\n\r\nHere's a quick overview:\r\n\r\nYour login is [[Username]]\r\nYour temporary password is [[Password]] (please change this on your first login)\r\n\r\nNeed help? Reach out to our support team at anytime.\r\n\r\nWe're here to ensure you have an amazing experience with our services. Let us know how we can best support you.\r\n\r\nWelcome to the [[company]] family!" + } diff --git a/ui/ui/app-notifications.tpl b/ui/ui/app-notifications.tpl index cb133a39..94e9e299 100644 --- a/ui/ui/app-notifications.tpl +++ b/ui/ui/app-notifications.tpl @@ -136,6 +136,22 @@
+
+ [[name]] - {Lang::T('will be replaced with Customer Name')}.
+ [[username]] - {Lang::T('will be replaced with Customer username')}.
+ [[password]] - {Lang::T('will be replaced with Customer password')}.
+ [[url]] - {Lang::T('will be replaced with Customer Portal URL')}.
+ [[company]] - {Lang::T('will be replaced with Company Name')}.
+