From a7a0f84df51ff1dac720d6556f47004864e262e4 Mon Sep 17 00:00:00 2001
From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com>
Date: Thu, 14 Dec 2023 03:21:55 +0100
Subject: [PATCH] add new feature "service type" Hotspot PPPoE and Others
ability to display packages according to the user type.
Hotspot users Can now see only hotspot packages
PPPoE users can now see only PPPoE Packages
Others Can see both Hotspot and PPPoE packages
---
install/phpnuxbill.sql | 1 +
system/controllers/customers.php | 9 +-
system/updates.json | 3 +
ui/ui/customers-add.tpl | 10 +
ui/ui/customers-edit.tpl | 10 +
ui/ui/customers-view.tpl | 3 +
ui/ui/customers.tpl | 2 +
ui/ui/user-dashboard.tpl | 163 +++++----
ui/ui/user-orderPlan.tpl | 558 ++++++++++++++++++++-----------
9 files changed, 480 insertions(+), 279 deletions(-)
diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql
index 2f10779e..77d2bbfc 100644
--- a/install/phpnuxbill.sql
+++ b/install/phpnuxbill.sql
@@ -27,6 +27,7 @@ CREATE TABLE `tbl_customers` (
`phonenumber` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
`email` varchar(128) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1',
`balance` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT 'For Money Deposit',
+ `service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type',
`auto_renewal` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Auto renewall using balance',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_login` datetime DEFAULT NULL
diff --git a/system/controllers/customers.php b/system/controllers/customers.php
index 4f13f648..8638a271 100644
--- a/system/controllers/customers.php
+++ b/system/controllers/customers.php
@@ -28,7 +28,8 @@ switch ($action) {
'username' => '%' . $search . '%',
'fullname' => '%' . $search . '%',
'phonenumber' => '%' . $search . '%',
- 'email' => '%' . $search . '%'
+ 'email' => '%' . $search . '%',
+ 'service_type' => '%' . $search . '%'
], $search);
$d = ORM::for_table('tbl_customers')
->where_raw("(`username` LIKE '%$search%' OR `fullname` LIKE '%$search%' OR `phonenumber` LIKE '%$search%' OR `email` LIKE '%$search%')", [$search, $search, $search, $search])
@@ -225,8 +226,9 @@ switch ($action) {
$password = _post('password');
$pppoe_password = _post('pppoe_password');
$email = _post('email');
- $address = _post('address');
+ $address = _post('address');
$phonenumber = _post('phonenumber');
+ $service_type = _post('service_type');
run_hook('add_customer'); #HOOK
$msg = '';
if (Validator::Length($username, 35, 2) == false) {
@@ -253,6 +255,7 @@ switch ($action) {
$d->fullname = $fullname;
$d->address = $address;
$d->phonenumber = Lang::phoneFormat($phonenumber);
+ $d->service_type = $service_type;
$d->save();
r2(U . 'customers/list', 's', $_L['account_created_successfully']);
} else {
@@ -268,6 +271,7 @@ switch ($action) {
$email = _post('email');
$address = _post('address');
$phonenumber = Lang::phoneFormat(_post('phonenumber'));
+ $service_type = _post('service_type');
run_hook('edit_customer'); #HOOK
$msg = '';
if (Validator::Length($username, 16, 2) == false) {
@@ -320,6 +324,7 @@ switch ($action) {
$d->email = $email;
$d->address = $address;
$d->phonenumber = $phonenumber;
+ $d->service_type = $service_type;
$d->save();
if ($userDiff || $pppoeDiff || $passDiff) {
$c = ORM::for_table('tbl_user_recharges')->where('username', ($userDiff) ? $oldusername : $username)->find_one();
diff --git a/system/updates.json b/system/updates.json
index 86796d35..06e365a8 100644
--- a/system/updates.json
+++ b/system/updates.json
@@ -35,5 +35,8 @@
],
"2023.10.24" : [
"ALTER TABLE `nas` ADD `routers` VARCHAR(32) NOT NULL DEFAULT '' AFTER `description`;"
+ ],
+ "2023.12.15": [
+ "ALTER TABLE `tbl_customers` ADD `service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type' AFTER `balance`;"
]
}
\ No newline at end of file
diff --git a/ui/ui/customers-add.tpl b/ui/ui/customers-add.tpl
index c4bcf59c..6aaa44d1 100644
--- a/ui/ui/customers-add.tpl
+++ b/ui/ui/customers-add.tpl
@@ -72,6 +72,16 @@
+
+