diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1be54699..ca4727e6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
# CHANGELOG
+## 2024.1.16
+
+- Add yellow color to table for plan not allowed to purchase
+- Fix Radius pool select
+- add price to reminder notification
+- Support thermal printer for invoice
+
+## 2024.1.15
+
+- Fix cron job for Plan only for admin by @Focuslinkstech
+
## 2024.1.11
- Add Plan only for admin by @Focuslinkstech
diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php
index 6736c700..eafcc870 100644
--- a/system/autoload/Lang.php
+++ b/system/autoload/Lang.php
@@ -99,4 +99,38 @@ class Lang
}
return $result;
}
+
+ /**
+ * $pad_type
+ * 0 Left
+ * 1 right
+ * 2 center
+ * */
+ public static function pad($text, $pad_string = ' ', $pad_type = 0){
+ global $config;
+ $cols = 37;
+ if($config['printer_cols']){
+ $cols = $config['printer_cols'];
+ }
+ $text = trim($text);
+ $texts = explode("\n", $text);
+ if(count($texts)>1){
+ $text = '';
+ foreach($texts as $t){
+ $text.= self::pad(trim($t), $pad_string, $pad_type)."\n";
+ }
+ return $text;
+ }else{
+ return str_pad(trim($text), $cols, $pad_string, $pad_type);
+ }
+ }
+
+ public static function pads($textLeft, $textRight, $pad_string = ' '){
+ global $config;
+ $cols = 37;
+ if($config['printer_cols']){
+ $cols = $config['printer_cols'];
+ }
+ return $textLeft.str_pad($textRight, $cols-strlen($textLeft), $pad_string, 0);
+ }
}
diff --git a/system/autoload/Message.php b/system/autoload/Message.php
index 3ee749d8..df17aec1 100644
--- a/system/autoload/Message.php
+++ b/system/autoload/Message.php
@@ -62,14 +62,15 @@ class Message
if (!empty($config['wa_url'])) {
$waurl = str_replace('[number]', urlencode($phone), $config['wa_url']);
$waurl = str_replace('[text]', urlencode($txt), $waurl);
- Http::getData($waurl);
+ return Http::getData($waurl);
}
}
- public static function sendPackageNotification($phone, $name, $package, $message, $via)
+ public static function sendPackageNotification($phone, $name, $package, $price, $message, $via)
{
- $msg = str_replace('[[name]]', "*$name*", $message);
- $msg = str_replace('[[package]]', "*$package*", $msg);
+ $msg = str_replace('[[name]]', $name, $message);
+ $msg = str_replace('[[package]]', $package, $msg);
+ $msg = str_replace('[[price]]', $price, $msg);
if (
!empty($phone) && strlen($phone) > 5
&& !empty($message) && in_array($via, ['sms', 'wa'])
@@ -85,9 +86,9 @@ class Message
public static function sendBalanceNotification($phone, $name, $balance, $balance_now, $message, $via)
{
- $msg = str_replace('[[name]]', "*$name*", $message);
+ $msg = str_replace('[[name]]', $name, $message);
$msg = str_replace('[[current_balance]]', Lang::moneyFormat($balance_now), $msg);
- $msg = str_replace('[[balance]]', "*" . Lang::moneyFormat($balance) . "*", $msg);
+ $msg = str_replace('[[balance]]', Lang::moneyFormat($balance), $msg);
if (
!empty($phone) && strlen($phone) > 5
&& !empty($message) && in_array($via, ['sms', 'wa'])
diff --git a/system/boot.php b/system/boot.php
index f4e88701..d0312bac 100644
--- a/system/boot.php
+++ b/system/boot.php
@@ -118,7 +118,7 @@ try {
$ui->assign("error_title", "PHPNuxBill Crash");
if (isset($_SESSION['uid'])) {
$ui->assign("error_message", $e->getMessage() . '
');
- }else{
+ } else {
$ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . ''); } $ui->display('router-error.tpl'); @@ -130,13 +130,13 @@ function _notify($msg, $type = 'e') $_SESSION['ntype'] = $type; $_SESSION['notify'] = $msg; } -if(empty($config['language'])){ +if (empty($config['language'])) { $config['language'] = 'english'; } $lan_file = File::pathFixer('system/lan/' . $config['language'] . '/common.lan.php'); -if(file_exists($lan_file)){ +if (file_exists($lan_file)) { require $lan_file; -}else{ +} else { die("$lan_file not found"); } @@ -190,7 +190,11 @@ $_notifmsg_default = json_decode(file_get_contents(File::pathFixer('system/uploa //register all plugin foreach (glob(File::pathFixer("system/plugin/*.php")) as $filename) { - include $filename; + try { + include $filename; + } catch (Throwable $e) { + } catch (Exception $e) { + } } @@ -299,7 +303,8 @@ function time_elapsed_string($datetime, $full = false) } } - if (!$full) $string = array_slice($string, 0, 1); + if (!$full) + $string = array_slice($string, 0, 1); return $string ? implode(', ', $string) . ' ago' : 'just now'; } @@ -356,7 +361,7 @@ try { } } catch (Exception $e) { if (!isset($_SESSION['aid']) || empty($_SESSION['aid'])) { - r2(U . 'home' , 'e', $e->getMessage()); + r2(U . 'home', 'e', $e->getMessage()); } $ui->assign("error_message", $e->getMessage() . '
' . $e->getTraceAsString() . ''); $ui->assign("error_title", "PHPNuxBill Crash"); diff --git a/system/controllers/home.php b/system/controllers/home.php index e480b92a..265c8e89 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -96,6 +96,12 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { $router = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one(); if ($config['enable_balance'] == 'yes') { $plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']); + if(!$plan['enabled']){ + r2(U . "home", 'e', 'Plan is not exists'); + } + if($plan['allow_purchase'] != 'yes'){ + r2(U . "home", 'e', 'Cannot recharge this plan'); + } if ($user['balance'] > $plan['price']) { r2(U . "order/pay/$router[id]/$bill[plan_id]", 'e', 'Order Plan'); } else { diff --git a/system/controllers/order.php b/system/controllers/order.php index a14d15e0..31b53dd0 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -149,6 +149,12 @@ switch ($action) { if (empty($plan)) { r2(U . "order/package", 'e', Lang::T("Plan Not found")); } + if(!$plan['enabled']){ + r2(U . "home", 'e', 'Plan is not exists'); + } + if($plan['allow_purchase'] != 'yes'){ + r2(U . "home", 'e', 'Cannot recharge this plan'); + } if ($routes['2'] == 'radius') { $router_name = 'radius'; } else { @@ -166,7 +172,7 @@ switch ($action) { "\nPrice: " . $p['price']); } } else { - echo "no renewall | plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n"; + r2(U . "home", 'e', 'Plan is not exists'); } break; case 'send': @@ -179,6 +185,12 @@ switch ($action) { if (empty($plan)) { r2(U . "order/package", 'e', Lang::T("Plan Not found")); } + if(!$plan['enabled']){ + r2(U . "home", 'e', 'Plan is not exists'); + } + if($plan['allow_purchase'] != 'yes'){ + r2(U . "home", 'e', 'Cannot recharge this plan'); + } if ($routes['2'] == 'radius') { $router_name = 'radius'; } else { diff --git a/system/controllers/pool.php b/system/controllers/pool.php index de7b2932..2261d8eb 100644 --- a/system/controllers/pool.php +++ b/system/controllers/pool.php @@ -68,6 +68,8 @@ switch ($action) { Mikrotik::removePool($client, $d['pool_name']); } catch (Exception $e) { //ignore exception, it means router has already deleted + } catch(Throwable $e){ + //ignore exception, it means router has already deleted } } $d->delete(); diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index ea521c8a..63f27c86 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -159,7 +159,7 @@ switch ($action) { case 'print': $id = _post('id'); $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one(); - $ui->assign('d', $d); + $ui->assign('in', $d); $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time'])); run_hook('print_invoice'); #HOOK diff --git a/system/controllers/services.php b/system/controllers/services.php index 093c1343..4909a9c3 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -173,6 +173,8 @@ switch ($action) { Mikrotik::removeHotspotPlan($client, $d['name_plan']); } catch (Exception $e) { //ignore exception, it means router has already deleted + } catch(Throwable $e){ + //ignore exception, it means router has already deleted } } @@ -441,6 +443,8 @@ switch ($action) { Mikrotik::removePpoePlan($client, $d['name_plan']); } catch (Exception $e) { //ignore exception, it means router has already deleted + } catch(Throwable $e){ + //ignore exception, it means router has already deleted } } $d->delete(); diff --git a/system/cron.php b/system/cron.php index cac928ab..be5b42e6 100644 --- a/system/cron.php +++ b/system/cron.php @@ -35,16 +35,16 @@ if (php_sapi_name() !== 'cli') { echo "
"; } -if(!file_exists('../config.php')){ +if (!file_exists('../config.php')) { die("config.php file not found"); } -if(!file_exists('orm.php')){ +if (!file_exists('orm.php')) { die("orm.php file not found"); } -if(!file_exists('uploads/notifications.default.json')){ +if (!file_exists('uploads/notifications.default.json')) { die("uploads/notifications.default.json file not found"); } @@ -68,7 +68,13 @@ $_notifmsg_default = json_decode(file_get_contents('uploads/notifications.defaul //register all plugin foreach (glob(File::pathFixer("plugin/*.php")) as $filename) { - include $filename; + try{ + include $filename; + } catch(Throwable $e){ + //ignore plugin error + }catch(Exception $e){ + //ignore plugin error + } } $result = ORM::for_table('tbl_appconfig')->find_many(); @@ -111,9 +117,9 @@ foreach ($d as $ds) { echo " : EXPIRED \r\n"; $u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one(); $c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one(); - $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); + $m = Mikrotik::info($ds['routers']); $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); - + $price = Lang::moneyFormat($p['price']); if ($p['is_radius']) { if (empty($p['pool_expired'])) { print_r(Radius::customerDeactivate($c['username'])); @@ -130,14 +136,14 @@ foreach ($d as $ds) { } Mikrotik::removeHotspotActiveUser($client, $c['username']); } - Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); + echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $price, $textExpired, $config['user_notification_expired'])."\n"; //update database user dengan status off $u->status = 'off'; $u->save(); // autorenewal from deposit if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) { - if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] =='yes') { + if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] == 'yes') { if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) { // if success, then get the balance Balance::min($ds['customer_id'], $p['price']); @@ -156,7 +162,8 @@ foreach ($d as $ds) { } else { echo "no renewall | balance $config[enable_balance] auto_renewal $c[auto_renewal]\n"; } - } else echo " : ACTIVE \r\n"; + } else + echo " : ACTIVE \r\n"; } else { $date_now = strtotime(date("Y-m-d H:i:s")); $expiration = strtotime($ds['expiration'] . ' ' . $ds['time']); @@ -167,7 +174,7 @@ foreach ($d as $ds) { $c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one(); $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); - + $price = Lang::moneyFormat($p['price']); if ($p['is_radius']) { if (empty($p['pool_expired'])) { print_r(Radius::customerDeactivate($c['username'])); @@ -184,14 +191,14 @@ foreach ($d as $ds) { } Mikrotik::removePpoeActive($client, $c['username']); } - Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $textExpired, $config['user_notification_expired']); + echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $price, $textExpired, $config['user_notification_expired'])."\n"; $u->status = 'off'; $u->save(); // autorenewal from deposit if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) { - if ($p && $p['enabled'] && $c['balance'] >= $p['price']&& $p['allow_purchase'] =='yes') { + if ($p && $p['enabled'] && $c['balance'] >= $p['price'] && $p['allow_purchase'] == 'yes') { if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) { // if success, then get the balance Balance::min($ds['customer_id'], $p['price']); @@ -206,6 +213,7 @@ foreach ($d as $ds) { } } } - } else echo " : ACTIVE \r\n"; + } else + echo " : ACTIVE \r\n"; } } diff --git a/system/cron_reminder.php b/system/cron_reminder.php index 1b77aac8..b09b7dec 100644 --- a/system/cron_reminder.php +++ b/system/cron_reminder.php @@ -67,7 +67,13 @@ $_notifmsg_default = json_decode(file_get_contents('uploads/notifications.defaul //register all plugin foreach (glob(File::pathFixer("plugin/*.php")) as $filename) { - include $filename; + try{ + include $filename; + } catch(Throwable $e){ + //ignore plugin error + }catch(Exception $e){ + //ignore plugin error + } } $result = ORM::for_table('tbl_appconfig')->find_many(); @@ -98,13 +104,15 @@ print_r([$day1, $day3, $day7]); foreach ($d as $ds) { if (in_array($ds['expiration'], [$day1, $day3, $day7])) { $u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one(); + $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); $c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one(); + $price = Lang::moneyFormat($p['price']); if ($ds['expiration'] == $day7) { - echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n"; + echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $p['name_plan'], $price, Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n"; } else if ($ds['expiration'] == $day3) { - echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_3_day'), $config['user_notification_reminder']) . "\n"; + echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $p['name_plan'], $price, Lang::getNotifText('reminder_3_day'), $config['user_notification_reminder']) . "\n"; } else if ($ds['expiration'] == $day1) { - echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_1_day'), $config['user_notification_reminder']) . "\n"; + echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $p['name_plan'], $price, Lang::getNotifText('reminder_1_day'), $config['user_notification_reminder']) . "\n"; } } } diff --git a/system/lan/english/common.lan.php b/system/lan/english/common.lan.php index 2dd0680e..5345f97f 100644 --- a/system/lan/english/common.lan.php +++ b/system/lan/english/common.lan.php @@ -3,8 +3,6 @@ ----------------------------------- Language Name: English Contributor: Ismail Marzuqi -Web: www.phpnuxbill.com -Email: iesien22@yahoo.com 2017 Contributor: Ibnu Maksum (@ibnux) @@ -261,7 +259,6 @@ $_L['Plan_Not_found'] = 'Plan Not found'; $_L['Failed_to_create_transaction'] = 'Failed to create transaction.'; $_L['Seller_has_not_yet_setup_Xendit_payment_gateway'] = 'Seller has not yet setup Xendit payment gateway'; $_L['Admin_has_not_yet_setup_Xendit_payment_gateway_please_tell_admin'] = 'Admin has not yet setup Xendit payment gateway, please tell admin'; -$_L['Buy_this_your_active_package_will_be_overwrite'] = 'Buy this? your active package will be overwrite'; $_L['You_already_have_unpaid_transaction_cancel_it_or_pay_it'] = 'You already have unpaid transaction, cancel it or pay it.'; $_L['Transaction_Not_found'] = 'Transaction Not found'; $_L['Cancel_it'] = 'Cancel it?'; @@ -314,7 +311,6 @@ $_L['User_Notification'] = 'User Notification'; $_L['Expired_Notification'] = 'Expired Notification'; $_L['User_will_get_notification_when_package_expired'] = 'User will get notification when package expired'; $_L['Expired_Notification_Message'] = 'Expired Notification Message'; -$_L['bnameb_will_be_replaced_with_Customer_Name_bpackageb_will_be_replaced_with_Package_name'] = '[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.'; $_L['Payment_Notification'] = 'Payment Notification'; $_L['User_will_get_invoice_notification_when_buy_package_or_package_refilled'] = 'User will get invoice notification when buy package or package refilled'; $_L['Current_IP'] = 'Current IP'; @@ -411,12 +407,14 @@ $_L['Resend_To_Customer'] = 'Resend To Customer'; $_L['Your_friend_do_not_have_active_package'] = 'Your friend do not have active package'; $_L['Service_Type'] = 'Service Type'; $_L['Others'] = 'Others'; -$_L['PPPoE'] = 'PPPoE'; -$_L['Hotspot'] = 'Hotspot'; -$_L['Disable_Registration'] = 'Disable Registration'; -$_L['Customer_just_Login_with_Phone_number_and_Voucher_Code_Voucher_will_be_password'] = 'Customer just Login with Phone number and Voucher Code, Voucher will be password'; -$_L['Login__Activate_Voucher'] = 'Login / Activate Voucher'; -$_L['After_Customer_activate_voucher_or_login_customer_will_be_redirected_to_this_url'] = 'After Customer activate voucher or login, customer will be redirected to this url'; -$_L['Voucher_Prefix'] = 'Voucher Prefix'; -$_L['Voucher_activation_success_now_you_can_login'] = 'Voucher activation success, now you can login'; -$_L['Client_Can_Purchase'] = 'Client Can Purchase'; +$_L['PPPoE'] = 'PPPoE'; +$_L['Hotspot'] = 'Hotspot'; +$_L['Disable_Registration'] = 'Disable Registration'; +$_L['Customer_just_Login_with_Phone_number_and_Voucher_Code_Voucher_will_be_password'] = 'Customer just Login with Phone number and Voucher Code, Voucher will be password'; +$_L['Login__Activate_Voucher'] = 'Login / Activate Voucher'; +$_L['After_Customer_activate_voucher_or_login_customer_will_be_redirected_to_this_url'] = 'After Customer activate voucher or login, customer will be redirected to this url'; +$_L['Voucher_Prefix'] = 'Voucher Prefix'; +$_L['Voucher_activation_success_now_you_can_login'] = 'Voucher activation success, now you can login'; +$_L['Client_Can_Purchase'] = 'Client Can Purchase'; +$_L['Buy_this_your_active_package_will_be_overwritten'] = 'Buy this? your active package will be overwritten'; +$_L['Pay_this_with_Balance_your_active_package_will_be_overwritten'] = 'Pay this with Balance? your active package will be overwritten'; diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php index f6a88e37..22c42831 100644 --- a/system/lan/indonesia/common.lan.php +++ b/system/lan/indonesia/common.lan.php @@ -3,9 +3,6 @@ ----------------------------------- Language Name: Indonesia Contributor: Ismail Marzuqi -Web: www.phpnuxbill.com -Email: iesien22@yahoo.com - 2017 Contributor: Ibnu Maksum (@ibnux) diff --git a/ui/ui/app-notifications.tpl b/ui/ui/app-notifications.tpl index b3d14000..2471c979 100644 --- a/ui/ui/app-notifications.tpl +++ b/ui/ui/app-notifications.tpl @@ -21,7 +21,7 @@ rows="3">{if $_json['expired']!=''}{Lang::htmlspecialchars($_json['expired'])}{else}Hello [[name]], your internet package [[package]] has been expired.{/if}- {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} + [[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name. [[price]] will be replaced with Package price.
@@ -33,7 +33,7 @@ rows="3">{Lang::htmlspecialchars($_json['reminder_7_day'])}- {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} + [[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name. [[price]] will be replaced with Package price.
@@ -45,7 +45,7 @@ rows="3">{Lang::htmlspecialchars($_json['reminder_3_day'])}- {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} + [[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name. [[price]] will be replaced with Package price.
@@ -57,7 +57,7 @@ rows="3">{Lang::htmlspecialchars($_json['reminder_1_day'])}- {Lang::T('[[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name.')} + [[name]] will be replaced with Customer Name. [[package]] will be replaced with Package name. [[price]] will be replaced with Package price.
diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index f84b56f5..12854e41 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -53,6 +53,14 @@ ++ ++ ++ For invoice print using Thermal Printer +-{if $_c['radius_enable']} +{if $_c['radius_enable'] && $d['is_radius']} {literal}diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index 4472be80..fd16f816 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -175,21 +175,20 @@ if (cek.checked) { $("#routerChoose").addClass('hidden'); document.getElementById("routers").required = false; + $("#pool_expired").html(''); + $.ajax({ + url: "index.php?_route=autoload/pool", + data: "routers=radius", + cache: false, + success: function(msg) { + $("#pool_expired").html(msg); + } + }); } else { document.getElementById("routers").required = true; $("#routerChoose").removeClass('hidden'); } } - setTimeout(() => { - $.ajax({ - url: "index.php?_route=autoload/pool", - data: "routers=radius", - cache: false, - success: function(msg) { - $("#pool_expired").html(msg); - } - }); - }, 2000); {/literal} {/if} diff --git a/ui/ui/hotspot-edit.tpl b/ui/ui/hotspot-edit.tpl index ffe6af7a..b5fa76a6 100644 --- a/ui/ui/hotspot-edit.tpl +++ b/ui/ui/hotspot-edit.tpl @@ -179,7 +179,7 @@