From 9f96da34b5d8f649a3f5b2633be5e0cdd1596e92 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 5 Aug 2024 10:50:37 +0700 Subject: [PATCH] pppoe ip and username --- install/phpnuxbill.sql | 2 + system/controllers/customers.php | 8 ++++ system/devices/MikrotikPppoe.php | 47 +++++++++++-------- system/lan/english.json | 4 +- system/updates.json | 4 ++ ui/ui/customers-add.tpl | 40 +++++++++++----- ui/ui/customers-edit.tpl | 80 +++++++++++++++++++------------- ui/ui/customers-view.tpl | 10 ++++ ui/ui/user-dashboard.tpl | 2 +- version.json | 2 +- 10 files changed, 134 insertions(+), 65 deletions(-) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index bcb966f..4bf59e1 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -27,7 +27,9 @@ CREATE TABLE `tbl_customers` ( `id` int NOT NULL, `username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `pppoe_username` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login', `pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login', + `pppoe_ip` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login', `fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `address` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 12d5700..86af795 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -363,7 +363,9 @@ switch ($action) { $username = alphanumeric(_post('username'), ":+_.@-"); $fullname = _post('fullname'); $password = trim(_post('password')); + $pppoe_username = trim(_post('pppoe_username')); $pppoe_password = trim(_post('pppoe_password')); + $pppoe_ip = trim(_post('pppoe_ip')); $email = _post('email'); $address = _post('address'); $phonenumber = _post('phonenumber'); @@ -399,7 +401,9 @@ switch ($action) { $d = ORM::for_table('tbl_customers')->create(); $d->username = $username; $d->password = $password; + $d->pppoe_username = $pppoe_username; $d->pppoe_password = $pppoe_password; + $d->pppoe_ip = $pppoe_ip; $d->email = $email; $d->account_type = $account_type; $d->fullname = $fullname; @@ -484,7 +488,9 @@ switch ($action) { $fullname = _post('fullname'); $account_type = _post('account_type'); $password = trim(_post('password')); + $pppoe_username = trim(_post('pppoe_username')); $pppoe_password = trim(_post('pppoe_password')); + $pppoe_ip = trim(_post('pppoe_ip')); $email = _post('email'); $address = _post('address'); $phonenumber = Lang::phoneFormat(_post('phonenumber')); @@ -544,7 +550,9 @@ switch ($action) { if ($password != '') { $c->password = $password; } + $c->pppoe_username = $pppoe_username; $c->pppoe_password = $pppoe_password; + $c->pppoe_ip = $pppoe_ip; $c->fullname = $fullname; $c->email = $email; $c->account_type = $account_type; diff --git a/system/devices/MikrotikPppoe.php b/system/devices/MikrotikPppoe.php index d7cc99f..2c9e2c6 100644 --- a/system/devices/MikrotikPppoe.php +++ b/system/devices/MikrotikPppoe.php @@ -40,16 +40,23 @@ class MikrotikPppoe //customer not exists, add it $this->addPpoeUser($client, $plan, $customer); }else{ - if (!empty($customer['pppoe_password'])) { - $pass = $customer['pppoe_password']; - } else { - $pass = $customer['password']; - } $setRequest = new RouterOS\Request('/ppp/secret/set'); + if (!empty($customer['pppoe_password'])) { + $setRequest->setArgument('password', $customer['pppoe_password']); + } else { + $setRequest->setArgument('password', $customer['password']); + } + if (!empty($customer['pppoe_username'])) { + $setRequest->setArgument('name', $customer['pppoe_username']); + } else { + $setRequest->setArgument('name', $customer['username']); + } + if (!empty($customer['pppoe_ip'])) { + $setRequest->setArgument('local-address', $customer['pppoe_ip']); + } $setRequest->setArgument('numbers', $cid); $setRequest->setArgument('profile', $plan['name_plan']); $setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id']))); - $setRequest->setArgument('password', $pass); $client->sendSync($setRequest); //disconnect then if(isset($isChangePlan) && $isChangePlan){ @@ -285,26 +292,28 @@ class MikrotikPppoe function addPpoeUser($client, $plan, $customer) { - global $_app_stage; - $addRequest = new RouterOS\Request('/ppp/secret/add'); + $setRequest = new RouterOS\Request('/ppp/secret/add'); + $setRequest->setArgument('service', 'pppoe'); + $setRequest->setArgument('profile', $plan['name_plan']); + $setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id']))); if (!empty($customer['pppoe_password'])) { - $pass = $customer['pppoe_password']; + $setRequest->setArgument('password', $customer['pppoe_password']); } else { - $pass = $customer['password']; + $setRequest->setArgument('password', $customer['password']); } - $client->sendSync( - $addRequest - ->setArgument('name', $customer['username']) - ->setArgument('service', 'pppoe') - ->setArgument('profile', $plan['name_plan']) - ->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id']))) - ->setArgument('password', $pass) - ); + if (!empty($customer['pppoe_username'])) { + $setRequest->setArgument('name', $customer['pppoe_username']); + } else { + $setRequest->setArgument('name', $customer['username']); + } + if (!empty($customer['pppoe_ip'])) { + $setRequest->setArgument('local-address', $customer['pppoe_ip']); + } + $client->sendSync($setRequest); } function setPpoeUser($client, $user, $pass) { - global $_app_stage; $printRequest = new RouterOS\Request('/ppp/secret/print'); $printRequest->setArgument('.proplist', '.id'); $printRequest->setQuery(RouterOS\Query::where('name', $user)); diff --git a/system/lan/english.json b/system/lan/english.json index 280aaef..d2d7717 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -688,5 +688,7 @@ "Previous": "Previous", "Share": "Share", "Mail_Deleted_Successfully": "Mail Deleted Successfully", - "Message_Not_Found": "Message Not Found" + "Message_Not_Found": "Message Not Found", + "Send_Welcome_Message": "Send Welcome Message", + "WA": "WA" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index ceb443a..32df040 100644 --- a/system/updates.json +++ b/system/updates.json @@ -136,5 +136,9 @@ ], "2024.8.2" : [ "CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;" + ], + "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`;" ] } \ No newline at end of file diff --git a/ui/ui/customers-add.tpl b/ui/ui/customers-add.tpl index 6c811c7..730986a 100644 --- a/ui/ui/customers-add.tpl +++ b/ui/ui/customers-add.tpl @@ -57,17 +57,6 @@ onmouseenter="this.type = 'text'"> -
- -
- - - {Lang::T('User Cannot change this, only admin. if it Empty it will use user password')} - -
-
@@ -103,6 +92,35 @@
+ +
PPPOE
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + {Lang::T('User Cannot change this, only admin. if it Empty it will use user password')} + +
+
+
diff --git a/ui/ui/customers-edit.tpl b/ui/ui/customers-edit.tpl index 40fca4b..1dc2b8c 100644 --- a/ui/ui/customers-edit.tpl +++ b/ui/ui/customers-edit.tpl @@ -3,7 +3,8 @@
-
+
{Lang::T('Edit Contact')}
@@ -61,17 +62,6 @@ {Lang::T('Keep Blank to do not change Password')}
-
- -
- - - {Lang::T('User Cannot change this, only admin. if it Empty it will use user password')} - -
-
@@ -113,18 +103,47 @@
{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('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')}.
+
PPPOE
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + {Lang::T('User Cannot change this, only admin. if it Empty it will use user password')} + +
@@ -173,8 +192,7 @@
- + {Lang::T('City of Resident')}
@@ -189,16 +207,14 @@
- + {Lang::T('State of Resident')}
- + {Lang::T('Zip Code')}
@@ -280,15 +296,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 534d8d2..77f9632 100644 --- a/ui/ui/customers-view.tpl +++ b/ui/ui/customers-view.tpl @@ -41,6 +41,11 @@ onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'" onclick="this.select()"> + {if $d['pppoe_username'] != ''} +
  • + PPPOE {Lang::T('Username')} {$d['pppoe_username']} +
  • + {/if} {if $d['pppoe_password'] != ''}
  • PPPOE {Lang::T('Password')}
  • {/if} + {if $d['pppoe_ip'] != ''} +
  • + PPPOE Local IP {$d['pppoe_ip']} +
  • + {/if} {if $customFields} {foreach $customFields as $customField} diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index 7c387ee..1fdc44c 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -197,7 +197,7 @@ {Lang::T('Type')} {if $_bill['prepaid'] eq yes}Prepaid{else}Postpaid{/if} - {Lang::T($_bill['plan_type'])} + {$_bill['plan_type']} {if $nux_ip neq ''} diff --git a/version.json b/version.json index a67cb5d..9db2c31 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.8.2" + "version": "2024.8.5" } \ No newline at end of file