From ed9a4110959b2665a5de5acf380e34907a315466 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 09:37:45 +0700 Subject: [PATCH 1/7] Fix install Plugin --- system/controllers/pluginmanager.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/controllers/pluginmanager.php b/system/controllers/pluginmanager.php index c6eb5996..a289e0bf 100644 --- a/system/controllers/pluginmanager.php +++ b/system/controllers/pluginmanager.php @@ -32,7 +32,6 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { file_put_contents($cache, $data); $json = json_decode($data, true); } - switch ($action) { case 'delete': if (!is_writeable($CACHE_PATH)) { @@ -89,7 +88,9 @@ switch ($action) { if (!is_writeable($PLUGIN_PATH)) { r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable'); } - + set_time_limit(-1); + $tipe = $routes['2']; + $plugin = $routes['3']; $file = $CACHE_PATH . DIRECTORY_SEPARATOR . $plugin . '.zip'; if (file_exists($file)) unlink($file); if ($tipe == 'plugin') { @@ -121,7 +122,7 @@ switch ($action) { File::copyFolder($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']); File::deleteFolder($folder); unlink($file); - r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been deleted'); + r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed'); break; } } From ca0edb4e17aeb7919a96aedd71c21024ac4db9b3 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:32:10 +0700 Subject: [PATCH 2/7] Postpaid --- install/phpnuxbill.sql | 3 +- system/autoload/Package.php | 31 ++++++++--- system/autoload/User.php | 91 +++++++++++++++++++++++++++------ system/controllers/order.php | 18 +++---- system/controllers/prepaid.php | 6 ++- system/controllers/services.php | 23 ++++----- system/lan/english.json | 2 +- system/updates.json | 3 ++ ui/ui/autoload.tpl | 2 +- ui/ui/balance-add.tpl | 11 ---- ui/ui/balance-edit.tpl | 12 ----- ui/ui/deposit.tpl | 2 +- ui/ui/hotspot-add.tpl | 33 ++++++++---- ui/ui/hotspot-edit.tpl | 58 ++++++++++++++------- ui/ui/hotspot.tpl | 2 +- ui/ui/pppoe-add.tpl | 30 +++++++---- ui/ui/pppoe-edit.tpl | 52 +++++++++++++------ ui/ui/pppoe.tpl | 2 +- ui/ui/recharge.tpl | 1 + ui/ui/sections/user-header.tpl | 87 +++++++++++++++---------------- ui/ui/user-dashboard.tpl | 10 +++- 21 files changed, 305 insertions(+), 174 deletions(-) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 1e5ea998..3ea5e188 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -315,4 +315,5 @@ ALTER TABLE `tbl_customers` ADD `created_by` INT NOT NULL DEFAULT '0' AFTER `aut ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`; ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`; ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`; -ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`; \ No newline at end of file +ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`; +ALTER TABLE `tbl_plans` CHANGE `allow_purchase` `prepaid` ENUM('yes','no') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'yes' COMMENT 'is prepaid'; \ No newline at end of file diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 3bbc7405..8c585d94 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -32,12 +32,12 @@ class Package $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one(); - if(isset($zero) && $zero==1){ + if (isset($zero) && $zero == 1) { $p['price'] = 0; } - if(!$p['enabled']){ - if(!isset($admin) || !isset($admin['id']) || empty($admin['id'])){ + if (!$p['enabled']) { + if (!isset($admin) || !isset($admin['id']) || empty($admin['id'])) { r2(U . 'home', 'e', Lang::T('Plan Not found')); } if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { @@ -114,12 +114,29 @@ class Package } /** - * 1 Customer only can have 1 PPPOE and 1 Hotspot Plan + * 1 Customer only can have 1 PPPOE and 1 Hotspot Plan, 1 prepaid and 1 postpaid */ $b = ORM::for_table('tbl_user_recharges') + ->select('tbl_user_recharges.id', 'id') + ->select('customer_id') + ->select('username') + ->select('plan_id') + ->select('namebp') + ->select('recharged_on') + ->select('recharged_time') + ->select('expiration') + ->select('time') + ->select('status') + ->select('method') + ->select('tbl_user_recharges.routers', 'routers') + ->select('tbl_user_recharges.type', 'type') + ->select('admin_id') + ->select('prepaid') ->where('customer_id', $id_customer) - ->where('routers', $router_name) - ->where('Type', $p['type']) + ->where('tbl_user_recharges.routers', $router_name) + ->where('tbl_user_recharges.Type', $p['type']) + ->where('prepaid', $p['prepaid']) + ->join('tbl_plans', array('tbl_plans.id', '=', 'tbl_user_recharges.plan_id')) ->find_one(); run_hook("recharge_user"); @@ -608,7 +625,7 @@ class Package public static function _raid() { - return ORM::for_table('tbl_transactions')->max('id')+1; + return ORM::for_table('tbl_transactions')->max('id') + 1; } /** diff --git a/system/autoload/User.php b/system/autoload/User.php index 645190c7..af0a05f6 100644 --- a/system/autoload/User.php +++ b/system/autoload/User.php @@ -8,15 +8,16 @@ class User { - public static function getID(){ + public static function getID() + { global $db_password; - if(isset($_SESSION['uid']) && !empty($_SESSION['uid'])){ + if (isset($_SESSION['uid']) && !empty($_SESSION['uid'])) { return $_SESSION['uid']; - }else if(isset($_COOKIE['uid'])){ + } else if (isset($_COOKIE['uid'])) { // id.time.sha1 - $tmp = explode('.',$_COOKIE['uid']); - if(sha1($tmp[0].'.'.$tmp[1].'.'.$db_password)==$tmp[2]){ - if(time()-$tmp[1] < 86400*30){ + $tmp = explode('.', $_COOKIE['uid']); + if (sha1($tmp[0] . '.' . $tmp[1] . '.' . $db_password) == $tmp[2]) { + if (time() - $tmp[1] < 86400 * 30) { $_SESSION['uid'] = $tmp[0]; return $tmp[0]; } @@ -25,37 +26,93 @@ class User return 0; } - public static function setCookie($uid){ + public static function getAttribute($name, $id = 0) + { + if (!$id) { + $id = User::getID(); + } + if (!$id) { + return ''; + } + $f = ORM::for_table('tbl_customers_fields')->where('field_name', $name)->where('customer_id', $id)->find_one(); + if ($f) { + return $f['field_value']; + } + return ''; + } + + public static function getAttributes($endWith, $id = 0) + { + if (!$id) { + $id = User::getID(); + } + if (!$id) { + return []; + } + $attrs = []; + $f = ORM::for_table('tbl_customers_fields')->where_like('field_name', $endWith)->where('customer_id', $id)->find_one(); + if ($f) { + foreach ($f as $k) { + $attrs[$k['field_name']] = $k['field_value']; + } + return $attrs; + } + return []; + } + + public static function setCookie($uid) + { global $db_password; - if(isset($uid)){ + if (isset($uid)) { $time = time(); - setcookie('uid', $uid.'.'.$time.'.'.sha1($uid.'.'.$time.'.'.$db_password), time()+86400*30); + setcookie('uid', $uid . '.' . $time . '.' . sha1($uid . '.' . $time . '.' . $db_password), time() + 86400 * 30); } } - public static function removeCookie(){ - if(isset($_COOKIE['uid'])){ - setcookie('uid', '', time()-86400); + public static function removeCookie() + { + if (isset($_COOKIE['uid'])) { + setcookie('uid', '', time() - 86400); } } public static function _info($id = 0) { - if(!$id){ + if (!$id) { $id = User::getID(); } $d = ORM::for_table('tbl_customers')->find_one($id); - if(empty($d['username'])){ + if (empty($d['username'])) { r2(U . 'logout', 'd', ''); } return $d; } - public static function _billing() + public static function _billing($id = 0) { - $id = User::getID(); - $d = ORM::for_table('tbl_user_recharges')->where('customer_id', $id)->find_many(); + if (!$id) { + $id = User::getID(); + } + $d = ORM::for_table('tbl_user_recharges') + ->select('tbl_user_recharges.id', 'id') + ->select('customer_id') + ->select('username') + ->select('plan_id') + ->select('namebp') + ->select('recharged_on') + ->select('recharged_time') + ->select('expiration') + ->select('time') + ->select('status') + ->select('method') + ->select('tbl_user_recharges.routers', 'routers') + ->select('tbl_user_recharges.type', 'type') + ->select('admin_id') + ->select('prepaid') + ->where('customer_id', $id) + ->join('tbl_plans', array('tbl_plans.id', '=', 'tbl_user_recharges.plan_id')) + ->find_many(); return $d; } } diff --git a/system/controllers/order.php b/system/controllers/order.php index 03bdfd97..08ae8067 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -37,7 +37,7 @@ switch ($action) { } $ui->assign('_title', 'Top Up'); $ui->assign('_system_menu', 'balance'); - $plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->where('allow_purchase', 'yes')->find_many(); + $plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->where('prepaid', 'yes')->find_many(); $ui->assign('plans_balance', $plans_balance); $ui->display('user-orderBalance.tpl'); break; @@ -49,24 +49,24 @@ switch ($action) { $ui->assign('_system_menu', 'package'); if (!empty($_SESSION['nux-router'])) { if ($_SESSION['nux-router'] == 'radius') { - $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many(); - $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many(); + $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many(); + $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many(); } else { $routers = ORM::for_table('tbl_routers')->where('id', $_SESSION['nux-router'])->find_many(); $rs = []; foreach ($routers as $r) { $rs[] = $r['name']; } - $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many(); - $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many(); + $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many(); + $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many(); } } else { - $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many(); - $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many(); + $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many(); + $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many(); $routers = ORM::for_table('tbl_routers')->find_many(); - $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many(); - $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many(); + $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many(); + $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many(); } $ui->assign('routers', $routers); $ui->assign('radius_pppoe', $radius_pppoe); diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index f31aadd5..af66d95a 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -692,7 +692,11 @@ switch ($action) { } $ui->assign('_title', Lang::T('Refill Balance')); $ui->assign('xfooter', $select2_customer); - $ui->assign('p', ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many()); + if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { + $ui->assign('p', ORM::for_table('tbl_plans')->where('type', 'Balance')->find_many()); + }else{ + $ui->assign('p', ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many()); + } run_hook('view_deposit'); #HOOK $ui->display('deposit.tpl'); break; diff --git a/system/controllers/services.php b/system/controllers/services.php index 29991dc7..d0fb3b41 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -201,7 +201,7 @@ switch ($action) { $pool_expired = _post('pool_expired'); $list_expired = _post('list_expired'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); + $prepaid = _post('prepaid'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -269,7 +269,7 @@ switch ($action) { $d->pool_expired = $pool_expired; $d->list_expired = $list_expired; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = $prepaid; $d->save(); $plan_id = $d->id(); @@ -309,7 +309,7 @@ switch ($action) { $pool_expired = _post('pool_expired'); $list_expired = _post('list_expired'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); + $prepaid = _post('prepaid'); $routers = _post('routers'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -374,7 +374,7 @@ switch ($action) { $d->pool_expired = $pool_expired; $d->list_expired = $list_expired; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = $prepaid; $d->save(); r2(U . 'services/hotspot', 's', Lang::T('Data Updated Successfully')); @@ -471,7 +471,7 @@ switch ($action) { $pool_expired = _post('pool_expired'); $list_expired = _post('list_expired'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); + $prepaid = _post('prepaid'); $msg = ''; @@ -533,7 +533,7 @@ switch ($action) { $d->pool_expired = $pool_expired; $d->list_expired = $list_expired; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = $prepaid; $d->save(); $plan_id = $d->id(); @@ -566,7 +566,7 @@ switch ($action) { $pool_expired = _post('pool_expired'); $list_expired = _post('list_expired'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); + $prepaid = _post('prepaid'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -626,7 +626,7 @@ switch ($action) { $d->pool_expired = $pool_expired; $d->list_expired = $list_expired; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = $prepaid; $d->save(); r2(U . 'services/pppoe', 's', Lang::T('Data Updated Successfully')); @@ -678,7 +678,7 @@ switch ($action) { $name = _post('name'); $price = _post('price'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); + $prepaid = _post('prepaid'); $msg = ''; if (Validator::UnsignedNumber($price) == false) { @@ -698,7 +698,7 @@ switch ($action) { $d->name_plan = $name; $d->price = $price; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = 'yes'; $d->save(); r2(U . 'services/balance', 's', Lang::T('Data Updated Successfully')); @@ -710,7 +710,6 @@ switch ($action) { $name = _post('name'); $price = _post('price'); $enabled = _post('enabled'); - $allow_purchase = _post('allow_purchase'); $msg = ''; if (Validator::UnsignedNumber($price) == false) { @@ -736,7 +735,7 @@ switch ($action) { $d->routers = ''; $d->pool = ''; $d->enabled = $enabled; - $d->allow_purchase = $allow_purchase; + $d->prepaid = 'yes'; $d->save(); r2(U . 'services/balance', 's', Lang::T('Data Created Successfully')); diff --git a/system/lan/english.json b/system/lan/english.json index 4e8d8977..08349a9f 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -468,7 +468,7 @@ "Payment_Gateway_Deleted": "Payment Gateway Deleted", "Payment_Gateway_not_set__please_set_it_in_Settings": "Payment Gateway not set, please set it in Settings", "Failed_to_create_Transaction__": "Failed to create Transaction..", - "Show_To_Customer": "Show To Customer", + "Show_To_Customer": "Type", "Using": "Using", "Default": "Default", "Customer_Balance": "Customer Balance" diff --git a/system/updates.json b/system/updates.json index aa67225a..60cd6177 100644 --- a/system/updates.json +++ b/system/updates.json @@ -72,5 +72,8 @@ ], "2024.3.3" : [ "ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;" + ], + "2024.3.12" : [ + "ALTER TABLE `tbl_plans` CHANGE `allow_purchase` `prepaid` ENUM('yes','no') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'yes' COMMENT 'is prepaid';" ] } \ No newline at end of file diff --git a/ui/ui/autoload.tpl b/ui/ui/autoload.tpl index 30ff8b96..e5dffbcf 100644 --- a/ui/ui/autoload.tpl +++ b/ui/ui/autoload.tpl @@ -1,4 +1,4 @@ {foreach $d as $ds} - + {/foreach} \ No newline at end of file diff --git a/ui/ui/balance-add.tpl b/ui/ui/balance-add.tpl index 748ffcba..d2116352 100644 --- a/ui/ui/balance-add.tpl +++ b/ui/ui/balance-add.tpl @@ -17,17 +17,6 @@ -
- -
- - -
-
diff --git a/ui/ui/balance-edit.tpl b/ui/ui/balance-edit.tpl index e188f0ec..4ca8bd8e 100644 --- a/ui/ui/balance-edit.tpl +++ b/ui/ui/balance-edit.tpl @@ -18,18 +18,6 @@
-
- -
- - -
-
diff --git a/ui/ui/deposit.tpl b/ui/ui/deposit.tpl index 6a29897b..1fa74c6b 100644 --- a/ui/ui/deposit.tpl +++ b/ui/ui/deposit.tpl @@ -21,7 +21,7 @@ data-placeholder="{Lang::T('Select Plans')}..."> {foreach $p as $pl} - + {/foreach}
diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index f2f86d0e..f0528edd 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -14,10 +14,10 @@
- +
- Yes - No + Prepaid + Postpaid
{if $_c['radius_enable']} @@ -118,17 +118,12 @@
-

{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}

+

{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}

@@ -163,8 +158,7 @@
*}
- + Or {Lang::T('Cancel')}
@@ -173,6 +167,23 @@ + {if $_c['radius_enable']} {literal} + {if $_c['radius_enable'] && $d['is_radius']} {literal} {/literal} {/if} -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/hotspot.tpl b/ui/ui/hotspot.tpl index 8ce5f656..3662d386 100644 --- a/ui/ui/hotspot.tpl +++ b/ui/ui/hotspot.tpl @@ -51,7 +51,7 @@ {foreach $d as $ds} + {elseif $ds['prepaid'] != 'yes'}class="warning" title="Postpaid" {/if}> {$ds['name_plan']} {$ds['typebp']} {$ds['name_bw']} diff --git a/ui/ui/pppoe-add.tpl b/ui/ui/pppoe-add.tpl index 1ef2d80f..b0e55ded 100644 --- a/ui/ui/pppoe-add.tpl +++ b/ui/ui/pppoe-add.tpl @@ -14,10 +14,10 @@
- +
- Yes - No + Prepaid + Postpaid
{if $_c['radius_enable']} @@ -60,17 +60,12 @@
-

{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}

+

{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}

+ {if $_c['radius_enable']} {literal} {if $_c['radius_enable'] && $d['is_radius']} {literal} {/literal} {/if} -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/pppoe.tpl b/ui/ui/pppoe.tpl index 68c216f6..4bb711e6 100644 --- a/ui/ui/pppoe.tpl +++ b/ui/ui/pppoe.tpl @@ -49,7 +49,7 @@ {foreach $d as $ds} + {elseif $ds['prepaid'] != 'yes'}class="warning" title="Postpaid" {/if}> {$ds['name_plan']} {$ds['name_bw']} {Lang::moneyFormat($ds['price'])} diff --git a/ui/ui/recharge.tpl b/ui/ui/recharge.tpl index b07c990d..58fd9848 100644 --- a/ui/ui/recharge.tpl +++ b/ui/ui/recharge.tpl @@ -52,6 +52,7 @@ +

Postpaid Recharge for the first time use {$_c['currency_code']} 0

diff --git a/ui/ui/sections/user-header.tpl b/ui/ui/sections/user-header.tpl index af5343ca..030b0fed 100644 --- a/ui/ui/sections/user-header.tpl +++ b/ui/ui/sections/user-header.tpl @@ -37,36 +37,36 @@ margin-top: 100px; } } - - + + .loading { - pointer-events: none; - opacity: 0.7; + pointer-events: none; + opacity: 0.7; } - + .loading::after { - content: ""; - display: inline-block; - width: 16px; - height: 16px; - vertical-align: middle; - margin-left: 10px; - border: 2px solid #fff; - border-top-color: transparent; - border-radius: 50%; - animation: spin 0.8s infinite linear; + content: ""; + display: inline-block; + width: 16px; + height: 16px; + vertical-align: middle; + margin-left: 10px; + border: 2px solid #fff; + border-top-color: transparent; + border-radius: 50%; + animation: spin 0.8s infinite linear; } - + @keyframes spin { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } } - + {if isset($xheader)} {$xheader} @@ -90,7 +90,8 @@
  • @@ -197,20 +198,20 @@ {if isset($notify)} - - {/if} \ No newline at end of file + +{/if} \ No newline at end of file diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index 732f4414..a2f19db9 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -148,13 +148,19 @@ {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  - {if $nux_ip} + + {Lang::T('Type')} + + {if $_bill['prepaid'] eq yes}Prepaid{else}Postpaid{/if} + + + {if $nux_ip neq ''} {Lang::T('Current IP')} {$nux_ip} {/if} - {if $nux_mac} + {if $nux_mac neq ''} {Lang::T('Current MAC')} {$nux_mac} From e6e993cf2114378c52fa7727d089b3adc42a3168 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:40:47 +0700 Subject: [PATCH 3/7] Expired day postpaid --- system/autoload/Package.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 8c585d94..661fc62b 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -46,16 +46,16 @@ class Package } if ($p['validity_unit'] == 'Period') { - $f = ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one(); - if (!$f) { - $day = date('d', strtotime($c['created_at'])); - if ($day > 28) { - $day = 1; + $day_exp = User::getAttribute("Expired Date", $c['id']); //ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one(); + if (!$day_exp) { + $day_exp = date('d', strtotime($c['created_at'])); + if (empty($day_exp) || $day_exp > 28) { + $day_exp = 1; } $f = ORM::for_table('tbl_customers_fields')->create(); $f->customer_id = $c['id']; $f->field_name = 'Expired Date'; - $f->field_value = $day; + $f->field_value = $day_exp; $f->save(); } } @@ -146,15 +146,15 @@ class Package if ($p['validity_unit'] == 'Months') { $date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month')); } else if ($p['validity_unit'] == 'Period') { - $date_tmp = date("Y-m-{$f['field_value']}", strtotime('+' . $p['validity'] . ' month')); + $date_tmp = date("Y-m-$day_exp", strtotime('+' . $p['validity'] . ' month')); $dt1 = new DateTime("$date_only"); $dt2 = new DateTime("$date_tmp"); $diff = $dt2->diff($dt1); $sum = $diff->format("%a"); // => 453 if ($sum >= 35) { - $date_exp = date("Y-m-{$f['field_value']}", strtotime('+0 month')); + $date_exp = date("Y-m-$day_exp", strtotime('+0 month')); } else { - $date_exp = date("Y-m-{$f['field_value']}", strtotime('+' . $p['validity'] . ' month')); + $date_exp = date("Y-m-$day_exp", strtotime('+' . $p['validity'] . ' month')); }; $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { @@ -177,7 +177,7 @@ class Package $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = $b['time']; } else if ($p['validity_unit'] == 'Period') { - $date_exp = date("Y-m-{$f['field_value']}", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + $date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); @@ -362,7 +362,7 @@ class Package $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = $b['time']; } else if ($p['validity_unit'] == 'Period') { - $date_exp = date("Y-m-{$f['field_value']}", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + $date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); From 60c573821b9812454f57e52cde6fc3b8f157a972 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:48:01 +0700 Subject: [PATCH 4/7] Additional Cost from Customer Attributes --- system/autoload/Package.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 661fc62b..a09691c1 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -32,8 +32,16 @@ class Package $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one(); + // Additional cost + $add_cost = User::getAttribute("Additional Cost", $id_customer); + if(empty($add_cost)){ + $add_cost = 0; + } + + // Zero cost recharge if (isset($zero) && $zero == 1) { $p['price'] = 0; + $add_cost = 0; } if (!$p['enabled']) { @@ -226,7 +234,7 @@ class Package $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; $t->recharged_on = $date_only; $t->recharged_time = $time_only; $t->expiration = $date_exp; @@ -306,12 +314,12 @@ class Package $fd = $td->format("%a"); $gi = ($p['price'] / 30) * $fd; if ($gi > $p['price']) { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } else { - $t->price = $gi; + $t->price = $gi + $add_cost; } } else { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } $t->recharged_on = $date_only; $t->recharged_time = $time_only; @@ -411,7 +419,7 @@ class Package $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; $t->recharged_on = $date_only; $t->recharged_time = $time_only; $t->expiration = $date_exp; @@ -490,12 +498,12 @@ class Package $fd = $td->format("%a"); $gi = ($p['price'] / 30) * $fd; if ($gi > $p['price']) { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } else { - $t->price = $gi; + $t->price = $gi + $add_cost; } } else { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } $t->recharged_on = $date_only; $t->recharged_time = $time_only; From c8f457498428899f1ea01e06c7e37dff78c3fe72 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:53:33 +0700 Subject: [PATCH 5/7] Recharge with additional Cost --- system/controllers/prepaid.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index af66d95a..95e89f7f 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -135,6 +135,10 @@ switch ($action) { $channel = $admin['fullname']; $cust = User::_info($id_customer); if ($using == 'balance' && $config['enable_balance'] == 'yes') { + $add_cost = User::getAttribute("Additional Cost", $id_customer); + if(empty($add_cost)){ + $add_cost = 0; + } $plan = ORM::for_table('tbl_plans')->find_one($planId); if (!$cust) { r2(U . 'prepaid/recharge', 'e', Lang::T('Customer not found')); @@ -142,7 +146,7 @@ switch ($action) { if (!$plan) { r2(U . 'prepaid/recharge', 'e', Lang::T('Plan not found')); } - if ($cust['balance'] < $plan['price']) { + if ($cust['balance'] < ($plan['price']+$add_cost)) { r2(U . 'prepaid/recharge', 'e', Lang::T('insufficient balance')); } $gateway = 'Recharge Balance'; @@ -153,7 +157,7 @@ switch ($action) { } if (Package::rechargeUser($id_customer, $server, $planId, $gateway, $channel)) { if ($using == 'balance') { - Balance::min($cust['id'], $plan['price']); + Balance::min($cust['id'], $plan['price']+$add_cost); } $in = ORM::for_table('tbl_transactions')->where('username', $cust['username'])->order_by_desc('id')->find_one(); Package::createInvoice($in); From b68e4d2e68d88c55867917ab07db1e5031438ee1 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:54:36 +0700 Subject: [PATCH 6/7] 2024.3.13 --- CHANGELOG.md | 5 +++++ version.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef564dfc..ab535414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ # CHANGELOG +## 2024.3.13 + +- Postpaid System +- Additional Cost + ## 2024.3.12 - Check if Validity Period, so calculate price will not affected other validity diff --git a/version.json b/version.json index 13a15d0a..5c44e79f 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.3.12" + "version": "2024.3.13" } \ No newline at end of file From afbab3dd4258d115efeda3908f1b0c807cca1405 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:34:57 +0100 Subject: [PATCH 7/7] Update dashboard.php fix reporting --- system/controllers/dashboard.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 2fb9abc2..caeeda52 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -19,6 +19,7 @@ $month_n = date('n'); $iday = ORM::for_table('tbl_transactions') ->where('recharged_on', $mdate) ->where_not_equal('method', 'Customer - Balance') + ->where_not_equal('method', 'Recharge Balance - Administrator') ->sum('price'); if ($iday == '') { @@ -26,7 +27,7 @@ if ($iday == '') { } $ui->assign('iday', $iday); -$imonth = ORM::for_table('tbl_transactions')->where_not_equal('method', 'Customer - Balance')->where_gte('recharged_on', $first_day_month)->where_lte('recharged_on', $mdate)->sum('price'); +$imonth = ORM::for_table('tbl_transactions')->where_not_equal('method', 'Customer - Balance')->where_not_equal('method', 'Recharge Balance - Administrator')->where_gte('recharged_on', $first_day_month)->where_lte('recharged_on', $mdate)->sum('price'); if ($imonth == '') { $imonth = '0.00'; } @@ -149,6 +150,7 @@ if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) { ->select_expr('SUM(price)', 'total') ->where_raw("YEAR(recharged_on) = YEAR(CURRENT_DATE())") // Filter by the current year ->where_not_equal('method', 'Customer - Balance') + ->where_not_equal('method', 'Recharge Balance - Administrator') ->group_by_expr('MONTH(recharged_on)') ->find_many();