From 4fa341d85477f2a63aa4169033188e685c337987 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Thu, 8 Sep 2022 10:43:46 +0700 Subject: [PATCH] Enable disable router and plan --- system/controllers/routers.php | 43 +++--- system/controllers/services.php | 8 + system/lan/indonesia/common.lan.php | 2 + system/radius.php | 26 ++++ ui/ui/hotspot-add.tpl | 231 +++++++++++++++------------- ui/ui/hotspot-edit.tpl | 12 +- ui/ui/hotspot.tpl | 70 ++++----- ui/ui/pppoe-add.tpl | 11 ++ ui/ui/pppoe-edit.tpl | 11 ++ ui/ui/pppoe.tpl | 62 ++++---- ui/ui/routers-add.tpl | 11 ++ ui/ui/routers-edit.tpl | 12 +- ui/ui/routers.tpl | 7 +- ui/ui/user-orderHotspot.tpl | 53 +++---- 14 files changed, 332 insertions(+), 227 deletions(-) create mode 100644 system/radius.php diff --git a/system/controllers/routers.php b/system/controllers/routers.php index 45fb59aa..e8c83089 100644 --- a/system/controllers/routers.php +++ b/system/controllers/routers.php @@ -69,6 +69,7 @@ switch ($action) { $username = _post('username'); $password = _post('password'); $description = _post('description'); + $enabled = _post('enabled')*1; $msg = ''; if(Validator::Length($name,30,4) == false){ @@ -99,6 +100,7 @@ switch ($action) { $d->username = $username; $d->password = $password; $d->description = $description; + $d->enabled = $enabled; $d->save(); r2(U . 'routers/list', 's', $_L['Created_Successfully']); @@ -114,7 +116,7 @@ switch ($action) { $username = _post('username'); $password = _post('password'); $description = _post('description'); - + $enabled = $_POST['enabled']*1; $msg = ''; if(Validator::Length($name,30,4) == false){ $msg .= 'Name should be between 5 to 30 characters'. '
'; @@ -163,25 +165,28 @@ switch ($action) { $d->username = $username; $d->password = $password; $d->description = $description; + $d->enabled = $enabled; $d->save(); - $p = ORM::for_table('tbl_plans')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); - $p = ORM::for_table('tbl_payment_gateway')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); - $p = ORM::for_table('tbl_pool')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); - $p = ORM::for_table('tbl_transactions')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); - $p = ORM::for_table('tbl_user_recharges')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); - $p = ORM::for_table('tbl_voucher')->where('routers',$oldname)->find_result_set(); - $p->set('routers',$name); - $p->save(); + if($name!=$oldname){ + $p = ORM::for_table('tbl_plans')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + $p = ORM::for_table('tbl_payment_gateway')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + $p = ORM::for_table('tbl_pool')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + $p = ORM::for_table('tbl_transactions')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + $p = ORM::for_table('tbl_user_recharges')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + $p = ORM::for_table('tbl_voucher')->where('routers',$oldname)->find_result_set(); + $p->set('routers',$name); + $p->save(); + } r2(U . 'routers/list', 's', $_L['Updated_Successfully']); }else{ r2(U . 'routers/edit/'.$id, 'e', $msg); diff --git a/system/controllers/services.php b/system/controllers/services.php index dc2d8480..15f82b09 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -109,6 +109,7 @@ switch ($action) { $validity = _post('validity'); $validity_unit = _post('validity_unit'); $routers = _post('routers'); + $enabled = _post('enabled')*1; $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -172,6 +173,7 @@ switch ($action) { $d->validity_unit = $validity_unit; $d->shared_users = $sharedusers; $d->routers = $routers; + $d->enabled = $enabled; $d->save(); r2(U . 'services/hotspot', 's', $_L['Created_Successfully']); @@ -196,6 +198,7 @@ switch ($action) { $validity = _post('validity'); $validity_unit = _post('validity_unit'); $routers = _post('routers'); + $enabled = _post('enabled')*1; $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -264,6 +267,7 @@ switch ($action) { $d->validity_unit = $validity_unit; $d->shared_users = $sharedusers; $d->routers = $routers; + $d->enabled = $enabled; $d->save(); r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']); @@ -357,6 +361,7 @@ switch ($action) { $validity_unit = _post('validity_unit'); $routers = _post('routers'); $pool = _post('pool_name'); + $enabled = _post('enabled')*1; $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -415,6 +420,7 @@ switch ($action) { $d->validity_unit = $validity_unit; $d->routers = $routers; $d->pool = $pool; + $d->enabled = $enabled; $d->save(); r2(U . 'services/pppoe', 's', $_L['Created_Successfully']); @@ -432,6 +438,7 @@ switch ($action) { $validity_unit = _post('validity_unit'); $routers = _post('routers'); $pool = _post('pool_name'); + $enabled = _post('enabled')*1; $msg = ''; if (Validator::UnsignedNumber($validity) == false) { @@ -495,6 +502,7 @@ switch ($action) { $d->validity_unit = $validity_unit; $d->routers = $routers; $d->pool = $pool; + $d->enabled = $enabled; $d->save(); r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']); diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php index 6259ed43..4c4b7e68 100644 --- a/system/lan/indonesia/common.lan.php +++ b/system/lan/indonesia/common.lan.php @@ -254,3 +254,5 @@ $_L['Explain_Coverage_of_router'] = 'Jelaskan Cakupan wilayah hotspot'; $_L['Name_of_Area_that_router_operated'] = 'Nama Lokasi/Wilayah Router beroperasi'; $_L['Payment_Notification_URL_Recurring_Notification_URL_Pay_Account_Notification_URL'] = 'Payment Notification URL, Recurring Notification URL, Pay Account Notification URL'; $_L['Finish_Redirect_URL_Unfinish_Redirect_URL_Error_Redirect_URL'] = 'Finish Redirect URL, Unfinish Redirect URL, Error Redirect URL'; +$_L['Status'] = 'Status'; +$_L['Status'] = 'Status'; diff --git a/system/radius.php b/system/radius.php new file mode 100644 index 00000000..bd6ae1de --- /dev/null +++ b/system/radius.php @@ -0,0 +1,26 @@ +find_many(); +foreach($result as $value){ + $config[$value['setting']]=$value['value']; +} +date_default_timezone_set($config['timezone']); \ No newline at end of file diff --git a/ui/ui/hotspot-add.tpl b/ui/ui/hotspot-add.tpl index d3338abc..de8d0096 100644 --- a/ui/ui/hotspot-add.tpl +++ b/ui/ui/hotspot-add.tpl @@ -5,118 +5,127 @@
{$_L['Add_Plan']}
+
+
+ +
+ + +
+
+
+ +
+ +

{Lang::T('Cannot be change after saved')}

+
+
+
+ +
+ {$_L['Unlimited']} + {$_L['Limited']} +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +

{Lang::T('1 user can be used for many devices?')}

+
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +

{Lang::T('Cannot be change after saved')}

+
+
- -
- -
- -

{Lang::T('Cannot be change after saved')}

-
-
-
- -
- {$_L['Unlimited']} - {$_L['Limited']} -
-
- - - -
- -
- -
-
-
- -
- -
-
-
- -
- -

{Lang::T('1 user can be used for many devices?')}

-
-
-
- -
- -
-
- -
-
-
- -
- -

{Lang::T('Cannot be change after saved')}

-
-
- -
-
- - Or {$_L['Cancel']} -
-
-
- +
+
+ + Or {$_L['Cancel']} +
+
+
diff --git a/ui/ui/hotspot-edit.tpl b/ui/ui/hotspot-edit.tpl index bae30c20..95b7407c 100644 --- a/ui/ui/hotspot-edit.tpl +++ b/ui/ui/hotspot-edit.tpl @@ -5,9 +5,19 @@
{$_L['Edit_Plan']}
-
+
+ +
+ + +
+
diff --git a/ui/ui/hotspot.tpl b/ui/ui/hotspot.tpl index 720e6fae..604095fd 100644 --- a/ui/ui/hotspot.tpl +++ b/ui/ui/hotspot.tpl @@ -23,42 +23,42 @@ {$_L['New_Plan']}
 
+
+ + + + + + + + + + + + + + + + {foreach $d as $ds} + + + + + + + + + + + + {/foreach} + +
{$_L['Plan_Name']}{$_L['Plan_Type']}{$_L['Bandwidth_Plans']}{$_L['Plan_Price']}{$_L['Time_Limit']}{$_L['Data_Limit']}{$_L['Plan_Validity']}{$_L['Routers']}{$_L['Manage']}
{$ds['name_plan']}{$ds['typebp']}{$ds['name_bw']}{$ds['price']}{$ds['time_limit']} {$ds['time_unit']}{$ds['data_limit']} {$ds['data_unit']}{$ds['validity']} {$ds['validity_unit']}{$ds['routers']} + {$_L['Edit']} +
+
+ {$paginator['contents']} - - - - - - - - - - - - - - - - {foreach $d as $ds} - - - - - - - - - - - - {/foreach} - -
{$_L['Plan_Name']}{$_L['Plan_Type']}{$_L['Bandwidth_Plans']}{$_L['Plan_Price']}{$_L['Time_Limit']}{$_L['Data_Limit']}{$_L['Plan_Validity']}{$_L['Routers']}{$_L['Manage']}
{$ds['name_plan']}{$ds['typebp']}{$ds['name_bw']}{$ds['price']}{$ds['time_limit']} {$ds['time_unit']}{$ds['data_limit']} {$ds['data_unit']}{$ds['validity']} {$ds['validity_unit']}{$ds['routers']} - {$_L['Edit']} - {$_L['Delete']} -
- {$paginator['contents']} -
diff --git a/ui/ui/pppoe-add.tpl b/ui/ui/pppoe-add.tpl index d4c99b0e..70046ac9 100644 --- a/ui/ui/pppoe-add.tpl +++ b/ui/ui/pppoe-add.tpl @@ -6,6 +6,17 @@
{$_L['Add_Plan']}
+
+ +
+ + +
+
diff --git a/ui/ui/pppoe-edit.tpl b/ui/ui/pppoe-edit.tpl index 0d329136..a5e71948 100644 --- a/ui/ui/pppoe-edit.tpl +++ b/ui/ui/pppoe-edit.tpl @@ -7,6 +7,17 @@
+
+ +
+ + +
+
diff --git a/ui/ui/pppoe.tpl b/ui/ui/pppoe.tpl index e677eca1..d963d5e0 100644 --- a/ui/ui/pppoe.tpl +++ b/ui/ui/pppoe.tpl @@ -23,37 +23,37 @@ {$_L['New_Plan']}
 
- - - - - - - - - - - - - - - {foreach $d as $ds} - - - - - - - - - - {/foreach} - -
{$_L['Plan_Name']}{$_L['Bandwidth_Plans']}{$_L['Plan_Price']}{$_L['Plan_Validity']}{$_L['Pool']}{$_L['Routers']}{$_L['Manage']}
{$ds['name_plan']}{$ds['name_bw']}{$ds['price']}{$ds['validity']} {$ds['validity_unit']}{$ds['pool']}{$ds['routers']} - {$_L['Edit']} - {$_L['Delete']} -
- {$paginator['contents']} +
+ + + + + + + + + + + + + + {foreach $d as $ds} + + + + + + + + + + {/foreach} + +
{$_L['Plan_Name']}{$_L['Bandwidth_Plans']}{$_L['Plan_Price']}{$_L['Plan_Validity']}{$_L['Pool']}{$_L['Routers']}{$_L['Manage']}
{$ds['name_plan']}{$ds['name_bw']}{$ds['price']}{$ds['validity']} {$ds['validity_unit']}{$ds['pool']}{$ds['routers']} + {$_L['Edit']} +
+
+ {$paginator['contents']}
diff --git a/ui/ui/routers-add.tpl b/ui/ui/routers-add.tpl index 439016aa..70c3a71f 100644 --- a/ui/ui/routers-add.tpl +++ b/ui/ui/routers-add.tpl @@ -7,6 +7,17 @@
+
+ +
+ + +
+
diff --git a/ui/ui/routers-edit.tpl b/ui/ui/routers-edit.tpl index 7e224ea4..a78ac2b1 100644 --- a/ui/ui/routers-edit.tpl +++ b/ui/ui/routers-edit.tpl @@ -7,6 +7,17 @@
+
+ +
+ + +
+
@@ -39,7 +50,6 @@

{Lang::T('Explain Coverage of router')}

-
diff --git a/ui/ui/routers.tpl b/ui/ui/routers.tpl index 7119449e..4348398d 100644 --- a/ui/ui/routers.tpl +++ b/ui/ui/routers.tpl @@ -32,19 +32,20 @@ {$_L['IP_Address']} {$_L['Username']} {$_L['Description']} + {Lang::T('Status')} {$_L['Manage']} {foreach $d as $ds} - + {$ds['name']} {$ds['ip_address']} {$ds['username']} {$ds['description']} + {if $ds['enabled'] == 1}Enabled{else}Disabled{/if} - {$_L['Edit']} - {$_L['Delete']} + {$_L['Edit']} {/foreach} diff --git a/ui/ui/user-orderHotspot.tpl b/ui/ui/user-orderHotspot.tpl index 47ca9b06..3be9c4f4 100644 --- a/ui/ui/user-orderHotspot.tpl +++ b/ui/ui/user-orderHotspot.tpl @@ -12,34 +12,35 @@ {$router['description']}
{/if} -
-
- {foreach $plans as $plan} - {if $router['name'] eq $plan['routers']} -
-
-
{$plan['name_plan']}
-
- - - - - - - - - - - -
Price{$plan['price']}
Validity{$plan['validity']} {$plan['validity_unit']}
-
-
{/foreach}