Notification Message Editor

This commit is contained in:
Ibnu Maksum
2023-08-14 11:24:27 +07:00
parent aeeb04fd67
commit 1904e5e8a0
10 changed files with 224 additions and 97 deletions

View File

@ -19,7 +19,7 @@ class Package
*/
public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel)
{
global $_c, $_L;
global $_c, $_L, $_notifmsg;
$date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d");
$time = date("H:i:s");
@ -198,28 +198,26 @@ class Package
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
$msg = "*$_c[CompanyName]*\n" .
"$_c[address]\n" .
"$_c[phone]\n" .
"\n\n" .
"INVOICE: *$in[invoice]*\n" .
"$_L[Date] : $date_now\n" .
"$gateway $channel\n" .
"\n\n" .
"$_L[Type] : *$in[type]*\n" .
"$_L[Plan_Name] : *$in[plan_name]*\n" .
"$_L[Plan_Price] : *$_c[currency_code] " . number_format($in['price'], 2, $_c['dec_point'], $_c['thousands_sep']) . "*\n\n" .
"$_L[Username] : *$in[username]*\n" .
"$_L[Password] : **********\n\n" .
"$_L[Created_On] :\n*" . date($_c['date_format'], strtotime($in['recharged_on'])) . "*\n" .
"$_L[Expires_On] :\n*" . date($_c['date_format'], strtotime($in['expiration'])) . " $in[time]*\n" .
"\n\n" .
"$_c[note]";
$textInvoice = $_notifmsg['invoice_paid'];
$textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice);
$textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice);
$textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $_c['CompanyName'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $in['invoice'], $textInvoice);
$textInvoice = str_replace('[[date]]', $date_now, $textInvoice);
$textInvoice = str_replace('[[payment_gateway]]', $_c['gateway'], $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', $_c['channel'], $textInvoice);
$textInvoice = str_replace('[[type]]', $in['type'], $textInvoice);
$textInvoice = str_replace('[[plan_name]]', $in['plan_name'], $textInvoice);
$textInvoice = str_replace('[[plan_price]]', $_c['currency_code'] . " ". number_format($in['price'], 2, $_c['dec_point'], $_c['thousands_sep']), $textInvoice);
$textInvoice = str_replace('[[user_name]]', $in['username'], $textInvoice);
$textInvoice = str_replace('[[user_password]]', $c['password'], $textInvoice);
$textInvoice = str_replace('[[expired_date]]', date($_c['date_format'], strtotime($in['expiration'])) . " ".$in['time'], $textInvoice);
if ($_c['user_notification_payment'] == 'sms') {
Message::sendSMS($c['phonenumber'], $msg);
Message::sendSMS($c['phonenumber'], $textInvoice);
} else if ($_c['user_notification_payment'] == 'wa') {
Message::sendWhatsapp($c['phonenumber'], $msg);
Message::sendWhatsapp($c['phonenumber'], $textInvoice);
}
return true;
}

View File

@ -128,6 +128,12 @@ if (isset($_SESSION['notify'])) {
include "autoload/Hookers.php";
// notification message
if(file_exists("system/uploads/notifications.json")){
$_notifmsg =json_decode(file_get_contents('system/uploads/notifications.json'), true);
}else{
$_notifmsg = json_decode(file_get_contents('system/uploads/notifications.default.json'), true);
}
//register all plugin
foreach (glob("system/plugin/*.php") as $filename) {

View File

@ -214,7 +214,7 @@ switch ($action) {
$sms_url = _post('sms_url');
$wa_url = _post('wa_url');
$user_notification_expired = _post('user_notification_expired');
$user_notification_expired_text = _post('user_notification_expired_text');
$user_notification_reminder = _post('user_notification_reminder');
$user_notification_payment = _post('user_notification_payment');
$address = _post('address');
$tawkto = _post('tawkto');
@ -336,14 +336,14 @@ switch ($action) {
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired_text')->find_one();
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_reminder')->find_one();
if($d){
$d->value = $user_notification_expired_text;
$d->value = $user_notification_reminder;
$d->save();
}else{
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'user_notification_expired_text';
$d->value = $user_notification_expired_text;
$d->setting = 'user_notification_reminder';
$d->value = $user_notification_reminder;
$d->save();
}
@ -492,7 +492,22 @@ switch ($action) {
}
break;
case 'notifications':
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
run_hook('view_notifications'); #HOOK
if(file_exists("system/uploads/notifications.json")){
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.json'), true));
}else{
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.default.json'), true));
}
$ui->display('app-notifications.tpl');
break;
case 'notifications-post':
file_put_contents("system/uploads/notifications.json", json_encode($_POST));
r2(U . 'settings/notifications', 's', $_L['Settings_Saved_Successfully']);
break;
case 'dbstatus':
if ($admin['user_type'] != 'Admin') {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);

View File

@ -18,9 +18,15 @@ ORM::configure('logging', true);
include "autoload/Hookers.php";
// notification message
if(file_exists("uploads/notifications.json")){
$_notifmsg =json_decode(file_get_contents('uploads/notifications.json'), true);
}else{
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
}
//register all plugin
foreach (glob("system/plugin/*.php") as $filename) {
foreach (glob("plugin/*.php") as $filename) {
include $filename;
}
@ -55,7 +61,7 @@ foreach ($result as $value) {
}
date_default_timezone_set($config['timezone']);
$textExpired = $config['user_notification_expired_text'];
$textExpired = $_notifmsg['expired'];
$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();

View File

@ -345,3 +345,9 @@ $_L['Country_Code_Phone'] = 'Country Code Phone';
$_L['Voucher_activation_menu_will_be_hidden'] = 'Voucher activation menu will be hidden';
$_L['Customer_can_deposit_money_to_buy_voucher'] = 'Customer can deposit money to buy voucher';
$_L['Allow_balance_transfer_between_customers'] = 'Allow balance transfer between customers';
$_L['Reminder_Notification'] = 'Reminder Notification';
$_L['Invoice_Notification_Message'] = 'Invoice Notification Message';
$_L['Reminder_Notification_Message'] = 'Reminder Notification Message';
$_L['Reminder_7_days'] = 'Reminder 7 days';
$_L['Reminder_3_days'] = 'Reminder 3 days';
$_L['Reminder_1_day'] = 'Reminder 1 day';

View File

@ -0,0 +1 @@
{"user_notification_expired_text":"Hello [[name]],\r\nyour internet package [[package]] has been expired.","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\nThank you...","reminder_7_day":"Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 7 days.","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."}