forked from kevinowino869/mitrobill
Merge branch 'Development' into feature/radius
This commit is contained in:
@ -75,6 +75,8 @@ switch ($action) {
|
||||
$b->expiration = date('Y-m-d');
|
||||
$b->time = date('H:i:s');
|
||||
$b->save();
|
||||
_log('Admin ' . $admin['username'] . ' Deactivate '.$b['namebp'].' for '.$b['username'], 'User', $b['customer_id']);
|
||||
Message::sendTelegram('Admin ' . $admin['username'] . ' Deactivate '.$b['namebp'].' for u'.$b['username']);
|
||||
r2(U . 'customers/view/' . $id_customer, 's', 'Success deactivate customer to Mikrotik');
|
||||
}
|
||||
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
|
||||
|
@ -50,7 +50,7 @@ if (empty($c_all)) {
|
||||
$ui->assign('c_all', $c_all);
|
||||
|
||||
//user expire
|
||||
$expire = ORM::for_table('tbl_user_recharges')->where('expiration', $mdate)->order_by_desc('id')->find_many();
|
||||
$expire = ORM::for_table('tbl_user_recharges')->whereLte('expiration', $mdate)->order_by_desc('id')->limit(30)->find_many();
|
||||
$ui->assign('expire', $expire);
|
||||
|
||||
//activity log
|
||||
|
@ -90,6 +90,41 @@ if (_post('send') == 'balance') {
|
||||
$bill = User::_billing();
|
||||
$ui->assign('_bill', $bill);
|
||||
|
||||
if(isset($_GET['recharge']) && $_GET['recharge'] == 1){
|
||||
$router = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one();
|
||||
if ($config['enable_balance'] == 'yes') {
|
||||
$plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
|
||||
if($user['balance']>$plan['price']){
|
||||
r2(U . "order/pay/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
|
||||
}else{
|
||||
r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
|
||||
}
|
||||
}else{
|
||||
r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
|
||||
}
|
||||
}else if(isset($_GET['deactivate']) && $_GET['deactivate'] == 1){
|
||||
if ($bill) {
|
||||
$mikrotik = Mikrotik::info($bill['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
if ($bill['type'] == 'Hotspot') {
|
||||
Mikrotik::removeHotspotUser($client, $bill['username']);
|
||||
Mikrotik::removeHotspotActiveUser($client, $bill['username']);
|
||||
} else if ($bill['type'] == 'PPPOE') {
|
||||
Mikrotik::removePpoeUser($client, $bill['username']);
|
||||
Mikrotik::removePpoeActive($client, $bill['username']);
|
||||
}
|
||||
$bill->status = 'off';
|
||||
$bill->expiration = date('Y-m-d');
|
||||
$bill->time = date('H:i:s');
|
||||
$bill->save();
|
||||
_log('User ' . $bill['username'] . ' Deactivate '.$bill['namebp'], 'User', $bill['customer_id']);
|
||||
Message::sendTelegram('User u' . $bill['username'] . ' Deactivate '.$bill['namebp']);
|
||||
r2(U . 'home', 's', 'Success deactivate '.$bill['namebp']);
|
||||
}else{
|
||||
r2(U . 'home', 'e', 'No Active Plan');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
$ui->assign('nux_mac', $_SESSION['nux-mac']);
|
||||
$ui->assign('nux_ip', $_SESSION['nux-ip']);
|
||||
|
@ -35,9 +35,19 @@ switch ($action) {
|
||||
}
|
||||
$ui->assign('_title', 'Order Plan');
|
||||
$ui->assign('_system_menu', 'package');
|
||||
$routers = ORM::for_table('tbl_routers')->find_many();
|
||||
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'PPPOE')->find_many();
|
||||
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Hotspot')->find_many();
|
||||
if(!empty($_SESSION['nux-router'])){
|
||||
$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('type', 'PPPOE')->find_many();
|
||||
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('type', 'Hotspot')->find_many();
|
||||
}else{
|
||||
$routers = ORM::for_table('tbl_routers')->find_many();
|
||||
$plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'PPPOE')->find_many();
|
||||
$plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Hotspot')->find_many();
|
||||
}
|
||||
$plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->find_many();
|
||||
$ui->assign('routers', $routers);
|
||||
$ui->assign('plans_pppoe', $plans_pppoe);
|
||||
|
@ -15,7 +15,14 @@ if(strpos($action,"-post")===false){
|
||||
//echo $path;
|
||||
run_hook('view_edit_pages'); #HOOK
|
||||
if(!file_exists($path)){
|
||||
touch($path);
|
||||
$temp = "pages_template/".str_replace(".","",$action).".html";
|
||||
if(file_exists($temp)){
|
||||
if(!copy($temp, $path)){
|
||||
touch($path);
|
||||
}
|
||||
}else{
|
||||
touch($path);
|
||||
}
|
||||
}
|
||||
if(file_exists($path)){
|
||||
$html = file_get_contents($path);
|
||||
|
@ -258,10 +258,10 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
case 'print-voucher':
|
||||
$from_id = _post('from_id') * 1;
|
||||
$planid = _post('planid') * 1;
|
||||
$pagebreak = _post('pagebreak') * 1;
|
||||
$limit = _post('limit') * 1;
|
||||
$from_id = _post('from_id');
|
||||
$planid = _post('planid');
|
||||
$pagebreak = _post('pagebreak');
|
||||
$limit = _post('limit');
|
||||
|
||||
if ($pagebreak < 1) $pagebreak = 6;
|
||||
|
||||
|
@ -70,7 +70,7 @@ switch ($action) {
|
||||
$username = _post('username');
|
||||
$password = _post('password');
|
||||
$description = _post('description');
|
||||
$enabled = _post('enabled')*1;
|
||||
$enabled = _post('enabled');
|
||||
|
||||
$msg = '';
|
||||
if(Validator::Length($name,30,4) == false){
|
||||
@ -113,7 +113,7 @@ switch ($action) {
|
||||
$username = _post('username');
|
||||
$password = _post('password');
|
||||
$description = _post('description');
|
||||
$enabled = $_POST['enabled']*1;
|
||||
$enabled = $_POST['enabled'];
|
||||
$msg = '';
|
||||
if(Validator::Length($name,30,4) == false){
|
||||
$msg .= 'Name should be between 5 to 30 characters'. '<br>';
|
||||
|
Reference in New Issue
Block a user