Fix edit customer plan
This commit is contained in:
parent
b9ff4399a4
commit
29ad9dec73
@ -127,11 +127,19 @@ class Lang
|
|||||||
if(time()>strtotime($datetime)){
|
if(time()>strtotime($datetime)){
|
||||||
$when = Lang::T('ago');
|
$when = Lang::T('ago');
|
||||||
}else{
|
}else{
|
||||||
$when = Lang::T('later');
|
$when = '';
|
||||||
}
|
}
|
||||||
if (!$full)
|
if (!$full)
|
||||||
$string = array_slice($string, 0, 1);
|
$string = array_slice($string, 0, 1);
|
||||||
return $string ? implode(', ', $string) .' '. $when : Lang::T('just now');
|
if($string){
|
||||||
|
if(empty($when)){
|
||||||
|
return '<b>'. implode(', ', $string) .'</b>';
|
||||||
|
}else{
|
||||||
|
return implode(', ', $string) .' '. $when;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return Lang::T('just now');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nl2br($text)
|
public static function nl2br($text)
|
||||||
|
@ -37,20 +37,28 @@ switch ($action) {
|
|||||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||||
}
|
}
|
||||||
set_time_limit(-1);
|
set_time_limit(-1);
|
||||||
$plans = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();
|
$turs = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();
|
||||||
$log = '';
|
$log = '';
|
||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($turs as $tur) {
|
||||||
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
|
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
||||||
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
|
if($p){
|
||||||
$dvc = Package::getDevice($plan);
|
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
||||||
if (file_exists($dvc) && $_app_stage != 'demo') {
|
if($c){
|
||||||
require_once $dvc;
|
$dvc = Package::getDevice($p);
|
||||||
(new $p['device'])->add_customer($c, $p);
|
if (file_exists($dvc) && $_app_stage != 'demo') {
|
||||||
} else {
|
require_once $dvc;
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
(new $p['device'])->add_customer($c, $p);
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
|
$log .= "DONE : $tur[username], $ptur[namebp], $tur[type], $tur[routers]<br>";
|
||||||
|
}else{
|
||||||
|
$log .= "Customer NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$log .= "PLAN NOT FOUND : $tur[username], $tur[namebp], $tur[type], $tur[routers]<br>";
|
||||||
}
|
}
|
||||||
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
|
|
||||||
}
|
}
|
||||||
r2(U . 'plan/list', 's', $log);
|
r2(U . 'plan/list', 's', $log);
|
||||||
case 'recharge':
|
case 'recharge':
|
||||||
@ -235,12 +243,13 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('tbl_user_recharges')->find_one($id);
|
$d = ORM::for_table('tbl_user_recharges')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$ui->assign('d', $d);
|
$ui->assign('d', $d);
|
||||||
|
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
|
||||||
if (in_array($admin['user_type'], array('SuperAdmin', 'Admin'))) {
|
if (in_array($admin['user_type'], array('SuperAdmin', 'Admin'))) {
|
||||||
$p = ORM::for_table('tbl_plans')->where_not_equal('type', 'Balance')->find_many();
|
$ps = ORM::for_table('tbl_plans')->where('type', $p['type'])->where('is_radius', $p['is_radius'])->find_many();
|
||||||
} else {
|
} else {
|
||||||
$p = ORM::for_table('tbl_plans')->where('enabled', '1')->where_not_equal('type', 'Balance')->find_many();
|
$ps = ORM::for_table('tbl_plans')->where("enabled", 1)->where('is_radius', $p['is_radius'])->where('type', $p['type'])->find_many();
|
||||||
}
|
}
|
||||||
$ui->assign('p', $p);
|
$ui->assign('p', $ps);
|
||||||
run_hook('view_edit_customer_plan'); #HOOK
|
run_hook('view_edit_customer_plan'); #HOOK
|
||||||
$ui->assign('_title', 'Edit Plan');
|
$ui->assign('_title', 'Edit Plan');
|
||||||
$ui->display('plan-edit.tpl');
|
$ui->display('plan-edit.tpl');
|
||||||
@ -274,7 +283,6 @@ switch ($action) {
|
|||||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||||
}
|
}
|
||||||
$username = _post('username');
|
|
||||||
$id_plan = _post('id_plan');
|
$id_plan = _post('id_plan');
|
||||||
$recharged_on = _post('recharged_on');
|
$recharged_on = _post('recharged_on');
|
||||||
$expiration = _post('expiration');
|
$expiration = _post('expiration');
|
||||||
@ -286,17 +294,14 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$msg .= Lang::T('Data Not Found') . '<br>';
|
$msg .= Lang::T('Data Not Found') . '<br>';
|
||||||
}
|
}
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $id_plan)->where('enabled', '1')->find_one();
|
$oldPlanID = $d['plan_id'];
|
||||||
if ($d) {
|
$newPlan = ORM::for_table('tbl_plans')->where('id', $id_plan)->find_one();
|
||||||
|
if ($newPlan) {
|
||||||
} else {
|
} else {
|
||||||
$msg .= ' Plan Not Found<br>';
|
$msg .= ' Plan Not Found<br>';
|
||||||
}
|
}
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
run_hook('edit_customer_plan'); #HOOK
|
run_hook('edit_customer_plan'); #HOOK
|
||||||
$d->username = $username;
|
|
||||||
$d->plan_id = $id_plan;
|
|
||||||
$d->namebp = $p['name_plan'];
|
|
||||||
//$d->recharged_on = $recharged_on;
|
|
||||||
$d->expiration = $expiration;
|
$d->expiration = $expiration;
|
||||||
$d->time = $time;
|
$d->time = $time;
|
||||||
if ($d['status'] == 'off') {
|
if ($d['status'] == 'off') {
|
||||||
@ -304,15 +309,29 @@ switch ($action) {
|
|||||||
$d->status = 'on';
|
$d->status = 'on';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($p['is_radius']) {
|
if ($d['status'] == 'on' && $oldPlanID != $id_plan) {
|
||||||
$d->routers = 'radius';
|
$d->plan_id = $newPlan['id'];
|
||||||
} else {
|
$d->namebp = $newPlan['name_plan'];
|
||||||
$d->routers = $p['routers'];
|
$customer = User::_info($d['customer_id']);
|
||||||
|
//remove from old plan
|
||||||
|
$p = ORM::for_table('tbl_plans')->find_one($oldPlanID);
|
||||||
|
$dvc = Package::getDevice($p);
|
||||||
|
if (file_exists($dvc) && $_app_stage != 'demo') {
|
||||||
|
require_once $dvc;
|
||||||
|
(new $p['device'])->remove_customer($customer, $p);
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
|
//add new plan
|
||||||
|
$dvc = Package::getDevice($newPlan);
|
||||||
|
if (file_exists($dvc) && $_app_stage != 'demo') {
|
||||||
|
require_once $dvc;
|
||||||
|
(new $newPlan['device'])->add_customer($customer, $newPlan);
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$d->save();
|
$d->save();
|
||||||
if ($d['status'] == 'on') {
|
|
||||||
Package::changeTo($username, $id_plan, $id);
|
|
||||||
}
|
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
|
||||||
r2(U . 'plan/list', 's', Lang::T('Data Updated Successfully'));
|
r2(U . 'plan/list', 's', Lang::T('Data Updated Successfully'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,15 +35,6 @@ class MikrotikHotspot
|
|||||||
$this->removeHotspotActiveUser($client, $customer['username']);
|
$this->removeHotspotActiveUser($client, $customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($customer, $plan)
|
|
||||||
{
|
|
||||||
$mikrotik = $this->info($plan['routers']);
|
|
||||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$this->removeHotspotUser($client, $customer['username']);
|
|
||||||
$this->removeHotspotActiveUser($client, $customer['username']);
|
|
||||||
$this->addHotspotUser($client, $plan, $customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
|
@ -35,16 +35,6 @@ class MikrotikPppoe
|
|||||||
$this->removePpoeActive($client, $customer['username']);
|
$this->removePpoeActive($client, $customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($customer, $plan)
|
|
||||||
{
|
|
||||||
$mikrotik = $this->info($plan['routers']);
|
|
||||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$this->removePpoeUser($client, $customer['username']);
|
|
||||||
$this->removePpoeActive($client, $customer['username']);
|
|
||||||
$this->addPpoeUser($client, $plan, $customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
|
@ -20,19 +20,13 @@ class Radius {
|
|||||||
{
|
{
|
||||||
if (empty($plan['plan_expired'])) {
|
if (empty($plan['plan_expired'])) {
|
||||||
$p = ORM::for_table("tbl_plans")->find_one($plan['plan_expired']);
|
$p = ORM::for_table("tbl_plans")->find_one($plan['plan_expired']);
|
||||||
$this->customerDeactivate($customer['username']);
|
$this->customerAddPlan($customer, $plan);
|
||||||
$this->customerAddPlan($customer, $p);
|
|
||||||
} else {
|
} else {
|
||||||
$this->upsertCustomerAttr($customer['username'], 'Framed-Pool', $plan['pool_expired'], ':=');
|
$this->upsertCustomerAttr($customer['username'], 'Framed-Pool', $plan['pool_expired'], ':=');
|
||||||
$this->disconnectCustomer($customer['username']);
|
$this->disconnectCustomer($customer['username']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($customer, $plan)
|
|
||||||
{
|
|
||||||
$this->customerUpsert($customer, $plan);
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
|
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
|
||||||
@ -92,6 +86,7 @@ class Radius {
|
|||||||
|
|
||||||
function disconnect_customer($customer, $router_name)
|
function disconnect_customer($customer, $router_name)
|
||||||
{
|
{
|
||||||
|
$this->disconnectCustomer($customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTableNas()
|
public function getTableNas()
|
||||||
|
@ -7,38 +7,42 @@ just follow the template
|
|||||||
|
|
||||||
class FileName {
|
class FileName {
|
||||||
|
|
||||||
|
// Add Customer to Mikrotik/Device
|
||||||
function add_customer($customer, $plan)
|
function add_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove Customer to Mikrotik/Device
|
||||||
function remove_customer($customer, $plan)
|
function remove_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($customer, $plan)
|
// Add Plan to Mikrotik/Device
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update Plan to Mikrotik/Device
|
||||||
function update_plan($old_name, $plan)
|
function update_plan($old_name, $plan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove Plan from Mikrotik/Device
|
||||||
function remove_plan($plan)
|
function remove_plan($plan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if customer is online
|
||||||
function online_customer($customer, $router_name)
|
function online_customer($customer, $router_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make customer online
|
||||||
function connect_customer($customer, $ip, $mac_address, $router_name)
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make customer disconnect
|
||||||
function disconnect_customer($customer, $router_name)
|
function disconnect_customer($customer, $router_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,15 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Service Plan')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Service Plan')}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
<select id="id_plan" name="id_plan" class="form-control select2">
|
<select id="id_plan" name="id_plan" class="form-control select2">
|
||||||
{foreach $p as $ps}
|
{foreach $p as $ps}
|
||||||
<option value="{$ps['id']}" {if $d['plan_id'] eq $ps['id']} selected {/if}>
|
<option value="{$ps['id']}" {if $d['plan_id'] eq $ps['id']} selected {/if}>
|
||||||
{if $ps['enabled'] neq 1}DISABLED PLAN • {/if}
|
{if $ps['enabled'] neq 1}DISABLED PLAN • {/if}
|
||||||
{if $ps['is_radius']=='1'}Radius{else}{$ps['routers']}{/if} • {$ps['name_plan']}</option>
|
{$ps['name_plan']} •
|
||||||
|
{Lang::moneyFormat($ps['price'])}
|
||||||
|
{if $ps['prepaid'] neq 'yes'} • POSTPAID {/if}
|
||||||
|
</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -32,7 +36,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Created On')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Created On')}</label>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<input type="date" class="form-control" name="expiration" readonly
|
<input type="date" class="form-control" readonly
|
||||||
value="{$d['recharged_on']}">
|
value="{$d['recharged_on']}">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
@ -54,8 +58,7 @@
|
|||||||
|
|
||||||
<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"
|
<button class="btn btn-success" type="submit">{Lang::T('Edit')}</button>
|
||||||
type="submit">{Lang::T('Edit')}</button>
|
|
||||||
Or <a href="{$_url}plan/list">{Lang::T('Cancel')}</a>
|
Or <a href="{$_url}plan/list">{Lang::T('Cancel')}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{include file="sections/user-header.tpl"}
|
{include file="sections/user-header.tpl"}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-md-6 col-md-offset-3">
|
||||||
<div class="panel panel-info panel-hovered">
|
<div class="panel panel-info panel-hovered">
|
||||||
<div class="panel-heading">{Lang::T('Available Payment Gateway')}</div>
|
<div class="panel-heading">{Lang::T('Available Payment Gateway')}</div>
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<form method="post" action="{$_url}order/buy/{$route2}/{$route3}">
|
<form method="post" action="{$_url}order/buy/{$route2}/{$route3}">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-2 control-label">Payment Gateway</label>
|
<label class="col-md-4 ">Payment Gateway</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<select name="gateway" id="gateway" class="form-control">
|
<select name="gateway" id="gateway" class="form-control">
|
||||||
{foreach $pgs as $pg}
|
{foreach $pgs as $pg}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user