check if router has plan

This commit is contained in:
Ibnu Maksum 2023-09-21 12:09:13 +07:00
parent c5b96df43f
commit c9eeefcf3d
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
2 changed files with 119 additions and 98 deletions

View File

@ -299,4 +299,23 @@ class Validator
return (bool)in_array($format, $formats); return (bool)in_array($format, $formats);
} }
public static function countRouterPlan($plans, $router){
$n = 0;
foreach ($plans as $plan){
if($plan['routers'] == $router){
$n++;
}
}
return $n;
}
public static function isRouterHasPlan($plans, $router){
foreach ($plans as $plan){
if($plan['routers'] == $router){
return true;
}
}
return false;
}
} }

View File

@ -35,112 +35,114 @@
</div> </div>
{/if} {/if}
{foreach $routers as $router} {foreach $routers as $router}
<div class="box box-solid box-info"> {if Validator::isRouterHasPlan($plans_hotspot, $router['name'])>0 && Validator::isRouterHasPlan($plans_pppoe, $router['name'])>0}
<div class="box-header text-black">{$router['name']}</div> <div class="box box-solid box-info">
{if $router['description'] != ''} <div class="box-header text-black">{$router['name']}</div>
<div class="box-body"> {if $router['description'] != ''}
{$router['description']} <div class="box-body">
</div> {$router['description']}
{/if} </div>
{if count($plans_hotspot)>0} {/if}
<div class="box-header">{Lang::T('Hotspot Plan')}</div> {if Validator::countRouterPlan($plans_hotspot, $router['name'])>0}
<div class="box-body row"> <div class="box-header">{Lang::T('Hotspot Plan')}</div>
{foreach $plans_hotspot as $plan} <div class="box-body row">
{if $router['name'] eq $plan['routers']} {foreach $plans_hotspot as $plan}
<div class="col col-md-4"> {if $router['name'] eq $plan['routers']}
<div class="box box-solid box-default"> <div class="col col-md-4">
<div class="box-header">{$plan['name_plan']}</div> <div class="box box-solid box-default">
<div class="table-responsive"> <div class="box-header">{$plan['name_plan']}</div>
<table class="table table-bordered table-striped"> <div class="table-responsive">
<tbody> <table class="table table-bordered table-striped">
<tr> <tbody>
<td>{Lang::T('Type')}</td> <tr>
<td>{$plan['type']}</td> <td>{Lang::T('Type')}</td>
</tr> <td>{$plan['type']}</td>
<tr> </tr>
<td>{Lang::T('Price')}</td> <tr>
<td>{Lang::moneyFormat($plan['price'])}</td> <td>{Lang::T('Price')}</td>
</tr> <td>{Lang::moneyFormat($plan['price'])}</td>
<tr> </tr>
<td>{Lang::T('Validity')}</td> <tr>
<td>{$plan['validity']} {$plan['validity_unit']}</td> <td>{Lang::T('Validity')}</td>
</tr> <td>{$plan['validity']} {$plan['validity_unit']}</td>
</tbody> </tr>
</table> </tbody>
</div> </table>
<div class="box-body"> </div>
<div class="btn-group btn-group-justified" role="group" aria-label="..."> <div class="box-body">
<a href="{$_url}order/buy/{$router['id']}/{$plan['id']}" <div class="btn-group btn-group-justified" role="group" aria-label="...">
onclick="return confirm('{Lang::T('Buy this? your active package will be overwrite')}')" <a href="{$_url}order/buy/{$router['id']}/{$plan['id']}"
class="btn btn-sm btn-block btn-warning text-black">Buy</a> onclick="return confirm('{Lang::T('Buy this? your active package will be overwrite')}')"
{if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} class="btn btn-sm btn-block btn-warning text-black">Buy</a>
<a href="{$_url}order/pay/{$router['id']}/{$plan['id']}" {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']}
onclick="return confirm('{Lang::T('Pay this with Balance? your active package will be overwrite')}')" <a href="{$_url}order/pay/{$router['id']}/{$plan['id']}"
class="btn btn-sm btn-block btn-success">{Lang::T('Pay With Balance')}</a> 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/{$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} {/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> {/if}
{/if} {/foreach}
{/foreach} </div>
</div> {/if}
{/if} {if Validator::countRouterPlan($plans_pppoe,$router['name'])>0}
{if count($plans_pppoe)>0} <div class="box-header text-sm">{Lang::T('PPPOE Plan')}</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']} <div class="col col-md-4">
<div class="col col-md-4"> <div class="box box-solid box-default">
<div class="box box-solid box-default"> <div class="box-header">{$plan['name_plan']}</div>
<div class="box-header">{$plan['name_plan']}</div> <div class="table-responsive">
<div class="table-responsive"> <table class="table table-bordered table-striped">
<table class="table table-bordered table-striped"> <tbody>
<tbody> <tr>
<tr> <td>{Lang::T('Type')}</td>
<td>{Lang::T('Type')}</td> <td>{$plan['type']}</td>
<td>{$plan['type']}</td> </tr>
</tr> <tr>
<tr> <td>{Lang::T('Price')}</td>
<td>{Lang::T('Price')}</td> <td>{Lang::moneyFormat($plan['price'])}</td>
<td>{Lang::moneyFormat($plan['price'])}</td> </tr>
</tr> <tr>
<tr> <td>{Lang::T('Validity')}</td>
<td>{Lang::T('Validity')}</td> <td>{$plan['validity']} {$plan['validity_unit']}</td>
<td>{$plan['validity']} {$plan['validity_unit']}</td> </tr>
</tr> </tbody>
</tbody> </table>
</table> </div>
</div> <div class="box-body">
<div class="box-body"> <div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group btn-group-justified" role="group" aria-label="..."> <a href="{$_url}order/buy/{$router['id']}/{$plan['id']}"
<a href="{$_url}order/buy/{$router['id']}/{$plan['id']}" onclick="return confirm('{Lang::T('Buy this? your active package will be overwrite')}')"
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>
class="btn btn-sm btn-block btn-warning text-black">Buy</a> {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']}
{if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} <a href="{$_url}order/pay/{$router['id']}/{$plan['id']}"
<a href="{$_url}order/pay/{$router['id']}/{$plan['id']}" onclick="return confirm('{Lang::T('Pay this with Balance? your active package will be overwrite')}')"
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>
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/{$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} {/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> {/if}
{/if} {/foreach}
{/foreach} </div>
</div> {/if}
{/if} </div>
</div> {/if}
{/foreach} {/foreach}
</div> </div>
</div> </div>