View Order

This commit is contained in:
Ibnu Maksum 2023-10-04 17:07:13 +07:00
parent 0bb20d4a16
commit 1891dee6b2
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
6 changed files with 206 additions and 30 deletions

View File

@ -19,55 +19,63 @@ class Lang
public static function moneyFormat($var)
{
global $config;
return $config['currency_code'] . ' ' .number_format($var, 0, $config['dec_point'], $config['thousands_sep']);
return $config['currency_code'] . ' ' . number_format($var, 0, $config['dec_point'], $config['thousands_sep']);
}
public static function phoneFormat($phone)
{
global $config;
if(Validator::UnsignedNumber($phone) && !empty($config['country_code_phone'])){
if (Validator::UnsignedNumber($phone) && !empty($config['country_code_phone'])) {
return preg_replace('/^0/', $config['country_code_phone'], $phone);
}else{
} else {
return $phone;
}
}
public static function dateFormat($date){
public static function dateFormat($date)
{
global $config;
return date($config['date_format'], strtotime($date));
}
public static function dateTimeFormat($date){
public static function dateTimeFormat($date)
{
global $config;
if(strtotime($date) < strtotime("2000-01-01 00:00:00")){
if (strtotime($date) < strtotime("2000-01-01 00:00:00")) {
return "";
}else{
return date($config['date_format']. ' H:i', strtotime($date));
} else {
return date($config['date_format'] . ' H:i', strtotime($date));
}
}
public static function dateAndTimeFormat($date, $time){
public static function dateAndTimeFormat($date, $time)
{
global $config;
return date($config['date_format']. ' H:i', strtotime("$date $time"));
return date($config['date_format'] . ' H:i', strtotime("$date $time"));
}
public static function nl2br($text){
public static function nl2br($text)
{
return nl2br($text);
}
public static function arrayCount($arr){
if(is_array($arr)){
public static function arrayCount($arr)
{
if (is_array($arr)) {
return count($arr);
}else{
} else if (is_object($arr)) {
return count($arr);
} else {
return 0;
}
}
public static function getNotifText($key){
public static function getNotifText($key)
{
global $_notifmsg, $_notifmsg_default;
if(isset($_notifmsg[$key])){
if (isset($_notifmsg[$key])) {
return $_notifmsg[$key];
}else{
} else {
return $_notifmsg_default[$key];
}
}

View File

@ -36,20 +36,30 @@ switch ($action) {
$ui->assign('_title', 'Order Plan');
$ui->assign('_system_menu', 'package');
if(!empty($_SESSION['nux-router'])){
$routers = ORM::for_table('tbl_routers')->where('id',$_SESSION['nux-router'])->find_many();
$rs = [];
foreach($routers as $r){
$rs[] = $r['name'];
if($_SESSION['nux-router']=='radius'){
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',1)->where('type', 'PPPOE')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',1)->where('type', 'Hotspot')->find_many();
}else{
$routers = ORM::for_table('tbl_routers')->where('id',$_SESSION['nux-router'])->find_many();
$rs = [];
foreach($routers as $r){
$rs[] = $r['name'];
}
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius',0)->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius',0)->where('type', 'Hotspot')->find_many();
}
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('type', 'Hotspot')->find_many();
}else{
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',1)->where('type', 'PPPOE')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',1)->where('type', 'Hotspot')->find_many();
$routers = ORM::for_table('tbl_routers')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Hotspot')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',0)->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius',0)->where('type', 'Hotspot')->find_many();
}
$plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many();
$ui->assign('routers', $routers);
$ui->assign('radius_pppoe', $radius_pppoe);
$ui->assign('radius_hotspot', $radius_hotspot);
$ui->assign('plans_pppoe', $plans_pppoe);
$ui->assign('plans_hotspot', $plans_hotspot);
$ui->assign('plans_balance', $plans_balance);

View File

@ -477,7 +477,6 @@ switch ($action) {
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'country_code_phone')->find_one();
if ($d) {
$d->value = $country_code_phone;
@ -489,6 +488,37 @@ switch ($action) {
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_plan')->find_one();
if ($d) {
$d->value = _post('radius_plan');
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'radius_plan';
$d->value = _post('radius_plan');
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'hotspot_plan')->find_one();
if ($d) {
$d->value = _post('hotspot_plan');
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'hotspot_plan';
$d->value = _post('hotspot_plan');
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'pppoe_plan')->find_one();
if ($d) {
$d->value = _post('pppoe_plan');
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'pppoe_plan';
$d->value = _post('pppoe_plan');
$d->save();
}
$currency_code = $_POST['currency_code'];
$d = ORM::for_table('tbl_appconfig')->where('setting', 'currency_code')->find_one();
$d->value = $currency_code;

View File

@ -404,3 +404,4 @@ $_L['Sync'] = 'Sync';
$_L['Failed_to_create_PaymeTrust_transaction'] = 'Failed to create PaymeTrust transaction.';
$_L['Location'] = 'Location';
$_L['Radius_Plans'] = 'Radius Plans';
$_L['Change_title_in_user_Plan_order'] = 'Change title in user Plan order';

View File

@ -48,8 +48,8 @@
<div class="col-md-6">
<select class="form-control" name="lan" id="lan">
{foreach $lan as $lans}
<option value="{$lans}" {if $_c['language'] eq $lans}
selected="selected" {/if}>{$lans}</option>
<option value="{$lans}" {if $_c['language'] eq $lans} selected="selected" {/if}>{$lans}
</option>
{/foreach}
</select>
</div>
@ -89,6 +89,31 @@
</div>
</div>
</div>
<hr>
<div class="form-group">
<label class="col-md-2 control-label">Radius Plan</label>
<div class="col-md-6">
<input type="text" class="form-control" id="radius_plan" name="radius_plan"
value="{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}">
</div>
<span class="help-block col-md-4">{Lang::T('Change title in user Plan order')}</span>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Hotspot Plan</label>
<div class="col-md-6">
<input type="text" class="form-control" id="hotspot_plan" name="hotspot_plan"
value="{if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if}">
</div>
<span class="help-block col-md-4">{Lang::T('Change title in user Plan order')}</span>
</div>
<div class="form-group">
<label class="col-md-2 control-label">PPPOE Plan</label>
<div class="col-md-6">
<input type="text" class="form-control" id="pppoe_plan" name="pppoe_plan"
value="{if $_c['pppoe_plan']==''}PPPOE Plan{else}{$_c['pppoe_plan']}{/if}">
</div>
<span class="help-block col-md-4">{Lang::T('Change title in user Plan order')}</span>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-primary waves-effect waves-light"

View File

@ -34,6 +34,107 @@
</div>
</div>
{/if}
{if $_c['radius_enable']}
<div class="box box-solid box-info bg-gray-light">
<div class="box-header text-black text-bold">{if $_c['radius_plan']==''}Radius
Plan{else}{$_c['radius_plan']}
{/if}</div>
{if Lang::arrayCount($radius_hotspot)>0}
<div class="box-header text-black">{if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if}</div>
<div class="box-body row">
{foreach $radius_hotspot as $plan}
<div class="col col-md-4">
<div class="box box-primary">
<div class="box-header text-bold">{$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-body">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<a href="{$_url}order/buy/radius/{$plan['id']}"
onclick="return confirm('{Lang::T('Buy this? your active package will be overwrite')}')"
class="btn btn-sm btn-block btn-warning text-black">Buy</a>
{if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']}
<a href="{$_url}order/pay/radius/{$plan['id']}"
onclick="return confirm('{Lang::T('Pay this with Balance? your active package will be overwrite')}')"
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
{/if}
</div>
{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']}
<a href="{$_url}order/send/radius/{$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>
{/foreach}
</div>
{/if}
{if Lang::arrayCount($radius_pppoe)>0}
<div class="box-header text-black">{if $_c['pppoe_plan']==''}PPPOE Plan{else}{$_c['pppoe_plan']}{/if}</div>
<div class="box-body row">
{foreach $radius_pppoe as $plan}
<div class="col col-md-4">
<div class="box box- box-primary">
<div class="box-header text-bold">{$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-body">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<a href="{$_url}order/buy/radius/{$plan['id']}"
onclick="return confirm('{Lang::T('Buy this? your active package will be overwrite')}')"
class="btn btn-sm btn-block btn-warning text-black">Buy</a>
{if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']}
<a href="{$_url}order/pay/radius/{$plan['id']}"
onclick="return confirm('{Lang::T('Pay this with Balance? your active package will be overwrite')}')"
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a>
{/if}
</div>
{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']}
<a href="{$_url}order/send/radius/{$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>
{/foreach}
</div>
{/if}
</div>
{/if}
{foreach $routers as $router}
{if Validator::isRouterHasPlan($plans_hotspot, $router['name']) || Validator::isRouterHasPlan($plans_pppoe, $router['name'])}
<div class="box box-solid box-info bg-gray-light">
@ -44,7 +145,7 @@
</div>
{/if}
{if Validator::countRouterPlan($plans_hotspot, $router['name'])>0}
<div class="box-header text-black">{Lang::T('Hotspot Plan')}</div>
<div class="box-header text-black">{if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if}</div>
<div class="box-body row">
{foreach $plans_hotspot as $plan}
{if $router['name'] eq $plan['routers']}
@ -93,7 +194,7 @@
</div>
{/if}
{if Validator::countRouterPlan($plans_pppoe,$router['name'])>0}
<div class="box-header text-black">{Lang::T('PPPOE Plan')}</div>
<div class="box-header text-black">{if $_c['pppoe_plan']==''}PPPOE Plan{else}{$_c['pppoe_plan']}{/if}</div>
<div class="box-body row">
{foreach $plans_pppoe as $plan}
{if $router['name'] eq $plan['routers']}
@ -146,4 +247,5 @@
{/foreach}
</div>
</div>
</div>
{include file="sections/user-footer.tpl"}