From 1832332d99a3c29ccfde10a95263c87405d6ca73 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Thu, 21 Sep 2023 13:45:28 +0700 Subject: [PATCH] show plan by nux-router --- system/controllers/order.php | 16 +++++++++++++--- ui/ui/routers.tpl | 6 +++++- ui/ui/user-orderPlan.tpl | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/system/controllers/order.php b/system/controllers/order.php index df5652ee..5460d791 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -35,9 +35,19 @@ switch ($action) { } $ui->assign('_title', 'Order Plan'); $ui->assign('_system_menu', 'package'); - $routers = ORM::for_table('tbl_routers')->find_many(); - $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'PPPOE')->find_many(); - $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Hotspot')->find_many(); + if(!empty($_SESSION['nux-router'])){ + $routers = ORM::for_table('tbl_routers')->where('id',$_SESSION['nux-router'])->find_many(); + $rs = []; + foreach($routers as $r){ + $rs[] = $r['name']; + } + $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('type', 'PPPOE')->find_many(); + $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('type', 'Hotspot')->find_many(); + }else{ + $routers = ORM::for_table('tbl_routers')->find_many(); + $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'PPPOE')->find_many(); + $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Hotspot')->find_many(); + } $plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many(); $ui->assign('routers', $routers); $ui->assign('plans_pppoe', $plans_pppoe); diff --git a/ui/ui/routers.tpl b/ui/ui/routers.tpl index e4857e62..57670c2e 100644 --- a/ui/ui/routers.tpl +++ b/ui/ui/routers.tpl @@ -31,6 +31,7 @@ + @@ -42,6 +43,7 @@ {foreach $d as $ds} + @@ -50,7 +52,9 @@ {/foreach} diff --git a/ui/ui/user-orderPlan.tpl b/ui/ui/user-orderPlan.tpl index ffc16779..764d6c9f 100644 --- a/ui/ui/user-orderPlan.tpl +++ b/ui/ui/user-orderPlan.tpl @@ -6,13 +6,13 @@
{Lang::T('Order Internet Package')}
{if $_c['enable_balance'] == 'yes'} -
+
{Lang::T('Balance Plans')}
{foreach $plans_balance as $plan}
-
{$plan['name_plan']}
+
{$plan['name_plan']}
ID {$_L['Router_Name']} {$_L['IP_Address']} {$_L['Username']}
{$ds['id']} {$ds['name']} {$ds['ip_address']} {$ds['username']} {$_L['Edit']} - {$_L['Delete']} + {$_L['Delete']}
@@ -35,22 +35,22 @@ {/if} {foreach $routers as $router} - {if Validator::isRouterHasPlan($plans_hotspot, $router['name'])>0 && Validator::isRouterHasPlan($plans_pppoe, $router['name'])>0} -
-
{$router['name']}
+ {if Validator::isRouterHasPlan($plans_hotspot, $router['name']) || Validator::isRouterHasPlan($plans_pppoe, $router['name'])} +
+
{$router['name']}
{if $router['description'] != ''}
{$router['description']}
{/if} {if Validator::countRouterPlan($plans_hotspot, $router['name'])>0} -
{Lang::T('Hotspot Plan')}
+
{Lang::T('Hotspot Plan')}
{foreach $plans_hotspot as $plan} {if $router['name'] eq $plan['routers']}
-
-
{$plan['name_plan']}
+
+
{$plan['name_plan']}
@@ -93,13 +93,13 @@ {/if} {if Validator::countRouterPlan($plans_pppoe,$router['name'])>0} -
{Lang::T('PPPOE Plan')}
+
{Lang::T('PPPOE Plan')}
{foreach $plans_pppoe as $plan} {if $router['name'] eq $plan['routers']}
-
-
{$plan['name_plan']}
+
+
{$plan['name_plan']}