Refill Balance with Custom Amount Requested by Javi Tech

This commit is contained in:
iBNu Maksum
2024-10-23 14:04:11 +07:00
parent bdda199523
commit dc55957a53
6 changed files with 152 additions and 70 deletions

View File

@ -32,6 +32,14 @@ switch ($action) {
$bw = ORM::for_table('tbl_bandwidth')->select("name_bw")->find_one($routes['2']);
echo $bw['name_bw'];
die();
case 'balance':
$balance = ORM::for_table('tbl_customers')->select("balance")->find_one($routes['2'])['balance'];
if($routes['3']=='1'){
echo Lang::moneyFormat($balance);
}else{
echo $balance;
}
die();
case 'server':
$d = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
$ui->assign('d', $d);

View File

@ -797,24 +797,42 @@ switch ($action) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
$user = _post('id_customer');
$amount = _post('amount');
$plan = _post('id_plan');
$note = _post('note');
$stoken = _req('stoken');
$c = ORM::for_table('tbl_customers')->find_one($user);
if (App::getTokenValue($stoken)) {
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
$in = ORM::for_table('tbl_transactions')->find_one(App::getTokenValue($stoken));
Package::createInvoice($in);
$ui->display('invoice.tpl');
die();
}
run_hook('deposit_customer'); #HOOK
if (!empty($user) && !empty($plan)) {
if (Package::rechargeUser($user, 'balance', $plan, "Deposit", $admin['fullname'])) {
$c = ORM::for_table('tbl_customers')->where('id', $user)->find_one();
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
if (!empty($user) && strlen($amount)>0 && $amount != 0) {
$plan = [];
$plan['name_plan'] = Lang::T('Balance');
$plan['price'] = $amount;
$trxId = Package::rechargeBalance($c, $plan, "Deposit", $admin['fullname'], $note);
if ($trxId > 0) {
$in = ORM::for_table('tbl_transactions')->find_one($trxId);
Package::createInvoice($in);
if (!empty($stoken)) {
App::setToken($stoken, $in['id']);
App::setToken($stoken, $trxId);
}
$ui->display('invoice.tpl');
} else {
r2(U . 'plan/refill', 'e', "Failed to refill account");
}
}else if (!empty($user) && !empty($plan)) {
$p = ORM::for_table('tbl_plans')->find_one($plan);
$trxId = Package::rechargeBalance($c, $p, "Deposit", $admin['fullname'], $note);
if ($trxId > 0) {
$in = ORM::for_table('tbl_transactions')->find_one($trxId);
Package::createInvoice($in);
if (!empty($stoken)) {
App::setToken($stoken, $trxId);
}
$ui->display('invoice.tpl');
} else {