forked from kevinowino869/mitrobill
allow extend expired for postpaid customer
This commit is contained in:
@ -60,23 +60,6 @@ switch ($action) {
|
||||
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
|
||||
}
|
||||
r2(U . 'plan/list', 's', $log);
|
||||
case 'list':
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/plan.js"></script>');
|
||||
$ui->assign('_title', Lang::T('Customer'));
|
||||
$search = _post('search');
|
||||
if ($search != '') {
|
||||
$query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query, ['search' => $search]);
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query);
|
||||
}
|
||||
run_hook('view_list_billing'); #HOOK
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('search', $search);
|
||||
$ui->display('plan.tpl');
|
||||
break;
|
||||
|
||||
case 'recharge':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
@ -756,6 +739,60 @@ switch ($action) {
|
||||
r2(U . 'plan/refill', 'e', "All field is required");
|
||||
}
|
||||
break;
|
||||
case 'extend':
|
||||
$id = $routes[2];
|
||||
$days = $routes[3];
|
||||
$stoken = $_GET['stoken'];
|
||||
if(App::getTokenValue($stoken)){
|
||||
r2(U . 'plan', 's', "Extend already done");
|
||||
}
|
||||
$tur = ORM::for_table('tbl_user_recharges')->find_one($id);
|
||||
$status = $tur['status'];
|
||||
if(strtotime($tur['expiration'].' '.$tur['time']) > time()){
|
||||
// not expired
|
||||
$expiration = date('Y-m-d', strtotime($tur['expiration']." +$days day"));
|
||||
}else{
|
||||
//expired
|
||||
$expiration = date('Y-m-d', strtotime(" +$days day"));
|
||||
}
|
||||
$tur->expiration = $expiration;
|
||||
$tur->status = "on";
|
||||
$tur->save();
|
||||
App::setToken($stoken, $id);
|
||||
if($status=='off'){
|
||||
if ($tur['routers'] != 'radius') {
|
||||
$mikrotik = Mikrotik::info($tur['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$router = $tur['routers'];
|
||||
}
|
||||
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
||||
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
||||
if ($tur['routers'] == 'radius') {
|
||||
Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']);
|
||||
} else {
|
||||
if ($tur['type'] == 'Hotspot') {
|
||||
Mikrotik::addHotspotUser($client, $p, $c);
|
||||
} else if ($tur['type'] == 'PPPOE') {
|
||||
Mikrotik::addPpoeUser($client, $p, $c);
|
||||
}
|
||||
}
|
||||
}
|
||||
r2(U . 'plan', 's', "Extend until $expiration");
|
||||
break;
|
||||
default:
|
||||
$ui->display('a404.tpl');
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/plan.js"></script>');
|
||||
$ui->assign('_title', Lang::T('Customer'));
|
||||
$search = _post('search');
|
||||
if ($search != '') {
|
||||
$query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query, ['search' => $search]);
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query);
|
||||
}
|
||||
run_hook('view_list_billing'); #HOOK
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('search', $search);
|
||||
$ui->display('plan.tpl');
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user