From b153e5b5951b890e8bebf67d0a8d315c5af8cd5f Mon Sep 17 00:00:00 2001 From: gerandonk Date: Sun, 3 Mar 2024 11:00:42 +0700 Subject: [PATCH 1/3] distinguish between announcements on the user dashboard and the login page --- pages_template/Announcement_Users.html.html | 1 + ui/ui/sections/header.tpl | 2 ++ ui/ui/user-dashboard.tpl | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 pages_template/Announcement_Users.html.html diff --git a/pages_template/Announcement_Users.html.html b/pages_template/Announcement_Users.html.html new file mode 100644 index 00000000..3f0a6c99 --- /dev/null +++ b/pages_template/Announcement_Users.html.html @@ -0,0 +1 @@ +Pengumuman!!
Besok libur

Announcement!!
Tomorrow holiday
\ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 066d5d37..487636a2 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -249,6 +249,8 @@ href="{$_url}pages/Voucher">{Lang::T('Voucher')} Template
  • {Lang::T('Announcement')}
  • +
  • {Lang::T('Users Announcement')}
  • {Lang::T('Registration Info')}
  • {Lang::T('Announcement')}
    - {include file="$_path/../pages/Announcement.html"} + {include file="$_path/../pages/Announcement_Users.html"}
    From 61b3f5b5f56a4bdcbb02af312e11a6ca2e1ceadc Mon Sep 17 00:00:00 2001 From: gerandonk Date: Sun, 3 Mar 2024 11:03:25 +0700 Subject: [PATCH 2/3] Add planwith validity period --- install/phpnuxbill.sql | 2 +- system/autoload/Package.php | 42 +++++++++++++++++++++++++++++++++---- ui/ui/pppoe-add.tpl | 2 ++ ui/ui/pppoe-edit.tpl | 2 ++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 5f4bd014..1e5ea998 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -91,7 +91,7 @@ CREATE TABLE `tbl_plans` ( `data_limit` int(10) UNSIGNED DEFAULT NULL, `data_unit` enum('MB','GB') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `validity` int(10) NOT NULL, - `validity_unit` enum('Mins','Hrs','Days','Months') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `validity_unit` enum('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `shared_users` int(10) DEFAULT NULL, `routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `is_radius` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 is radius', diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 7dab432e..693e5faa 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -100,6 +100,18 @@ class Package $mikrotik = Mikrotik::info($router_name); if ($p['validity_unit'] == 'Months') { $date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month')); + } else if ($p['validity_unit'] == 'Period') { + $date_tmp = date("Y-m-20", strtotime('+' . $p['validity'] . ' month')); + $dt1 = new DateTime("$date_only"); + $dt2 = new DateTime("$date_tmp"); + $diff = $dt2->diff($dt1); + $sum = $diff->format("%a");// => 453 + if ($sum >= 35) { + $date_exp = date("Y-m-20", strtotime('+0 month')); + } else { + $date_exp = date("Y-m-20", strtotime('+' . $p['validity'] . ' month')); + }; + $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' day')); } else if ($p['validity_unit'] == 'Hrs') { @@ -119,6 +131,9 @@ class Package if ($p['validity_unit'] == 'Months') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = $b['time']; + } else if ($p['validity_unit'] == 'Period') { + $date_exp = date("Y-m-20", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); $time = $b['time']; @@ -180,6 +195,12 @@ class Package $t->admin_id = '0'; } $t->save(); + + Message::sendTelegram("#u$c[username] #recharge #Hotspot \n" . $p['name_plan'] . + "\nRouter: " . $router_name . + "\nGateway: " . $gateway . + "\nChannel: " . $channel . + "\nPrice: " . Lang::moneyFormat($p['price'])); } else { if ($p['is_radius']) { Radius::customerAddPlan($c, $p, "$date_exp $time"); @@ -229,12 +250,14 @@ class Package $t->admin_id = '0'; } $t->save(); - } - Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . + + Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . "\nPrice: " . Lang::moneyFormat($p['price'])); + } + } else { if ($b) { @@ -243,6 +266,9 @@ class Package if ($p['validity_unit'] == 'Months') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); $time = $b['time']; + } else if ($p['validity_unit'] == 'Period') { + $date_exp = date("Y-m-20", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + $time = date("23:59:00"); } else if ($p['validity_unit'] == 'Days') { $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); $time = $b['time']; @@ -304,6 +330,12 @@ class Package $t->admin_id = '0'; } $t->save(); + + Message::sendTelegram("#u$c[username] #recharge #PPPOE \n" . $p['name_plan'] . + "\nRouter: " . $router_name . + "\nGateway: " . $gateway . + "\nChannel: " . $channel . + "\nPrice: " . Lang::moneyFormat($p['price'])); } else { if ($p['is_radius']) { Radius::customerAddPlan($c, $p, "$date_exp $time"); @@ -353,12 +385,14 @@ class Package } $t->type = "PPPOE"; $t->save(); - } - Message::sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . + + Message::sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . "\nPrice: " . Lang::moneyFormat($p['price'])); + } + } run_hook("recharge_user_finish"); Message::sendInvoice($c, $t); diff --git a/ui/ui/pppoe-add.tpl b/ui/ui/pppoe-add.tpl index 4f0093ae..98b308dc 100644 --- a/ui/ui/pppoe-add.tpl +++ b/ui/ui/pppoe-add.tpl @@ -60,6 +60,7 @@
    +

    {Lang::T('1 Period = 1 Month, Expires the 20th of each month')}

    diff --git a/ui/ui/pppoe-edit.tpl b/ui/ui/pppoe-edit.tpl index 45ce18b0..d866c724 100644 --- a/ui/ui/pppoe-edit.tpl +++ b/ui/ui/pppoe-edit.tpl @@ -62,6 +62,7 @@
    +

    {Lang::T('1 Period = 30 Month, Expires the 20th of each month')}

    From a76ba6ee8b82b2bf44a8e5c2adfe51e50f73b34d Mon Sep 17 00:00:00 2001 From: gerandonk Date: Sun, 3 Mar 2024 11:30:34 +0700 Subject: [PATCH 3/3] update db for validity period --- system/updates.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/updates.json b/system/updates.json index e5ecdff6..237741ae 100644 --- a/system/updates.json +++ b/system/updates.json @@ -68,6 +68,7 @@ ], "2024.2.23" : [ "ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;", - "ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;" + "ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;", + "ALTER TABLE `tbl_plans` CHANGE `validity_unit` `validity_unit` ENUM('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;" ] } \ No newline at end of file