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);
}
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,6 +35,7 @@
</div>
{/if}
{foreach $routers as $router}
{if Validator::isRouterHasPlan($plans_hotspot, $router['name'])>0 && Validator::isRouterHasPlan($plans_pppoe, $router['name'])>0}
<div class="box box-solid box-info">
<div class="box-header text-black">{$router['name']}</div>
{if $router['description'] != ''}
@ -42,7 +43,7 @@
{$router['description']}
</div>
{/if}
{if count($plans_hotspot)>0}
{if Validator::countRouterPlan($plans_hotspot, $router['name'])>0}
<div class="box-header">{Lang::T('Hotspot Plan')}</div>
<div class="box-body row">
{foreach $plans_hotspot as $plan}
@ -91,7 +92,7 @@
{/foreach}
</div>
{/if}
{if count($plans_pppoe)>0}
{if Validator::countRouterPlan($plans_pppoe,$router['name'])>0}
<div class="box-header text-sm">{Lang::T('PPPOE Plan')}</div>
<div class="box-body row">
{foreach $plans_pppoe as $plan}
@ -141,6 +142,7 @@
</div>
{/if}
</div>
{/if}
{/foreach}
</div>
</div>