send package to friend
This commit is contained in:
parent
28fcabd1fd
commit
f292da9d8d
@ -19,12 +19,7 @@ class Balance
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
if (Balance::min($id_customer, $amount)) {
|
if (Balance::min($id_customer, $amount)) {
|
||||||
if (Balance::plusByPhone($phoneTarget, $amount)) {
|
return Balance::plusByPhone($phoneTarget, $amount);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
Balance::plus($id_customer, $amount);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,17 @@ if (_post('send') == 'balance') {
|
|||||||
r2(U . 'home', 's', Lang::T('Sending balance success'));
|
r2(U . 'home', 's', Lang::T('Sending balance success'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'home', 'd', 'Failed, balance is not available');
|
r2(U . 'home', 'd', Lang::T('Failed, balance is not available'));
|
||||||
|
}
|
||||||
|
}else if (_post('send') == 'plan') {
|
||||||
|
$active = ORM::for_table('tbl_user_recharges')
|
||||||
|
->where('username', _post('username'))
|
||||||
|
->find_one();
|
||||||
|
$router = ORM::for_table('tbl_routers') ->where('name', $active['routers'])->find_one();
|
||||||
|
if($router){
|
||||||
|
r2(U . "order/send/$router[id]/$active[plan_id]&u=".trim(_post('username')), 's', Lang::T('Review package before recharge'));
|
||||||
|
}else{
|
||||||
|
r2(U . 'package/order', 'w', Lang::T('Your friend do not have active package'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($trx)) {
|
if (empty($trx)) {
|
||||||
r2(U . "order", 'e', Lang::T("Transaction Not found"));
|
r2(U . "order/package", 'e', Lang::T("Transaction Not found"));
|
||||||
}
|
}
|
||||||
$router = ORM::for_table('tbl_routers')->find_one($trx['routers_id']);
|
$router = ORM::for_table('tbl_routers')->find_one($trx['routers_id']);
|
||||||
$plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']);
|
$plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']);
|
||||||
@ -111,8 +111,8 @@ switch ($action) {
|
|||||||
$ui->display('user-orderView.tpl');
|
$ui->display('user-orderView.tpl');
|
||||||
break;
|
break;
|
||||||
case 'pay':
|
case 'pay':
|
||||||
if ($_c['enable_balance'] != 'yes'){
|
if ($_c['enable_balance'] != 'yes' && $config['allow_balance_transfer'] != 'yes') {
|
||||||
r2(U . "order", 'e', Lang::T("Balance not enabled"));
|
r2(U . "order/package", 'e', Lang::T("Balance not enabled"));
|
||||||
}
|
}
|
||||||
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
|
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
|
||||||
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']);
|
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']);
|
||||||
@ -134,6 +134,87 @@ switch ($action) {
|
|||||||
echo "no renewall | plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
|
echo "no renewall | plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'send':
|
||||||
|
if ($_c['enable_balance'] != 'yes') {
|
||||||
|
r2(U . "order/package", 'e', Lang::T("Balance not enabled"));
|
||||||
|
}
|
||||||
|
$ui->assign('_title', Lang::T('Buy for friend'));
|
||||||
|
$ui->assign('_system_menu', 'package');
|
||||||
|
$plan = ORM::for_table('tbl_plans')->find_one($routes['3']);
|
||||||
|
if (empty($plan)) {
|
||||||
|
r2(U . "order/package", 'e', Lang::T("Plan Not found"));
|
||||||
|
}
|
||||||
|
if (isset($_POST['send']) && $_POST['send'] == 'plan') {
|
||||||
|
$target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one();
|
||||||
|
if (!$target) {
|
||||||
|
r2(U . 'home', 'd', Lang::T('Username not found'));
|
||||||
|
}
|
||||||
|
if ($user['balance'] < $plan['price']) {
|
||||||
|
r2(U . 'home', 'd', Lang::T('insufficient balance'));
|
||||||
|
}
|
||||||
|
if ($user['username'] == $target['username']) {
|
||||||
|
r2(U . "order/pay/$routes[2]/$routes[3]", 's', '^_^ v');
|
||||||
|
}
|
||||||
|
$active = ORM::for_table('tbl_user_recharges')
|
||||||
|
->where('username', _post('username'))
|
||||||
|
->where('status', 'on')
|
||||||
|
->find_one();
|
||||||
|
|
||||||
|
if ($active['plan_id'] != $plan['id']) {
|
||||||
|
r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.")." [ <b>$active[namebp]</b> ]");
|
||||||
|
}
|
||||||
|
if (Package::rechargeUser($target['id'], $plan['routers'], $plan['id'], $user['fullname'], 'Balance')) {
|
||||||
|
// if success, then get the balance
|
||||||
|
Balance::min($user['id'], $plan['price']);
|
||||||
|
//sender
|
||||||
|
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||||
|
$d->username = $user['username'];
|
||||||
|
$d->gateway = $target['username'];
|
||||||
|
$d->plan_id = $plan['id'];
|
||||||
|
$d->plan_name = $plan['name_plan'];
|
||||||
|
$d->routers_id = $routes['2'];
|
||||||
|
$d->routers = $plan['routers'];
|
||||||
|
$d->price = $plan['price'];
|
||||||
|
$d->payment_method = "Balance";
|
||||||
|
$d->payment_channel = "Send Plan";
|
||||||
|
$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();
|
||||||
|
$trx_id = $d->id();
|
||||||
|
//receiver
|
||||||
|
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||||
|
$d->username = $target['username'];
|
||||||
|
$d->gateway = $user['username'];
|
||||||
|
$d->plan_id = $plan['id'];
|
||||||
|
$d->plan_name = $plan['name_plan'];
|
||||||
|
$d->routers_id = $routes['2'];
|
||||||
|
$d->routers = $plan['routers'];
|
||||||
|
$d->price = $plan['price'];
|
||||||
|
$d->payment_method = "Balance";
|
||||||
|
$d->payment_channel = "Received Plan";
|
||||||
|
$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 . "order/view/$trx_id", 's', Lang::T("Success to send package"));
|
||||||
|
} else {
|
||||||
|
r2(U . "order/package", 'e', Lang::T("Failed to Send package"));
|
||||||
|
Message::sendTelegram("Send Package with Balance Failed\n\n#u$user[username] #send \n" . $plan['name_plan'] .
|
||||||
|
"\nRouter: " . $plan['routers'] .
|
||||||
|
"\nPrice: " . $plan['price']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ui->assign('username', $_GET['u']);
|
||||||
|
$ui->assign('router', $router);
|
||||||
|
$ui->assign('plan', $plan);
|
||||||
|
$ui->display('user-sendPlan.tpl');
|
||||||
|
break;
|
||||||
case 'buy':
|
case 'buy':
|
||||||
if (strpos($user['email'], '@') === false) {
|
if (strpos($user['email'], '@') === false) {
|
||||||
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
|
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
|
||||||
|
@ -390,3 +390,13 @@ $_L['Expired_IP_Pool'] = 'Expired IP Pool';
|
|||||||
$_L['Proxy'] = 'Proxy';
|
$_L['Proxy'] = 'Proxy';
|
||||||
$_L['Proxy_Server'] = 'Proxy Server';
|
$_L['Proxy_Server'] = 'Proxy Server';
|
||||||
$_L['Proxy_Server_Login'] = 'Proxy Server Login';
|
$_L['Proxy_Server_Login'] = 'Proxy Server Login';
|
||||||
|
$_L['Hotspot_Plan'] = 'Hotspot Plan';
|
||||||
|
$_L['PPPOE_Plan'] = 'PPPOE Plan';
|
||||||
|
$_L['UNKNOWN'] = 'UNKNOWN';
|
||||||
|
$_L['Are_You_Sure'] = 'Are You Sure?';
|
||||||
|
$_L['Success_to_send_package'] = 'Success to send package';
|
||||||
|
$_L['Target_has_active_plan_different_with_current_plant'] = 'Target has active plan, different with current plant.';
|
||||||
|
$_L['Recharge_a_friend'] = 'Recharge a friend';
|
||||||
|
$_L['Buy_for_friend'] = 'Buy for friend';
|
||||||
|
$_L['Buy_this_for_friend_account'] = 'Buy this for friend account?';
|
||||||
|
$_L['Review_package_before_recharge'] = 'Review package before recharge';
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<aside class="main-sidebar">
|
<aside class="main-sidebar" style="position:fixed;">
|
||||||
<section class="sidebar">
|
<section class="sidebar">
|
||||||
<ul class="sidebar-menu" data-widget="tree">
|
<ul class="sidebar-menu" data-widget="tree">
|
||||||
<li {if $_system_menu eq 'home'}class="active" {/if}>
|
<li {if $_system_menu eq 'home'}class="active" {/if}>
|
||||||
|
@ -167,7 +167,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-sm-2" align="center">
|
<div class="form-group col-sm-2" align="center">
|
||||||
<button class="btn btn-success btn-block" id="sendBtn" type="submit" name="send"
|
<button class="btn btn-success btn-block" id="sendBtn" type="submit" name="send"
|
||||||
value="balance"><i class="glyphicon glyphicon-send"></i></button>
|
onclick="return confirm('{Lang::T("Are You Sure?")}')" value="balance"><i class="glyphicon glyphicon-send"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -183,6 +183,23 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box-header">
|
||||||
|
<h4 class="box-title">{Lang::T("Recharge a friend")}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="box-body p-0">
|
||||||
|
<form method="post" role="form" action="{$_url}home">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" id="username" name="username" class="form-control" required
|
||||||
|
placeholder="{$_L['Username']}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-sm-2" align="center">
|
||||||
|
<button class="btn btn-success btn-block" id="sendBtn" type="submit" name="send"
|
||||||
|
onclick="return confirm('{Lang::T("Are You Sure?")}')" value="plan"><i class="glyphicon glyphicon-send"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<br>
|
<br>
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{if count($plans_hotspot)>0}
|
{if count($plans_hotspot)>0}
|
||||||
<div class="box-header">Hotspot</div>
|
<div class="box-header">{Lang::T('Hotspot Plan')}</div>
|
||||||
<div class="box-body row">
|
<div class="box-body row">
|
||||||
{foreach $plans_hotspot as $plan}
|
{foreach $plans_hotspot as $plan}
|
||||||
{if $router['name'] eq $plan['routers']}
|
{if $router['name'] eq $plan['routers']}
|
||||||
@ -79,6 +79,11 @@
|
|||||||
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
|
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']}
|
||||||
|
<a href="{$_url}order/send/{$router['id']}/{$plan['id']}"
|
||||||
|
onclick="return confirm('{Lang::T('Buy this for friend account?')}')"
|
||||||
|
class="btn btn-sm btn-block btn-primary">{Lang::T('Buy for friend')}</a>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -87,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{if count($plans_pppoe)>0}
|
{if count($plans_pppoe)>0}
|
||||||
<div class="box-header text-sm">PPPOE</div>
|
<div class="box-header text-sm">{Lang::T('PPPOE Plan')}</div>
|
||||||
<div class="box-body row">
|
<div class="box-body row">
|
||||||
{foreach $plans_pppoe as $plan}
|
{foreach $plans_pppoe as $plan}
|
||||||
{if $router['name'] eq $plan['routers']}
|
{if $router['name'] eq $plan['routers']}
|
||||||
@ -123,6 +128,11 @@
|
|||||||
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
|
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']}
|
||||||
|
<a href="{$_url}order/send/{$router['id']}/{$plan['id']}"
|
||||||
|
onclick="return confirm('{Lang::T('Buy this for friend account?')}')"
|
||||||
|
class="btn btn-sm btn-block btn-primary">{Lang::T('Buy for friend')}</a>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
43
ui/ui/user-sendPlan.tpl
Normal file
43
ui/ui/user-sendPlan.tpl
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{include file="sections/user-header.tpl"}
|
||||||
|
<!-- user-orderView -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3"></div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="box box-solid box-default">
|
||||||
|
<div class="box-header">{$plan['name_plan']}</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-striped">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Type')}</td>
|
||||||
|
<td>{$plan['type']}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Price')}</td>
|
||||||
|
<td>{Lang::moneyFormat($plan['price'])}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{Lang::T('Validity')}</td>
|
||||||
|
<td>{$plan['validity']} {$plan['validity_unit']}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer">
|
||||||
|
<form method="post" onsubmit="return askConfirm()" role="form">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" id="username" name="username" class="form-control" required value="{$username}"
|
||||||
|
placeholder="{$_L['Username']}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-sm-3" align="center">
|
||||||
|
<button class="btn btn-success btn-block" id="sendBtn" type="submit" name="send" onclick="return confirm('{Lang::T("Are You Sure?")}')"
|
||||||
|
value="plan"><i class="glyphicon glyphicon-send"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{include file="sections/user-footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user