refactor: improve SMS and email handling in Message class; add success/failure return values and update language file with new translations

This commit is contained in:
Focuslinkstech 2025-04-09 10:29:22 +01:00
parent f0b9b56bb0
commit 3347b39f3b
3 changed files with 164 additions and 4 deletions

View File

@ -46,7 +46,7 @@ class Message
$txts = str_split($txt, 160); $txts = str_split($txt, 160);
try { try {
foreach ($txts as $txt) { foreach ($txts as $txt) {
self::sendSMS( $phone, $txt); self::sendSMS($phone, $txt);
self::logMessage('SMS', $phone, $txt, 'Success'); self::logMessage('SMS', $phone, $txt, 'Success');
} }
} catch (Throwable $e) { } catch (Throwable $e) {
@ -140,6 +140,7 @@ class Message
} }
mail($to, $subject, $body, $attr); mail($to, $subject, $body, $attr);
self::logMessage('Email', $to, $body, 'Success'); self::logMessage('Email', $to, $body, 'Success');
return true;
} else { } else {
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->isSMTP(); $mail->isSMTP();
@ -188,8 +189,10 @@ class Message
if (!$mail->send()) { if (!$mail->send()) {
$errorMessage = Lang::T("Email not sent, Mailer Error: ") . $mail->ErrorInfo; $errorMessage = Lang::T("Email not sent, Mailer Error: ") . $mail->ErrorInfo;
self::logMessage('Email', $to, $body, 'Error', $errorMessage); self::logMessage('Email', $to, $body, 'Error', $errorMessage);
return false;
} else { } else {
self::logMessage('Email', $to, $body, 'Success'); self::logMessage('Email', $to, $body, 'Success');
return true;
} }
//<p style="font-family: Helvetica, sans-serif; font-size: 16px; font-weight: normal; margin: 0; margin-bottom: 16px;"> //<p style="font-family: Helvetica, sans-serif; font-size: 16px; font-weight: normal; margin: 0; margin-bottom: 16px;">

View File

@ -202,7 +202,7 @@ EOT;
['tbl_customers.fullname', 'fullname'], ['tbl_customers.fullname', 'fullname'],
['tbl_customers.username', 'username'], ['tbl_customers.username', 'username'],
['tbl_customers.email', 'email'], ['tbl_customers.email', 'email'],
['tbl_customers.service_type','service_type'], ['tbl_customers.service_type', 'service_type'],
]); ]);
$customers = $query->find_array(); $customers = $query->find_array();
} else { } else {
@ -295,7 +295,7 @@ EOT;
$totalInboxSent = 0; $totalInboxSent = 0;
$totalInboxFailed = 0; $totalInboxFailed = 0;
$batchStatus = []; $batchStatus = [];
$subject = Lang::T('Notification Message'); $subject = $config['CompanyName'] . ' ' . Lang::T('Notification Message');
$form = 'Admin'; $form = 'Admin';
foreach ($customers as $customer) { foreach ($customers as $customer) {

View File

@ -385,5 +385,162 @@
"Notification_Message": "Notification Message", "Notification_Message": "Notification Message",
"Share": "Share", "Share": "Share",
"Previous": "Previous", "Previous": "Previous",
"Email_not_sent__Mailer_Error__": "Email not sent, Mailer Error: " "Email_not_sent__Mailer_Error__": "Email not sent, Mailer Error: ",
"Invoice_Lists": "Invoice Lists",
"Invoices": "Invoices",
"Invoice_No": "Invoice No",
"Customer_Name": "Customer Name",
"Amount": "Amount",
"Due_Date": "Due Date",
"Actions": "Actions",
"Pending": "Pending",
"Send": "Send",
"": "",
"Commission": "Commission",
"Last_30_Days_Overall_Usage": "Last 30 Days Overall Usage",
"Last_30_Days_Total_Usage": "Last 30 Days Total Usage",
"Top_10_Downloaders": "Top 10 Downloaders",
"Rank": "Rank",
"Downloaded": "Downloaded",
"Upload_Data": "Upload Data",
"Download_Data": "Download Data",
"Total_Data": "Total Data",
"Service": "Service",
"Mac_Address": "Mac Address",
"Location": "Location",
"Last_Updated": "Last Updated",
"View_Details": "View Details",
"Successful_Payments": "Successful Payments",
"Failed_Payments": "Failed Payments",
"Pending_Payments": "Pending Payments",
"Cancelled_Payments": "Cancelled Payments",
"Refresh_Dashboard": "Refresh Dashboard",
"Daily_Sales": "Daily Sales",
"Monthly_Sales": "Monthly Sales",
"Weekly_Sales": "Weekly Sales",
"Hotspot_Vouchers_Overview": "Hotspot Vouchers Overview",
"Transaction_Ref": "Transaction Ref",
"Router_Name": "Router Name",
"Voucher_Code": "Voucher Code",
"Transaction_Status": "Transaction Status",
"Payment_Date": "Payment Date",
"Plan_Expiry_Date": "Plan Expiry Date",
"Action": "Action",
"Block_Mac_Address": "Block Mac Address",
"Unblock_Mac_Address": "Unblock Mac Address",
"Captive_Portal_Dashboard": "Captive Portal Dashboard",
"Manage_Router_NAS": "Manage Router\/NAS",
"Captive_Portal_Routers": "Captive Portal Routers",
"Add_New_Router": "Add New Router",
"Router_Details": "Router Details",
"MAP": "MAP",
"LANDING_PAGE": "LANDING PAGE",
"FILE": "FILE",
"EDIT": "EDIT",
"Edit_Router": "Edit Router",
"Description": "Description",
"Enter_Description": "Enter Description",
"Coordinate": "Coordinate",
"DELETE": "DELETE",
"Back_To_Dashboard": "Back To Dashboard",
"Device_Type": "Device Type",
"Mikrotik_API": "Mikrotik API",
"Choose_Router": "Choose Router",
"Choose": "Choose",
"Select": "Select",
"Add_Router": "Add Router",
"Router_Location": "Router Location",
"Go_Back": "Go Back",
"Preview": "Preview",
"Login_html": "Login.html",
"Branding": "Branding",
"Sliders": "Sliders",
"Advertisements": "Advertisements",
"Announcements": "Announcements",
"Integrations": "Integrations",
"Basic_Settings": "Basic Settings",
"Page_Title": "Page Title",
"Displayed_in_browser_title_bar": "Displayed in browser title bar",
"Page_description_browser_title_bar": "Page description browser title bar",
"Hotspot_Name": "Hotspot Name",
"Hotspot_Name_will_be_display_on_Login_Page_Nav_Bar_if_Logo_is_not_available": "Hotspot Name will be display on Login Page Nav Bar if Logo is not available",
"Footer_Text": "Footer Text",
"Allow_Free_Trial": "Allow Free Trial",
"Choose_No_if_you_dont_want_to_allow_Free_Trial": "Choose No if you dont want to allow Free Trial",
"Make_sure_you_enable_free_trial_in_Mikrotik_Router": "Make sure you enable free trial in Mikrotik Router",
"free_trial_button_wont_display_on_captive_portal_preview__but_will_work_if_you_connect_from_a_hotspot": "free trial button wont display on captive portal preview, but will work if you connect from a hotspot",
"Allow_Member_Login": "Allow Member Login",
"Choose_No_If_you_want_to_disable_Member_Login": "Choose No If you want to disable Member Login",
"Allow_Randomized_MAC": "Allow Randomized MAC",
"Choose_Yes_If_you_want_to_allow_Randomized_or_Private_MAC": "Choose Yes If you want to allow Randomized or Private MAC",
"Assign_Plan": "Assign Plan",
"Service_Plan": "Service Plan",
"Change": "Change",
"Select_Plans": "Select Plans",
"Choose_plan_that_will_that_your_users_will_be_assigned": "Choose plan that will that your users will be assigned",
"Restore_Default_Settings": "Restore Default Settings",
"Restore_Default": "Restore Default",
"Branding_Image": "Branding Image",
"Logo": "Logo",
"Backgrounds": "Backgrounds",
"Background_Type": "Background Type",
"Static_Color": "Static Color",
"Gradient_Color": "Gradient Color",
"Image": "Image",
"Static_Background_Color": "Static Background Color",
"Gradient_Background_Colors": "Gradient Background Colors",
"Gradient_Direction": "Gradient Direction",
"Left_to_Right": "Left to Right",
"Top_to_Bottom": "Top to Bottom",
"Right_to_Left": "Right to Left",
"Bottom_to_Top": "Bottom to Top",
"Choose_Image": "Choose Image",
"Buttons": "Buttons",
"Slider_Contact_Us_Button_BG_Color": "Slider Contact Us Button BG Color",
"Slider_Contact_Us_Button_Text_Color": "Slider Contact Us Button Text Color",
"Slider_Navigation_Button_BG_Color": "Slider Navigation Button BG Color",
"Slider_Navigation_Button_Icon_Color": "Slider Navigation Button Icon Color",
"Trial_Button_BG_Color": "Trial Button BG Color",
"Trial_Button_Text_Color": "Trial Button Text Color",
"Footer_Settings": "Footer Settings",
"Footer_Background_Color": "Footer Background Color",
"Misc": "Misc",
"Title": "Title",
"Link": "Link",
"Button": "Button",
"Add_New_Slider": "Add New Slider",
"Welcome_to_the_Captive_Portal": "Welcome to the Captive Portal",
"Button_Link": "Button Link",
"Button_Text": "Button Text",
"Click_Here": "Click Here",
"Target_Link": "Target Link",
"Create_New_Advert": "Create New Advert",
"Add_New_Advertisement": "Add New Advertisement",
"Content": "Content",
"Enter_Interstitial_Content": "Enter Interstitial Content",
"Upload_File": "Upload File",
"File_size_limit__5MB_for_images__100MB_for_videos": "File size limit: 5MB for images, 100MB for videos",
"Target_URL": "Target URL",
"Create_Advert": "Create Advert",
"You_cannot_perform_this_action_in_Demo_mode": "You cannot perform this action in Demo mode",
"Income_Today": "Income Today",
"Income_This_Month": "Income This Month",
"Customers": "Customers",
"Monthly_Registered_Customers": "Monthly Registered Customers",
"Cron_has_not_run_for_over_1_hour__Please_check_your_setup_": "Cron has not run for over 1 hour. Please check your setup.",
"Total_Monthly_Sales": "Total Monthly Sales",
"Customers_Expired__Today": "Customers Expired, Today",
"Phone": "Phone",
"Created___Expired": "Created \/ Expired",
"Internet_Package": "Internet Package",
"year": "year",
"month": "month",
"week": "week",
"day": "day",
"hour": "hour",
"minute": "minute",
"second": "second",
"ago": "ago",
"All_Users_Insights": "All Users Insights",
"Activity_Log": "Activity Log"
} }