diff --git a/system/autoload/Validator.php b/system/autoload/Validator.php index e7d46039..996caea2 100644 --- a/system/autoload/Validator.php +++ b/system/autoload/Validator.php @@ -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; + } + } diff --git a/ui/ui/user-orderPlan.tpl b/ui/ui/user-orderPlan.tpl index 96a5829d..ffc16779 100644 --- a/ui/ui/user-orderPlan.tpl +++ b/ui/ui/user-orderPlan.tpl @@ -35,112 +35,114 @@ </div> {/if} {foreach $routers as $router} - <div class="box box-solid box-info"> - <div class="box-header text-black">{$router['name']}</div> - {if $router['description'] != ''} - <div class="box-body"> - {$router['description']} - </div> - {/if} - {if count($plans_hotspot)>0} - <div class="box-header">{Lang::T('Hotspot Plan')}</div> - <div class="box-body row"> - {foreach $plans_hotspot as $plan} - {if $router['name'] eq $plan['routers']} - <div class="col col-md-4"> - <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-body"> - <div class="btn-group btn-group-justified" role="group" aria-label="..."> - <a href="{$_url}order/buy/{$router['id']}/{$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/{$router['id']}/{$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 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'] != ''} + <div class="box-body"> + {$router['description']} + </div> + {/if} + {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} + {if $router['name'] eq $plan['routers']} + <div class="col col-md-4"> + <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-body"> + <div class="btn-group btn-group-justified" role="group" aria-label="..."> + <a href="{$_url}order/buy/{$router['id']}/{$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/{$router['id']}/{$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/{$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> - {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> - {/if} - {/foreach} - </div> - {/if} - {if count($plans_pppoe)>0} - <div class="box-header text-sm">{Lang::T('PPPOE Plan')}</div> - <div class="box-body row"> - {foreach $plans_pppoe as $plan} - {if $router['name'] eq $plan['routers']} - <div class="col col-md-4"> - <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-body"> - <div class="btn-group btn-group-justified" role="group" aria-label="..."> - <a href="{$_url}order/buy/{$router['id']}/{$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/{$router['id']}/{$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} + {/foreach} + </div> + {/if} + {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} + {if $router['name'] eq $plan['routers']} + <div class="col col-md-4"> + <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-body"> + <div class="btn-group btn-group-justified" role="group" aria-label="..."> + <a href="{$_url}order/buy/{$router['id']}/{$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/{$router['id']}/{$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/{$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> - {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> - {/if} - {/foreach} - </div> - {/if} - </div> + {/if} + {/foreach} + </div> + {/if} + </div> + {/if} {/foreach} </div> </div>