From d680548ebae79261e018ff8ab7e805bcc915fc5a Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 08:57:08 +0700 Subject: [PATCH 01/19] recharged_on datetime --- system/updates.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/updates.json b/system/updates.json index a0151c59..2e9b9530 100644 --- a/system/updates.json +++ b/system/updates.json @@ -13,5 +13,8 @@ ], "2023.8.23" : [ "ALTER TABLE `tbl_customers` CHANGE `pppoe_password` `pppoe_password` VARCHAR(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT 'For PPPOE Login';" + ], + "2023.8.28" : [ + "ALTER TABLE `tbl_user_recharges` CHANGE `recharged_on` `recharged_on` DATETIME NOT NULL;" ] } \ No newline at end of file From 51ac162642caa576ba81561f3456fb72c5a12295 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 08:57:33 +0700 Subject: [PATCH 02/19] Fix date field --- system/controllers/prepaid.php | 2 + ui/ui/prepaid-edit.tpl | 69 ++++++++++++++++++---------------- ui/ui/reports-period.tpl | 10 +---- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 8a9cb2d2..b3cf7e32 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -168,6 +168,7 @@ switch ($action) { $id_plan = _post('id_plan'); $recharged_on = _post('recharged_on'); $expiration = _post('expiration'); + $time = _post('time'); $id = _post('id'); $d = ORM::for_table('tbl_user_recharges')->find_one($id); @@ -182,6 +183,7 @@ switch ($action) { $d->plan_id = $id_plan; $d->recharged_on = $recharged_on; $d->expiration = $expiration; + $d->time = $time; $d->save(); Package::changeTo($username, $id_plan); _log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['plan_name'] . '][' . Lang::moneyFormat($d['price']) . ']', 'Admin', $admin['id']); diff --git a/ui/ui/prepaid-edit.tpl b/ui/ui/prepaid-edit.tpl index 03abd043..d95009cc 100644 --- a/ui/ui/prepaid-edit.tpl +++ b/ui/ui/prepaid-edit.tpl @@ -3,57 +3,62 @@
-

{$_L['Recharge_Account']}

+
+

{$_L['Recharge_Account']}

+
- +
- -
- -
+ +
+ +
- -
- {foreach $p as $ps} - + {/foreach} -
+
- -
-
- - -
-
+ +
+ +
- -
-
- - -
-
+ +
+ +
+
+ +
-
-
- - Or {$_L['Cancel']} -
-
+
+
+ + Or {$_L['Cancel']} +
+
-{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/reports-period.tpl b/ui/ui/reports-period.tpl index 67a378b6..557c2932 100644 --- a/ui/ui/reports-period.tpl +++ b/ui/ui/reports-period.tpl @@ -10,19 +10,13 @@
-
- - -
+
-
- - -
+
From b4f5cf895496be7881bc4adaa9df5dac2cb81da3 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 09:44:57 +0700 Subject: [PATCH 03/19] Fix Recharge time --- install/phpnuxbill.sql | 2 + system/autoload/Package.php | 10 ++ system/controllers/prepaid.php | 2 +- system/controllers/voucher.php | 177 +-------------------------------- system/updates.json | 3 +- ui/ui/customers-view.tpl | 18 ++-- ui/ui/dashboard.tpl | 4 +- ui/ui/invoice-print.tpl | 5 +- ui/ui/invoice.tpl | 5 +- ui/ui/prepaid-edit.tpl | 4 +- ui/ui/prepaid.tpl | 128 ++++++++++++------------ ui/ui/print-by-date.tpl | 4 +- ui/ui/print-by-period.tpl | 4 +- ui/ui/reports-daily.tpl | 4 +- ui/ui/reports-period-view.tpl | 4 +- ui/ui/user-activation-list.tpl | 5 +- ui/ui/user-dashboard.tpl | 27 ++--- 17 files changed, 124 insertions(+), 282 deletions(-) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 28903fe6..c2c2127b 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -228,6 +228,7 @@ CREATE TABLE `plan_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `recharged_on` date NOT NULL, + `recharged_time` time NOT NULL DEFAULT '00:00:00', `expiration` date NOT NULL, `time` time NOT NULL, `method` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, @@ -271,6 +272,7 @@ CREATE TABLE `plan_id` int(10) NOT NULL, `namebp` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `recharged_on` date NOT NULL, + `recharged_time` time NOT NULL DEFAULT '00:00:00', `expiration` date NOT NULL, `time` time NOT NULL, `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 97fbda01..e99bf889 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -22,6 +22,7 @@ class Package global $_c, $_L, $_notifmsg; $date_now = date("Y-m-d H:i:s"); $date_only = date("Y-m-d"); + $time_only = date("H:i:s"); $time = date("H:i:s"); if ($id_customer == '' or $router_name == '' or $plan_id == '') { @@ -40,6 +41,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; + $t->recharge_time = date("H:i:s"); $t->expiration = $date_only; $t->time = $time; $t->method = "$gateway - $channel"; @@ -105,6 +107,7 @@ class Package $b->plan_id = $plan_id; $b->namebp = $p['name_plan']; $b->recharged_on = $date_only; + $b->recharge_time = $time_only; $b->expiration = $date_exp; $b->time = $time; $b->status = "on"; @@ -120,6 +123,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; + $t->recharge_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -139,6 +143,7 @@ class Package $d->plan_id = $plan_id; $d->namebp = $p['name_plan']; $d->recharged_on = $date_only; + $d->recharge_time = $time_only; $d->expiration = $date_exp; $d->time = $time; $d->status = "on"; @@ -154,6 +159,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; + $t->recharge_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -181,6 +187,7 @@ class Package $b->plan_id = $plan_id; $b->namebp = $p['name_plan']; $b->recharged_on = $date_only; + $b->recharge_time = $time_only; $b->expiration = $date_exp; $b->time = $time; $b->status = "on"; @@ -196,6 +203,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; + $t->recharge_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -215,6 +223,7 @@ class Package $d->plan_id = $plan_id; $d->namebp = $p['name_plan']; $d->recharged_on = $date_only; + $d->recharge_time = $time_only; $d->expiration = $date_exp; $d->time = $time; $d->status = "on"; @@ -230,6 +239,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; + $t->recharge_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index b3cf7e32..28c85ccd 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -181,7 +181,7 @@ switch ($action) { run_hook('edit_customer_plan'); #HOOK $d->username = $username; $d->plan_id = $id_plan; - $d->recharged_on = $recharged_on; + //$d->recharged_on = $recharged_on; $d->expiration = $expiration; $d->time = $time; $d->save(); diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index eb322db4..f40ee9a5 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -26,187 +26,16 @@ switch ($action) { case 'activation-post': $code = _post('code'); $v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one(); - - $c = ORM::for_table('tbl_customers')->find_one($user['id']); - $p = ORM::for_table('tbl_plans')->find_one($v1['id_plan']); - $b = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->find_one(); - - $date_now = date("Y-m-d H:i:s"); - $date_only = date("Y-m-d"); - $time = date("H:i:s"); - - $mikrotik = Mikrotik::info($v1['routers']); - if ($p['validity_unit'] == 'Months') { - $date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month')); - } else if ($p['validity_unit'] == 'Days') { - $date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' day')); - } else if ($p['validity_unit'] == 'Hrs') { - $datetime = explode(' ', date("Y-m-d H:i:s", strtotime('+' . $p['validity'] . ' hour'))); - $date_exp = $datetime[0]; - $time = $datetime[1]; - } else if ($p['validity_unit'] == 'Mins') { - $datetime = explode(' ', date("Y-m-d H:i:s", strtotime('+' . $p['validity'] . ' minute'))); - $date_exp = $datetime[0]; - $time = $datetime[1]; - } run_hook('customer_activate_voucher'); #HOOK if ($v1) { - if ($v1['type'] == 'Hotspot') { - if ($b) { - if (!$config['radius_mode']) { - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removeHotspotUser($client, $c['username']); - Mikrotik::addHotspotUser($client, $p, $c); - } - $b->customer_id = $user['id']; - $b->username = $c['username']; - $b->plan_id = $v1['id_plan']; - $b->namebp = $p['name_plan']; - $b->recharged_on = $date_only; - $b->expiration = $date_exp; - $b->time = $time; - $b->status = "on"; - $b->method = "voucher"; - $b->routers = $v1['routers']; - $b->type = "Hotspot"; - $b->save(); - - // insert table transactions - $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); - $t->username = $c['username']; - $t->plan_name = $p['name_plan']; - $t->price = $p['price']; - $t->recharged_on = $date_only; - $t->expiration = $date_exp; - $t->time = $time; - $t->method = "voucher"; - $t->routers = $v1['routers']; - $t->type = "Hotspot"; - $t->save(); - } else { - if (!$config['radius_mode']) { - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addHotspotUser($client, $p, $c); - } - - $d = ORM::for_table('tbl_user_recharges')->create(); - $d->customer_id = $user['id']; - $d->username = $c['username']; - $d->plan_id = $v1['id_plan']; - $d->namebp = $p['name_plan']; - $d->recharged_on = $date_only; - $d->expiration = $date_exp; - $d->time = $time; - $d->status = "on"; - $d->method = "voucher"; - $d->routers = $v1['routers']; - $d->type = "Hotspot"; - $d->save(); - - // insert table transactions - $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); - $t->username = $c['username']; - $t->plan_name = $p['name_plan']; - $t->price = $p['price']; - $t->recharged_on = $date_only; - $t->expiration = $date_exp; - $t->time = $time; - $t->method = "voucher"; - $t->routers = $v1['routers']; - $t->type = "Hotspot"; - $t->save(); - } - + if (Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) { $v1->status = "1"; $v1->user = $c['username']; $v1->save(); - // Telegram to Admin - Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #Hotspot\n" . $p['name_plan'] . - "\nCode: " . $code . - "\nRouter: " . $v1['routers'] . - "\nPrice: " . $p['price']); + r2(U . "voucher/list-activated", 's', $_L['Activation_Vouchers_Successfully']); } else { - if ($b) { - if (!$config['radius_mode']) { - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removePpoeUser($client, $c['username']); - Mikrotik::addPpoeUser($client, $p, $c); - } - - $b->customer_id = $user['id']; - $b->username = $c['username']; - $b->plan_id = $v1['id_plan']; - $b->namebp = $p['name_plan']; - $b->recharged_on = $date_only; - $b->expiration = $date_exp; - $b->time = $time; - $b->status = "on"; - $b->method = "voucher"; - $b->routers = $v1['routers']; - $b->type = "PPPOE"; - $b->save(); - - // insert table transactions - $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); - $t->username = $c['username']; - $t->plan_name = $p['name_plan']; - $t->price = $p['price']; - $t->recharged_on = $date_only; - $t->expiration = $date_exp; - $t->time = $time; - $t->method = "voucher"; - $t->routers = $v1['routers']; - $t->type = "PPPOE"; - $t->save(); - } else { - if (!$config['radius_mode']) { - $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addPpoeUser($client, $p, $c); - } - - $d = ORM::for_table('tbl_user_recharges')->create(); - $d->customer_id = $user['id']; - $d->username = $c['username']; - $d->plan_id = $v1['id_plan']; - $d->namebp = $p['name_plan']; - $d->recharged_on = $date_only; - $d->expiration = $date_exp; - $d->time = $time; - $d->status = "on"; - $d->method = "voucher"; - $d->routers = $v1['routers']; - $d->type = "PPPOE"; - $d->save(); - - // insert table transactions - $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); - $t->username = $c['username']; - $t->plan_name = $p['name_plan']; - $t->price = $p['price']; - $t->recharged_on = $date_only; - $t->expiration = $date_exp; - $t->time = $time; - $t->method = "voucher"; - $t->routers = $v1['routers']; - $t->type = "PPPOE"; - $t->save(); - } - - $v1->status = "1"; - $v1->user = $c['username']; - $v1->save(); - // Telegram to Admin - Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #PPPOE\n" . $p['name_plan'] . - "\nCode: " . $code . - "\nRouter: " . $v1['routers'] . - "\nPrice: " . $p['price']); + r2(U . 'voucher/activation', 'e', "Failed to refill account"); } - - r2(U . "voucher/list-activated", 's', $_L['Activation_Vouchers_Successfully']); } else { r2(U . 'voucher/activation', 'e', $_L['Voucher_Not_Valid']); } diff --git a/system/updates.json b/system/updates.json index 2e9b9530..6269b896 100644 --- a/system/updates.json +++ b/system/updates.json @@ -15,6 +15,7 @@ "ALTER TABLE `tbl_customers` CHANGE `pppoe_password` `pppoe_password` VARCHAR(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT 'For PPPOE Login';" ], "2023.8.28" : [ - "ALTER TABLE `tbl_user_recharges` CHANGE `recharged_on` `recharged_on` DATETIME NOT NULL;" + "ALTER TABLE `tbl_user_recharges` ADD `recharged_time` time NOT NULL DEFAULT '00:00:00' AFTER `recharged_on`;", + "ALTER TABLE `tbl_transactions` ADD `recharged_time` time NOT NULL DEFAULT '00:00:00' AFTER `recharged_on`;" ] } \ No newline at end of file diff --git a/ui/ui/customers-view.tpl b/ui/ui/customers-view.tpl index c990fa1f..422aaadb 100644 --- a/ui/ui/customers-view.tpl +++ b/ui/ui/customers-view.tpl @@ -73,7 +73,8 @@ class="pull-right">{if $package['status']=='on'}yes{else}no{/if}
  • - {$_L['Created_On']} {Lang::dateFormat($package['recharged_on'])} + {$_L['Created_On']} {Lang::dateAndTimeFormat($package['recharged_on'],$package['recharged_time'])}
  • {$_L['Expires_On']} {$ds['plan_name']} {Lang::moneyFormat($ds['price'])} {$ds['type']} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} - {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {/foreach} @@ -146,12 +147,9 @@ {$ds['routers']} {$ds['payment_channel']} {Lang::moneyFormat($ds['price'])} - {date("{$_c['date_format']} H:i", - strtotime($ds['created_date']))} - {date("{$_c['date_format']} H:i", - strtotime($ds['expired_date']))} - {if $ds['status']!=1}{date("{$_c['date_format']} H:i", - strtotime($ds['paid_date']))}{/if} + {Lang::dateTimeFormat($ds['created_date'])} + {Lang::dateTimeFormat($ds['expired_date'])} + {if $ds['status']!=1}{Lang::dateTimeFormat($ds['paid_date'])}{/if} {if $ds['status']==1}{$_L['UNPAID']} {elseif $ds['status']==2}{$_L['PAID']} {elseif $ds['status']==3}{$_L['FAILED']} diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl index 6d8151fc..873d4ee0 100644 --- a/ui/ui/dashboard.tpl +++ b/ui/ui/dashboard.tpl @@ -108,9 +108,9 @@ {$no++} {$expired['username']} - {date($_c['date_format'], strtotime($expired['recharged_on']))} + {Lang::dateAndTimeFormat($expired['recharged_on'],$expired['recharged_time'])} - {date($_c['date_format'], strtotime($expired['expiration']))} {$expired['time']} + {Lang::dateAndTimeFormat($expired['expiration'],$expired['time'])} diff --git a/ui/ui/invoice-print.tpl b/ui/ui/invoice-print.tpl index 8da794d5..942692ec 100644 --- a/ui/ui/invoice-print.tpl +++ b/ui/ui/invoice-print.tpl @@ -39,9 +39,8 @@ {$_L['Password']} : **********
    {if $in['type'] != 'Balance'}
    - {$_L['Created_On']} : {date($_c['date_format'], strtotime($d['recharged_on']))}
    - {$_L['Expires_On']} : {date($_c['date_format'], strtotime($d['expiration']))} - {$d['time']}
    + {$_L['Created_On']} : {Lang::dateAndTimeFormat($d['recharged_on'],$d['recharged_time'])}
    + {$_L['Expires_On']} : {Lang::dateAndTimeFormat($d['expiration'],$d['time'])}
    {/if} ============================================
    {$_c['note']}
    diff --git a/ui/ui/invoice.tpl b/ui/ui/invoice.tpl index 5f4a9d3f..fdb48984 100644 --- a/ui/ui/invoice.tpl +++ b/ui/ui/invoice.tpl @@ -24,9 +24,8 @@ {$_L['Password']} : **********
    {if $in['type'] != 'Balance'}
    - {$_L['Created_On']} : {date($_c['date_format'], strtotime($in['recharged_on']))}
    - {$_L['Expires_On']} : {date($_c['date_format'], strtotime($in['expiration']))} - {$in['time']}
    + {$_L['Created_On']} : {Lang::dateAndTimeFormat($in['recharged_on'],$in['recharged_time'])}
    + {$_L['Expires_On']} : {Lang::dateAndTimeFormat($in['expiration'],$in['time'])}
    {/if} =====================================================
    {$_c['note']}
    diff --git a/ui/ui/prepaid-edit.tpl b/ui/ui/prepaid-edit.tpl index d95009cc..07080688 100644 --- a/ui/ui/prepaid-edit.tpl +++ b/ui/ui/prepaid-edit.tpl @@ -32,8 +32,8 @@
    - +
    diff --git a/ui/ui/prepaid.tpl b/ui/ui/prepaid.tpl index a80aabcb..3a8ad2be 100644 --- a/ui/ui/prepaid.tpl +++ b/ui/ui/prepaid.tpl @@ -1,66 +1,70 @@ {include file="sections/header.tpl"} -
    -
    -
    -
    {$_L['Prepaid_User']}
    -
    -
    -
    - -
    -   -
    -
    - - - - - - - - - - - - - - - {foreach $d as $ds} - - - - - - - - - - - {/foreach} - -
    {$_L['Username']}{$_L['Plan_Name']}{$_L['Type']}{$_L['Created_On']}{$_L['Expires_On']}{$_L['Method']}{$_L['Routers']}{$_L['Manage']}
    {$ds['username']}{$ds['namebp']}{$ds['type']}{$ds['recharged_on']}{$ds['expiration']} {$ds['time']}{$ds['method']}{$ds['routers']} - {$_L['Edit']} - {$_L['Delete']} -
    -
    - {$paginator['contents']} -
    -
    -
    -
    +
    +
    +
    +
    {$_L['Prepaid_User']}
    +
    +
    +
    + +
    +   +
    +
    + + + + + + + + + + + + + + + {foreach $d as $ds} + + + + + + + + + + + {/foreach} + +
    {$_L['Username']}{$_L['Plan_Name']}{$_L['Type']}{$_L['Created_On']}{$_L['Expires_On']}{$_L['Method']}{$_L['Routers']}{$_L['Manage']}
    {$ds['username']}{$ds['namebp']}{$ds['type']}{Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])}{Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])}{$ds['method']}{$ds['routers']} + {$_L['Edit']} + {$_L['Delete']} +
    +
    + {$paginator['contents']} +
    +
    +
    +
    -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/print-by-date.tpl b/ui/ui/print-by-date.tpl index fd8f3d9a..ed7e96ee 100644 --- a/ui/ui/print-by-date.tpl +++ b/ui/ui/print-by-date.tpl @@ -39,8 +39,8 @@ {$ds['plan_name']} {$ds['type']} {Lang::moneyFormat($ds['price'])} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {$ds['routers']} diff --git a/ui/ui/print-by-period.tpl b/ui/ui/print-by-period.tpl index 95f47a51..ec8d0ab6 100644 --- a/ui/ui/print-by-period.tpl +++ b/ui/ui/print-by-period.tpl @@ -39,8 +39,8 @@ {$ds['plan_name']} {$ds['type']} {Lang::moneyFormat($ds['price'])} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {$ds['routers']} diff --git a/ui/ui/reports-daily.tpl b/ui/ui/reports-daily.tpl index 116a342c..53525a83 100644 --- a/ui/ui/reports-daily.tpl +++ b/ui/ui/reports-daily.tpl @@ -42,8 +42,8 @@ {$ds['type']} {$ds['plan_name']} {Lang::moneyFormat($ds['price'])} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {$ds['routers']} diff --git a/ui/ui/reports-period-view.tpl b/ui/ui/reports-period-view.tpl index 1082f1b5..69a5f43c 100644 --- a/ui/ui/reports-period-view.tpl +++ b/ui/ui/reports-period-view.tpl @@ -53,8 +53,8 @@ {$ds['type']} {$ds['plan_name']} {Lang::moneyFormat($ds['price'])} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {$ds['routers']} diff --git a/ui/ui/user-activation-list.tpl b/ui/ui/user-activation-list.tpl index e0a4542e..8d6c8841 100644 --- a/ui/ui/user-activation-list.tpl +++ b/ui/ui/user-activation-list.tpl @@ -26,9 +26,8 @@ {$ds['plan_name']} {Lang::moneyFormat($ds['price'])} {$ds['type']} - {date($_c['date_format'], strtotime($ds['recharged_on']))} - {date($_c['date_format'], strtotime($ds['expiration']))} - {$ds['time']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])} {$ds['method']} {/foreach} diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index 39a63c31..12941cd7 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -84,14 +84,14 @@ {$_L['Created_On']} - {if $_bill['time'] ne ''}{date($_c['date_format'], strtotime($_bill['recharged_on']))} + {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])} {/if}  {$_L['Expires_On']} - {if $_bill['time'] ne ''}{date($_c['date_format'], strtotime($_bill['expiration']))} - {$_bill['time']}{/if}  + {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  + {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'} {if $nux_ip} @@ -151,23 +151,24 @@ placeholder="{$_L['Username']}">
    - +
    - +
  • From 3b4e3c778986c25cdec35aaa4fac14c5ac21082b Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 09:46:19 +0700 Subject: [PATCH 04/19] fix allow_balance_transfer in customer home --- ui/ui/user-dashboard.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index 12941cd7..4a7f413d 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -138,7 +138,7 @@ }, 2000); {/if} - {if $_c['enable_balance'] == 'yes'} + {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes'}

    {Lang::T("Transfer Balance")}

    From 3eefec6e216521d055d8ae947610d66fbac8225f Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 09:47:04 +0700 Subject: [PATCH 05/19] if enable_balance and allow_balance_transfer --- system/controllers/home.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/controllers/home.php b/system/controllers/home.php index 821261be..851a7a16 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -15,7 +15,7 @@ if (isset($_GET['renewal'])) { } if (_post('send') == 'balance') { - if ($config['allow_balance_transfer'] == 'yes') { + if ($config['enable_balance'] == 'yes' && $config['allow_balance_transfer'] == 'yes') { $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); if (!$target) { r2(U . 'home', 'd', Lang::T('Username not found')); From 1dd03168f02dd6b2b848aebe973ba6c600fbb63b Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 10:12:55 +0700 Subject: [PATCH 06/19] Fix time Field --- system/autoload/Mikrotik.php | 5 ++- system/autoload/Package.php | 18 +++++------ ui/ui/prepaid-edit.tpl | 2 +- ui/ui/router-error.tpl | 59 ++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 ui/ui/router-error.tpl diff --git a/system/autoload/Mikrotik.php b/system/autoload/Mikrotik.php index 7b7f82ca..ae9809ec 100644 --- a/system/autoload/Mikrotik.php +++ b/system/autoload/Mikrotik.php @@ -12,11 +12,14 @@ class Mikrotik public static function getClient($ip, $user, $pass) { + global $ui; try { $iport = explode(":", $ip); return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null); } catch (Exception $e) { - die("Unable to connect to the router.
    " . $e->getMessage()); + $ui->assign("error_meesage","Unable to connect to the router.
    " . $e->getMessage()); + $ui->display('router-error.tpl'); + die(); } } diff --git a/system/autoload/Package.php b/system/autoload/Package.php index e99bf889..499067a8 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -41,7 +41,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; - $t->recharge_time = date("H:i:s"); + $t->recharged_time = date("H:i:s"); $t->expiration = $date_only; $t->time = $time; $t->method = "$gateway - $channel"; @@ -107,7 +107,7 @@ class Package $b->plan_id = $plan_id; $b->namebp = $p['name_plan']; $b->recharged_on = $date_only; - $b->recharge_time = $time_only; + $b->recharged_time = $time_only; $b->expiration = $date_exp; $b->time = $time; $b->status = "on"; @@ -123,7 +123,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; - $t->recharge_time = $time_only; + $t->recharged_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -143,7 +143,7 @@ class Package $d->plan_id = $plan_id; $d->namebp = $p['name_plan']; $d->recharged_on = $date_only; - $d->recharge_time = $time_only; + $d->recharged_time = $time_only; $d->expiration = $date_exp; $d->time = $time; $d->status = "on"; @@ -159,7 +159,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; - $t->recharge_time = $time_only; + $t->recharged_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -187,7 +187,7 @@ class Package $b->plan_id = $plan_id; $b->namebp = $p['name_plan']; $b->recharged_on = $date_only; - $b->recharge_time = $time_only; + $b->recharged_time = $time_only; $b->expiration = $date_exp; $b->time = $time; $b->status = "on"; @@ -203,7 +203,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; - $t->recharge_time = $time_only; + $t->recharged_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; @@ -223,7 +223,7 @@ class Package $d->plan_id = $plan_id; $d->namebp = $p['name_plan']; $d->recharged_on = $date_only; - $d->recharge_time = $time_only; + $d->recharged_time = $time_only; $d->expiration = $date_exp; $d->time = $time; $d->status = "on"; @@ -239,7 +239,7 @@ class Package $t->plan_name = $p['name_plan']; $t->price = $p['price']; $t->recharged_on = $date_only; - $t->recharge_time = $time_only; + $t->recharged_time = $time_only; $t->expiration = $date_exp; $t->time = $time; $t->method = "$gateway - $channel"; diff --git a/ui/ui/prepaid-edit.tpl b/ui/ui/prepaid-edit.tpl index 07080688..90a02adb 100644 --- a/ui/ui/prepaid-edit.tpl +++ b/ui/ui/prepaid-edit.tpl @@ -43,7 +43,7 @@ value="{$d['expiration']}">
    -
    diff --git a/ui/ui/router-error.tpl b/ui/ui/router-error.tpl new file mode 100644 index 00000000..fad1e26d --- /dev/null +++ b/ui/ui/router-error.tpl @@ -0,0 +1,59 @@ + + + + + + + Router Error - PHPNuxBill + + + + + + + + + + + + + + + +
    +
    +

    + Router Error +

    +
    + +
    +
    +
    +
    +
    + {$error_meesage} +
    + back +
    +
    +
    +
    + PHPNuxBill by iBNuX +
    +
    + + + \ No newline at end of file From fe1310bd576688d9349de6ebcf1fc5cfacafc84e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 10:23:54 +0700 Subject: [PATCH 07/19] extend expiration after buy same package --- system/autoload/Package.php | 35 ++++++++++++++++++++++++++++++++++ system/controllers/voucher.php | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 499067a8..1cb6473a 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -102,6 +102,23 @@ class Package Mikrotik::addHotspotUser($client, $p, $c); } + if ($b['namebp'] == $p['name_plan']) { + // if it same internet plan, expired will extend + if ($p['validity_unit'] == 'Months') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + } else if ($p['validity_unit'] == 'Days') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); + } else if ($p['validity_unit'] == 'Hrs') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } else if ($p['validity_unit'] == 'Mins') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; @@ -182,6 +199,24 @@ class Package Mikrotik::addPpoeUser($client, $p, $c); } + + if ($b['namebp'] == $p['name_plan']) { + // if it same internet plan, expired will extend + if ($p['validity_unit'] == 'Months') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + } else if ($p['validity_unit'] == 'Days') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); + } else if ($p['validity_unit'] == 'Hrs') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } else if ($p['validity_unit'] == 'Mins') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index f40ee9a5..3f2c8993 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -28,9 +28,9 @@ switch ($action) { $v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one(); run_hook('customer_activate_voucher'); #HOOK if ($v1) { - if (Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) { + if (Package::rechargeUser($user['id'], $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) { $v1->status = "1"; - $v1->user = $c['username']; + $v1->user = $user['username']; $v1->save(); r2(U . "voucher/list-activated", 's', $_L['Activation_Vouchers_Successfully']); } else { From d0cebe7458b4094112c6d17af48314df3f88182e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 10:27:31 +0700 Subject: [PATCH 08/19] 2023.8.28 --- CHANGELOG.md | 7 +++++++ version.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d09b0f..44a51477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ # CHANGELOG +## 2023.8.28 + +- Extend expiration if buy same package +- Fix calendar +- Add recharge time +- Fix allow balance transfer + ## 2023.8.24 - Balance transfer between Customer diff --git a/version.json b/version.json index 89bbc3fb..defafa7d 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2023.8.24" + "version": "2023.8.28" } \ No newline at end of file From 717b21e65e190e78c406b78471972f781df84388 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 10:38:59 +0700 Subject: [PATCH 09/19] Fix Remove PPPOE user --- system/autoload/Mikrotik.php | 20 ++++++++++---------- system/autoload/Package.php | 7 +++++++ system/cron.php | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/system/autoload/Mikrotik.php b/system/autoload/Mikrotik.php index ae9809ec..a965e785 100644 --- a/system/autoload/Mikrotik.php +++ b/system/autoload/Mikrotik.php @@ -219,17 +219,17 @@ class Mikrotik public static function removePpoeUser($client, $username) { - $printRequest = new RouterOS\Request( - '/ppp secret print .proplist=name', - RouterOS\Query::where('name', $username) - ); - $id = $client->sendSync($printRequest)->getProperty('.id'); - $removeRequest = new RouterOS\Request('/ppp/secret/remove'); - $client( - $removeRequest - ->setArgument('numbers', $id) - ); + $printRequest = new RouterOS\Request('/ppp/secret/print'); + $printRequest->setArgument('.proplist', '.id'); + $printRequest->setQuery(RouterOS\Query::where('name', $username)); + $id = $client->sendSync($printRequest)->getProperty('.id'); + + $removeRequest = new RouterOS\Request('/ppp/secret/remove'); + $client( + $removeRequest + ->setArgument('numbers', $id) + ); } public static function addPpoeUser($client, $plan, $customer) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 1cb6473a..61c6dd1d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -249,6 +249,7 @@ class Package if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); } @@ -327,11 +328,14 @@ class Package if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); } } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); } } @@ -339,12 +343,15 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); } } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); } } diff --git a/system/cron.php b/system/cron.php index 75465898..6c324b7f 100644 --- a/system/cron.php +++ b/system/cron.php @@ -65,7 +65,7 @@ date_default_timezone_set($config['timezone']); $textExpired = Lang::getNotifText('expired'); -$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->where('expiration', date("Y-m-d"))->find_many(); +$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->where_lte('expiration', date("Y-m-d"))->find_many(); echo "Found ".count($d)." user(s)\n"; run_hook('cronjob'); #HOOK From 341e26f4d6a655a582df257b7fa0117a6e6bb40f Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 15:21:57 +0700 Subject: [PATCH 10/19] rename pages --- install/index.php | 7 ++---- install/step2.php | 7 ++---- install/step3.php | 7 ++---- install/step4.php | 7 ++---- install/step5.php | 62 +++++++++++++++++++++++----------------------- install/update.php | 7 ++---- 6 files changed, 41 insertions(+), 56 deletions(-) diff --git a/install/index.php b/install/index.php index 7e5e0206..9299ab4e 100644 --- a/install/index.php +++ b/install/index.php @@ -16,11 +16,8 @@
    -
    -
    - -
    -
    + Logo +
    diff --git a/install/step2.php b/install/step2.php index df1989e3..616201db 100644 --- a/install/step2.php +++ b/install/step2.php @@ -16,11 +16,8 @@
    -
    -
    - -
    -
    + Logo +

    PHPNuxBill Installer

    diff --git a/install/step3.php b/install/step3.php index 4e3e4f9a..bd168a89 100644 --- a/install/step3.php +++ b/install/step3.php @@ -15,11 +15,8 @@
    -
    -
    - -
    -
    + Logo +

    PHPNuxBill Installer

    diff --git a/install/step4.php b/install/step4.php index 306d3b15..2208a751 100644 --- a/install/step4.php +++ b/install/step4.php @@ -82,11 +82,8 @@ $wConfig = "../config.php";
    -
    -
    - -
    -
    + Logo +

    PHPNuxBill Installer

    diff --git a/install/step5.php b/install/step5.php index 714669db..4530ab06 100644 --- a/install/step5.php +++ b/install/step5.php @@ -1,7 +1,8 @@ + - PHPNuxBill Installer + PHPNuxBill Installer @@ -9,38 +10,37 @@ - + - + -
    -
    -
    - -
    -
    - -
    -

    PHPNuxBill Installer

    -

    - Congratulations!
    - You have just install PHPNuxBill !
    - To Login Admin Portal:
    - Use this link - - ' . $appurl . '/admin'; - ?> -
    - Username: admin
    - Password: admin
    - For security, Delete the install directory inside system folder. -

    -
    -
    - +
    + Logo +
    +
    +

    PHPNuxBill Installer

    +

    + Congratulations!
    + You have just install PHPNuxBill !

    + But wait!!
    + Don't forget to rename folder pages_example to pages


    + To Login Admin Portal:
    + Use this link - + ' . $appurl . '/admin'; + ?> +
    + Username: admin
    + Password: admin
    + For security, Delete the install directory inside system folder. +

    +
    +
    + + \ No newline at end of file diff --git a/install/update.php b/install/update.php index 009532d4..d58e551c 100644 --- a/install/update.php +++ b/install/update.php @@ -16,11 +16,8 @@
    -
    -
    - -
    -
    + Logo +

    PHPNuxBill Updater

    From 00cf90e6eadb3287d16f699e79aed7686ad2ae5e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 15:23:23 +0700 Subject: [PATCH 11/19] auto rename pages_example --- install/step5.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/step5.php b/install/step5.php index 4530ab06..ac3098bc 100644 --- a/install/step5.php +++ b/install/step5.php @@ -24,7 +24,8 @@ Congratulations!
    You have just install PHPNuxBill !

    But wait!!
    - Don't forget to rename folder pages_example to pages


    + Don't forget to rename folder pages_example to pages.
    + if it not yet renamed

    To Login Admin Portal:
    Use this link - Date: Mon, 28 Aug 2023 15:45:47 +0700 Subject: [PATCH 12/19] info about PHPNuxBill --- install/step5.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/install/step5.php b/install/step5.php index ac3098bc..bf44338c 100644 --- a/install/step5.php +++ b/install/step5.php @@ -13,7 +13,8 @@ - + +
    Logo @@ -24,8 +25,15 @@ Congratulations!
    You have just install PHPNuxBill !

    But wait!!
    - Don't forget to rename folder pages_example to pages.
    - if it not yet renamed


    +
      +
    1. Don't forget to rename folder pages_example to pages.
      + if it not yet renamed
    2. +
    3. Activate Cronjob for Expired and Reminder.
    4. +
    5. Check how PHPNuxbill Works
    6. +
    7. how to link Mikrotik Login to PHPNuxBill
    8. +
    9. or use Mikrotik Login Template for PHPNuxBill
    10. +
    +

    To Login Admin Portal:
    Use this link - Date: Mon, 28 Aug 2023 15:46:25 +0700 Subject: [PATCH 13/19] PHP NuxBill -> PHPNuxBill --- update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.php b/update.php index 6222790e..c11fe563 100644 --- a/update.php +++ b/update.php @@ -208,7 +208,7 @@ function deleteFolder($path)

    - Update PHP NuxBill + Update PHPNuxBill

    From 51416626fbab96e2ad514044360cf0fab25487b6 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 09:01:37 +0700 Subject: [PATCH 14/19] Fix Print Invoice --- system/controllers/prepaid.php | 11 ++++------- ui/ui/invoice-print.tpl | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 28c85ccd..e3910e1b 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -114,7 +114,6 @@ switch ($action) { case 'print': $id = _post('id'); - $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one(); $ui->assign('d', $d); @@ -367,19 +366,17 @@ switch ($action) { break; case 'refill-post': - $user = _post('id_customer'); $code = _post('code'); - + $user = ORM::for_table('tbl_customers')->where('id', _post('id_customer'))->find_one(); $v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one(); run_hook('refill_customer'); #HOOK if ($v1) { - if (Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Refill", "Voucher")) { + if (Package::rechargeUser($user['id'], $v1['routers'], $v1['id_plan'], "Refill", "Voucher")) { $v1->status = "1"; - $v1->user = $c['username']; + $v1->user = $user['username']; $v1->save(); - $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); - $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); + $in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->order_by_desc('id')->find_one(); $ui->assign('in', $in); $ui->assign('date', date("Y-m-d H:i:s")); $ui->display('invoice.tpl'); diff --git a/ui/ui/invoice-print.tpl b/ui/ui/invoice-print.tpl index 942692ec..09899735 100644 --- a/ui/ui/invoice-print.tpl +++ b/ui/ui/invoice-print.tpl @@ -33,7 +33,7 @@ ============================================
    {$_L['Type']} : {$d['type']}
    {$_L['Plan_Name']} : {$d['plan_name']}
    - {$_L['Plan_Price']} : {Lang::moneyFormat($in['price'])}
    + {$_L['Plan_Price']} : {Lang::moneyFormat($d['price'])}

    {$_L['Username']} : {$d['username']}
    {$_L['Password']} : **********
    From 1b15da5c0448e7c44a8813f24e09fc77ef85e6bb Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 09:55:39 +0700 Subject: [PATCH 15/19] Upload Logo For PDF Reports --- system/autoload/File.php | 57 ++++++++++++++++++++++ system/controllers/settings.php | 81 ++++++++++++++++++------------- system/lan/english/common.lan.php | 1 + ui/ui/app-settings.tpl | 13 ++++- 4 files changed, 117 insertions(+), 35 deletions(-) diff --git a/system/autoload/File.php b/system/autoload/File.php index 9f94b7c2..1a8e4cf6 100644 --- a/system/autoload/File.php +++ b/system/autoload/File.php @@ -33,6 +33,63 @@ class File rmdir($path); } + public static function resizeCropImage($source_file, $dst_dir, $max_width, $max_height, $quality = 80) + { + $imgsize = getimagesize($source_file); + $width = $imgsize[0]; + $height = $imgsize[1]; + $mime = $imgsize['mime']; + + switch ($mime) { + case 'image/gif': + $image_create = "imagecreatefromgif"; + $image = "imagegif"; + break; + + case 'image/png': + $image_create = "imagecreatefrompng"; + $image = "imagepng"; + $quality = 7; + break; + + case 'image/jpeg': + $image_create = "imagecreatefromjpeg"; + $image = "imagejpeg"; + $quality = 80; + break; + + default: + return false; + break; + } + + if ($max_width == 0) { + $max_width = $width; + } + + if ($max_height == 0) { + $max_height = $height; + } + + $widthRatio = $max_width / $width; + $heightRatio = $max_height / $height; + $ratio = min($widthRatio, $heightRatio); + $nwidth = (int)$width * $ratio; + $nheight = (int)$height * $ratio; + + $dst_img = imagecreatetruecolor($nwidth, $nheight); + $white = imagecolorallocate($dst_img, 255, 255, 255); + imagefill($dst_img, 0, 0, $white); + $src_img = $image_create($source_file); + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height); + + $image($dst_img, $dst_dir, $quality); + + if ($dst_img) imagedestroy($dst_img); + if ($src_img) imagedestroy($src_img); + return file_exists($dst_dir); + } + /** * file path fixer diff --git a/system/controllers/settings.php b/system/controllers/settings.php index c764a33f..409a1459 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -17,6 +17,12 @@ switch ($action) { if ($admin['user_type'] != 'Admin') { r2(U . "dashboard", 'e', $_L['Do_Not_Access']); } + if (file_exists('system/uploads/logo.png')) { + $logo = 'system/uploads/logo.png?' . time(); + } else { + $logo = 'system/uploads/logo.default.png'; + } + $ui->assign('logo', $logo); run_hook('view_app_settings'); #HOOK $ui->display('app-settings.tpl'); break; @@ -219,8 +225,17 @@ switch ($action) { $user_notification_payment = _post('user_notification_payment'); $address = _post('address'); $tawkto = _post('tawkto'); - $radius_mode = _post('radius_mode')*1; + $radius_mode = _post('radius_mode') * 1; run_hook('save_settings'); #HOOK + + + if ($_FILES['logo']['error'] > 0) { + r2(U . 'settings/app', 'e', 'Failed to process logo'); + } + if (!empty($_FILES['logo']['name'])) { + if (file_exists('system/uploads/logo.png')) unlink('system/uploads/logo.png'); + File::resizeCropImage($_FILES['logo']['tmp_name'], 'system/uploads/logo.png', 1078, 200, 100); + } if ($company == '') { r2(U . 'settings/app', 'e', $_L['All_field_is_required']); } else { @@ -239,10 +254,10 @@ switch ($action) { $d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyFooter')->find_one(); - if($d){ + if ($d) { $d->value = $footer; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'CompanyFooter'; $d->value = $footer; @@ -250,10 +265,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'disable_voucher')->find_one(); - if($d){ + if ($d) { $d->value = $disable_voucher; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'disable_voucher'; $d->value = $disable_voucher; @@ -261,10 +276,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'enable_balance')->find_one(); - if($d){ + if ($d) { $d->value = $enable_balance; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'enable_balance'; $d->value = $enable_balance; @@ -272,10 +287,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'allow_balance_transfer')->find_one(); - if($d){ + if ($d) { $d->value = $allow_balance_transfer; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'allow_balance_transfer'; $d->value = $allow_balance_transfer; @@ -283,10 +298,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'minimum_transfer')->find_one(); - if($d){ + if ($d) { $d->value = $minimum_transfer; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'minimum_transfer'; $d->value = $minimum_transfer; @@ -294,10 +309,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_bot')->find_one(); - if($d){ + if ($d) { $d->value = $telegram_bot; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'telegram_bot'; $d->value = $telegram_bot; @@ -305,10 +320,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_target_id')->find_one(); - if($d){ + if ($d) { $d->value = $telegram_target_id; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'telegram_target_id'; $d->value = $telegram_target_id; @@ -316,10 +331,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'sms_url')->find_one(); - if($d){ + if ($d) { $d->value = $sms_url; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'sms_url'; $d->value = $sms_url; @@ -327,10 +342,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'wa_url')->find_one(); - if($d){ + if ($d) { $d->value = $wa_url; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'wa_url'; $d->value = $wa_url; @@ -338,10 +353,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired')->find_one(); - if($d){ + if ($d) { $d->value = $user_notification_expired; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'user_notification_expired'; $d->value = $user_notification_expired; @@ -349,10 +364,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_reminder')->find_one(); - if($d){ + if ($d) { $d->value = $user_notification_reminder; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'user_notification_reminder'; $d->value = $user_notification_reminder; @@ -360,10 +375,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_payment')->find_one(); - if($d){ + if ($d) { $d->value = $user_notification_payment; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'user_notification_payment'; $d->value = $user_notification_payment; @@ -371,10 +386,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'tawkto')->find_one(); - if($d){ + if ($d) { $d->value = $tawkto; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'tawkto'; $d->value = $tawkto; @@ -382,10 +397,10 @@ switch ($action) { } $d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_mode')->find_one(); - if($d){ + if ($d) { $d->value = $radius_mode; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'radius_mode'; $d->value = $radius_mode; @@ -436,10 +451,10 @@ switch ($action) { $d = ORM::for_table('tbl_appconfig')->where('setting', 'country_code_phone')->find_one(); - if($d){ + if ($d) { $d->value = $country_code_phone; $d->save(); - }else{ + } else { $d = ORM::for_table('tbl_appconfig')->create(); $d->setting = 'country_code_phone'; $d->value = $country_code_phone; @@ -509,9 +524,9 @@ switch ($action) { r2(U . "dashboard", 'e', $_L['Do_Not_Access']); } run_hook('view_notifications'); #HOOK - if(file_exists("system/uploads/notifications.json")){ + if (file_exists("system/uploads/notifications.json")) { $ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.json'), true)); - }else{ + } else { $ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.default.json'), true)); } $ui->assign('_default', json_decode(file_get_contents('system/uploads/notifications.default.json'), true)); diff --git a/system/lan/english/common.lan.php b/system/lan/english/common.lan.php index 4a65d646..44d946ba 100644 --- a/system/lan/english/common.lan.php +++ b/system/lan/english/common.lan.php @@ -384,3 +384,4 @@ $_L['Send_Balance'] = 'Send Balance'; $_L['Received_Balance'] = 'Received Balance'; $_L['Minimum_Balance_Transfer'] = 'Minimum Balance Transfer'; $_L['Minimum_Transfer'] = 'Minimum Transfer'; +$_L['Company_Logo'] = 'Company Logo'; diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index 566849df..bcf268b6 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -1,6 +1,6 @@ {include file="sections/header.tpl"} -
    +
    @@ -17,10 +17,19 @@
    -
    {$_L['App_Name_Help_Text']}
    +
    + +
    + + For PDF Reports | Beset size 1078 x 200 | uploaded image will be autosize +
    + + logo for PDF + +
    From 18d68d68c8fc1a909852999c88929272b8f8ef10 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 10:02:58 +0700 Subject: [PATCH 16/19] fix time, using text --- ui/ui/prepaid-edit.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/ui/prepaid-edit.tpl b/ui/ui/prepaid-edit.tpl index 90a02adb..8e46332e 100644 --- a/ui/ui/prepaid-edit.tpl +++ b/ui/ui/prepaid-edit.tpl @@ -43,7 +43,7 @@ value="{$d['expiration']}">
    -
    From 4de849fe3482b60c4ea296e0b182ed50f6c355e6 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 10:06:04 +0700 Subject: [PATCH 17/19] 2023.8.30 --- CHANGELOG.md | 6 ++++++ version.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a51477..487e4c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ # CHANGELOG +## 2023.8.30 + +- Upload Logo from settings +- Fix Print value +- Fix Time when editing prepaid + ## 2023.8.28 - Extend expiration if buy same package diff --git a/version.json b/version.json index defafa7d..ede51202 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2023.8.28" + "version": "2023.8.30" } \ No newline at end of file From 863dd6514571d5fc3bddd5bb9a57316fab0da50b Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 10:22:58 +0700 Subject: [PATCH 18/19] remove debug echo --- system/controllers/settings.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 409a1459..dbac280b 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -229,9 +229,6 @@ switch ($action) { run_hook('save_settings'); #HOOK - if ($_FILES['logo']['error'] > 0) { - r2(U . 'settings/app', 'e', 'Failed to process logo'); - } if (!empty($_FILES['logo']['name'])) { if (file_exists('system/uploads/logo.png')) unlink('system/uploads/logo.png'); File::resizeCropImage($_FILES['logo']['tmp_name'], 'system/uploads/logo.png', 1078, 200, 100); From 620bfaeb29323c883776c8b581d634c6b39d444c Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 30 Aug 2023 11:24:08 +0700 Subject: [PATCH 19/19] unlink after upload --- system/controllers/settings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/controllers/settings.php b/system/controllers/settings.php index dbac280b..b152eec8 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -232,6 +232,7 @@ switch ($action) { if (!empty($_FILES['logo']['name'])) { if (file_exists('system/uploads/logo.png')) unlink('system/uploads/logo.png'); File::resizeCropImage($_FILES['logo']['tmp_name'], 'system/uploads/logo.png', 1078, 200, 100); + if (file_exists($_FILES['logo']['tmp_name'])) unlink($_FILES['logo']['tmp_name']); } if ($company == '') { r2(U . 'settings/app', 'e', $_L['All_field_is_required']);