send balance to other users
This commit is contained in:
parent
74ac7f3eb4
commit
a09dc57495
@ -18,15 +18,11 @@ class Balance
|
|||||||
public static function transfer($id_customer, $phoneTarget, $amount)
|
public static function transfer($id_customer, $phoneTarget, $amount)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
if ($config['allow_balance_transfer'] == 'yes') {
|
if (Balance::min($id_customer, $amount)) {
|
||||||
if (Balance::min($id_customer, $amount)) {
|
if (Balance::plusByPhone($phoneTarget, $amount)) {
|
||||||
if (Balance::plusByPhone($phoneTarget, $amount)) {
|
return true;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
Balance::plus($id_customer, $amount);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
Balance::plus($id_customer, $amount);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,11 +9,66 @@ $ui->assign('_title', $_L['Dashboard']);
|
|||||||
$user = User::_info();
|
$user = User::_info();
|
||||||
$ui->assign('_user', $user);
|
$ui->assign('_user', $user);
|
||||||
|
|
||||||
if(isset($_GET['renewal'])){
|
if (isset($_GET['renewal'])) {
|
||||||
$user->auto_renewal = $_GET['renewal'];
|
$user->auto_renewal = $_GET['renewal'];
|
||||||
$user->save();
|
$user->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_post('send') == 'balance') {
|
||||||
|
if ($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'));
|
||||||
|
}
|
||||||
|
$username = _post('username');
|
||||||
|
$balance = _post('balance');
|
||||||
|
if ($user['balance'] < $balance) {
|
||||||
|
r2(U . 'home', 'd', Lang::T('insufficient balance'));
|
||||||
|
}
|
||||||
|
if ($user['username'] == $target['username']) {
|
||||||
|
r2(U . 'home', 'd', Lang::T('Cannot send to yourself'));
|
||||||
|
}
|
||||||
|
if(Balance::transfer($user['id'], $username, $balance)){
|
||||||
|
//sender
|
||||||
|
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||||
|
$d->username = $user['username'];
|
||||||
|
$d->gateway = $target['username'];
|
||||||
|
$d->plan_id = 0;
|
||||||
|
$d->plan_name = 'Send Balance';
|
||||||
|
$d->routers_id = 0;
|
||||||
|
$d->routers = 'balance';
|
||||||
|
$d->price = $balance;
|
||||||
|
$d->payment_method = "Customer";
|
||||||
|
$d->payment_channel = "Balance";
|
||||||
|
$d->created_date = date('Y-m-d H:i:s');
|
||||||
|
$d->paid_date = date('Y-m-d H:i:s');
|
||||||
|
$d->expired_date = date('Y-m-d H:i:s');
|
||||||
|
$d->pg_url_payment = 'balance';
|
||||||
|
$d->status = 2;
|
||||||
|
$d->save();
|
||||||
|
//receiver
|
||||||
|
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||||
|
$d->username = $target['username'];
|
||||||
|
$d->gateway = $user['username'];
|
||||||
|
$d->plan_id = 0;
|
||||||
|
$d->plan_name = 'Receive Balance';
|
||||||
|
$d->routers_id = 0;
|
||||||
|
$d->routers = 'balance';
|
||||||
|
$d->payment_method = "Customer";
|
||||||
|
$d->payment_channel = "Balance";
|
||||||
|
$d->price = $balance;
|
||||||
|
$d->created_date = date('Y-m-d H:i:s');
|
||||||
|
$d->paid_date = date('Y-m-d H:i:s');
|
||||||
|
$d->expired_date = date('Y-m-d H:i:s');
|
||||||
|
$d->pg_url_payment = 'balance';
|
||||||
|
$d->status = 2;
|
||||||
|
$d->save();
|
||||||
|
r2(U . 'home', 's', Lang::T('Sending balance success'));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
r2(U . 'home', 'd', 'Failed, balance is not available');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Client Page
|
//Client Page
|
||||||
$bill = User::_billing();
|
$bill = User::_billing();
|
||||||
@ -27,7 +82,7 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
|||||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||||
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
||||||
r2(U . 'home', 's', Lang::T('Login Request successfully'));
|
r2(U . 'home', 's', Lang::T('Login Request successfully'));
|
||||||
}else if ($_GET['mikrotik'] == 'logout') {
|
} else if ($_GET['mikrotik'] == 'logout') {
|
||||||
$m = Mikrotik::info($bill['routers']);
|
$m = Mikrotik::info($bill['routers']);
|
||||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||||
Mikrotik::logMeOut($c, $user['username']);
|
Mikrotik::logMeOut($c, $user['username']);
|
||||||
|
@ -63,7 +63,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'view':
|
case 'view':
|
||||||
$trxid = $routes['2'] * 1;
|
$trxid = $routes['2'];
|
||||||
$trx = ORM::for_table('tbl_payment_gateway')
|
$trx = ORM::for_table('tbl_payment_gateway')
|
||||||
->where('username', $user['username'])
|
->where('username', $user['username'])
|
||||||
->find_one($trxid);
|
->find_one($trxid);
|
||||||
|
@ -372,3 +372,10 @@ $_L['Auto_Renewal'] = 'Auto Renewal';
|
|||||||
$_L['View'] = 'View';
|
$_L['View'] = 'View';
|
||||||
$_L['Back'] = 'Back';
|
$_L['Back'] = 'Back';
|
||||||
$_L['Active'] = 'Active';
|
$_L['Active'] = 'Active';
|
||||||
|
$_L['Transfer_Balance'] = 'Transfer Balance';
|
||||||
|
$_L['Send_your_balance'] = 'Send your balance?';
|
||||||
|
$_L['Send'] = 'Send';
|
||||||
|
$_L['Cannot_send_to_yourself'] = 'Cannot send to yourself';
|
||||||
|
$_L['Sending_balance_success'] = 'Sending balance success';
|
||||||
|
$_L['From'] = 'From';
|
||||||
|
$_L['To'] = 'To';
|
||||||
|
@ -138,6 +138,30 @@
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
</script>
|
</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
{if $_c['enable_balance'] == 'yes'}
|
||||||
|
<div class="box box-primary box-solid mb30">
|
||||||
|
<div class="box-header">
|
||||||
|
<h4 class="box-title">{Lang::T("Transfer Balance")}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="box-body p-0">
|
||||||
|
<form method="post" onsubmit="return confirm('{Lang::T('Send your balance?')}')" role="form" action="{$_url}home">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-5">
|
||||||
|
<input type="text" id="username" name="username" class="form-control" required
|
||||||
|
placeholder="{$_L['Username']}">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">
|
||||||
|
<input type="number" id="balance" name="balance" autocomplete="off" class="form-control" required
|
||||||
|
placeholder="{$_L['Balance']}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-sm-2" align="center">
|
||||||
|
<button class="btn btn-success btn-block" type="submit" name="send" value="balance"><i class="glyphicon glyphicon-send"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<br>
|
<br>
|
||||||
{if $_c['disable_voucher'] != 'yes'}
|
{if $_c['disable_voucher'] != 'yes'}
|
||||||
<div class="box box-primary box-solid mb30">
|
<div class="box box-primary box-solid mb30">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div
|
<div
|
||||||
class="panel mb20 {if $trx['status']==1}panel-warning{elseif $trx['status']==2}panel-success{elseif $trx['status']==3}panel-danger{elseif $trx['status']==4}panel-danger{else}panel-primary{/if} panel-hovered">
|
class="panel mb20 {if $trx['status']==1}panel-warning{elseif $trx['status']==2}panel-success{elseif $trx['status']==3}panel-danger{elseif $trx['status']==4}panel-danger{else}panel-primary{/if} panel-hovered">
|
||||||
<div class="panel-footer">Transaction #{$trx['id']}</div>
|
<div class="panel-footer">Transaction #{$trx['id']}</div>
|
||||||
{if $plan['type']!='Balance'}
|
{if $trx['routers']!='balance'}
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="panel panel-primary panel-hovered">
|
<div class="panel panel-primary panel-hovered">
|
||||||
<div class="panel-heading">{$router['name']}</div>
|
<div class="panel-heading">{$router['name']}</div>
|
||||||
@ -17,70 +17,98 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered table-striped table-bordered">
|
{if $trx['pg_url_payment']=='balance'}
|
||||||
<tbody>
|
<table class="table table-bordered table-striped table-bordered">
|
||||||
<tr>
|
<tbody>
|
||||||
<td>{Lang::T('Status')}</td>
|
<tr>
|
||||||
<td>{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}
|
<td>{Lang::T('Type')}</td>
|
||||||
</td>
|
<td>{$trx['plan_name']}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>{Lang::T('expired')}</td>
|
|
||||||
<td>{date($_c['date_format'], strtotime($trx['expired_date']))}
|
|
||||||
{date('H:i', strtotime($trx['expired_date']))} </td>
|
|
||||||
</tr>
|
|
||||||
{if $trx['status']==2}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{Lang::T('Paid Date')}</td>
|
<td>{Lang::T('Paid Date')}</td>
|
||||||
<td>{date($_c['date_format'], strtotime($trx['paid_date']))}
|
<td>{date($_c['date_format'], strtotime($trx['paid_date']))}
|
||||||
{date('H:i', strtotime($trx['paid_date']))} </td>
|
{date('H:i', strtotime($trx['paid_date']))} </td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
|
||||||
<tr>
|
|
||||||
<td>{$_L['Plan_Name']}</td>
|
|
||||||
<td>{$plan['name_plan']}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{$_L['Plan_Price']}</td>
|
|
||||||
<td>{Lang::moneyFormat($plan['price'])}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{Lang::T('Type')}</td>
|
|
||||||
<td>{$plan['type']}</td>
|
|
||||||
</tr>
|
|
||||||
{if $plan['type']!='Balance'}
|
|
||||||
{if $plan['type'] eq 'Hotspot'}
|
|
||||||
<tr>
|
|
||||||
<td>{Lang::T('Plan_Type')}</td>
|
|
||||||
<td>{Lang::T($plan['typebp'])}</td>
|
|
||||||
</tr>
|
|
||||||
{if $plan['typebp'] eq 'Limited'}
|
|
||||||
{if $plan['limit_type'] eq 'Time_Limit' or $plan['limit_type'] eq 'Both_Limit'}
|
|
||||||
<tr>
|
|
||||||
<td>{Lang::T('Time_Limit')}</td>
|
|
||||||
<td>{$ds['time_limit']} {$ds['time_unit']}</td>
|
|
||||||
</tr>
|
|
||||||
{/if}
|
|
||||||
{if $plan['limit_type'] eq 'Data_Limit' or $plan['limit_type'] eq 'Both_Limit'}
|
|
||||||
<tr>
|
|
||||||
<td>{Lang::T('Data_Limit')}</td>
|
|
||||||
<td>{$ds['data_limit']} {$ds['data_unit']}</td>
|
|
||||||
</tr>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$_L['Plan_Validity']}</td>
|
{if $trx['plan_name'] == 'Receive Balance'}
|
||||||
<td>{$plan['validity']} {$plan['validity_unit']}</td>
|
<td>{Lang::T('From')}</td>
|
||||||
|
{else}
|
||||||
|
<td>{Lang::T('To')}</td>
|
||||||
|
{/if}
|
||||||
|
<td>{$trx['gateway']}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$_L['Bandwidth_Plans']}</td>
|
<td>{$_L['Balance']}</td>
|
||||||
<td>{$bandw['name_bw']}<br>{$bandw['rate_down']}{$bandw['rate_down_unit']}/{$bandw['rate_up']}{$bandw['rate_up_unit']}
|
<td>{Lang::moneyFormat($trx['price'])}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{else}
|
||||||
|
<table class="table table-bordered table-striped table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Status')}</td>
|
||||||
|
<td>{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}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
<tr>
|
||||||
</tbody>
|
<td>{Lang::T('expired')}</td>
|
||||||
</table>
|
<td>{date($_c['date_format'], strtotime($trx['expired_date']))}
|
||||||
|
{date('H:i', strtotime($trx['expired_date']))} </td>
|
||||||
|
</tr>
|
||||||
|
{if $trx['status']==2}
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Paid Date')}</td>
|
||||||
|
<td>{date($_c['date_format'], strtotime($trx['paid_date']))}
|
||||||
|
{date('H:i', strtotime($trx['paid_date']))} </td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
<tr>
|
||||||
|
<td>{$_L['Plan_Name']}</td>
|
||||||
|
<td>{$plan['name_plan']}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{$_L['Plan_Price']}</td>
|
||||||
|
<td>{Lang::moneyFormat($plan['price'])}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Type')}</td>
|
||||||
|
<td>{$plan['type']}</td>
|
||||||
|
</tr>
|
||||||
|
{if $plan['type']!='Balance'}
|
||||||
|
{if $plan['type'] eq 'Hotspot'}
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Plan_Type')}</td>
|
||||||
|
<td>{Lang::T($plan['typebp'])}</td>
|
||||||
|
</tr>
|
||||||
|
{if $plan['typebp'] eq 'Limited'}
|
||||||
|
{if $plan['limit_type'] eq 'Time_Limit' or $plan['limit_type'] eq 'Both_Limit'}
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Time_Limit')}</td>
|
||||||
|
<td>{$ds['time_limit']} {$ds['time_unit']}</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
{if $plan['limit_type'] eq 'Data_Limit' or $plan['limit_type'] eq 'Both_Limit'}
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Data_Limit')}</td>
|
||||||
|
<td>{$ds['data_limit']} {$ds['data_unit']}</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
<tr>
|
||||||
|
<td>{$_L['Plan_Validity']}</td>
|
||||||
|
<td>{$plan['validity']} {$plan['validity_unit']}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{$_L['Bandwidth_Plans']}</td>
|
||||||
|
<td>{$bandw['name_bw']}<br>{$bandw['rate_down']}{$bandw['rate_down_unit']}/{$bandw['rate_up']}{$bandw['rate_up_unit']}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{if $trx['status']==1}
|
{if $trx['status']==1}
|
||||||
<div class="panel-footer ">
|
<div class="panel-footer ">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user