diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 66eefea0..51ee96f8 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -33,13 +33,6 @@ CREATE TABLE `tbl_customers` ( `last_login` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `tbl_customers_meta`; -CREATE TABLE `tbl_customers_meta` ( - `id` int(11) NOT NULL, - `customer_id` int(11) NOT NULL, - `meta_key` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', - `meta_value` longtext COLLATE utf8mb4_general_ci -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; DROP TABLE IF EXISTS `tbl_logs`; CREATE TABLE `tbl_logs` ( diff --git a/system/autoload/Mikrotik.php b/system/autoload/Mikrotik.php index bf28ad51..d917582a 100644 --- a/system/autoload/Mikrotik.php +++ b/system/autoload/Mikrotik.php @@ -515,6 +515,18 @@ class Mikrotik $client->sendSync($smsRequest); } + public static function getIpHotspotUser($client, $username){ + global $_app_stage; + if ($_app_stage == 'demo') { + return null; + } + $printRequest = new RouterOS\Request( + '/ip hotspot active print', + RouterOS\Query::where('user', $username) + ); + return $client->sendSync($printRequest)->getProperty('address'); + } + public static function addIpToAddressList($client, $ip, $listName, $comment = '') { global $_app_stage; diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 333cd830..1dff5f8d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -100,17 +100,6 @@ class Package if ($p['type'] == 'Hotspot') { if ($b) { - if ($p['is_radius']) { - Radius::customerAddPlan($c, $p, "$date_exp $time"); - }else{ - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removeHotspotUser($client, $c['username']); - Mikrotik::removePpoeUser($client, $c['username']); - Mikrotik::removeHotspotActiveUser($client, $c['username']); - Mikrotik::removePpoeActive($client, $c['username']); - Mikrotik::addHotspotUser($client, $p, $c); - } - if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') { // if it same internet plan, expired will extend if ($p['validity_unit'] == 'Months') { @@ -130,6 +119,17 @@ class Package } } + if ($p['is_radius']) { + Radius::customerAddPlan($c, $p, "$date_exp $time"); + }else{ + $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); + Mikrotik::addHotspotUser($client, $p, $c); + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; @@ -208,18 +208,6 @@ class Package } else { if ($b) { - if ($p['is_radius']) { - Radius::customerAddPlan($c, $p, "$date_exp $time"); - }else{ - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removeHotspotUser($client, $c['username']); - Mikrotik::removePpoeUser($client, $c['username']); - Mikrotik::removeHotspotActiveUser($client, $c['username']); - Mikrotik::removePpoeActive($client, $c['username']); - Mikrotik::addPpoeUser($client, $p, $c); - } - - if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') { // if it same internet plan, expired will extend if ($p['validity_unit'] == 'Months') { @@ -239,6 +227,17 @@ class Package } } + if ($p['is_radius']) { + Radius::customerAddPlan($c, $p, "$date_exp $time"); + }else{ + $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); + Mikrotik::removeHotspotActiveUser($client, $c['username']); + Mikrotik::removePpoeActive($client, $c['username']); + Mikrotik::addPpoeUser($client, $p, $c); + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 5e3826b6..113c1209 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -280,14 +280,16 @@ switch ($action) { 'username' => '%' . $search . '%', ['user_type' => 'Report'], ['user_type' => 'Agent'], - ['user_type' => 'Sales'] + ['user_type' => 'Sales'], + ['id' => $admin['id']] ], $search); $d = ORM::for_table('tbl_users') ->where_like('username', '%' . $search . '%') ->where_any_is([ ['user_type' => 'Report'], ['user_type' => 'Agent'], - ['user_type' => 'Sales'] + ['user_type' => 'Sales'], + ['id' => $admin['id']] ]) ->offset($paginator['startpoint']) ->limit($paginator['limit'])->order_by_asc('id')->findArray(); @@ -311,7 +313,8 @@ switch ($action) { $d = ORM::for_table('tbl_users')->where_any_is([ ['user_type' => 'Report'], ['user_type' => 'Agent'], - ['user_type' => 'Sales'] + ['user_type' => 'Sales'], + ['id' => $admin['id']] ])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray(); } else { $paginator = Paginator::build(ORM::for_table('tbl_users')); @@ -591,7 +594,9 @@ switch ($action) { $d->city = $city; $d->subdistrict = $subdistrict; $d->ward = $ward; - $d->status = $status; + if(isset($_POST['status'])){ + $d->status = $status; + } if ($admin['user_type'] == 'Agent') { // Prevent hacking from form diff --git a/system/cron.php b/system/cron.php index e3cdd5b2..de95b87f 100644 --- a/system/cron.php +++ b/system/cron.php @@ -46,8 +46,9 @@ foreach ($d as $ds) { $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); if (!empty($p['pool_expired'])) { Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']); - }if (!empty($p['list_expired'])) { - Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']); + // }if (!empty($p['list_expired'])) { + // $ip = Mikrotik::getIpHotspotUser($client, $ds['username']); + // Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']); } else { Mikrotik::removeHotspotUser($client, $c['username']); } diff --git a/system/lan/english.json b/system/lan/english.json index 0f7f8bd3..602a1cda 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -418,5 +418,8 @@ "Expired_Action": "Expired Action", "Expired_Address_List_Name": "Expired Address List Name", "Address_List": "Address List", - "Optional": "Optional" + "Optional": "Optional", + "Generated_By": "Generated By", + "Admin": "Admin", + "Password_should_be_minimum_6_characters": "Password should be minimum 6 characters" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index b6a03853..ab751d9b 100644 --- a/system/updates.json +++ b/system/updates.json @@ -62,5 +62,8 @@ "2024.2.20" : [ "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`;" + ], + "2024.2.20.1" : [ + "DROP TABLE IF EXISTS `tbl_customers_meta`;" ] } \ No newline at end of file diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index 5d4c43be..20094b14 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -157,12 +157,12 @@ -
+ {*
-
+
*}
-
+ {*
-
+
*}
-
+ {*
-
+
*}
-
+ {*
-
+
*}