diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 2c775428..a55baa64 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -321,4 +321,5 @@ ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `ty 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'; ALTER TABLE `tbl_transactions` ADD `note` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'for note' AFTER `type`; -ALTER TABLE `tbl_payment_gateway` ADD `trx_invoice` VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'from tbl_transactions' AFTER `paid_date`; \ No newline at end of file +ALTER TABLE `tbl_payment_gateway` ADD `trx_invoice` VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'from tbl_transactions' AFTER `paid_date`; +ALTER TABLE `tbl_customers` ADD `status` ENUM('Active','Banned','Disabled') NOT NULL DEFAULT 'Active' AFTER `auto_renewal`; \ No newline at end of file diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 41827e1f..d89d757d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -34,6 +34,10 @@ 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($c['status'] != 'Active'){ + _alert(Lang::T('This account status').' : '.Lang::T($c['status']),'danger', ""); + } + $add_cost = 0; $bills = []; // Zero cost recharge diff --git a/system/autoload/User.php b/system/autoload/User.php index 5b3167e7..93125f15 100644 --- a/system/autoload/User.php +++ b/system/autoload/User.php @@ -163,7 +163,9 @@ class User $id = User::getID(); } $d = ORM::for_table('tbl_customers')->find_one($id); - + if ($d['status'] != 'Banned') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($d['status']), 'danger', "logout"); + } if (empty($d['username'])) { r2(U . 'logout', 'd', ''); } diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 8fb4689c..7436b23d 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -459,6 +459,7 @@ switch ($action) { $phonenumber = Lang::phoneFormat(_post('phonenumber')); $service_type = _post('service_type'); $coordinates = _post('coordinates'); + $status = _post('status'); run_hook('edit_customer'); #HOOK $msg = ''; if (Validator::Length($username, 35, 2) == false) { @@ -517,6 +518,7 @@ switch ($action) { $d->email = $email; $d->account_type = $account_type; $d->address = $address; + $d->status = $status; $d->phonenumber = $phonenumber; $d->service_type = $service_type; $d->coordinates = $coordinates; @@ -606,19 +608,33 @@ switch ($action) { default: run_hook('list_customers'); #HOOK $search = _post('search'); + $order = _post('order', 'username'); + $orderby = _post('orderby', 'asc'); + $order_pos = [ + 'username' => 0, + 'created_at' => 8, + 'balance' => 3 + ]; + if ($search != '') { $query = ORM::for_table('tbl_customers') ->whereRaw("username LIKE '%$search%' OR fullname LIKE '%$search%' OR address LIKE '%$search%' ". - "OR phonenumber LIKE '%$search%' OR email LIKE '%$search%' ") - ->order_by_asc('username'); - $d = $query->findMany(); + "OR phonenumber LIKE '%$search%' OR email LIKE '%$search%' "); } else { - $query = ORM::for_table('tbl_customers')->order_by_asc('username'); + $query = ORM::for_table('tbl_customers'); + } + if($orderby=='asc'){ + $query->order_by_asc($order); + }else{ + $query->order_by_desc($order); } $d = $query->findMany(); $ui->assign('xheader', ''); $ui->assign('d', $d); $ui->assign('search', $search); + $ui->assign('order', $order); + $ui->assign('order_pos', $order_pos[$order]); + $ui->assign('orderby', $orderby); $ui->display('customers.tpl'); break; } diff --git a/system/controllers/home.php b/system/controllers/home.php index 2f08dc77..7640d057 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -18,6 +18,9 @@ if (isset($_GET['renewal'])) { if (_post('send') == 'balance') { if ($config['enable_balance'] == 'yes' && $config['allow_balance_transfer'] == 'yes') { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); if (!$target) { r2(U . 'home', 'd', Lang::T('Username not found')); @@ -77,6 +80,9 @@ if (_post('send') == 'balance') { r2(U . 'home', 'd', Lang::T('Failed, balance is not available')); } } else if (_post('send') == 'plan') { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } $actives = ORM::for_table('tbl_user_recharges') ->where('username', _post('username')) ->find_many(); @@ -92,6 +98,9 @@ if (_post('send') == 'balance') { $ui->assign('_bills', User::_billing()); if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } if (!empty(App::getTokenValue(_get('stoken')))) { r2(U . "voucher/invoice/"); die(); @@ -119,7 +128,10 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { } } } else if (!empty(_get('extend'))) { - if(!$config['extend_expired']){ + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } + if (!$config['extend_expired']) { r2(U . 'home', 'e', "cannot extend"); } if (!empty(App::getTokenValue(_get('stoken')))) { @@ -130,7 +142,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { if ($tur) { $m = date("m"); $path = $CACHE_PATH . DIRECTORY_SEPARATOR . "extends" . DIRECTORY_SEPARATOR; - if(!file_exists($path)){ + if (!file_exists($path)) { mkdir($path); } $path .= $user['id'] . ".txt"; @@ -148,7 +160,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { $router = $tur['routers']; } $p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']); - if(!$p){ + if (!$p) { r2(U . 'home', '3', "Plan Not Found"); } if ($tur['routers'] == 'radius') { @@ -171,12 +183,12 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { App::setToken(_get('stoken'), $id); file_put_contents($path, $m); _log("Customer $tur[customer_id] $tur[username] extend for $days days", "Customer", $user['id']); - Message::sendTelegram("#u$user[username] #extend #".$p['type']." \n" . $p['name_plan'] . - "\nLocation: " . $p['routers'] . - "\nCustomer: " . $user['fullname'] . - "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); + Message::sendTelegram("#u$user[username] #extend #" . $p['type'] . " \n" . $p['name_plan'] . + "\nLocation: " . $p['routers'] . + "\nCustomer: " . $user['fullname'] . + "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); r2(U . 'home', 's', "Extend until $expiration"); - }else{ + } else { r2(U . 'home', 'e', "Plan is not expired"); } } else { diff --git a/system/controllers/login.php b/system/controllers/login.php index 15b5eaf0..4845c6f4 100644 --- a/system/controllers/login.php +++ b/system/controllers/login.php @@ -5,8 +5,8 @@ * by https://t.me/ibnux **/ -if(User::getID()){ - r2(U.'home'); +if (User::getID()) { + r2(U . 'home'); } if (isset($routes['1'])) { @@ -24,13 +24,16 @@ switch ($do) { $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); if ($d) { $d_pass = $d['password']; + if ($d['status'] != 'Banned') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($d['status']), 'danger', ""); + } if (Password::_uverify($password, $d_pass) == true) { $_SESSION['uid'] = $d['id']; User::setCookie($d['id']); $d->last_login = date('Y-m-d H:i:s'); $d->save(); _log($username . ' ' . Lang::T('Login Successful'), 'User', $d['id']); - _alert(Lang::T('Login Successful'),'success', "home"); + _alert(Lang::T('Login Successful'), 'success', "home"); } else { _msglog('e', Lang::T('Invalid Username or Password')); _log($username . ' ' . Lang::T('Failed Login'), 'User'); @@ -68,7 +71,7 @@ switch ($do) { r2(U . 'login', 'e', Lang::T('Voucher activation failed')); } } else { - _alert(Lang::T('Login Successful'),'success', "dashboard"); + _alert(Lang::T('Login Successful'), 'success', "dashboard"); r2(U . 'login', 'e', Lang::T('Voucher activation failed') . '.'); } } diff --git a/system/controllers/order.php b/system/controllers/order.php index 61f730c7..c5b7a897 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -148,6 +148,9 @@ switch ($action) { r2(U . "voucher/invoice/"); die(); } + if($user['status'] != 'Active'){ + _alert(Lang::T('This account status').' : '.Lang::T($user['status']),'danger', ""); + } $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']); if (empty($plan)) { r2(U . "order/package", 'e', Lang::T("Plan Not found")); @@ -181,6 +184,9 @@ switch ($action) { if ($config['enable_balance'] != 'yes') { r2(U . "order/package", 'e', Lang::T("Balance not enabled")); } + if($user['status'] != 'Active'){ + _alert(Lang::T('This account status').' : '.Lang::T($user['status']),'danger', ""); + } $ui->assign('_title', Lang::T('Buy for friend')); $ui->assign('_system_menu', 'package'); $plan = ORM::for_table('tbl_plans')->find_one($routes['3']); @@ -322,6 +328,9 @@ switch ($action) { } else if (!empty($gateway)) { $_SESSION['gateway'] = $gateway; } + if($user['status'] != 'Active'){ + _alert(Lang::T('This account status').' : '.Lang::T($user['status']),'danger', ""); + } if (empty($gateway)) { r2(U . 'order/gateway/' . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please select Payment Gateway")); } diff --git a/system/lan/english.json b/system/lan/english.json index 3d33b6e9..5f8ec277 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -581,5 +581,13 @@ "Created___Expired": "Created \/ Expired", "Bank_Transfer": "Bank Transfer", "Recharge_Using": "Recharge Using", - "ago": "ago" + "ago": "ago", + "Disabled": "Disabled", + "Banned": "Banned", + "Customer_cannot_login_again": "Customer cannot login again", + "Customer_can_login_but_cannot_buy_internet_plan__Admin_cannot_recharge_customer": "Customer can login but cannot buy internet plan, Admin cannot recharge customer", + "Don_t_forget_to_deactivate_all_active_plan_too": "Don't forget to deactivate all active plan too", + "Ascending": "Ascending", + "Descending": "Descending", + "Created_Date": "Created Date" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index a4eca5a1..aebb6960 100644 --- a/system/updates.json +++ b/system/updates.json @@ -93,5 +93,8 @@ ], "2024.4.5" : [ "ALTER TABLE `tbl_payment_gateway` ADD `trx_invoice` VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'from tbl_transactions' AFTER `paid_date`;" + ], + "2024.5.17" : [ + "ALTER TABLE `tbl_customers` ADD `status` ENUM('Active','Banned','Disabled') NOT NULL DEFAULT 'Active' AFTER `auto_renewal`;" ] } \ No newline at end of file diff --git a/ui/ui/customers-edit.tpl b/ui/ui/customers-edit.tpl index 863f97b8..f0564cb8 100644 --- a/ui/ui/customers-edit.tpl +++ b/ui/ui/customers-edit.tpl @@ -3,7 +3,7 @@
-
+
{Lang::T('Edit Contact')}
@@ -20,7 +20,7 @@ {/if} + placeholder="{if $_c['country_code_phone']!= ''}{$_c['country_code_phone']} {Lang::T('Phone Number')}{else}{Lang::T('Username')}{/if}">
@@ -108,6 +108,26 @@
+
+ +
+ + + {Lang::T('Banned')}: {Lang::T('Customer cannot login again')}.
+ {Lang::T('Disabled')}: {Lang::T('Customer can login but cannot buy internet plan, Admin cannot recharge customer')}.
+ {Lang::T('Don\'t forget to deactivate all active plan too')}. +
+
+
@@ -219,13 +239,15 @@ }); } window.onload = function() { - {/literal}{if $d['coordinates']} - setupMap({$d['coordinates']}); - {else} - getLocation(); - {/if}{literal} - } - -{/literal} + {/literal} + {if $d['coordinates']} + setupMap({$d['coordinates']}); + {else} + getLocation(); + {/if} + {literal} + } + + {/literal} -{include file="sections/footer.tpl"} \ No newline at end of file + {include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/customers-view.tpl b/ui/ui/customers-view.tpl index fbc25a9b..3b96430e 100644 --- a/ui/ui/customers-view.tpl +++ b/ui/ui/customers-view.tpl @@ -2,15 +2,17 @@
-
+
avatar -

{$d['fullname']}

-
    +
  • + {Lang::T('Status')}  {Lang::T($d['status'])}  +
  • {Lang::T('Username')} {$d['username']}
  • @@ -233,23 +235,23 @@
{if $d['coordinates']} -{literal} - - -{/literal} + {literal} + + + {/literal} {/if} {include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index 3c255bc0..081f86b9 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -16,18 +16,38 @@
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])} -
- CSV -
+
+ CSV +
{/if} {Lang::T('Manage Contact')}
-
-
- + +
+
+
+ Order    +
+
+ +
+
+ +
+
+
+
+
@@ -38,13 +58,15 @@
- +
+
-   -
+ +
 
@@ -56,50 +78,52 @@ + {foreach $d as $ds} - - - - - - - - - - - + + + + + + + + + + + + {/foreach}
{Lang::T('Contact')} {Lang::T('Package')} {Lang::T('Service Type')}{Lang::T('Status')} {Lang::T('Created On')} {Lang::T('Manage')}
{$ds['username']}{$ds['account_type']}{$ds['fullname']}{Lang::moneyFormat($ds['balance'])} - {if $ds['phonenumber']} - - {/if} - {if $ds['email']} - - {/if} - {if $ds['coordinates']} - - {/if} - - - {$ds['service_type']}{Lang::dateTimeFormat($ds['created_at'])} -   {Lang::T('View')}   -   {Lang::T('Edit')}   - {Lang::T('Recharge')} -
{$ds['username']}{$ds['account_type']}{$ds['fullname']}{Lang::moneyFormat($ds['balance'])} + {if $ds['phonenumber']} + + {/if} + {if $ds['email']} + + {/if} + {if $ds['coordinates']} + + {/if} + + + {$ds['service_type']}{Lang::T($ds['status'])}{Lang::dateTimeFormat($ds['created_at'])} +   {Lang::T('View')}   +   {Lang::T('Edit')}   + {Lang::T('Recharge')} +
@@ -115,11 +139,15 @@