diff --git a/CHANGELOG.md b/CHANGELOG.md index 3575d3ed..a1d09b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ # CHANGELOG +## 2023.8.24 + +- Balance transfer between Customer +- Optimize Cronjob +- View Customer Info +- Ajax for select customer + ## 2023.8.18 - Fix Auto Renewall Cronjob diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index 1eb738e7..28903fe6 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -50,7 +50,7 @@ CREATE TABLE `id` int(10) NOT NULL, `username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1', + `pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `address` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `phonenumber` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0', diff --git a/system/autoload/Balance.php b/system/autoload/Balance.php index a3686e7d..f6557a3f 100644 --- a/system/autoload/Balance.php +++ b/system/autoload/Balance.php @@ -18,15 +18,11 @@ class Balance public static function transfer($id_customer, $phoneTarget, $amount) { global $config; - if ($config['allow_balance_transfer'] == 'yes') { - if (Balance::min($id_customer, $amount)) { - if (Balance::plusByPhone($phoneTarget, $amount)) { - return true; - } else { - Balance::plus($id_customer, $amount); - return false; - } + if (Balance::min($id_customer, $amount)) { + if (Balance::plusByPhone($phoneTarget, $amount)) { + return true; } else { + Balance::plus($id_customer, $amount); return false; } } else { diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php index 6c790bd4..52abdd0f 100644 --- a/system/autoload/Lang.php +++ b/system/autoload/Lang.php @@ -31,4 +31,31 @@ class Lang return $phone; } } + + public static function dateFormat($date){ + global $config; + return date($config['date_format'], strtotime($date)); + } + + public static function dateTimeFormat($date){ + global $config; + return date($config['date_format']. ' H:i', strtotime($date)); + } + + public static function nl2br($text){ + return nl2br($text); + } + + public static function arrayCount($arr){ + return count($arr); + } + + public static function getNotifText($key){ + global $_notifmsg, $_notifmsg_default; + if(isset($_notifmsg[$key])){ + return $_notifmsg[$key]; + }else{ + return $_notifmsg_default[$key]; + } + } } diff --git a/system/autoload/Message.php b/system/autoload/Message.php index 0373d682..15981d06 100644 --- a/system/autoload/Message.php +++ b/system/autoload/Message.php @@ -56,4 +56,20 @@ class Message return "$via: $msg"; } + public static function sendBalanceNotification($phone, $name, $balance, $message, $via) + { + $msg = str_replace('[[name]]', "*$name*", $message); + $msg = str_replace('[[balance]]', "*" . Lang::moneyFormat($balance) . "*", $msg); + if ( + !empty($phone) && strlen($phone) > 5 + && !empty($message) && in_array($via, ['sms', 'wa']) + ) { + if ($via == 'sms') { + Message::sendSMS($phone, $msg); + } else if ($via == 'wa') { + Message::sendWhatsapp($phone, $msg); + } + } + return "$via: $msg"; + } } diff --git a/system/autoload/Package.php b/system/autoload/Package.php index a62107ec..97fbda01 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -49,7 +49,7 @@ class Package Balance::plus($id_customer, $p['price']); - $textInvoice = $_notifmsg['invoice_balance']; + $textInvoice = Lang::getNotifText('invoice_balance'); $textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice); $textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice); $textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice); @@ -96,6 +96,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::addHotspotUser($client, $p, $c); } @@ -128,6 +129,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::addHotspotUser($client, $p, $c); } @@ -163,12 +165,13 @@ class Package "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . - "\nPrice: " . $p['price']); + "\nPrice: " . Lang::moneyFormat($p['price'])); } else { 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); } @@ -202,6 +205,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::addPpoeUser($client, $p, $c); } @@ -237,12 +241,12 @@ class Package "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . - "\nPrice: " . $p['price']); + "\nPrice: " . Lang::moneyFormat($p['price'])); } $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); - $textInvoice = $_notifmsg['invoice_paid']; + $textInvoice = Lang::getNotifText('invoice_paid'); $textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice); $textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice); $textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice); diff --git a/system/autoload/Paginator.php b/system/autoload/Paginator.php index 97553cd8..cb6e4b92 100644 --- a/system/autoload/Paginator.php +++ b/system/autoload/Paginator.php @@ -1,28 +1,29 @@ where($w1,$c1)->count(); - }elseif($w2 != ''){ - $totalReq = ORM::for_table($table)->where($w1,$c1)->where($w2,$c2)->count(); - }elseif($w3 != ''){ - $totalReq = ORM::for_table($table)->where($w1,$c1)->where($w2,$c2)->where($w3,$c3)->count(); - }elseif($w4 != ''){ - $totalReq = ORM::for_table($table)->where($w1,$c1)->where($w2,$c2)->where($w3,$c3)->where($w4,$c4)->count(); - }else{ + if ($w1 != '') { + $totalReq = ORM::for_table($table)->where($w1, $c1)->count(); + } elseif ($w2 != '') { + $totalReq = ORM::for_table($table)->where($w1, $c1)->where($w2, $c2)->count(); + } elseif ($w3 != '') { + $totalReq = ORM::for_table($table)->where($w1, $c1)->where($w2, $c2)->where($w3, $c3)->count(); + } elseif ($w4 != '') { + $totalReq = ORM::for_table($table)->where($w1, $c1)->where($w2, $c2)->where($w3, $c3)->where($w4, $c4)->count(); + } else { $totalReq = ORM::for_table($table)->count(); } @@ -85,16 +86,103 @@ Class Paginator } if ($page < $counter - 1) { - $pagination .= "
+ [[name]] Receiver name.
+ [[balance]] how much balance have been send.
+
+ [[name]] Sender name.
+ [[balance]] how much balance have been received.
+
{Lang::T('Allow balance transfer between customers')}
+{Lang::nl2br($d['address'])}
+{$_L['Username']} | +{$_L['Plan_Name']} | +{$_L['Plan_Price']} | +{$_L['Type']} | +{$_L['Created_On']} | +{$_L['Expires_On']} | +{$_L['Method']} | +||
---|---|---|---|---|---|---|---|---|
{$ds['username']} | +{$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']} | +{$ds['method']} | +||
{$_L['Plan_Name']} | +{Lang::T('Gateway')} | +{Lang::T('Routers')} | +{$_L['Type']} | +{$_L['Plan_Price']} | +{$_L['Created_On']} | +{$_L['Expires_On']} | +{Lang::T('Date Done')} | +{$_L['Method']} | +
{$ds['plan_name']} | +{$ds['gateway']} | +{$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} | +{if $ds['status']==1}{$_L['UNPAID']} + {elseif $ds['status']==2}{$_L['PAID']} + {elseif $ds['status']==3}{$_L['FAILED']} + {elseif $ds['status']==4}{$_L['CANCELED']} + {elseif $ds['status']==5}{$_L['UNKNOWN']} + {/if} | +
{$_L['Manage']} | {$_L['Username']} | {$_L['Full_Name']} | {Lang::T('Balance')} | @@ -41,27 +35,23 @@{$_L['Email']} | {$_L['Created_On']} | {$_L['Recharge']} | -{$_L['Manage']} | ||
---|---|---|---|---|---|---|---|---|---|
+ {Lang::T('View')} + | {$ds['username']} | {$ds['fullname']} | {Lang::moneyFormat($ds['balance'])} | {$ds['phonenumber']} | {$ds['email']} | -{$ds['created_at']} | +{Lang::dateTimeFormat($ds['created_at'])} | {$_L['Recharge']} | -- {$_L['Edit']} - {$_L['Delete']} - |
{$no++} | -{$expired['username']} | +{$expired['username']} | {date($_c['date_format'], strtotime($expired['recharged_on']))} | {date($_c['date_format'], strtotime($expired['expiration']))} {$expired['time']}
diff --git a/ui/ui/deposit.tpl b/ui/ui/deposit.tpl
index 02e5810e..a76311fa 100644
--- a/ui/ui/deposit.tpl
+++ b/ui/ui/deposit.tpl
@@ -11,10 +11,6 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
{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 a1926078..67a378b6 100644
--- a/ui/ui/reports-period.tpl
+++ b/ui/ui/reports-period.tpl
@@ -32,6 +32,7 @@
+
diff --git a/ui/ui/routers-edit.tpl b/ui/ui/routers-edit.tpl
index e33d0327..b6afb78d 100644
--- a/ui/ui/routers-edit.tpl
+++ b/ui/ui/routers-edit.tpl
@@ -41,7 +41,8 @@
-
-
+
diff --git a/ui/ui/scripts/select2.min.js b/ui/ui/scripts/select2.min.js
deleted file mode 100644
index 49a988c7..00000000
--- a/ui/ui/scripts/select2.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! Select2 4.0.0 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.concat(a),k=0;k
+
+ {$_L['Announcement']}
+
@@ -138,6 +138,39 @@
}, 2000);
{/if}
+ {if $_c['enable_balance'] == 'yes'}
+
{include file="$_path/../pages/Announcement.html"}
+
+ {/if}
+
+ {Lang::T("Transfer Balance")}+
+
+
+
+
+
+
+
+
+
+
+
+
+ {if $_c['disable_voucher'] != 'yes'}
diff --git a/ui/ui/user-orderPlan.tpl b/ui/ui/user-orderPlan.tpl
index 6315baad..d8a2c91b 100644
--- a/ui/ui/user-orderPlan.tpl
+++ b/ui/ui/user-orderPlan.tpl
@@ -33,6 +33,10 @@
{/foreach}
+
{/if}
{foreach $routers as $router}
{Lang::T('Balance')} {Lang::moneyFormat($_user['balance'])}
+
@@ -69,9 +73,16 @@
|
{Lang::T('Status')} | -{if $trx['status']==1}{Lang::T('UNPAID')}{elseif $trx['status']==2}{Lang::T('PAID')}{elseif $trx['status']==3}{Lang::T('FAILED')}{elseif $trx['status']==4}{Lang::T('CANCELED')}{else}{Lang::T('UNKNOWN')}{/if} - | -|||
{Lang::T('expired')} | -{date($_c['date_format'], strtotime($trx['expired_date']))} - {date('H:i', strtotime($trx['expired_date']))} | -
{Lang::T('Type')} | +{$trx['plan_name']} | +|||
{Lang::T('Paid Date')} | {date($_c['date_format'], strtotime($trx['paid_date']))} {date('H:i', strtotime($trx['paid_date']))} | |||
{$_L['Plan_Name']} | -{$plan['name_plan']} | -|||
{$_L['Plan_Price']} | -{Lang::moneyFormat($plan['price'])} | -|||
{Lang::T('Type')} | -{$plan['type']} | -|||
{Lang::T('Plan_Type')} | -{Lang::T($plan['typebp'])} | -|||
{Lang::T('Time_Limit')} | -{$ds['time_limit']} {$ds['time_unit']} | -|||
{Lang::T('Data_Limit')} | -{$ds['data_limit']} {$ds['data_unit']} | -|||
{$_L['Plan_Validity']} | -{$plan['validity']} {$plan['validity_unit']} | + {if $trx['plan_name'] == 'Receive Balance'} +{Lang::T('From')} | + {else} +{Lang::T('To')} | + {/if} +{$trx['gateway']} |
{$_L['Bandwidth_Plans']} | -{$bandw['name_bw']} {$bandw['rate_down']}{$bandw['rate_down_unit']}/{$bandw['rate_up']}{$bandw['rate_up_unit']} + | {$_L['Balance']} | +{Lang::moneyFormat($trx['price'])} | +
{Lang::T('Status')} | +{if $trx['status']==1}{Lang::T('UNPAID')}{elseif $trx['status']==2}{Lang::T('PAID')}{elseif $trx['status']==3}{Lang::T('FAILED')}{elseif $trx['status']==4}{Lang::T('CANCELED')}{else}{Lang::T('UNKNOWN')}{/if} |