From 6e07c3ae85723c40cb9eb88aebfc1f00699febd8 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Sun, 10 Mar 2024 22:41:48 +0100 Subject: [PATCH 01/20] Update dashboard.php Fix when user purchase services with his/her balance it wont be added as income because the balance has been added earlier --- system/controllers/dashboard.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 7ed5732..2fb9abc 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -16,13 +16,17 @@ $first_day_month = date('Y-m-01'); $mdate = date('Y-m-d'); $month_n = date('n'); -$iday = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->sum('price'); +$iday = ORM::for_table('tbl_transactions') + ->where('recharged_on', $mdate) + ->where_not_equal('method', 'Customer - Balance') + ->sum('price'); + if ($iday == '') { $iday = '0.00'; } $ui->assign('iday', $iday); -$imonth = ORM::for_table('tbl_transactions')->where_gte('recharged_on', $first_day_month)->where_lte('recharged_on', $mdate)->sum('price'); +$imonth = ORM::for_table('tbl_transactions')->where_not_equal('method', 'Customer - Balance')->where_gte('recharged_on', $first_day_month)->where_lte('recharged_on', $mdate)->sum('price'); if ($imonth == '') { $imonth = '0.00'; } @@ -144,6 +148,7 @@ if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) { ->select_expr('MONTH(recharged_on)', 'month') ->select_expr('SUM(price)', 'total') ->where_raw("YEAR(recharged_on) = YEAR(CURRENT_DATE())") // Filter by the current year + ->where_not_equal('method', 'Customer - Balance') ->group_by_expr('MONTH(recharged_on)') ->find_many(); From 758a0a99a93890f15fa93511cdae5465eb095049 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:34:25 +0100 Subject: [PATCH 02/20] We are excited to introduce a new feature I am delighted to announce that a highly requested feature has been added to Nuxbill! We now support Multiple Payment Gateways, allowing customers to choose their preferred payment method. This update brings greater flexibility and convenience to our users. --- system/controllers/order.php | 31 ++++++++++++++++++++++++++----- ui/ui/paymentgateway.tpl | 17 ++++++++--------- ui/ui/user-selectGateway.tpl | 30 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 ui/ui/user-selectGateway.tpl diff --git a/system/controllers/order.php b/system/controllers/order.php index cee6b45..3b59e7b 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -267,18 +267,39 @@ switch ($action) { $ui->display('user-sendPlan.tpl'); break; case 'buy': + $ui->assign('_title', Lang::T('Select Payment Gateway')); + $ui->assign('_system_menu', 'package'); if (strpos($user['email'], '@') === false) { r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); } - if ($config['payment_gateway'] == 'none') { - r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); - } if (!file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $config['payment_gateway'] . '.php')) { r2(U . 'home', 'e', Lang::T("No Payment Gateway Available")); } + require_once $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $config['payment_gateway'] . '.php'; + $files = scandir($PAYMENTGATEWAY_PATH); + foreach ($files as $file) { + if (pathinfo($file, PATHINFO_EXTENSION) == 'php') { + $pgs[] = str_replace('.php', '', $file); + } + } + $ui->assign('pgs', $pgs); + $ui->assign('route2', $routes[2]); + $ui->assign('route3', $routes[3]); + + //$ui->assign('plan', $plan); + $ui->display('user-selectGateway.tpl'); + break; + + case 'pay_now': + $gateway = $_POST['gateway']; + //$routes[2] = $_GET['route2']; + //$routes[3] = $_GET['route3']; + if ($gateway == 'none') { + r2(U . 'order/buy/' . $routes[2] . '/' . $routes[3], 'e', Lang::T("No Payment Gateway Selected")); + } run_hook('customer_buy_plan'); #HOOK - include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $config['payment_gateway'] . '.php'; - call_user_func($config['payment_gateway'] . '_validate_config'); + include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $gateway . '.php'; + call_user_func($gateway . '_validate_config'); if ($routes['2'] == 'radius') { $router['id'] = 0; diff --git a/ui/ui/paymentgateway.tpl b/ui/ui/paymentgateway.tpl index f1d4057..3100bb3 100644 --- a/ui/ui/paymentgateway.tpl +++ b/ui/ui/paymentgateway.tpl @@ -1,17 +1,16 @@ {include file="sections/header.tpl"}
-
+
{Lang::T('Payment Gateway')}
{foreach $pgs as $pg} - + {/foreach}
-
-
-{include file="sections/footer.tpl"} + {include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/user-selectGateway.tpl b/ui/ui/user-selectGateway.tpl new file mode 100644 index 0000000..42b0c2d --- /dev/null +++ b/ui/ui/user-selectGateway.tpl @@ -0,0 +1,30 @@ +{include file="sections/user-header.tpl"} + +
+
+
+
{Lang::T('Available Payment Gateway')}
+ +
+
+
+ +{include file="sections/user-footer.tpl"} \ No newline at end of file From ca59c89e1d82ddb615d4f5e1aee7372eeca05a03 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 09:06:11 +0700 Subject: [PATCH 03/20] Check if Period Validity --- system/autoload/Package.php | 159 +++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 73 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 454ade3..0e153b5 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -206,18 +206,20 @@ class Package } $t->save(); - // insert to fields - $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); - if (!$fl) { - $fl = ORM::for_table('tbl_customers_fields')->create(); - $fl->customer_id = $c['id']; - $fl->field_name = 'Invoice'; - $fl->field_value = $p['price']; - $fl->save(); - } else { - $fl->customer_id = $c['id']; - $fl->field_value = $p['price']; - $fl->save(); + if ($p['validity_unit'] == 'Period') { + // insert to fields + $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); + if (!$fl) { + $fl = ORM::for_table('tbl_customers_fields')->create(); + $fl->customer_id = $c['id']; + $fl->field_name = 'Invoice'; + $fl->field_value = $p['price']; + $fl->save(); + } else { + $fl->customer_id = $c['id']; + $fl->field_value = $p['price']; + $fl->save(); + } } @@ -256,22 +258,25 @@ class Package } $d->save(); - // Calculating Price - $sd = new DateTime("$date_only"); - $ed = new DateTime("$date_exp"); - $td = $ed->diff($sd); - $fd = $td->format("%a"); - $gi = ($p['price'] / 30) * $fd; - // 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']; - if ($gi > $p['price']) { - $t->price = $p['price']; + if ($p['validity_unit'] == 'Period') { + // Calculating Price + $sd = new DateTime("$date_only"); + $ed = new DateTime("$date_exp"); + $td = $ed->diff($sd); + $fd = $td->format("%a"); + $gi = ($p['price'] / 30) * $fd; + if ($gi > $p['price']) { + $t->price = $p['price']; + } else { + $t->price = $gi; + } } else { - $t->price = $gi; + $t->price = $p['price']; } $t->recharged_on = $date_only; $t->recharged_time = $time_only; @@ -287,22 +292,24 @@ class Package } $t->save(); - // insert to fields - $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); - if (!$fl) { - $fl = ORM::for_table('tbl_customers_fields')->create(); - $fl->customer_id = $c['id']; - $fl->field_name = 'Invoice'; - if ($gi > $p['price']) { - $fl->field_value = $p['price']; + if ($p['validity_unit'] == 'Period') { + // insert to fields + $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); + if (!$fl) { + $fl = ORM::for_table('tbl_customers_fields')->create(); + $fl->customer_id = $c['id']; + $fl->field_name = 'Invoice'; + if ($gi > $p['price']) { + $fl->field_value = $p['price']; + } else { + $fl->field_value = $gi; + } + $fl->save(); } else { - $fl->field_value = $gi; + $fl->customer_id = $c['id']; + $fl->field_value = $p['price']; + $fl->save(); } - $fl->save(); - } else { - $fl->customer_id = $c['id']; - $fl->field_value = $p['price']; - $fl->save(); } Message::sendTelegram("#u$c[username] $c[fullname] #buy #Hotspot \n" . $p['name_plan'] . @@ -384,19 +391,20 @@ class Package } $t->save(); - // insert to fields - $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); - $gp = $gi; - if (!$fl) { - $fl = ORM::for_table('tbl_customers_fields')->create(); - $fl->customer_id = $c['id']; - $fl->field_name = 'Invoice'; - $fl->field_value = $p['price']; - $fl->save(); - } else { - $fl->customer_id = $c['id']; - $fl->field_value = $p['price']; - $fl->save(); + if ($p['validity_unit'] == 'Period') { + // insert to fields + $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); + if (!$fl) { + $fl = ORM::for_table('tbl_customers_fields')->create(); + $fl->customer_id = $c['id']; + $fl->field_name = 'Invoice'; + $fl->field_value = $p['price']; + $fl->save(); + } else { + $fl->customer_id = $c['id']; + $fl->field_value = $p['price']; + $fl->save(); + } } Message::sendTelegram("#u$c[username] $c[fullname] #recharge #PPPOE \n" . $p['name_plan'] . @@ -434,22 +442,25 @@ class Package } $d->save(); - // Calculating Price - $sd = new DateTime("$date_only"); - $ed = new DateTime("$date_exp"); - $td = $ed->diff($sd); - $fd = $td->format("%a"); - $gi = ($p['price'] / 30) * $fd; - // 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']; - if ($gi > $p['price']) { - $t->price = $p['price']; + if ($p['validity_unit'] == 'Period') { + // Calculating Price + $sd = new DateTime("$date_only"); + $ed = new DateTime("$date_exp"); + $td = $ed->diff($sd); + $fd = $td->format("%a"); + $gi = ($p['price'] / 30) * $fd; + if ($gi > $p['price']) { + $t->price = $p['price']; + } else { + $t->price = $gi; + } } else { - $t->price = $gi; + $t->price = $p['price']; } $t->recharged_on = $date_only; $t->recharged_time = $time_only; @@ -465,22 +476,24 @@ class Package $t->type = "PPPOE"; $t->save(); - // insert to fields - $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); - if (!$fl) { - $fl = ORM::for_table('tbl_customers_fields')->create(); - $fl->customer_id = $c['id']; - $fl->field_name = 'Invoice'; - if ($gi > $p['price']) { - $fl->field_value = $p['price']; + if ($p['validity_unit'] == 'Period') { + // insert to fields + $fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one(); + if (!$fl) { + $fl = ORM::for_table('tbl_customers_fields')->create(); + $fl->customer_id = $c['id']; + $fl->field_name = 'Invoice'; + if ($gi > $p['price']) { + $fl->field_value = $p['price']; + } else { + $fl->field_value = $gi; + } + $fl->save(); } else { - $fl->field_value = $gi; + $fl->customer_id = $c['id']; + $fl->field_value = $p['price']; + $fl->save(); } - $fl->save(); - } else { - $fl->customer_id = $c['id']; - $fl->field_value = $p['price']; - $fl->save(); } Message::sendTelegram("#u$c[username] $c[fullname] #buy #PPPOE \n" . $p['name_plan'] . From 140b756994e73a6e389f4d2b60f8c9d9dfd8bfad Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 09:06:18 +0700 Subject: [PATCH 04/20] .htaccess Firewall --- .htaccess_firewall | 9 +++++++++ system/.htaccess | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .htaccess_firewall create mode 100644 system/.htaccess diff --git a/.htaccess_firewall b/.htaccess_firewall new file mode 100644 index 0000000..a58990b --- /dev/null +++ b/.htaccess_firewall @@ -0,0 +1,9 @@ + + Order Deny,Allow + Deny from all + + + + Order Allow,Deny + Allow from all + \ No newline at end of file diff --git a/system/.htaccess b/system/.htaccess new file mode 100644 index 0000000..5fd3ff1 --- /dev/null +++ b/system/.htaccess @@ -0,0 +1,19 @@ + + Order Deny,Allow + Deny from all + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + \ No newline at end of file From 9023f89456659482818abbf759b3e7209924a09a Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 09:23:59 +0700 Subject: [PATCH 05/20] delete none --- ui/ui/user-selectGateway.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/ui/user-selectGateway.tpl b/ui/ui/user-selectGateway.tpl index 42b0c2d..36bea44 100644 --- a/ui/ui/user-selectGateway.tpl +++ b/ui/ui/user-selectGateway.tpl @@ -10,7 +10,6 @@
+ {ucwords($pg)} + + + {/foreach} + + +
+
+ {include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/user-selectGateway.tpl b/ui/ui/user-selectGateway.tpl index d74bd75..4a86462 100644 --- a/ui/ui/user-selectGateway.tpl +++ b/ui/ui/user-selectGateway.tpl @@ -11,8 +11,8 @@
diff --git a/version.json b/version.json index 7a93c66..13a15d0 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.3.6" + "version": "2024.3.12" } \ No newline at end of file From b95788262d27ed7c69dcd580689e567ce492d4ca Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 11:48:17 +0700 Subject: [PATCH 13/20] Change button --- ui/ui/paymentgateway.tpl | 10 +++++----- ui/ui/user-dashboard.tpl | 29 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ui/ui/paymentgateway.tpl b/ui/ui/paymentgateway.tpl index 5fdf115..1429729 100644 --- a/ui/ui/paymentgateway.tpl +++ b/ui/ui/paymentgateway.tpl @@ -10,10 +10,10 @@ {foreach $pgs as $pg} + {if in_array($pg, $actives)}checked{/if} value="{$pg}"> {ucwords($pg)} + class="btn btn-block btn-{if in_array($pg, $actives)}info{else}default{/if} text-left">{ucwords($pg)} + @@ -22,8 +22,8 @@ - + diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index f797acc..732f441 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -53,10 +53,10 @@

{Lang::T('Announcement')}

- {$Announcement_Customer = "{$PAGES_PATH}/Announcement_Customer.html"} - {if file_exists($Announcement_Customer)} - {include file=$Announcement_Customer} - {/if} + {$Announcement_Customer = "{$PAGES_PATH}/Announcement_Customer.html"} + {if file_exists($Announcement_Customer)} + {include file=$Announcement_Customer} + {/if}
@@ -131,11 +131,8 @@ {Lang::T('Plan Name')} {$_bill['namebp']} - {if $_bill['status'] == 'on'} - {Lang::T('Deactivate')} - {else} - {Lang::T('expired')} + {if $_bill['status'] != 'on'} + {Lang::T('expired')} {/if} @@ -149,8 +146,6 @@ {Lang::T('Expires On')} {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  - {Lang::T('Recharge')} {if $nux_ip} @@ -173,6 +168,18 @@ {/if} + + + {if $_bill['status'] == 'on'} + + {/if} + + + {Lang::T('Recharge')} + + {/foreach} From b9e987570cb12452c5a4d67824089b80aa597f88 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 11:54:20 +0700 Subject: [PATCH 14/20] Show From Customer --- system/controllers/order.php | 8 +-- system/lan/english.json | 4 +- ui/ui/balance-add.tpl | 109 ++++++++++++++++++----------------- ui/ui/balance-edit.tpl | 2 +- ui/ui/hotspot-add.tpl | 2 +- ui/ui/hotspot-edit.tpl | 2 +- ui/ui/pppoe-add.tpl | 2 +- ui/ui/pppoe-edit.tpl | 2 +- 8 files changed, 63 insertions(+), 68 deletions(-) diff --git a/system/controllers/order.php b/system/controllers/order.php index b45aa8c..03bdfd9 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -152,9 +152,6 @@ switch ($action) { if (!$plan['enabled']) { r2(U . "home", 'e', 'Plan is not exists'); } - if ($plan['allow_purchase'] != 'yes') { - r2(U . "home", 'e', 'Cannot recharge this plan'); - } if ($routes['2'] == 'radius') { $router_name = 'radius'; } else { @@ -188,9 +185,6 @@ switch ($action) { if (!$plan['enabled']) { r2(U . "home", 'e', 'Plan is not exists'); } - if ($plan['allow_purchase'] != 'yes') { - r2(U . "home", 'e', 'Cannot recharge this plan'); - } if ($routes['2'] == 'radius') { $router_name = 'radius'; } else { @@ -319,7 +313,7 @@ switch ($action) { $router['id'] = 0; $router['name'] = 'balance'; } - $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->where('allow_purchase', 'yes')->find_one($routes['3']); + $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']); if (empty($router) || empty($plan)) { r2(U . "order/package", 'e', Lang::T("Plan Not found")); } diff --git a/system/lan/english.json b/system/lan/english.json index 071f1b7..7cf1720 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -384,7 +384,6 @@ "After_Customer_activate_voucher_or_login__customer_will_be_redirected_to_this_url": "After Customer activate voucher or login, customer will be redirected to this url", "Voucher_Prefix": "Voucher Prefix", "Voucher_activation_success__now_you_can_login": "Voucher activation success, now you can login", - "Client_Can_Purchase": "Client Can Purchase", "Buy_this__your_active_package_will_be_overwritten": "Buy this? your active package will be overwritten", "Pay_this_with_Balance__your_active_package_will_be_overwritten": "Pay this with Balance? your active package will be overwritten", "Buy_this__your_active_package_will_be_overwrite": "Buy this? your active package will be overwrite", @@ -468,5 +467,6 @@ "Please_select_Payment_Gateway": "Please select Payment Gateway", "Payment_Gateway_Deleted": "Payment Gateway Deleted", "Payment_Gateway_not_set__please_set_it_in_Settings": "Payment Gateway not set, please set it in Settings", - "Failed_to_create_Transaction__": "Failed to create Transaction.." + "Failed_to_create_Transaction__": "Failed to create Transaction..", + "Show_To_Customer": "Show To Customer" } \ No newline at end of file diff --git a/ui/ui/balance-add.tpl b/ui/ui/balance-add.tpl index 79a796a..748ffcb 100644 --- a/ui/ui/balance-add.tpl +++ b/ui/ui/balance-add.tpl @@ -1,59 +1,60 @@ {include file="sections/header.tpl"} -
-
-
-
{Lang::T('Add Service Plan')}
-
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- -
-
-
- -
-
- {$_c['currency_code']} - -
-
+
+
+
+
{Lang::T('Add Service Plan')}
+
+ +
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+ {$_c['currency_code']} +
+
+
-
-
- - Or {Lang::T('Cancel')} -
-
- -
-
-
-
+
+
+ + Or {Lang::T('Cancel')} +
+
+ +
+
+
+
-{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/balance-edit.tpl b/ui/ui/balance-edit.tpl index 8d735cd..e188f0e 100644 --- a/ui/ui/balance-edit.tpl +++ b/ui/ui/balance-edit.tpl @@ -19,7 +19,7 @@
- +
- +
Yes No diff --git a/ui/ui/hotspot-edit.tpl b/ui/ui/hotspot-edit.tpl index 97948af..30da3b3 100644 --- a/ui/ui/hotspot-edit.tpl +++ b/ui/ui/hotspot-edit.tpl @@ -15,7 +15,7 @@
- +
Yes No diff --git a/ui/ui/pppoe-add.tpl b/ui/ui/pppoe-add.tpl index 98b308d..1ef2d80 100644 --- a/ui/ui/pppoe-add.tpl +++ b/ui/ui/pppoe-add.tpl @@ -14,7 +14,7 @@
- +
Yes No diff --git a/ui/ui/pppoe-edit.tpl b/ui/ui/pppoe-edit.tpl index d866c72..5d9d044 100644 --- a/ui/ui/pppoe-edit.tpl +++ b/ui/ui/pppoe-edit.tpl @@ -15,7 +15,7 @@
- +
Yes No From 629d9e8ed4bca97ef6eba3007ae672a5a9305119 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 12:01:49 +0700 Subject: [PATCH 15/20] Period in hotspot --- ui/ui/hotspot-add.tpl | 14 ++++++-------- ui/ui/hotspot-edit.tpl | 2 ++ ui/ui/pppoe-edit.tpl | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index a7dd67b..f2f86d0 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -118,17 +118,15 @@
+

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

diff --git a/ui/ui/hotspot-edit.tpl b/ui/ui/hotspot-edit.tpl index 30da3b3..d73b87a 100644 --- a/ui/ui/hotspot-edit.tpl +++ b/ui/ui/hotspot-edit.tpl @@ -128,6 +128,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 5d9d044..010ec75 100644 --- a/ui/ui/pppoe-edit.tpl +++ b/ui/ui/pppoe-edit.tpl @@ -62,7 +62,7 @@
-

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

+

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

{foreach $p as $ps} + {if $ps['enabled'] neq 1}DISABLED PLAN • {/if} + {if $ps['is_radius']=='1'}Radius{else}{$ps['routers']}{/if} • {$ps['name_plan']} {/foreach}
From c9058769ce4c3cf6231ed25551db9406632524e3 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 15:09:00 +0700 Subject: [PATCH 19/20] Recharge with balance or zero cost --- system/autoload/Package.php | 16 ++++++++++++- system/autoload/User.php | 6 +++-- system/controllers/prepaid.php | 41 ++++++++++++++++++++++++++-------- system/lan/english.json | 5 ++++- ui/ui/autoload.tpl | 2 +- ui/ui/recharge.tpl | 15 +++++++++++-- 6 files changed, 69 insertions(+), 16 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index a33df78..c6c9b90 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -19,7 +19,7 @@ class Package */ public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel) { - global $config, $admin, $c, $p, $b, $t, $d; + global $config, $admin, $c, $p, $b, $t, $d, $zero; $date_now = date("Y-m-d H:i:s"); $date_only = date("Y-m-d"); $time_only = date("H:i:s"); @@ -31,6 +31,20 @@ class Package $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one(); + + if(isset($zero) && $zero==1){ + $p['price'] = 0; + } + + if(!$p['enabled']){ + if(!isset($admin) || !isset($admin['id']) || empty($admin['id'])){ + r2(U . 'home', 'e', Lang::T('Plan Not found')); + } + if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { + r2(U . 'dashboard', 'e', Lang::T('Plan Not found')); + } + } + if ($p['validity_unit'] == 'Period') { $f = ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one(); if (!$f) { diff --git a/system/autoload/User.php b/system/autoload/User.php index afda269..645190c 100644 --- a/system/autoload/User.php +++ b/system/autoload/User.php @@ -39,9 +39,11 @@ class User } } - public static function _info() + public static function _info($id = 0) { - $id = User::getID(); + if(!$id){ + $id = User::getID(); + } $d = ORM::for_table('tbl_customers')->find_one($id); if(empty($d['username'])){ diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 18f99ca..f31aadd 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -120,22 +120,45 @@ switch ($action) { $id_customer = _post('id_customer'); $type = _post('type'); $server = _post('server'); - $plan = _post('plan'); + $planId = _post('plan'); + $using = _post('using'); $date_only = date("Y-m-d"); $time = date("H:i:s"); $msg = ''; - if ($id_customer == '' or $type == '' or $server == '' or $plan == '') { - $msg .= 'All field is required' . '
'; + if ($id_customer == '' or $type == '' or $server == '' or $planId == '') { + $msg .= Lang::T('All field is required') . '
'; } if ($msg == '') { - if (Package::rechargeUser($id_customer, $server, $plan, "Recharge", $admin['fullname'])) { - $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(); + $gateway = 'Recharge'; + $channel = $admin['fullname']; + $cust = User::_info($id_customer); + if ($using == 'balance' && $config['enable_balance'] == 'yes') { + $plan = ORM::for_table('tbl_plans')->find_one($planId); + if (!$cust) { + r2(U . 'prepaid/recharge', 'e', Lang::T('Customer not found')); + } + if (!$plan) { + r2(U . 'prepaid/recharge', 'e', Lang::T('Plan not found')); + } + if ($cust['balance'] < $plan['price']) { + r2(U . 'prepaid/recharge', 'e', Lang::T('insufficient balance')); + } + $gateway = 'Recharge Balance'; + } + if ($using == 'zero') { + $zero = 1; + $gateway = 'Recharge Zero'; + } + if (Package::rechargeUser($id_customer, $server, $planId, $gateway, $channel)) { + if ($using == 'balance') { + Balance::min($cust['id'], $plan['price']); + } + $in = ORM::for_table('tbl_transactions')->where('username', $cust['username'])->order_by_desc('id')->find_one(); Package::createInvoice($in); $ui->display('invoice.tpl'); - _log('[' . $admin['username'] . ']: ' . 'Recharge ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); + _log('[' . $admin['username'] . ']: ' . 'Recharge ' . $cust['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']); } else { r2(U . 'prepaid/recharge', 'e', "Failed to recharge account"); } @@ -189,9 +212,9 @@ switch ($action) { $d = ORM::for_table('tbl_user_recharges')->find_one($id); if ($d) { $ui->assign('d', $d); - if(in_array($admin['user_type'], array('SuperAdmin', 'Admin'))){ + if (in_array($admin['user_type'], array('SuperAdmin', 'Admin'))) { $p = ORM::for_table('tbl_plans')->where_not_equal('type', 'Balance')->find_many(); - }else{ + } else { $p = ORM::for_table('tbl_plans')->where('enabled', '1')->where_not_equal('type', 'Balance')->find_many(); } $ui->assign('p', $p); diff --git a/system/lan/english.json b/system/lan/english.json index 7cf1720..4e8d897 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -468,5 +468,8 @@ "Payment_Gateway_Deleted": "Payment Gateway Deleted", "Payment_Gateway_not_set__please_set_it_in_Settings": "Payment Gateway not set, please set it in Settings", "Failed_to_create_Transaction__": "Failed to create Transaction..", - "Show_To_Customer": "Show To Customer" + "Show_To_Customer": "Show To Customer", + "Using": "Using", + "Default": "Default", + "Customer_Balance": "Customer Balance" } \ No newline at end of file diff --git a/ui/ui/autoload.tpl b/ui/ui/autoload.tpl index caeff1a..30ff8b9 100644 --- a/ui/ui/autoload.tpl +++ b/ui/ui/autoload.tpl @@ -1,4 +1,4 @@ {foreach $d as $ds} - + {/foreach} \ No newline at end of file diff --git a/ui/ui/recharge.tpl b/ui/ui/recharge.tpl index eba82b0..b07c990 100644 --- a/ui/ui/recharge.tpl +++ b/ui/ui/recharge.tpl @@ -27,7 +27,7 @@
-
@@ -41,7 +41,18 @@
- +
+ +
+ +
+