Skip to content

Commit

Permalink
Merge pull request #94 from Focuslinkstech/master
Browse files Browse the repository at this point in the history
Allow Package Purchase Option Added.
admin can now decide if clients can purchase a particular package or not.

if No option is selected the package wont display in the package list
  • Loading branch information
ibnux authored Jan 11, 2024
2 parents a953157 + 4ba3848 commit 2fdc3c9
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 15 deletions.
20 changes: 10 additions & 10 deletions system/controllers/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
$ui->assign('_title', 'Top Up');
$ui->assign('_system_menu', 'balance');
$plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many();
$plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->where('allow_purchase', 'yes')->find_many();
$ui->assign('plans_balance', $plans_balance);
$ui->display('user-orderBalance.tpl');
break;
Expand All @@ -49,24 +49,24 @@
$ui->assign('_system_menu', 'package');
if (!empty($_SESSION['nux-router'])) {
if ($_SESSION['nux-router'] == 'radius') {
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->find_many();
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many();
} else {
$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('is_radius', 0)->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many();
}
} else {
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->find_many();
$radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many();

$routers = ORM::for_table('tbl_routers')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('allow_purchase', 'yes')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('allow_purchase', 'yes')->find_many();
}
$ui->assign('routers', $routers);
$ui->assign('radius_pppoe', $radius_pppoe);
Expand Down Expand Up @@ -277,7 +277,7 @@
$router['id'] = 0;
$router['name'] = 'balance';
}
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->where('allow_purchase', 'yes')->find_one($routes['3']);
if (empty($router) || empty($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found"));
}
Expand Down
13 changes: 13 additions & 0 deletions system/controllers/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
$routers = _post('routers');
$pool_expired = _post('pool_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');

$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
Expand Down Expand Up @@ -264,6 +265,7 @@
$d->pool_expired = $pool_expired;
}
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();
$plan_id = $d->id();

Expand Down Expand Up @@ -302,6 +304,7 @@
$validity_unit = _post('validity_unit');
$pool_expired = _post('pool_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');
$routers = _post('routers');
$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
Expand Down Expand Up @@ -363,6 +366,7 @@
$d->shared_users = $sharedusers;
$d->pool_expired = $pool_expired;
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();

r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']);
Expand Down Expand Up @@ -456,6 +460,8 @@
$pool = _post('pool_name');
$pool_expired = _post('pool_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');


$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
Expand Down Expand Up @@ -514,6 +520,7 @@
$d->pool_expired = $pool_expired;
}
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();
$plan_id = $d->id();

Expand Down Expand Up @@ -545,6 +552,7 @@
$pool = _post('pool_name');
$pool_expired = _post('pool_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');

$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
Expand Down Expand Up @@ -602,6 +610,7 @@
$d->pool = $pool;
$d->pool_expired = $pool_expired;
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();

r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']);
Expand Down Expand Up @@ -653,6 +662,7 @@
$name = _post('name');
$price = _post('price');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');

$msg = '';
if (Validator::UnsignedNumber($price) == false) {
Expand All @@ -672,6 +682,7 @@
$d->name_plan = $name;
$d->price = $price;
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();

r2(U . 'services/balance', 's', $_L['Updated_Successfully']);
Expand All @@ -683,6 +694,7 @@
$name = _post('name');
$price = _post('price');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');

$msg = '';
if (Validator::UnsignedNumber($price) == false) {
Expand All @@ -708,6 +720,7 @@
$d->routers = '';
$d->pool = '';
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();

r2(U . 'services/balance', 's', $_L['Created_Successfully']);
Expand Down
3 changes: 3 additions & 0 deletions system/updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
],
"2023.12.15": [
"ALTER TABLE `tbl_customers` ADD `service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type' AFTER `balance`;"
],
"2024.1.11": [
"ALTER TABLE `tbl_plans` ADD `allow_purchase` ENUM('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page' AFTER `enabled`;"
]
}
11 changes: 11 additions & 0 deletions ui/ui/balance-add.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="allow_purchase" value="no"> No
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6">
Expand Down
12 changes: 12 additions & 0 deletions ui/ui/balance-edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['allow_purchase'] == yes}checked{/if} name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" {if $d['allow_purchase'] == no}checked{/if} name="allow_purchase" value="no">
No
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6">
Expand Down
13 changes: 12 additions & 1 deletion ui/ui/hotspot-add.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="allow_purchase" value="no"> No
</label>
</div>
</div>
{if $_c['radius_enable']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
Expand Down Expand Up @@ -191,4 +202,4 @@
{/literal}
{/if}

{include file="sections/footer.tpl"}
{include file="sections/footer.tpl"}
14 changes: 13 additions & 1 deletion ui/ui/hotspot-edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['allow_purchase'] == yes}checked{/if} name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" {if $d['allow_purchase'] == no}checked{/if} name="allow_purchase" value="no">
No
</label>
</div>
</div>
{if $_c['radius_enable'] and $d['is_radius']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
Expand Down Expand Up @@ -204,4 +216,4 @@
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"}
{include file="sections/footer.tpl"}
13 changes: 12 additions & 1 deletion ui/ui/pppoe-add.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="allow_purchase" value="no"> No
</label>
</div>
</div>
{if $_c['radius_enable']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
Expand Down Expand Up @@ -142,4 +153,4 @@
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"}
{include file="sections/footer.tpl"}
14 changes: 13 additions & 1 deletion ui/ui/pppoe-edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
</label>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Client Can Purchase')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['allow_purchase'] == yes}checked{/if} name="allow_purchase" value="yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" {if $d['allow_purchase'] == no}checked{/if} name="allow_purchase" value="no">
No
</label>
</div>
</div>
{if $_c['radius_enable'] and $d['is_radius']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
Expand Down Expand Up @@ -137,4 +149,4 @@
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"}
{include file="sections/footer.tpl"}
2 changes: 1 addition & 1 deletion ui/ui/user-dashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
Hotspot
{elseif $_user.service_type == 'PPPoE'}
PPPoE
{elseif $_user.service_type == 'Other' || $_user.service_type == null}
{elseif $_user.service_type == 'Others' || $_user.service_type == null}
Others
{/if}
</td>
Expand Down

0 comments on commit 2fdc3c9

Please sign in to comment.