User can deactivate package

This commit is contained in:
Ibnu Maksum 2023-09-21 14:12:49 +07:00
parent caad968655
commit 4df15819dd
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
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';

View File

@ -70,9 +70,8 @@
<tr>
<td class="small text-success text-uppercase text-normal">{$_L['Password']}</td>
<td class="small mb15"><input type="password" value="{$_user['password']}"
style="width:100%; border: 0px;"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
onclick="this.select()"></td>
style="width:100%; border: 0px;" onmouseleave="this.type = 'password'"
onmouseenter="this.type = 'text'" onclick="this.select()"></td>
</tr>
{if $_c['enable_balance'] == 'yes'}
<tr>
@ -89,41 +88,56 @@
</td>
</tr>
{/if}
<tr>
<td class="small text-primary text-uppercase text-normal">{$_L['Plan_Name']}</td>
<td class="small mb15">{$_bill['namebp']}</td>
</tr>
<tr>
<td class="small text-info text-uppercase text-normal">{$_L['Created_On']}</td>
<td class="small mb15">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])}
{/if}&nbsp;</td>
</tr>
<tr>
<td class="small text-danger text-uppercase text-normal">{$_L['Expires_On']}</td>
<td class="small mb15">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}&nbsp;
</td>
</tr>
{if $nux_ip}
{if $_bill}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current IP')}</td>
<td class="small mb15">{$nux_ip}</td>
<td class="small text-primary text-uppercase text-normal">{strtoupper(Lang::T('Location'))}</td>
<td class="small mb15">{$_bill['routers']}</td>
</tr>
{/if}
{if $nux_mac}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current MAC')}</td>
<td class="small mb15">{$nux_mac}</td>
</tr>
{/if}
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Login Status')}</td>
<td class="small mb15" id="login_status">
Loading....
<td class="small text-primary text-uppercase text-normal">{$_L['Plan_Name']}</td>
<td class="small mb15">
{$_bill['namebp']}
{if $_bill['status'] == 'on'}
<a class="label label-danger pull-right" href="{$_url}home&deactivate=1"
onclick="return confirm('{Lang::T('Deactivate')}?')">{Lang::T('Deactivate')}</a>
{else}
<a class="label label-warning pull-right" href="{$_url}order/package"
>{Lang::T('expired')}</a>
{/if}
</td>
</tr>
<tr>
<td class="small text-info text-uppercase text-normal">{$_L['Created_On']}</td>
<td class="small mb15">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])}
{/if}&nbsp;</td>
</tr>
<tr>
<td class="small text-danger text-uppercase text-normal">{$_L['Expires_On']}</td>
<td class="small mb15">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}&nbsp;
</td>
</tr>
{if $nux_ip}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current IP')}</td>
<td class="small mb15">{$nux_ip}</td>
</tr>
{/if}
{if $nux_mac}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current MAC')}</td>
<td class="small mb15">{$nux_mac}</td>
</tr>
{/if}
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Login Status')}</td>
<td class="small mb15" id="login_status">
Loading....
</td>
</tr>
{/if}
{/if}
</table>
{if $_c['disable_voucher'] == 'yes'}