From f6ff09957e7ce8856bb16339d8c076104c32488f Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Fri, 21 Jun 2024 15:52:36 +0700 Subject: [PATCH] add on-login / on-up & on-logout / on-down edit script --- CHANGELOG.md | 6 ++ install/phpnuxbill.sql | 4 +- system/controllers/services.php | 8 ++ system/devices/MikrotikHotspot.php | 2 + system/devices/MikrotikPppoe.php | 2 + system/lan/english.json | 8 +- system/updates.json | 4 + ui/ui/hotspot-add.tpl | 2 +- ui/ui/hotspot-edit.tpl | 153 ++++++++++++++++++----------- ui/ui/pppoe-add.tpl | 2 +- ui/ui/pppoe-edit.tpl | 132 ++++++++++++++++--------- version.json | 2 +- 12 files changed, 214 insertions(+), 111 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1916cbcf..c484c8c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ # CHANGELOG +## 2024.6.21 + +- Add filter result in voucher and internet plan +- Add input script on-login and on-logout +- Add local ip for pppoe + ## 2024.6.19 - new system for device, it can support non mikrotik devices, as long someone create device file diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 98ce533a..dcc48863 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -113,7 +113,9 @@ CREATE TABLE `tbl_plans` ( `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled\r\n', `prepaid` enum('yes','no') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'yes' COMMENT 'is prepaid', `plan_type` enum('Business','Personal') COLLATE utf8mb4_general_ci DEFAULT 'Personal' COMMENT 'For selecting account type', - `device` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' + `device` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', + `on_login` TEXT NULL DEFAULT NULL, + `on_logout` TEXT NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; DROP TABLE IF EXISTS `tbl_pool`; diff --git a/system/controllers/services.php b/system/controllers/services.php index 8e329b04..812e029e 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -329,6 +329,8 @@ switch ($action) { $enabled = _post('enabled'); $prepaid = _post('prepaid'); $routers = _post('routers'); + $on_login = _post('on_login'); + $on_logout = _post('on_logout'); $expired_date = _post('expired_date'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -384,6 +386,8 @@ switch ($action) { $d->plan_expired = $plan_expired; $d->enabled = $enabled; $d->prepaid = $prepaid; + $d->on_login = $on_login; + $d->on_logout = $on_logout; $d->device = $device; if ($prepaid == 'no') { if ($expired_date > 28 && $expired_date < 1) { @@ -700,6 +704,8 @@ switch ($action) { $enabled = _post('enabled'); $prepaid = _post('prepaid'); $expired_date = _post('expired_date'); + $on_login = _post('on_login'); + $on_logout = _post('on_logout'); $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -751,6 +757,8 @@ switch ($action) { $d->enabled = $enabled; $d->prepaid = $prepaid; $d->device = $device; + $d->on_login = $on_login; + $d->on_logout = $on_logout; if ($prepaid == 'no') { if ($expired_date > 28 && $expired_date < 1) { $expired_date = 20; diff --git a/system/devices/MikrotikHotspot.php b/system/devices/MikrotikHotspot.php index ed08786a..170a24f7 100644 --- a/system/devices/MikrotikHotspot.php +++ b/system/devices/MikrotikHotspot.php @@ -140,6 +140,8 @@ class MikrotikHotspot ->setArgument('name', $new_plan['name_plan']) ->setArgument('shared-users', $new_plan['shared_users']) ->setArgument('rate-limit', $rate) + ->setArgument('on-login', $new_plan['on_login']) + ->setArgument('on-logout', $new_plan['on_logout']) ); } } diff --git a/system/devices/MikrotikPppoe.php b/system/devices/MikrotikPppoe.php index 84c1a2df..46afa880 100644 --- a/system/devices/MikrotikPppoe.php +++ b/system/devices/MikrotikPppoe.php @@ -104,6 +104,8 @@ class MikrotikPppoe ->setArgument('local-address', (!empty($pool['local_ip'])) ? $pool['local_ip']: $pool['pool_name']) ->setArgument('remote-address', $pool['pool_name']) ->setArgument('rate-limit', $rate) + ->setArgument('on-up', $new_plan['on_login']) + ->setArgument('on-down', $new_plan['on_logout']) ); } } diff --git a/system/lan/english.json b/system/lan/english.json index 41150d6e..8f47f307 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -114,5 +114,11 @@ "New_Router": "New Router", "IP_Address": "IP Address", "Username": "Username", - "Description": "Description" + "Description": "Description", + "Edit_Service_Plan": "Edit Service Plan", + "Expired_Action": "Expired Action", + "Optional": "Optional", + "Expired_Internet_Plan": "Expired Internet Plan", + "When_Expired__customer_will_be_move_to_selected_internet_plan": "When Expired, customer will be move to selected internet plan", + "Data_Updated_Successfully": "Data Updated Successfully" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index 9a862d4e..a0aadee5 100644 --- a/system/updates.json +++ b/system/updates.json @@ -116,5 +116,9 @@ ], "2024.6.19" : [ "ALTER TABLE `tbl_plans` ADD `expired_date` TINYINT(1) NOT NULL DEFAULT '20' AFTER `plan_expired`;" + ], + "2024.6.21" : [ + "ALTER TABLE `tbl_plans` ADD `on_login` TEXT NULL DEFAULT NULL AFTER `device`;", + "ALTER TABLE `tbl_plans` ADD `on_logout` TEXT NULL DEFAULT NULL AFTER `on_login`;" ] } \ No newline at end of file diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index dbf9cd3f..a29069d7 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -45,7 +45,7 @@