From 37a245c94a4ae4380cc40e12c9aa17f8fd9a1219 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Sat, 18 May 2024 23:06:11 +0700 Subject: [PATCH 1/4] add Function getEnum in ORM --- system/orm.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/orm.php b/system/orm.php index 2228d83..46fee90 100644 --- a/system/orm.php +++ b/system/orm.php @@ -939,6 +939,8 @@ class ORM implements ArrayAccess return $this->_add_result_column($column, $alias); } + ## ibnux add function + /** * Add a column to the list of columns returned by the SELECT * query. This defaults to '*'. The second optional argument is @@ -959,6 +961,14 @@ class ORM implements ArrayAccess return $this; } + public function getEnum($column){ + $result = $this->raw_query("SHOW COLUMNS FROM ".$this->_table_name." WHERE Field = '$column'")->findArray(); + preg_match("/^enum\(\'(.*)\'\)$/", $result[0]['Type'], $matches); + return explode("','", $matches[1]); + } + + ## END ibnux add function + /** * Add an unquoted expression to the list of columns returned * by the SELECT query. The second optional argument is From 1bada918b9070b9c1df3ac830ef93ce0e62da992 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Sat, 18 May 2024 23:07:02 +0700 Subject: [PATCH 2/4] add status Inactive Limited Suspended to Customer --- install/phpnuxbill.sql | 3 ++- system/updates.json | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index a55baa6..b87ddb9 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -322,4 +322,5 @@ ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER ` 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`; -ALTER TABLE `tbl_customers` ADD `status` ENUM('Active','Banned','Disabled') NOT NULL DEFAULT 'Active' AFTER `auto_renewal`; \ No newline at end of file +ALTER TABLE `tbl_customers` ADD `status` ENUM('Active','Banned','Disabled') NOT NULL DEFAULT 'Active' AFTER `auto_renewal`; +ALTER TABLE `tbl_customers` CHANGE `status` `status` ENUM('Active','Banned','Disabled','Inactive','Limited','Suspended') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Active'; \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index aebb696..9146363 100644 --- a/system/updates.json +++ b/system/updates.json @@ -96,5 +96,8 @@ ], "2024.5.17" : [ "ALTER TABLE `tbl_customers` ADD `status` ENUM('Active','Banned','Disabled') NOT NULL DEFAULT 'Active' AFTER `auto_renewal`;" + ], + "2024.5.18" : [ + "ALTER TABLE `tbl_customers` CHANGE `status` `status` ENUM('Active','Banned','Disabled','Inactive','Limited','Suspended') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Active';" ] } \ No newline at end of file From 41161ebc7c446da5852c8f7818d6f18450d2d91e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Sat, 18 May 2024 23:14:03 +0700 Subject: [PATCH 3/4] Add new status when edit customers --- system/controllers/customers.php | 1 + system/controllers/home.php | 8 ++++---- system/lan/english.json | 4 +++- system/lan/indonesia.json | 4 +++- ui/ui/customers-edit.tpl | 10 +++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index dfff613..b21ffd1 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -315,6 +315,7 @@ switch ($action) { ->find_many(); if ($d) { $ui->assign('d', $d); + $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); $ui->assign('customFields', $customFields); $ui->assign('xheader', $leafletpickerHeader); $ui->display('customers-edit.tpl'); diff --git a/system/controllers/home.php b/system/controllers/home.php index 7bba5d1..d1a24a9 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -18,7 +18,7 @@ if (isset($_GET['renewal'])) { if (_post('send') == 'balance') { if ($config['enable_balance'] == 'yes' && $config['allow_balance_transfer'] == 'yes') { - if ($user['status'] == 'Disabled') { + 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(); @@ -80,7 +80,7 @@ if (_post('send') == 'balance') { r2(U . 'home', 'd', Lang::T('Failed, balance is not available')); } } else if (_post('send') == 'plan') { - if ($user['status'] == 'Disabled') { + if ($user['status'] == 'Active') { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } $actives = ORM::for_table('tbl_user_recharges') @@ -98,7 +98,7 @@ if (_post('send') == 'balance') { $ui->assign('_bills', User::_billing()); if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { - if ($user['status'] == 'Disabled') { + if ($user['status'] == 'Active') { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } if (!empty(App::getTokenValue(_get('stoken')))) { @@ -128,7 +128,7 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { } } } else if (!empty(_get('extend'))) { - if ($user['status'] == 'Disabled') { + if ($user['status'] == 'Active') { _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); } if (!$config['extend_expired']) { diff --git a/system/lan/english.json b/system/lan/english.json index 5f8ec27..fefadfc 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -589,5 +589,7 @@ "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" + "Created_Date": "Created Date", + "Inactive": "Inactive", + "Suspended": "Suspended" } \ No newline at end of file diff --git a/system/lan/indonesia.json b/system/lan/indonesia.json index 609fb86..f1ce7be 100644 --- a/system/lan/indonesia.json +++ b/system/lan/indonesia.json @@ -474,5 +474,7 @@ "SMS_and_WhatsApp": "SMS dan WhatsApp", "The_method_which_OTP_will_be_sent_to_user": "Metode OTP yang akan dikirimkan ke pengguna", "Disabled": "Dinonaktifkan", - "Banned": "Banned" + "Banned": "Dicekal", + "Inactive": "Tidak Aktif", + "Suspended": "Disuspend" } diff --git a/ui/ui/customers-edit.tpl b/ui/ui/customers-edit.tpl index f0564cb..23c59ff 100644 --- a/ui/ui/customers-edit.tpl +++ b/ui/ui/customers-edit.tpl @@ -112,14 +112,10 @@
{Lang::T('Banned')}: {Lang::T('Customer cannot login again')}.
From 8284b360a054d3d678d3c07a328b5bdd6dea9852 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Sat, 18 May 2024 23:16:03 +0700 Subject: [PATCH 4/4] add red line for Customer status != Active --- ui/ui/customers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index cd0f75c..62c5a2e 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -86,7 +86,7 @@ {foreach $d as $ds} - + {$ds['username']} {$ds['account_type']}