From 4df15819dd5ffa3fbfe44a809504cea1beb9208b Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Thu, 21 Sep 2023 14:12:49 +0700 Subject: [PATCH] User can deactivate package --- system/controllers/customers.php | 2 + system/controllers/home.php | 23 +++++++++ system/lan/english/common.lan.php | 1 + ui/ui/user-dashboard.tpl | 80 ++++++++++++++++++------------- 4 files changed, 73 insertions(+), 33 deletions(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index d454a3d7..b992b74e 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -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'); diff --git a/system/controllers/home.php b/system/controllers/home.php index c2eef6ce..bd1f3a77 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -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']); diff --git a/system/lan/english/common.lan.php b/system/lan/english/common.lan.php index 1c92e64a..64c5509c 100644 --- a/system/lan/english/common.lan.php +++ b/system/lan/english/common.lan.php @@ -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'; diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index c6a0e8db..5445f35b 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -70,9 +70,8 @@ {$_L['Password']} + style="width:100%; border: 0px;" onmouseleave="this.type = 'password'" + onmouseenter="this.type = 'text'" onclick="this.select()"> {if $_c['enable_balance'] == 'yes'} @@ -89,41 +88,56 @@ {/if} - - {$_L['Plan_Name']} - {$_bill['namebp']} - - - {$_L['Created_On']} - - {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])} - {/if}  - - - {$_L['Expires_On']} - - {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  - - - {if $nux_ip} + {if $_bill} - {Lang::T('Current IP')} - {$nux_ip} + {strtoupper(Lang::T('Location'))} + {$_bill['routers']} - {/if} - {if $nux_mac} - {Lang::T('Current MAC')} - {$nux_mac} - - {/if} - {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'} - - {Lang::T('Login Status')} - - Loading.... + {$_L['Plan_Name']} + + {$_bill['namebp']} + {if $_bill['status'] == 'on'} + {Lang::T('Deactivate')} + {else} + {Lang::T('expired')} + {/if} + + {$_L['Created_On']} + + {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])} + {/if}  + + + {$_L['Expires_On']} + + {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  + + + {if $nux_ip} + + {Lang::T('Current IP')} + {$nux_ip} + + {/if} + {if $nux_mac} + + {Lang::T('Current MAC')} + {$nux_mac} + + {/if} + {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'} + + {Lang::T('Login Status')} + + Loading.... + + + {/if} {/if} {if $_c['disable_voucher'] == 'yes'}