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,6 +35,7 @@
</div> </div>
{/if} {/if}
{foreach $routers as $router} {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 box-solid box-info">
<div class="box-header text-black">{$router['name']}</div> <div class="box-header text-black">{$router['name']}</div>
{if $router['description'] != ''} {if $router['description'] != ''}
@ -42,7 +43,7 @@
{$router['description']} {$router['description']}
</div> </div>
{/if} {/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-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}
@ -91,7 +92,7 @@
{/foreach} {/foreach}
</div> </div>
{/if} {/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-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}
@ -141,6 +142,7 @@
</div> </div>
{/if} {/if}
</div> </div>
{/if}
{/foreach} {/foreach}
</div> </div>
</div> </div>