diff --git a/.gitignore b/.gitignore index 164d3732..85d079af 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ ui/ui_custom/** !ui/ui_custom/README.md system/uploads/admin.png system/uploads/logo.png -system/uploads/user.jpg \ No newline at end of file +system/uploads/user.jpg +system/uploads/notifications.json \ No newline at end of file diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 384140dd..1764f7a6 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -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; } diff --git a/system/boot.php b/system/boot.php index c2e0c637..9e458289 100644 --- a/system/boot.php +++ b/system/boot.php @@ -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) { diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 3c10a010..0de22c16 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -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']); diff --git a/system/cron.php b/system/cron.php index 13a4837f..8a36f9c2 100644 --- a/system/cron.php +++ b/system/cron.php @@ -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(); diff --git a/system/lan/english/common.lan.php b/system/lan/english/common.lan.php index 0608b1c7..1798dfb4 100644 --- a/system/lan/english/common.lan.php +++ b/system/lan/english/common.lan.php @@ -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'; diff --git a/system/uploads/notifications.default.json b/system/uploads/notifications.default.json new file mode 100644 index 00000000..5535ddc5 --- /dev/null +++ b/system/uploads/notifications.default.json @@ -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."} \ No newline at end of file diff --git a/ui/ui/app-notifications.tpl b/ui/ui/app-notifications.tpl new file mode 100644 index 00000000..81b468fd --- /dev/null +++ b/ui/ui/app-notifications.tpl @@ -0,0 +1,103 @@ +{include file="sections/header.tpl"} + +
+
+
+
+
+
+ +
+ {Lang::T('User Notification')} +
+
+
+ +
+ +
+

+ {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} +

+
+
+
+
+ +
+ +
+

+ {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} +

+
+
+
+
+ +
+ +
+

+ {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} +

+
+
+
+
+ +
+ +
+

+ {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} +

+
+
+
+
+ +
+ +

+ {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} +

+
+

+ [[company_name]] Your Company Name at Settings.
+ [[address]] Your Company Address at Settings.
+ [[phone]] Your Company Phone at Settings.
+ [[invoice]] invoice number.
+ [[date]] Date invoice created.
+ [[payment_gateway]] Payment gateway user paid from.
+ [[payment_channel]] Payment channel user paid from.
+ [[type]] is Hotspot/PPPOE.
+ [[plan_name]] Internet Package.
+ [[plan_price]] Internet Package Prices.
+ [[user_name]] Username internet.
+ [[user_password]] User password.
+ [[expired_date]] Expired datetime. +

+
+
+
+ +
+
+ +
+
+
+
+
+{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index 08d66f28..83ee92ae 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -6,8 +6,8 @@
- +
{$_L['General_Settings']}
@@ -17,24 +17,25 @@
- {$_L['App_Name_Help_Text']} +
+ {$_L['App_Name_Help_Text']}
- {Lang::T('Will show below user pages')}
+ {Lang::T('Will show below user pages')}
- {$_L['You_can_use_html_tag']}
+ {$_L['You_can_use_html_tag']}
@@ -49,18 +50,17 @@ -

Still on Testing.

-

Changing from Radius will not add existing user to Mikrotik Hotspot. -

-

With Radius user can use Hotspot or PPOE.

+

Still on Testing.
+ Changing from Radius will not add existing user to Mikrotik Hotspot.
+ With Radius user can use Hotspot or PPOE.

-

edit at config.php

+

edit at config.php

@@ -71,14 +71,14 @@ -

{Lang::T('Voucher activation menu will be hidden')}

+

{Lang::T('Voucher activation menu will be hidden')}

- +
{Lang::T('Balance System')}
@@ -92,8 +92,8 @@ -

{Lang::T('Customer can deposit money to buy voucher')}

+

{Lang::T('Customer can deposit money to buy voucher')}

@@ -104,14 +104,14 @@ -

{Lang::T('Allow balance transfer between customers')}

+

{Lang::T('Allow balance transfer between customers')}

- +
{Lang::T('Telegram Notification')}
@@ -135,8 +135,8 @@
- +
{Lang::T('SMS OTP Registration')}
@@ -146,17 +146,18 @@
-

Must include [text] & [number], it will be replaced. -

+

Must include [text] & [number], it will be + replaced. +

You can use WhatsApp in here too. Free Server
- +
{Lang::T('Whatsapp Notification')}
@@ -166,15 +167,18 @@
-

Must include [text] & [number], it will be replaced. -

+

Must include [text] & [number], it will be + replaced. +

+ You can use WhatsApp in here too. Free Server
- +
{Lang::T('User Notification')}
@@ -190,20 +194,8 @@ -

{Lang::T('User will get notification when package expired')}

- - -
- -
- -

- {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} -

+

{Lang::T('User will get notification when package expired')}

@@ -216,15 +208,28 @@ -

- {Lang::T('User will get invoice notification when buy package or package refilled')}

+
+

+ {Lang::T('User will get invoice notification when buy package or package refilled')}

+ +
+ +
+
- +
{Lang::T('Tawk.to Chat Widget')}
@@ -234,29 +239,13 @@
-

From Direct Chat Link.

-
/ip hotspot walled-garden
-add dst-host=tawk.to
-add dst-host=*.tawk.to
-
- - -
-
- -
- {Lang::T('Invoice')} -
-
-
- -
- - {$_L['You_can_use_html_tag']}
+

From Direct Chat Link.

+ +

/ip hotspot walled-garden
+ add dst-host=tawk.to
+ add dst-host=*.tawk.to

@@ -268,8 +257,8 @@ add dst-host=*.tawk.to
/ip hotspot walled-garden
-            add dst-host={$_domain}
-            add dst-host=*.{$_domain}
+add dst-host={$_domain} +add dst-host=*.{$_domain} diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 187b5dad..b2f8bd00 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -224,7 +224,9 @@
  • {$_L['General_Settings']}
  • {$_L['Localisation']}
  • + href="{$_url}settings/localisation">{$_L['Localisation']} +
  • {Lang::T('User Notification')}
  • {$_L['Administrator_Users']}