PPPOE Radius Plan

This commit is contained in:
Ibnu Maksum 2023-10-04 11:37:32 +07:00
parent efc0ba93b6
commit 78cbb105aa
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
8 changed files with 389 additions and 272 deletions

View File

@ -105,25 +105,31 @@ class Radius
public static function planUpdate($plan_id, $plan_name, $rate, $pool = null) public static function planUpdate($plan_id, $plan_name, $rate, $pool = null)
{ {
$rates = explode('/', $rate); $rates = explode('/', $rate);
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Data-Rate')->findOne(); if(Radius::getTablePackage()->where_equal('plan_id', $plan_id)->find_one()){
$r->groupname = $plan_name; $r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Data-Rate')->findOne();
$r->value = $rates[1];
if ($r->save()) {
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Xmit-Rate')->findOne();
$r->groupname = $plan_name; $r->groupname = $plan_name;
$r->value = $rates[0]; $r->value = $rates[1];
if ($r->save()) { if ($r->save()) {
if ($pool != null) { $r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Xmit-Rate')->findOne();
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Framed-Pool')->findOne(); $r->groupname = $plan_name;
$r->groupname = $plan_name; $r->value = $rates[0];
$r->value = $pool; if ($r->save()) {
if ($r->save()) { if ($pool != null) {
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Framed-Pool')->findOne();
$r->groupname = $plan_name;
$r->value = $pool;
if ($r->save()) {
return true;
}
} else {
return true; return true;
} }
} else {
return true;
} }
} }
}else{
if(!empty($plan_id)){
return Radius::planAdd($plan_id, $plan_name, $rate, $pool);
}
} }
return false; return false;
} }

View File

@ -28,9 +28,8 @@ switch ($action) {
$log = ''; $log = '';
$router = ''; $router = '';
foreach ($plans as $plan) { foreach ($plans as $plan) {
if($plan['is_radius']){ if ($plan['is_radius']) {
} else {
}else{
if ($router != $plan['routers']) { if ($router != $plan['routers']) {
$mikrotik = Mikrotik::info($plan['routers']); $mikrotik = Mikrotik::info($plan['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
@ -56,7 +55,7 @@ switch ($action) {
} }
} }
r2(U . 'services/hotspot', 's', $log); r2(U . 'services/hotspot', 's', $log);
}else if ($routes['2'] == 'pppoe') { } else if ($routes['2'] == 'pppoe') {
$plans = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->where('tbl_plans.enabled', '1')->find_many(); $plans = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->where('tbl_plans.enabled', '1')->find_many();
$log = ''; $log = '';
$router = ''; $router = '';
@ -176,7 +175,7 @@ switch ($action) {
if ($name == '' or $id_bw == '' or $price == '' or $validity == '') { if ($name == '' or $id_bw == '' or $price == '' or $validity == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
if(empty($radius)){ if (empty($radius)) {
if ($routers == '') { if ($routers == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
@ -205,7 +204,7 @@ switch ($action) {
$radup = '000000'; $radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'].$radup.'/'.$b['rate_down'].$raddown; $radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
$d = ORM::for_table('tbl_plans')->create(); $d = ORM::for_table('tbl_plans')->create();
$d->name_plan = $name; $d->name_plan = $name;
@ -221,10 +220,10 @@ switch ($action) {
$d->validity = $validity; $d->validity = $validity;
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers; $d->shared_users = $sharedusers;
if(!empty($radius)){ if (!empty($radius)) {
$d->is_radius = 1; $d->is_radius = 1;
$d->routers = ''; $d->routers = '';
}else{ } else {
$d->is_radius = 0; $d->is_radius = 0;
$d->routers = $routers; $d->routers = $routers;
$d->pool_expired = $pool_expired; $d->pool_expired = $pool_expired;
@ -235,7 +234,7 @@ switch ($action) {
if ($config['radius_enable']) { if ($config['radius_enable']) {
Radius::planAdd($plan_id, $name, $radiusRate); Radius::planAdd($plan_id, $name, $radiusRate);
}else{ } else {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate); Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
@ -302,11 +301,11 @@ switch ($action) {
$radup = '000000'; $radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'].$radup.'/'.$b['rate_down'].$raddown; $radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
if ($config['radius_enable']) { if ($config['radius_enable']) {
Radius::planUpdate($id, $name, $radiusRate); Radius::planUpdate($id, $name, $radiusRate);
}else{ } else {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate); Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
@ -372,11 +371,14 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id); $d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) { if ($d) {
$ui->assign('d', $d); $ui->assign('d', $d);
$p = ORM::for_table('tbl_pool')->where('routers', $d['routers'])->find_many(); $p = ORM::for_table('tbl_pool')->where('routers', ($d['is_radius']) ? 'radius' : $d['routers'])->find_many();
$ui->assign('p', $p); $ui->assign('p', $p);
$b = ORM::for_table('tbl_bandwidth')->find_many(); $b = ORM::for_table('tbl_bandwidth')->find_many();
$ui->assign('b', $b); $ui->assign('b', $b);
$r = ORM::for_table('tbl_routers')->find_many(); $r = [];
if (($d['is_radius'])) {
$r = ORM::for_table('tbl_routers')->find_many();
}
$ui->assign('r', $r); $ui->assign('r', $r);
run_hook('view_edit_ppoe'); #HOOK run_hook('view_edit_ppoe'); #HOOK
$ui->display('pppoe-edit.tpl'); $ui->display('pppoe-edit.tpl');
@ -404,6 +406,7 @@ switch ($action) {
case 'pppoe-add-post': case 'pppoe-add-post':
$name = _post('name_plan'); $name = _post('name_plan');
$radius = _post('radius');
$id_bw = _post('id_bw'); $id_bw = _post('id_bw');
$price = _post('price'); $price = _post('price');
$validity = _post('validity'); $validity = _post('validity');
@ -420,9 +423,14 @@ switch ($action) {
if (Validator::UnsignedNumber($price) == false) { if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>'; $msg .= 'The price must be a number' . '<br>';
} }
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '' or $pool == '') { if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $pool == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
if (empty($radius)) {
if ($routers == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
}
$d = ORM::for_table('tbl_plans')->where('name_plan', $name)->find_one(); $d = ORM::for_table('tbl_plans')->where('name_plan', $name)->find_one();
if ($d) { if ($d) {
@ -433,24 +441,20 @@ switch ($action) {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one(); $b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') { if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K'; $unitdown = 'K';
$raddown = '000';
} else { } else {
$unitdown = 'M'; $unitdown = 'M';
$raddown = '000000';
} }
if ($b['rate_up_unit'] == 'Kbps') { if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K'; $unitup = 'K';
$radup = '000';
} else { } else {
$unitup = 'M'; $unitup = 'M';
$radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
if (!$config['radius_enable']) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoePlan($client, $name, $pool, $rate);
if (!empty($pool_expired)) {
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
}
}
$d = ORM::for_table('tbl_plans')->create(); $d = ORM::for_table('tbl_plans')->create();
$d->type = 'PPPOE'; $d->type = 'PPPOE';
@ -459,11 +463,29 @@ switch ($action) {
$d->price = $price; $d->price = $price;
$d->validity = $validity; $d->validity = $validity;
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->routers = $routers;
$d->pool = $pool; $d->pool = $pool;
$d->pool_expired = $pool_expired; if (!empty($radius)) {
$d->is_radius = 1;
$d->routers = '';
} else {
$d->is_radius = 0;
$d->routers = $routers;
$d->pool_expired = $pool_expired;
}
$d->enabled = $enabled; $d->enabled = $enabled;
$d->save(); $d->save();
$plan_id = $d->id();
if ($config['radius_enable']) {
Radius::planAdd($plan_id, $name, $radiusRate, $pool);
} else {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoePlan($client, $name, $pool, $rate);
if (!empty($pool_expired)) {
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
}
}
r2(U . 'services/pppoe', 's', $_L['Created_Successfully']); r2(U . 'services/pppoe', 's', $_L['Created_Successfully']);
} else { } else {
@ -490,7 +512,7 @@ switch ($action) {
if (Validator::UnsignedNumber($price) == false) { if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>'; $msg .= 'The price must be a number' . '<br>';
} }
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '' or $pool == '') { if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $pool == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
@ -504,17 +526,24 @@ switch ($action) {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one(); $b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') { if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K'; $unitdown = 'K';
$raddown = '000';
} else { } else {
$unitdown = 'M'; $unitdown = 'M';
$raddown = '000000';
} }
if ($b['rate_up_unit'] == 'Kbps') { if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K'; $unitup = 'K';
$radup = '000';
} else { } else {
$unitup = 'M'; $unitup = 'M';
$radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
if (!$config['radius_enable']) { if ($config['radius_enable']) {
Radius::planUpdate($id, $name, $radiusRate, $pool);
} else {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoePlan($client, $name, $pool, $rate); Mikrotik::setPpoePlan($client, $name, $pool, $rate);

View File

@ -1,4 +1,4 @@
<option value=''>{$_L['Select_Pool']}</option> <option value=''>{$_L['Select_Pool']}</option>
{foreach $d as $ds} {foreach $d as $ds}
<option value="{$ds['pool_name']}">{$ds['pool_name']}</option> <option value="{$ds['pool_name']}">{$ds['pool_name']}{if $routers==''} - {$ds['routers']}{/if}</option>
{/foreach} {/foreach}

View File

@ -20,11 +20,12 @@
{if $_c['radius_enable']} {if $_c['radius_enable']}
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Radius</label> <label class="col-md-2 control-label">Radius</label>
<div class="col-md-10"> <div class="col-md-6">
<label class="radio-inline"> <label class="radio-inline">
<input type="checkbox" name="radius" onclick="isRadius(this)" value="1"> Radius Plan <input type="checkbox" name="radius" onclick="isRadius(this)" value="1"> Radius Plan
</label> </label>
</div> </div>
<p class="help-block col-md-4">{Lang::T('Cannot be change after saved')}</p>
</div> </div>
{/if} {/if}
<div class="form-group"> <div class="form-group">
@ -164,26 +165,27 @@
</div> </div>
</div> </div>
</div> </div>
{if $_c['radius_enable']}
{literal} {literal}
<script> <script>
function isRadius(cek) { function isRadius(cek) {
if (cek.checked) { if (cek.checked) {
$("#routerChoose").addClass('hidden'); $("#routerChoose").addClass('hidden');
document.getElementById("routers").required = false; document.getElementById("routers").required = false;
document.getElementById("Limited").disabled = true; document.getElementById("Limited").disabled = true;
document.getElementById("Unlimited").checked = true; document.getElementById("Unlimited").checked = true;
document.getElementById("Limited").checked = false; document.getElementById("Limited").checked = false;
$('#Type').hide(); $('#Type').hide();
$('#TimeLimit').hide(); $('#TimeLimit').hide();
$('#DataLimit').hide(); $('#DataLimit').hide();
} else { } else {
document.getElementById("Limited").disabled = false; document.getElementById("Limited").disabled = false;
document.getElementById("routers").required = true; document.getElementById("routers").required = true;
$("#routerChoose").removeClass('hidden'); $("#routerChoose").removeClass('hidden');
} }
} }
</script> </script>
{/literal} {/literal}
{/if}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -39,8 +39,9 @@
<div class="col-md-10"> <div class="col-md-10">
<input type="radio" id="Unlimited" name="typebp" value="Unlimited" <input type="radio" id="Unlimited" name="typebp" value="Unlimited"
{if $d['typebp'] eq 'Unlimited'} checked {/if}> {$_L['Unlimited']} {if $d['typebp'] eq 'Unlimited'} checked {/if}> {$_L['Unlimited']}
<input type="radio" id="Limited" {if $_c['radius_enable'] and $d['is_radius']}disabled{/if} name="typebp" value="Limited" <input type="radio" id="Limited" {if $_c['radius_enable'] and $d['is_radius']}disabled{/if}
{if $d['typebp'] eq 'Limited'} checked {/if}> {$_L['Limited']} name="typebp" value="Limited" {if $d['typebp'] eq 'Limited'} checked {/if}>
{$_L['Limited']}
</div> </div>
</div> </div>
<div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {/if} id="Type"> <div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {/if} id="Type">
@ -176,19 +177,21 @@
</div> </div>
</div> </div>
{literal} {if $_c['radius_enable']}
<script> {literal}
function isRadius(cek) { <script>
if (cek.checked) { function isRadius(cek) {
$("#routerChoose").addClass('hidden'); if (cek.checked) {
document.getElementById("routers").required = false; $("#routerChoose").addClass('hidden');
document.getElementById("Limited").disabled = true; document.getElementById("routers").required = false;
} else { document.getElementById("Limited").disabled = true;
document.getElementById("Limited").disabled = false; } else {
document.getElementById("routers").required = true; document.getElementById("Limited").disabled = false;
$("#routerChoose").removeClass('hidden'); document.getElementById("routers").required = true;
$("#routerChoose").removeClass('hidden');
}
} }
} </script>
</script> {/literal}
{/literal} {/if}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -1,100 +1,139 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-12"> <div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30"> <div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{$_L['Add_Plan']}</div> <div class="panel-heading">{$_L['Add_Plan']}</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/pppoe-add-post" > <form class="form-horizontal" method="post" role="form" action="{$_url}services/pppoe-add-post">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label> <label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10"> <div class="col-md-10">
<label class="radio-inline warning"> <label class="radio-inline warning">
<input type="radio" checked name="enabled" value="1"> Enable <input type="radio" checked name="enabled" value="1"> Enable
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="enabled" value="0"> Disable <input type="radio" name="enabled" value="0"> Disable
</label> </label>
</div> </div>
</div>
{if $_c['radius_enable']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
<div class="col-md-6">
<label class="radio-inline">
<input type="checkbox" name="radius" onclick="isRadius(this)" value="1"> Radius Plan
</label>
</div> </div>
<div class="form-group"> <p class="help-block col-md-4">{Lang::T('Cannot be change after saved')}</p>
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> </div>
<div class="col-md-6"> {/if}
<input type="text" class="form-control" id="name_plan" maxlength="40" name="name_plan"> <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
</div> <div class="col-md-6">
<div class="form-group"> <input type="text" class="form-control" id="name_plan" maxlength="40" name="name_plan">
<label class="col-md-2 control-label"><a href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label> </div>
<div class="col-md-6"> </div>
<select id="id_bw" name="id_bw" class="form-control select2"> <div class="form-group">
<option value="">{$_L['Select_BW']}...</option> <label class="col-md-2 control-label"><a
{foreach $d as $ds} href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label>
<option value="{$ds['id']}">{$ds['name_bw']}</option> <div class="col-md-6">
{/foreach} <select id="id_bw" name="id_bw" class="form-control select2">
</select> <option value="">{$_L['Select_BW']}...</option>
</div> {foreach $d as $ds}
</div> <option value="{$ds['id']}">{$ds['name_bw']}</option>
<div class="form-group"> {/foreach}
<label class="col-md-2 control-label">{$_L['Plan_Price']}</label> </select>
<div class="col-md-6"> </div>
<div class="input-group"> </div>
<span class="input-group-addon">{$_c['currency_code']}</span> <div class="form-group">
<input type="number" class="form-control" name="price" required> <label class="col-md-2 control-label">{$_L['Plan_Price']}</label>
</div> <div class="col-md-6">
</div> <div class="input-group">
</div> <span class="input-group-addon">{$_c['currency_code']}</span>
<div class="form-group"> <input type="number" class="form-control" name="price" required>
<label class="col-md-2 control-label">{$_L['Plan_Validity']}</label> </div>
<div class="col-md-4"> </div>
<input type="text" class="form-control" id="validity" name="validity"> </div>
</div> <div class="form-group">
<div class="col-md-2"> <label class="col-md-2 control-label">{$_L['Plan_Validity']}</label>
<select class="form-control" id="validity_unit" name="validity_unit"> <div class="col-md-4">
<option value="Mins">{$_L['Mins']}</option> <input type="text" class="form-control" id="validity" name="validity">
<option value="Hrs">{$_L['Hrs']}</option> </div>
<option value="Days">{$_L['Days']}</option> <div class="col-md-2">
<option value="Months">{$_L['Months']}</option> <select class="form-control" id="validity_unit" name="validity_unit">
</select> <option value="Mins">{$_L['Mins']}</option>
</div> <option value="Hrs">{$_L['Hrs']}</option>
</div> <option value="Days">{$_L['Days']}</option>
<div class="form-group"> <option value="Months">{$_L['Months']}</option>
<label class="col-md-2 control-label"><a href="{$_url}routers/add">{$_L['Router_Name']}</a></label> </select>
<div class="col-md-6"> </div>
<select id="routers" name="routers" required class="form-control select2"> </div>
<option value=''>{$_L['Select_Routers']}</option> <div class="form-group">
{foreach $r as $rs} <label class="col-md-2 control-label"><a
<option value="{$rs['name']}">{$rs['name']}</option> href="{$_url}routers/add">{$_L['Router_Name']}</a></label>
{/foreach} <div class="col-md-6">
</select> <select id="routers" name="routers" required class="form-control select2">
<p class="help-block">{Lang::T('Cannot be change after saved')}</p> <option value=''>{$_L['Select_Routers']}</option>
</div> {foreach $r as $rs}
</div> <option value="{$rs['name']}">{$rs['name']}</option>
<div class="form-group"> {/foreach}
<label class="col-md-2 control-label"><a href="{$_url}pool/add">{$_L['Pool']}</a></label> </select>
<div class="col-md-6"> <p class="help-block">{Lang::T('Cannot be change after saved')}</p>
<select id="pool_name" name="pool_name" required class="form-control select2"> </div>
<option value=''>{$_L['Select_Pool']}</option> </div>
</select> <div class="form-group">
</div> <label class="col-md-2 control-label"><a href="{$_url}pool/add">{$_L['Pool']}</a></label>
</div> <div class="col-md-6">
<div class="form-group"> <select id="pool_name" name="pool_name" required class="form-control select2">
<label class="col-md-2 control-label"><a href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label> <option value=''>{$_L['Select_Pool']}</option>
<div class="col-md-6"> </select>
<select id="pool_expired" name="pool_expired" class="form-control select2"> </div>
<option value=''>{$_L['Select_Pool']}</option> </div>
</select> <div class="form-group">
</div> <label class="col-md-2 control-label"><a
</div> href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label>
<div class="form-group"> <div class="col-md-6">
<div class="col-md-offset-2 col-md-10"> <select id="pool_expired" name="pool_expired" class="form-control select2">
<button class="btn btn-primary waves-effect waves-light" type="submit">{$_L['Save']}</button> <option value=''>{$_L['Select_Pool']}</option>
Or <a href="{$_url}services/pppoe">{$_L['Cancel']}</a> </select>
</div> </div>
</div> </div>
</form> <div class="form-group">
</div> <div class="col-md-offset-2 col-md-10">
</div> <button class="btn btn-primary waves-effect waves-light"
</div> type="submit">{$_L['Save']}</button>
</div> Or <a href="{$_url}services/pppoe">{$_L['Cancel']}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{if $_c['radius_enable']}
{literal}
<script>
function isRadius(cek) {
if (cek.checked) {
document.getElementById("routers").required = false;
document.getElementById("routers").disabled = true;
document.getElementById("pool_expired").disabled = true;
$.ajax({
url: "index.php?_route=autoload/pool",
data: "routers=radius",
cache: false,
success: function(msg) {
$("#pool_name").html(msg);
}
});
} else {
document.getElementById("routers").required = true;
document.getElementById("routers").disabled = false;
document.getElementById("pool_expired").disabled = false;
}
}
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -1,100 +1,131 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-12"> <div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30"> <div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{$_L['Edit_Plan']}</div> <div class="panel-heading">{$_L['Edit_Plan']}</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-pppoe-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-pppoe-post">
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label> <label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10"> <div class="col-md-10">
<label class="radio-inline warning"> <label class="radio-inline warning">
<input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable <input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0"> Disable <input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0">
</label> Disable
</div> </label>
</div>
</div>
{if $_c['radius_enable'] and $d['is_radius']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
<div class="col-md-10">
<label class="label label-primary">RADIUS</label>
</div> </div>
<div class="form-group"> </div>
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> {/if}
<div class="col-md-6"> <div class="form-group">
<input type="text" class="form-control" id="name_plan" maxlength="40" name="name_plan" value="{$d['name_plan']}"> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
</div> <div class="col-md-6">
</div> <input type="text" class="form-control" id="name_plan" maxlength="40" name="name_plan"
<div class="form-group"> value="{$d['name_plan']}">
<label class="col-md-2 control-label"><a href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label> </div>
<div class="col-md-6"> </div>
<select id="id_bw" name="id_bw" class="form-control select2"> <div class="form-group">
{foreach $b as $bs} <label class="col-md-2 control-label"><a
<option value="{$bs['id']}" {if $d['id_bw'] eq $bs['id']} selected {/if}>{$bs['name_bw']}</option> href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label>
{/foreach} <div class="col-md-6">
</select> <select id="id_bw" name="id_bw" class="form-control select2">
</div> {foreach $b as $bs}
</div> <option value="{$bs['id']}" {if $d['id_bw'] eq $bs['id']} selected {/if}>
<div class="form-group"> {$bs['name_bw']}</option>
<label class="col-md-2 control-label">{$_L['Plan_Price']}</label> {/foreach}
<div class="col-md-6"> </select>
<div class="input-group"> </div>
<span class="input-group-addon">{$_c['currency_code']}</span> </div>
<input type="number" class="form-control" name="price" required value="{$d['price']}"> <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Plan_Price']}</label>
</div> <div class="col-md-6">
</div> <div class="input-group">
<div class="form-group"> <span class="input-group-addon">{$_c['currency_code']}</span>
<label class="col-md-2 control-label">{$_L['Plan_Validity']}</label> <input type="number" class="form-control" name="price" required value="{$d['price']}">
<div class="col-md-4"> </div>
<input type="text" class="form-control" id="validity" name="validity" value="{$d['validity']}"> </div>
</div> </div>
<div class="col-md-2"> <div class="form-group">
<select class="form-control" id="validity_unit" name="validity_unit"> <label class="col-md-2 control-label">{$_L['Plan_Validity']}</label>
<option value="Mins" {if $d['validity_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}</option> <div class="col-md-4">
<option value="Hrs" {if $d['validity_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}</option> <input type="text" class="form-control" id="validity" name="validity"
<option value="Days" {if $d['validity_unit'] eq 'Days'} selected {/if}>{$_L['Days']}</option> value="{$d['validity']}">
<option value="Months" {if $d['validity_unit'] eq 'Months'} selected {/if}>{$_L['Months']}</option> </div>
</select> <div class="col-md-2">
</div> <select class="form-control" id="validity_unit" name="validity_unit">
</div> <option value="Mins" {if $d['validity_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}
<div class="form-group"> </option>
<label class="col-md-2 control-label"><a href="{$_url}pool/add">{$_L['Pool']}</a></label> <option value="Hrs" {if $d['validity_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}
<div class="col-md-6"> </option>
<select id="pool_name" name="pool_name" required class="form-control select2"> <option value="Days" {if $d['validity_unit'] eq 'Days'} selected {/if}>{$_L['Days']}
{foreach $p as $ps} </option>
<option value="{$ps['pool_name']}" {if $d['pool'] eq $ps['pool_name']} selected {/if}>{$ps['pool_name']}</option> <option value="Months" {if $d['validity_unit'] eq 'Months'} selected {/if}>
{/foreach} {$_L['Months']}</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label"><a href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label> <label class="col-md-2 control-label"><a href="{$_url}pool/add">{$_L['Pool']}</a></label>
<div class="col-md-6"> <div class="col-md-6">
<select id="pool_expired" name="pool_expired" class="form-control select2"> <select id="pool_name" name="pool_name" required class="form-control select2">
<option value=''>{$_L['Select_Pool']}</option> {foreach $p as $ps}
{foreach $p as $ps} <option value="{$ps['pool_name']}" {if $d['pool'] eq $ps['pool_name']} selected {/if}>
<option value="{$ps['pool_name']}" {if $d['pool_expired'] eq $ps['pool_name']} selected {/if}>{$ps['pool_name']}</option> {$ps['pool_name']}</option>
{/foreach} {/foreach}
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Router_Name']}</label> <label class="col-md-2 control-label"><a
<div class="col-md-6"> href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label>
<input type="text" class="form-control" id="routers" name="routers" value="{$d['routers']}" readonly> <div class="col-md-6">
</div> <select id="pool_expired" name="pool_expired" class="form-control select2">
</div> <option value=''>{$_L['Select_Pool']}</option>
{foreach $p as $ps}
<option value="{$ps['pool_name']}" {if $d['pool_expired'] eq $ps['pool_name']} selected
{/if}>{$ps['pool_name']}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{$_L['Router_Name']}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="routers" name="routers" value="{$d['routers']}"
readonly>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-offset-2 col-lg-10"> <div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success waves-effect waves-light" type="submit">{$_L['Save']}</button> <button class="btn btn-success waves-effect waves-light"
Or <a href="{$_url}services/pppoe">{$_L['Cancel']}</a> type="submit">{$_L['Save']}</button>
</div> Or <a href="{$_url}services/pppoe">{$_L['Cancel']}</a>
</div> </div>
</form> </div>
</div> </form>
</div> </div>
</div> </div>
</div> </div>
</div>
{if $_c['radius_enable'] and $d['is_radius']}
{literal}
<script>
document.getElementById("routers").required = false;
document.getElementById("routers").disabled = true;
document.getElementById("pool_expired").disabled = true;
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View File

@ -54,7 +54,14 @@
<td>{$ds['validity']} {$ds['validity_unit']}</td> <td>{$ds['validity']} {$ds['validity_unit']}</td>
<td>{$ds['pool']}</td> <td>{$ds['pool']}</td>
<td>{$ds['pool_expired']}</td> <td>{$ds['pool_expired']}</td>
<td>{$ds['routers']}</td> <td>
{if $ds['is_radius']}
<span class="label label-primary">RADIUS</span>
{else}
{if $ds['routers']!=''}
<a href="{$_url}routers/edit/0&name={$ds['routers']}">{$ds['routers']}</a>
{/if}
{/if}</td>
<td> <td>
<a href="{$_url}services/pppoe-edit/{$ds['id']}" <a href="{$_url}services/pppoe-edit/{$ds['id']}"
class="btn btn-info btn-xs">{$_L['Edit']}</a> class="btn btn-info btn-xs">{$_L['Edit']}</a>