pppoe ip and username

This commit is contained in:
Ibnu Maksum 2024-08-05 10:50:37 +07:00
parent be507a013a
commit 9f96da34b5
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
10 changed files with 134 additions and 65 deletions

View file

@ -27,7 +27,9 @@ CREATE TABLE `tbl_customers` (
`id` int NOT NULL, `id` int NOT NULL,
`username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`pppoe_username` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login',
`pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login', `pppoe_password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login',
`pppoe_ip` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login',
`fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `fullname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`address` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, `address` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,

View file

@ -363,7 +363,9 @@ switch ($action) {
$username = alphanumeric(_post('username'), ":+_.@-"); $username = alphanumeric(_post('username'), ":+_.@-");
$fullname = _post('fullname'); $fullname = _post('fullname');
$password = trim(_post('password')); $password = trim(_post('password'));
$pppoe_username = trim(_post('pppoe_username'));
$pppoe_password = trim(_post('pppoe_password')); $pppoe_password = trim(_post('pppoe_password'));
$pppoe_ip = trim(_post('pppoe_ip'));
$email = _post('email'); $email = _post('email');
$address = _post('address'); $address = _post('address');
$phonenumber = _post('phonenumber'); $phonenumber = _post('phonenumber');
@ -399,7 +401,9 @@ switch ($action) {
$d = ORM::for_table('tbl_customers')->create(); $d = ORM::for_table('tbl_customers')->create();
$d->username = $username; $d->username = $username;
$d->password = $password; $d->password = $password;
$d->pppoe_username = $pppoe_username;
$d->pppoe_password = $pppoe_password; $d->pppoe_password = $pppoe_password;
$d->pppoe_ip = $pppoe_ip;
$d->email = $email; $d->email = $email;
$d->account_type = $account_type; $d->account_type = $account_type;
$d->fullname = $fullname; $d->fullname = $fullname;
@ -484,7 +488,9 @@ switch ($action) {
$fullname = _post('fullname'); $fullname = _post('fullname');
$account_type = _post('account_type'); $account_type = _post('account_type');
$password = trim(_post('password')); $password = trim(_post('password'));
$pppoe_username = trim(_post('pppoe_username'));
$pppoe_password = trim(_post('pppoe_password')); $pppoe_password = trim(_post('pppoe_password'));
$pppoe_ip = trim(_post('pppoe_ip'));
$email = _post('email'); $email = _post('email');
$address = _post('address'); $address = _post('address');
$phonenumber = Lang::phoneFormat(_post('phonenumber')); $phonenumber = Lang::phoneFormat(_post('phonenumber'));
@ -544,7 +550,9 @@ switch ($action) {
if ($password != '') { if ($password != '') {
$c->password = $password; $c->password = $password;
} }
$c->pppoe_username = $pppoe_username;
$c->pppoe_password = $pppoe_password; $c->pppoe_password = $pppoe_password;
$c->pppoe_ip = $pppoe_ip;
$c->fullname = $fullname; $c->fullname = $fullname;
$c->email = $email; $c->email = $email;
$c->account_type = $account_type; $c->account_type = $account_type;

View file

@ -40,16 +40,23 @@ class MikrotikPppoe
//customer not exists, add it //customer not exists, add it
$this->addPpoeUser($client, $plan, $customer); $this->addPpoeUser($client, $plan, $customer);
}else{ }else{
if (!empty($customer['pppoe_password'])) {
$pass = $customer['pppoe_password'];
} else {
$pass = $customer['password'];
}
$setRequest = new RouterOS\Request('/ppp/secret/set'); $setRequest = new RouterOS\Request('/ppp/secret/set');
if (!empty($customer['pppoe_password'])) {
$setRequest->setArgument('password', $customer['pppoe_password']);
} else {
$setRequest->setArgument('password', $customer['password']);
}
if (!empty($customer['pppoe_username'])) {
$setRequest->setArgument('name', $customer['pppoe_username']);
} else {
$setRequest->setArgument('name', $customer['username']);
}
if (!empty($customer['pppoe_ip'])) {
$setRequest->setArgument('local-address', $customer['pppoe_ip']);
}
$setRequest->setArgument('numbers', $cid); $setRequest->setArgument('numbers', $cid);
$setRequest->setArgument('profile', $plan['name_plan']); $setRequest->setArgument('profile', $plan['name_plan']);
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id']))); $setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id'])));
$setRequest->setArgument('password', $pass);
$client->sendSync($setRequest); $client->sendSync($setRequest);
//disconnect then //disconnect then
if(isset($isChangePlan) && $isChangePlan){ if(isset($isChangePlan) && $isChangePlan){
@ -285,26 +292,28 @@ class MikrotikPppoe
function addPpoeUser($client, $plan, $customer) function addPpoeUser($client, $plan, $customer)
{ {
global $_app_stage; $setRequest = new RouterOS\Request('/ppp/secret/add');
$addRequest = new RouterOS\Request('/ppp/secret/add'); $setRequest->setArgument('service', 'pppoe');
$setRequest->setArgument('profile', $plan['name_plan']);
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id'])));
if (!empty($customer['pppoe_password'])) { if (!empty($customer['pppoe_password'])) {
$pass = $customer['pppoe_password']; $setRequest->setArgument('password', $customer['pppoe_password']);
} else { } else {
$pass = $customer['password']; $setRequest->setArgument('password', $customer['password']);
} }
$client->sendSync( if (!empty($customer['pppoe_username'])) {
$addRequest $setRequest->setArgument('name', $customer['pppoe_username']);
->setArgument('name', $customer['username']) } else {
->setArgument('service', 'pppoe') $setRequest->setArgument('name', $customer['username']);
->setArgument('profile', $plan['name_plan']) }
->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id']))) if (!empty($customer['pppoe_ip'])) {
->setArgument('password', $pass) $setRequest->setArgument('local-address', $customer['pppoe_ip']);
); }
$client->sendSync($setRequest);
} }
function setPpoeUser($client, $user, $pass) function setPpoeUser($client, $user, $pass)
{ {
global $_app_stage;
$printRequest = new RouterOS\Request('/ppp/secret/print'); $printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id'); $printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $user)); $printRequest->setQuery(RouterOS\Query::where('name', $user));

View file

@ -688,5 +688,7 @@
"Previous": "Previous", "Previous": "Previous",
"Share": "Share", "Share": "Share",
"Mail_Deleted_Successfully": "Mail Deleted Successfully", "Mail_Deleted_Successfully": "Mail Deleted Successfully",
"Message_Not_Found": "Message Not Found" "Message_Not_Found": "Message Not Found",
"Send_Welcome_Message": "Send Welcome Message",
"WA": "WA"
} }

View file

@ -136,5 +136,9 @@
], ],
"2024.8.2" : [ "2024.8.2" : [
"CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;" "CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"
],
"2024.8.5" : [
"ALTER TABLE `tbl_customers` ADD `pppoe_username` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login' AFTER `password`;",
"ALTER TABLE `tbl_customers` ADD `pppoe_ip` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'For PPPOE Login' AFTER `pppoe_password`;"
] ]
} }

View file

@ -57,17 +57,6 @@
onmouseenter="this.type = 'text'"> onmouseenter="this.type = 'text'">
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('PPPOE Password')}</label>
<div class="col-md-9">
<input type="password" class="form-control" id="pppoe_password" name="pppoe_password"
value="{$d['pppoe_password']}" onmouseleave="this.type = 'password'"
onmouseenter="this.type = 'text'">
<span class="help-block">
{Lang::T('User Cannot change this, only admin. if it Empty it will use user password')}
</span>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Address')}</label> <label class="col-md-3 control-label">{Lang::T('Address')}</label>
<div class="col-md-9"> <div class="col-md-9">
@ -103,6 +92,35 @@
<div id="map" style="width: '100%'; height: 200px; min-height: 150px;"></div> <div id="map" style="width: '100%'; height: 200px; min-height: 150px;"></div>
</div> </div>
</div> </div>
</div>
<div class="panel-heading">PPPOE</div>
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
<div class="col-md-9">
<input type="username" class="form-control" id="pppoe_username" name="pppoe_username">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Password')}</label>
<div class="col-md-9">
<input type="password" class="form-control" id="pppoe_password" name="pppoe_password"
onmouseleave="this.type = 'password'"
onmouseenter="this.type = 'text'">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Local IP</label>
<div class="col-md-9">
<input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip">
</div>
</div>
<span class="help-block">
{Lang::T('User Cannot change this, only admin. if it Empty it will use user password')}
</span>
</div>
<div class="panel-heading"></div>
<div class="panel-body">
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Send Welcome Message')}</label> <label class="col-md-3 control-label">{Lang::T('Send Welcome Message')}</label>
<div class="col-md-9"> <div class="col-md-9">

View file

@ -3,7 +3,8 @@
<form class="form-horizontal" method="post" role="form" action="{$_url}customers/edit-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}customers/edit-post">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-{if $d['status']=='Active'}primary{else}danger{/if} panel-hovered panel-stacked mb30"> <div
class="panel panel-{if $d['status']=='Active'}primary{else}danger{/if} panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Edit Contact')}</div> <div class="panel-heading">{Lang::T('Edit Contact')}</div>
<div class="panel-body"> <div class="panel-body">
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
@ -61,17 +62,6 @@
<span class="help-block">{Lang::T('Keep Blank to do not change Password')}</span> <span class="help-block">{Lang::T('Keep Blank to do not change Password')}</span>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('PPPOE Password')}</label>
<div class="col-md-9">
<input type="password" autocomplete="off" class="form-control" id="pppoe_password"
name="pppoe_password" value="{$d['pppoe_password']}"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'">
<span class="help-block">
{Lang::T('User Cannot change this, only admin. if it Empty it will use user password')}
</span>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Address')}</label> <label class="col-md-3 control-label">{Lang::T('Address')}</label>
<div class="col-md-9"> <div class="col-md-9">
@ -113,18 +103,47 @@
<div class="col-md-9"> <div class="col-md-9">
<select class="form-control" id="status" name="status"> <select class="form-control" id="status" name="status">
{foreach $statuses as $status} {foreach $statuses as $status}
<option value="{$status}" {if $d['status'] eq $status }selected{/if}>{Lang::T($status)} <option value="{$status}" {if $d['status'] eq $status }selected{/if}>{Lang::T($status)}
</option> </option>
{/foreach} {/foreach}
</select> </select>
<span class="help-block"> <span class="help-block">
{Lang::T('Banned')}: {Lang::T('Customer cannot login again')}.<br> {Lang::T('Banned')}: {Lang::T('Customer cannot login again')}.<br>
{Lang::T('Disabled')}: {Lang::T('Customer can login but cannot buy internet plan, Admin cannot recharge customer')}.<br> {Lang::T('Disabled')}:
{Lang::T('Customer can login but cannot buy internet plan, Admin cannot recharge customer')}.<br>
{Lang::T('Don\'t forget to deactivate all active plan too')}. {Lang::T('Don\'t forget to deactivate all active plan too')}.
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="panel-heading">PPPOE</div>
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
<div class="col-md-9">
<input type="username" class="form-control" id="pppoe_username" name="pppoe_username"
value="{$d['pppoe_username']}">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Password')}</label>
<div class="col-md-9">
<input type="password" class="form-control" id="pppoe_password" name="pppoe_password"
value="{$d['pppoe_password']}" onmouseleave="this.type = 'password'"
onmouseenter="this.type = 'text'">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Local IP</label>
<div class="col-md-9">
<input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip"
value="{$d['pppoe_ip']}">
</div>
</div>
<span class="help-block">
{Lang::T('User Cannot change this, only admin. if it Empty it will use user password')}
</span>
</div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -173,8 +192,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('City')}</label> <label class="col-md-3 control-label">{Lang::T('City')}</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" id="city" name="city" <input type="text" class="form-control" id="city" name="city" value="{$d['city']}">
value="{$d['city']}">
<small class="form-text text-muted">{Lang::T('City of Resident')}</small> <small class="form-text text-muted">{Lang::T('City of Resident')}</small>
</div> </div>
</div> </div>
@ -189,16 +207,14 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('State')}</label> <label class="col-md-3 control-label">{Lang::T('State')}</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" id="state" name="state" <input type="text" class="form-control" id="state" name="state" value="{$d['state']}">
value="{$d['state']}">
<small class="form-text text-muted">{Lang::T('State of Resident')}</small> <small class="form-text text-muted">{Lang::T('State of Resident')}</small>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Zip')}</label> <label class="col-md-3 control-label">{Lang::T('Zip')}</label>
<div class="col-md-9"> <div class="col-md-9">
<input type="text" class="form-control" id="zip" name="zip" <input type="text" class="form-control" id="zip" name="zip" value="{$d['zip']}">
value="{$d['zip']}">
<small class="form-text text-muted">{Lang::T('Zip Code')}</small> <small class="form-text text-muted">{Lang::T('Zip Code')}</small>
</div> </div>
</div> </div>
@ -280,15 +296,15 @@
}); });
} }
window.onload = function() { window.onload = function() {
{/literal} {/literal}
{if $d['coordinates']} {if $d['coordinates']}
setupMap({$d['coordinates']}); setupMap({$d['coordinates']});
{else} {else}
getLocation(); getLocation();
{/if} {/if}
{literal} {literal}
} }
</script> </script>
{/literal} {/literal}
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}

View file

@ -41,6 +41,11 @@
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'" onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
onclick="this.select()"> onclick="this.select()">
</li> </li>
{if $d['pppoe_username'] != ''}
<li class="list-group-item">
<b>PPPOE {Lang::T('Username')}</b> <span class="pull-right">{$d['pppoe_username']}</span>
</li>
{/if}
{if $d['pppoe_password'] != ''} {if $d['pppoe_password'] != ''}
<li class="list-group-item"> <li class="list-group-item">
<b>PPPOE {Lang::T('Password')}</b> <input type="password" value="{$d['pppoe_password']}" <b>PPPOE {Lang::T('Password')}</b> <input type="password" value="{$d['pppoe_password']}"
@ -49,6 +54,11 @@
onclick="this.select()"> onclick="this.select()">
</li> </li>
{/if} {/if}
{if $d['pppoe_ip'] != ''}
<li class="list-group-item">
<b>PPPOE Local IP</b> <span class="pull-right">{$d['pppoe_ip']}</span>
</li>
{/if}
<!--Customers Attributes view start --> <!--Customers Attributes view start -->
{if $customFields} {if $customFields}
{foreach $customFields as $customField} {foreach $customFields as $customField}

View file

@ -197,7 +197,7 @@
<td class="small text-success text-uppercase text-normal">{Lang::T('Type')}</td> <td class="small text-success text-uppercase text-normal">{Lang::T('Type')}</td>
<td class="small mb15 text-success"> <td class="small mb15 text-success">
<b>{if $_bill['prepaid'] eq yes}Prepaid{else}Postpaid{/if}</b> <b>{if $_bill['prepaid'] eq yes}Prepaid{else}Postpaid{/if}</b>
{Lang::T($_bill['plan_type'])} {$_bill['plan_type']}
</td> </td>
</tr> </tr>
{if $nux_ip neq ''} {if $nux_ip neq ''}

View file

@ -1,3 +1,3 @@
{ {
"version": "2024.8.2" "version": "2024.8.5"
} }