diff --git a/system/controllers/order.php b/system/controllers/order.php index 3905596b..a14d15e0 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')->find_many(); + $plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->where('allow_purchase', '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')->find_many(); - $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->find_many(); + $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(); } 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')->find_many(); - $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->find_many(); + $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(); } } else { - $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->find_many(); - $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->find_many(); + $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(); $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')->find_many(); - $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->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(); } $ui->assign('routers', $routers); $ui->assign('radius_pppoe', $radius_pppoe); @@ -277,7 +277,7 @@ switch ($action) { $router['id'] = 0; $router['name'] = 'balance'; } - $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']); + $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->where('allow_purchase', 'yes')->find_one($routes['3']); if (empty($router) || empty($plan)) { r2(U . "order/package", 'e', Lang::T("Plan Not found")); } diff --git a/system/controllers/services.php b/system/controllers/services.php index 1bd88e09..093c1343 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -199,6 +199,7 @@ switch ($action) { $routers = _post('routers'); $pool_expired = _post('pool_expired'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -264,6 +265,7 @@ switch ($action) { $d->pool_expired = $pool_expired; } $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); $plan_id = $d->id(); @@ -302,6 +304,7 @@ switch ($action) { $validity_unit = _post('validity_unit'); $pool_expired = _post('pool_expired'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); $routers = _post('routers'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -363,6 +366,7 @@ switch ($action) { $d->shared_users = $sharedusers; $d->pool_expired = $pool_expired; $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']); @@ -456,6 +460,8 @@ switch ($action) { $pool = _post('pool_name'); $pool_expired = _post('pool_expired'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); + $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -514,6 +520,7 @@ switch ($action) { $d->pool_expired = $pool_expired; } $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); $plan_id = $d->id(); @@ -545,6 +552,7 @@ switch ($action) { $pool = _post('pool_name'); $pool_expired = _post('pool_expired'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -602,6 +610,7 @@ switch ($action) { $d->pool = $pool; $d->pool_expired = $pool_expired; $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']); @@ -653,6 +662,7 @@ switch ($action) { $name = _post('name'); $price = _post('price'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); $msg = ''; if (Validator::UnsignedNumber($price) == false) { @@ -672,6 +682,7 @@ switch ($action) { $d->name_plan = $name; $d->price = $price; $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); r2(U . 'services/balance', 's', $_L['Updated_Successfully']); @@ -683,6 +694,7 @@ switch ($action) { $name = _post('name'); $price = _post('price'); $enabled = _post('enabled'); + $allow_purchase = _post('allow_purchase'); $msg = ''; if (Validator::UnsignedNumber($price) == false) { @@ -708,6 +720,7 @@ switch ($action) { $d->routers = ''; $d->pool = ''; $d->enabled = $enabled; + $d->allow_purchase = $allow_purchase; $d->save(); r2(U . 'services/balance', 's', $_L['Created_Successfully']); diff --git a/system/updates.json b/system/updates.json index 06e365a8..2d07b866 100644 --- a/system/updates.json +++ b/system/updates.json @@ -38,5 +38,8 @@ ], "2023.12.15": [ "ALTER TABLE `tbl_customers` ADD `service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type' AFTER `balance`;" + ], + "2024.1.11": [ + "ALTER TABLE `tbl_plans` ADD `allow_purchase` ENUM('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page' AFTER `enabled`;" ] } \ No newline at end of file diff --git a/ui/ui/balance-add.tpl b/ui/ui/balance-add.tpl index 8fa3c734..c442906b 100644 --- a/ui/ui/balance-add.tpl +++ b/ui/ui/balance-add.tpl @@ -17,6 +17,17 @@ +