recharge customer from profile
This commit is contained in:
parent
aab2282e78
commit
95a8eaeadb
@ -45,8 +45,40 @@ switch ($action) {
|
|||||||
run_hook('view_add_customer'); #HOOK
|
run_hook('view_add_customer'); #HOOK
|
||||||
$ui->display('customers-add.tpl');
|
$ui->display('customers-add.tpl');
|
||||||
break;
|
break;
|
||||||
case 'sync':
|
case 'recharge':
|
||||||
|
$id_customer = $routes['2'];
|
||||||
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
||||||
|
if ($b) {
|
||||||
|
$mikrotik = Mikrotik::info($b['routers']);
|
||||||
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
if (Package::rechargeUser($id_customer, $b['routers'], $b['plan_id'], "Recharge", $admin['fullname'])) {
|
||||||
|
r2(U . 'customers/view/' . $id_customer, 's', 'Success Recharge Customer');
|
||||||
|
} else {
|
||||||
|
r2(U . 'customers/view/' . $id_customer, 'e', 'Customer plan is inactive');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
|
||||||
|
case 'deactivate':
|
||||||
|
$id_customer = $routes['2'];
|
||||||
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
||||||
|
if ($b) {
|
||||||
|
$mikrotik = Mikrotik::info($b['routers']);
|
||||||
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
if ($b['type'] == 'Hotspot') {
|
||||||
|
Mikrotik::removeHotspotUser($client, $b['username']);
|
||||||
|
Mikrotik::removeHotspotActiveUser($client, $b['username']);
|
||||||
|
} else if ($b['type'] == 'PPPOE') {
|
||||||
|
Mikrotik::removePpoeUser($client, $b['username']);
|
||||||
|
Mikrotik::removePpoeActive($client, $b['username']);
|
||||||
|
}
|
||||||
|
$b->status = 'off';
|
||||||
|
$b->expiration = date('Y-m-d');
|
||||||
|
$b->time = date('H:i:s');
|
||||||
|
$b->save();
|
||||||
|
r2(U . 'customers/view/' . $id_customer, 's', 'Success deactivate customer to Mikrotik');
|
||||||
|
}
|
||||||
|
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
|
||||||
|
break;
|
||||||
case 'sync':
|
case 'sync':
|
||||||
$id_customer = $routes['2'];
|
$id_customer = $routes['2'];
|
||||||
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->find_one();
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->find_one();
|
||||||
@ -61,7 +93,7 @@ switch ($action) {
|
|||||||
} else if ($b['type'] == 'PPPOE') {
|
} else if ($b['type'] == 'PPPOE') {
|
||||||
Mikrotik::addPpoeUser($client, $p, $c);
|
Mikrotik::addPpoeUser($client, $p, $c);
|
||||||
}
|
}
|
||||||
r2(U . 'customers/view/'.$id_customer , 's', 'success sync customer to Mikrotik');
|
r2(U . 'customers/view/' . $id_customer, 's', 'Success sync customer to Mikrotik');
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'customers/view/' . $id_customer, 'e', 'Customer plan is inactive');
|
r2(U . 'customers/view/' . $id_customer, 'e', 'Customer plan is inactive');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user