From c9eeefcf3d7b83f17b6e8008ab9892452f1556b3 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Thu, 21 Sep 2023 12:09:13 +0700 Subject: [PATCH] check if router has plan --- system/autoload/Validator.php | 19 ++++ ui/ui/user-orderPlan.tpl | 198 +++++++++++++++++----------------- 2 files changed, 119 insertions(+), 98 deletions(-) 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 @@ {/if} {foreach $routers as $router} -
-
{$router['name']}
- {if $router['description'] != ''} -
- {$router['description']} -
- {/if} - {if count($plans_hotspot)>0} -
{Lang::T('Hotspot Plan')}
-
- {foreach $plans_hotspot as $plan} - {if $router['name'] eq $plan['routers']} -
-
-
{$plan['name_plan']}
-
- - - - - - - - - - - - - - - -
{Lang::T('Type')}{$plan['type']}
{Lang::T('Price')}{Lang::moneyFormat($plan['price'])}
{Lang::T('Validity')}{$plan['validity']} {$plan['validity_unit']}
-
-
-
- Buy - {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} - {Lang::T('Pay With Balance')} + {if Validator::isRouterHasPlan($plans_hotspot, $router['name'])>0 && Validator::isRouterHasPlan($plans_pppoe, $router['name'])>0} +
+
{$router['name']}
+ {if $router['description'] != ''} +
+ {$router['description']} +
+ {/if} + {if Validator::countRouterPlan($plans_hotspot, $router['name'])>0} +
{Lang::T('Hotspot Plan')}
+
+ {foreach $plans_hotspot as $plan} + {if $router['name'] eq $plan['routers']} +
+
+
{$plan['name_plan']}
+
+ + + + + + + + + + + + + + + +
{Lang::T('Type')}{$plan['type']}
{Lang::T('Price')}{Lang::moneyFormat($plan['price'])}
{Lang::T('Validity')}{$plan['validity']} {$plan['validity_unit']}
+
+
+
+ Buy + {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} + {Lang::T('Pay With Balance')} + {/if} +
+ {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']} + {Lang::T('Buy for friend')} {/if}
- {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']} - {Lang::T('Buy for friend')} - {/if}
-
- {/if} - {/foreach} -
- {/if} - {if count($plans_pppoe)>0} -
{Lang::T('PPPOE Plan')}
-
- {foreach $plans_pppoe as $plan} - {if $router['name'] eq $plan['routers']} -
-
-
{$plan['name_plan']}
-
- - - - - - - - - - - - - - - -
{Lang::T('Type')}{$plan['type']}
{Lang::T('Price')}{Lang::moneyFormat($plan['price'])}
{Lang::T('Validity')}{$plan['validity']} {$plan['validity_unit']}
-
-
-
- Buy - {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} - {Lang::T('Pay With Balance')} + {/if} + {/foreach} +
+ {/if} + {if Validator::countRouterPlan($plans_pppoe,$router['name'])>0} +
{Lang::T('PPPOE Plan')}
+
+ {foreach $plans_pppoe as $plan} + {if $router['name'] eq $plan['routers']} +
+
+
{$plan['name_plan']}
+
+ + + + + + + + + + + + + + + +
{Lang::T('Type')}{$plan['type']}
{Lang::T('Price')}{Lang::moneyFormat($plan['price'])}
{Lang::T('Validity')}{$plan['validity']} {$plan['validity_unit']}
+
+
+
+ Buy + {if $_c['enable_balance'] == 'yes' && $_user['balance']>=$plan['price']} + {Lang::T('Pay With Balance')} + {/if} +
+ {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']} + {Lang::T('Buy for friend')} {/if}
- {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes' && $_user['balance']>=$plan['price']} - {Lang::T('Buy for friend')} - {/if}
-
- {/if} - {/foreach} -
- {/if} -
+ {/if} + {/foreach} +
+ {/if} +
+ {/if} {/foreach}