diff --git a/CHANGELOG.md b/CHANGELOG.md index 717b42c8..25c78165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add pppoe customer and pppoe IP to make static username and IP - Add Sync button - Allow Mac Address Username +- Router Maps ## 2024.8.1 diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 4bf59e16..e3b66ef4 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -137,6 +137,8 @@ CREATE TABLE `tbl_routers` ( `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `coordinates` VARCHAR(50) NOT NULL DEFAULT '', + `coverage` VARCHAR(8) NOT NULL DEFAULT '0', `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; diff --git a/system/autoload/Paginator.php b/system/autoload/Paginator.php index 3899d7b9..3d8b9014 100644 --- a/system/autoload/Paginator.php +++ b/system/autoload/Paginator.php @@ -8,7 +8,7 @@ class Paginator { - public static function findMany($query, $search = [], $per_page = '10', $append_url = "") + public static function findMany($query, $search = [], $per_page = '10', $append_url = "", $toArray = false) { global $routes, $ui; $adjacents = "2"; @@ -71,7 +71,11 @@ class Paginator if ($ui) { $ui->assign('paginator', $result); } - return $query->offset($startpoint)->limit($per_page)->find_many(); + if($toArray){ + return $query->offset($startpoint)->limit($per_page)->find_array(); + }else{ + return $query->offset($startpoint)->limit($per_page)->find_many(); + } } } diff --git a/system/controllers/customers.php b/system/controllers/customers.php index baf166cd..5aa83e80 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -713,7 +713,6 @@ switch ($action) { die(); } $d = Paginator::findMany($query, ['search' => $search], 30, $append_url); - $ui->assign('xheader', ''); $ui->assign('d', $d); $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); $ui->assign('filter', $filter); diff --git a/system/controllers/routers.php b/system/controllers/routers.php index a507207a..23bbbfb7 100644 --- a/system/controllers/routers.php +++ b/system/controllers/routers.php @@ -18,24 +18,26 @@ if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); } +$leafletpickerHeader = << +EOT; + switch ($action) { - case 'list': - $ui->assign('xfooter', ''); - + case 'maps': $name = _post('name'); + $query = ORM::for_table('tbl_routers')->where_not_equal('coordinates', '')->order_by_desc('id'); + $query->selects(['id', 'name', 'coordinates', 'description', 'coverage', 'enabled']); if ($name != '') { - $query = ORM::for_table('tbl_routers')->where_like('name', '%' . $name . '%')->order_by_desc('id'); - $d = Paginator::findMany($query, ['name' => $name]); - } else { - $query = ORM::for_table('tbl_routers')->order_by_desc('id'); - $d = Paginator::findMany($query); + $query->where_like('name', '%' . $name . '%'); } - + $d = Paginator::findMany($query, ['name' => $name], '20', '', true); + $ui->assign('name', $name); $ui->assign('d', $d); - run_hook('view_list_routers'); #HOOK - $ui->display('routers.tpl'); + $ui->assign('_title', Lang::T('Routers Geo Location Information')); + $ui->assign('xheader', $leafletpickerHeader); + $ui->assign('xfooter', ''); + $ui->display('routers-maps.tpl'); break; - case 'add': run_hook('view_add_routers'); #HOOK $ui->display('routers-add.tpl'); @@ -47,6 +49,7 @@ switch ($action) { if (!$d) { $d = ORM::for_table('tbl_routers')->where_equal('name', _get('name'))->find_one(); } + $ui->assign('xheader', $leafletpickerHeader); if ($d) { $ui->assign('d', $d); run_hook('view_router_edit'); #HOOK @@ -75,16 +78,18 @@ switch ($action) { $enabled = _post('enabled'); $msg = ''; - if (Validator::Length($name, 30, 4) == false) { - $msg .= 'Name should be between 5 to 30 characters' . ''; - } - if ($ip_address == '' or $username == '') { - $msg .= Lang::T('All field is required') . ''; + if (Validator::Length($name, 30, 1) == false) { + $msg .= 'Name should be between 1 to 30 characters' . ''; } + if($enabled || _post("testIt")){ + if ($ip_address == '' or $username == '') { + $msg .= Lang::T('All field is required') . ''; + } - $d = ORM::for_table('tbl_routers')->where('ip_address', $ip_address)->find_one(); - if ($d) { - $msg .= Lang::T('IP Router Already Exist') . ''; + $d = ORM::for_table('tbl_routers')->where('ip_address', $ip_address)->find_one(); + if ($d) { + $msg .= Lang::T('IP Router Already Exist') . ''; + } } if (strtolower($name) == 'radius') { $msg .= 'Radius name is reserved'; @@ -92,7 +97,7 @@ switch ($action) { if ($msg == '') { run_hook('add_router'); #HOOK - if(_post("testIt")){ + if (_post("testIt")) { (new MikrotikHotspot())->getClient($ip_address, $username, $password); } $d = ORM::for_table('tbl_routers')->create(); @@ -104,7 +109,7 @@ switch ($action) { $d->enabled = $enabled; $d->save(); - r2(U . 'routers/list', 's', Lang::T('Data Created Successfully')); + r2(U . 'routers/edit/' . $d->id(), 's', Lang::T('Data Created Successfully')); } else { r2(U . 'routers/add', 'e', $msg); } @@ -117,13 +122,17 @@ switch ($action) { $username = _post('username'); $password = _post('password'); $description = _post('description'); + $coordinates = _post('coordinates'); + $coverage = _post('coverage'); $enabled = $_POST['enabled']; $msg = ''; if (Validator::Length($name, 30, 4) == false) { $msg .= 'Name should be between 5 to 30 characters' . ''; } - if ($ip_address == '' or $username == '') { - $msg .= Lang::T('All field is required') . ''; + if($enabled || _post("testIt")){ + if ($ip_address == '' or $username == '') { + $msg .= Lang::T('All field is required') . ''; + } } $id = _post('id'); @@ -141,10 +150,12 @@ switch ($action) { } $oldname = $d['name']; - if ($d['ip_address'] != $ip_address) { - $c = ORM::for_table('tbl_routers')->where('ip_address', $ip_address)->where_not_equal('id', $id)->find_one(); - if ($c) { - $msg .= 'IP Already Exists'; + if($enabled || _post("testIt")){ + if ($d['ip_address'] != $ip_address) { + $c = ORM::for_table('tbl_routers')->where('ip_address', $ip_address)->where_not_equal('id', $id)->find_one(); + if ($c) { + $msg .= 'IP Already Exists'; + } } } @@ -154,7 +165,7 @@ switch ($action) { if ($msg == '') { run_hook('router_edit'); #HOOK - if(_post("testIt")){ + if (_post("testIt")) { (new MikrotikHotspot())->getClient($ip_address, $username, $password); } $d->name = $name; @@ -162,6 +173,8 @@ switch ($action) { $d->username = $username; $d->password = $password; $d->description = $description; + $d->coordinates = $coordinates; + $d->coverage = $coverage; $d->enabled = $enabled; $d->save(); if ($name != $oldname) { @@ -191,5 +204,17 @@ switch ($action) { break; default: - r2(U . 'routers/list/', 's', ''); + $ui->assign('xfooter', ''); + + $name = _post('name'); + $name = _post('name'); + $query = ORM::for_table('tbl_routers')->order_by_desc('id'); + if ($name != '') { + $query->where_like('name', '%' . $name . '%'); + } + $d = Paginator::findMany($query, ['name' => $name]); + $ui->assign('d', $d); + run_hook('view_list_routers'); #HOOK + $ui->display('routers.tpl'); + break; } diff --git a/system/lan/english.json b/system/lan/english.json index d2d7717a..e775eb4f 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -690,5 +690,9 @@ "Mail_Deleted_Successfully": "Mail Deleted Successfully", "Message_Not_Found": "Message Not Found", "Send_Welcome_Message": "Send Welcome Message", - "WA": "WA" + "WA": "WA", + "_": "-", + "Routers_Maps": "Routers Maps", + "Routers_Geo_Location_Information": "Routers Geo Location Information", + "Coverage": "Coverage" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index 32df040d..87db6cf1 100644 --- a/system/updates.json +++ b/system/updates.json @@ -140,5 +140,9 @@ "2024.8.5" : [ "ALTER TABLE `tbl_customers` ADD `pppoe_username` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login' AFTER `password`;", "ALTER TABLE `tbl_customers` ADD `pppoe_ip` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login' AFTER `pppoe_password`;" + ], + "2024.8.5.1" : [ + "ALTER TABLE `tbl_routers` ADD `coordinates` VARCHAR(50) NOT NULL DEFAULT '' AFTER `description`;", + "ALTER TABLE `tbl_routers` ADD `coverage` VARCHAR(8) NOT NULL DEFAULT '0' AFTER `coordinates`;" ] } \ No newline at end of file diff --git a/ui/ui/routers-edit.tpl b/ui/ui/routers-edit.tpl index 737d74a0..df2ffba2 100644 --- a/ui/ui/routers-edit.tpl +++ b/ui/ui/routers-edit.tpl @@ -5,70 +5,147 @@ {Lang::T('Edit Router')} - - - - - {Lang::T('Status')} - - - Enable - - - Disable - - + + + + + {Lang::T('Status')} + + + Enable + + + + Disable + - - {Lang::T('Router Name / Location')} - - - {Lang::T('Name of Area that router operated')} - + + + {Lang::T('Router Name / Location')} + + + {Lang::T('Name of Area that router operated')} - - {Lang::T('IP Address')} - - - + + + {Lang::T('IP Address')} + + - - {Lang::T('Username')} - - - + + + {Lang::T('Username')} + + - - {Lang::T('Router Secret')} - - + + {Lang::T('Router Secret')} + + + + + + {Lang::T('Description')} + + {$d['description']} + {Lang::T('Explain Coverage of router')} + + + + {Lang::T('Coordinates')} + + + + + + + {Lang::T('Coverage')} + + + + meter(s) - - {Lang::T('Description')} - - {$d['description']} - {Lang::T('Explain Coverage of router')} - + + + + {Lang::T('Save Changes')} + Or {Lang::T('Cancel')} - - - - Test Connection - - - - - {Lang::T('Save Changes')} - Or {Lang::T('Cancel')} - - - - + + + -{include file="sections/footer.tpl"} +{literal} + + +{/literal} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/routers-maps.tpl b/ui/ui/routers-maps.tpl new file mode 100644 index 00000000..7e5b1046 --- /dev/null +++ b/ui/ui/routers-maps.tpl @@ -0,0 +1,84 @@ +{include file="sections/header.tpl"} + + + + + + + + + + + {Lang::T('Search')} + + + + + + + +{include file="pagination.tpl"} + +{literal} + +{/literal} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/routers.tpl b/ui/ui/routers.tpl index 9aad56a3..53c2dd4d 100644 --- a/ui/ui/routers.tpl +++ b/ui/ui/routers.tpl @@ -4,7 +4,12 @@ - {Lang::T('Routers')} + {Lang::T('Routers')} + + + + + @@ -43,7 +48,13 @@ {foreach $d as $ds} - {$ds['name']} + + {if $ds['coordinates']} + + {/if} + {$ds['name']} {$ds['ip_address']} {$ds['username']} {$ds['description']} diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 307df2d9..cd337197 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -427,10 +427,12 @@ - {Lang::T('Routers')} + {Lang::T('Routers')} {Lang::T('IP Pool')} + {Lang::T('Routers Maps')} {$_MENU_NETWORK} diff --git a/version.json b/version.json index 9db2c31a..7602a143 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.8.5" + "version": "2024.8.5.1" } \ No newline at end of file
{Lang::T('Name of Area that router operated')}
{Lang::T('Explain Coverage of router')}