Fix Admin List for Admin

This commit is contained in:
Ibnu Maksum 2024-02-20 10:58:50 +07:00
parent 349a1d3250
commit 2063ae4159
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
11 changed files with 61 additions and 45 deletions

View File

@ -33,13 +33,6 @@ CREATE TABLE `tbl_customers` (
`last_login` datetime DEFAULT NULL `last_login` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) 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`; DROP TABLE IF EXISTS `tbl_logs`;
CREATE TABLE `tbl_logs` ( CREATE TABLE `tbl_logs` (

View File

@ -515,6 +515,18 @@ class Mikrotik
$client->sendSync($smsRequest); $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 = '') public static function addIpToAddressList($client, $ip, $listName, $comment = '')
{ {
global $_app_stage; global $_app_stage;

View File

@ -100,17 +100,6 @@ class Package
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { 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 ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
// if it same internet plan, expired will extend // if it same internet plan, expired will extend
if ($p['validity_unit'] == 'Months') { 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->customer_id = $id_customer;
$b->username = $c['username']; $b->username = $c['username'];
$b->plan_id = $plan_id; $b->plan_id = $plan_id;
@ -208,18 +208,6 @@ class Package
} else { } else {
if ($b) { 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 ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
// if it same internet plan, expired will extend // if it same internet plan, expired will extend
if ($p['validity_unit'] == 'Months') { 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->customer_id = $id_customer;
$b->username = $c['username']; $b->username = $c['username'];
$b->plan_id = $plan_id; $b->plan_id = $plan_id;

View File

@ -280,14 +280,16 @@ switch ($action) {
'username' => '%' . $search . '%', 'username' => '%' . $search . '%',
['user_type' => 'Report'], ['user_type' => 'Report'],
['user_type' => 'Agent'], ['user_type' => 'Agent'],
['user_type' => 'Sales'] ['user_type' => 'Sales'],
['id' => $admin['id']]
], $search); ], $search);
$d = ORM::for_table('tbl_users') $d = ORM::for_table('tbl_users')
->where_like('username', '%' . $search . '%') ->where_like('username', '%' . $search . '%')
->where_any_is([ ->where_any_is([
['user_type' => 'Report'], ['user_type' => 'Report'],
['user_type' => 'Agent'], ['user_type' => 'Agent'],
['user_type' => 'Sales'] ['user_type' => 'Sales'],
['id' => $admin['id']]
]) ])
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->findArray(); ->limit($paginator['limit'])->order_by_asc('id')->findArray();
@ -311,7 +313,8 @@ switch ($action) {
$d = ORM::for_table('tbl_users')->where_any_is([ $d = ORM::for_table('tbl_users')->where_any_is([
['user_type' => 'Report'], ['user_type' => 'Report'],
['user_type' => 'Agent'], ['user_type' => 'Agent'],
['user_type' => 'Sales'] ['user_type' => 'Sales'],
['id' => $admin['id']]
])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray(); ])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_users')); $paginator = Paginator::build(ORM::for_table('tbl_users'));
@ -591,7 +594,9 @@ switch ($action) {
$d->city = $city; $d->city = $city;
$d->subdistrict = $subdistrict; $d->subdistrict = $subdistrict;
$d->ward = $ward; $d->ward = $ward;
if(isset($_POST['status'])){
$d->status = $status; $d->status = $status;
}
if ($admin['user_type'] == 'Agent') { if ($admin['user_type'] == 'Agent') {
// Prevent hacking from form // Prevent hacking from form

View File

@ -46,8 +46,9 @@ foreach ($d as $ds) {
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if (!empty($p['pool_expired'])) { if (!empty($p['pool_expired'])) {
Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']); Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);
}if (!empty($p['list_expired'])) { // }if (!empty($p['list_expired'])) {
Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']); // $ip = Mikrotik::getIpHotspotUser($client, $ds['username']);
// Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']);
} else { } else {
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
} }

View File

@ -418,5 +418,8 @@
"Expired_Action": "Expired Action", "Expired_Action": "Expired Action",
"Expired_Address_List_Name": "Expired Address List Name", "Expired_Address_List_Name": "Expired Address List Name",
"Address_List": "Address List", "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"
} }

View File

@ -62,5 +62,8 @@
"2024.2.20" : [ "2024.2.20" : [
"ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;", "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_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;"
],
"2024.2.20.1" : [
"DROP TABLE IF EXISTS `tbl_customers_meta`;"
] ]
} }

View File

@ -157,12 +157,12 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" id="AddressList"> {* <div class="form-group" id="AddressList">
<label class="col-md-2 control-label">{Lang::T('Address List')}</label> <label class="col-md-2 control-label">{Lang::T('Address List')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" name="list_expired" id="list_expired"> <input type="text" class="form-control" name="list_expired" id="list_expired">
</div> </div>
</div> </div> *}
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<button class="btn btn-success waves-effect waves-light" <button class="btn btn-success waves-effect waves-light"

View File

@ -166,12 +166,12 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" id="AddressList"> {* <div class="form-group" id="AddressList">
<label class="col-md-2 control-label">{Lang::T('Address List')}</label> <label class="col-md-2 control-label">{Lang::T('Address List')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" name="list_expired" id="list_expired" value="{$d['list_expired']}"> <input type="text" class="form-control" name="list_expired" id="list_expired" value="{$d['list_expired']}">
</div> </div>
</div> </div> *}
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<button class="btn btn-success waves-effect waves-light" <button class="btn btn-success waves-effect waves-light"

View File

@ -101,12 +101,12 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" id="AddressList"> {* <div class="form-group" id="AddressList">
<label class="col-md-2 control-label">{Lang::T('Address List')}</label> <label class="col-md-2 control-label">{Lang::T('Address List')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" name="list_expired" id="list_expired"> <input type="text" class="form-control" name="list_expired" id="list_expired">
</div> </div>
</div> </div> *}
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<button class="btn btn-primary waves-effect waves-light" <button class="btn btn-primary waves-effect waves-light"

View File

@ -108,12 +108,12 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" id="AddressList"> {* <div class="form-group" id="AddressList">
<label class="col-md-2 control-label">{Lang::T('Address List')}</label> <label class="col-md-2 control-label">{Lang::T('Address List')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" name="list_expired" id="list_expired" value="{$d['list_expired']}"> <input type="text" class="form-control" name="list_expired" id="list_expired" value="{$d['list_expired']}">
</div> </div>
</div> </div> *}
<div class="form-group"> <div class="form-group">
<div class="col-lg-offset-2 col-lg-10"> <div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success waves-effect waves-light" <button class="btn btn-success waves-effect waves-light"