User can deactivate package

This commit is contained in:
Ibnu Maksum
2023-09-21 14:12:49 +07:00
parent caad968655
commit 4df15819dd
4 changed files with 73 additions and 33 deletions

View File

@ -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');

View File

@ -90,6 +90,29 @@ if (_post('send') == 'balance') {
$bill = User::_billing();
$ui->assign('_bill', $bill);
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']);

View File

@ -402,3 +402,4 @@ $_L['Activate'] = 'Activate';
$_L['Deactivate'] = 'Deactivate';
$_L['Sync'] = 'Sync';
$_L['Failed_to_create_PaymeTrust_transaction'] = 'Failed to create PaymeTrust transaction.';
$_L['Location'] = 'Location';