allow extend expired for postpaid customer
This commit is contained in:
parent
854fd54834
commit
8891cd5aaa
@ -80,8 +80,8 @@ if (_post('send') == 'balance') {
|
||||
$actives = ORM::for_table('tbl_user_recharges')
|
||||
->where('username', _post('username'))
|
||||
->find_many();
|
||||
foreach($actives as $active){
|
||||
$router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one();
|
||||
foreach ($actives as $active) {
|
||||
$router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one();
|
||||
if ($router) {
|
||||
r2(U . "order/send/$router[id]/$active[plan_id]&u=" . trim(_post('username')), 's', Lang::T('Review package before recharge'));
|
||||
}
|
||||
@ -92,13 +92,13 @@ if (_post('send') == 'balance') {
|
||||
$ui->assign('_bills', User::_billing());
|
||||
|
||||
if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
|
||||
if(!empty(App::getTokenValue($_GET['stoken']))){
|
||||
if (!empty(App::getTokenValue(_get('stoken')))) {
|
||||
r2(U . "voucher/invoice/");
|
||||
die();
|
||||
}
|
||||
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['recharge'])->where('username', $user['username'])->findOne();
|
||||
if ($bill) {
|
||||
if ($bill['routers'] == 'radius') {
|
||||
if ($bill['routers'] == 'radius') {
|
||||
$router = 'radius';
|
||||
} else {
|
||||
$routers = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one();
|
||||
@ -106,11 +106,11 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
|
||||
}
|
||||
if ($config['enable_balance'] == 'yes') {
|
||||
$plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
|
||||
if(!$plan['enabled']){
|
||||
if (!$plan['enabled']) {
|
||||
r2(U . "home", 'e', 'Plan is not exists');
|
||||
}
|
||||
if ($user['balance'] > $plan['price']) {
|
||||
r2(U . "order/pay/$router/$bill[plan_id]&stoken=".$_GET['stoken'], 'e', 'Order Plan');
|
||||
r2(U . "order/pay/$router/$bill[plan_id]&stoken=" . _get('stoken'), 'e', 'Order Plan');
|
||||
} else {
|
||||
r2(U . "order/buy/$router/$bill[plan_id]", 'e', 'Order Plan');
|
||||
}
|
||||
@ -118,6 +118,61 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
|
||||
r2(U . "order/buy/$router/$bill[plan_id]", 'e', 'Order Plan');
|
||||
}
|
||||
}
|
||||
} else if (!empty(_get('extend'))) {
|
||||
if(!$config['extend_expired']){
|
||||
r2(U . 'home', 'e', "cannot extend");
|
||||
}
|
||||
if (!empty(App::getTokenValue(_get('stoken')))) {
|
||||
r2(U . 'home', 'e', "You already extend");
|
||||
}
|
||||
$id = _get('extend');
|
||||
$tur = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->where('id', $id)->find_one();
|
||||
if ($tur) {
|
||||
$m = date("m");
|
||||
$path = $CACHE_PATH . DIRECTORY_SEPARATOR . "extends" . DIRECTORY_SEPARATOR;
|
||||
if(!file_exists($path)){
|
||||
mkdir($path);
|
||||
}
|
||||
$path .= $user['id'] . ".txt";
|
||||
if (file_exists($path)) {
|
||||
// is already extend
|
||||
$last = file_get_contents($path);
|
||||
if ($last == $m) {
|
||||
r2(U . 'home', 'e', "You already extend for this month");
|
||||
}
|
||||
}
|
||||
if ($tur['status'] != 'on') {
|
||||
$days = $config['extend_days'];
|
||||
$expiration = date('Y-m-d', strtotime(" +$days day"));
|
||||
$tur->expiration = $expiration;
|
||||
$tur->status = "on";
|
||||
$tur->save();
|
||||
App::setToken(_get('stoken'), $id);
|
||||
if ($tur['routers'] != 'radius') {
|
||||
$mikrotik = Mikrotik::info($tur['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$router = $tur['routers'];
|
||||
}
|
||||
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
||||
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
||||
if ($tur['routers'] == 'radius') {
|
||||
Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']);
|
||||
} else {
|
||||
if ($tur['type'] == 'Hotspot') {
|
||||
Mikrotik::addHotspotUser($client, $p, $c);
|
||||
} else if ($tur['type'] == 'PPPOE') {
|
||||
Mikrotik::addPpoeUser($client, $p, $c);
|
||||
}
|
||||
}
|
||||
// make customer cannot extend again
|
||||
file_put_contents($path, $m);
|
||||
r2(U . 'home', 's', "Extend until $expiration");
|
||||
}else{
|
||||
r2(U . 'home', 'e', "Plan is not expired");
|
||||
}
|
||||
} else {
|
||||
r2(U . 'home', 'e', "Plan Not Found or Not Active");
|
||||
}
|
||||
} else if (isset($_GET['deactivate']) && !empty($_GET['deactivate'])) {
|
||||
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne();
|
||||
if ($bill) {
|
||||
|
@ -60,23 +60,6 @@ switch ($action) {
|
||||
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
|
||||
}
|
||||
r2(U . 'plan/list', 's', $log);
|
||||
case 'list':
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/plan.js"></script>');
|
||||
$ui->assign('_title', Lang::T('Customer'));
|
||||
$search = _post('search');
|
||||
if ($search != '') {
|
||||
$query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query, ['search' => $search]);
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query);
|
||||
}
|
||||
run_hook('view_list_billing'); #HOOK
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('search', $search);
|
||||
$ui->display('plan.tpl');
|
||||
break;
|
||||
|
||||
case 'recharge':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
@ -756,6 +739,60 @@ switch ($action) {
|
||||
r2(U . 'plan/refill', 'e', "All field is required");
|
||||
}
|
||||
break;
|
||||
case 'extend':
|
||||
$id = $routes[2];
|
||||
$days = $routes[3];
|
||||
$stoken = $_GET['stoken'];
|
||||
if(App::getTokenValue($stoken)){
|
||||
r2(U . 'plan', 's', "Extend already done");
|
||||
}
|
||||
$tur = ORM::for_table('tbl_user_recharges')->find_one($id);
|
||||
$status = $tur['status'];
|
||||
if(strtotime($tur['expiration'].' '.$tur['time']) > time()){
|
||||
// not expired
|
||||
$expiration = date('Y-m-d', strtotime($tur['expiration']." +$days day"));
|
||||
}else{
|
||||
//expired
|
||||
$expiration = date('Y-m-d', strtotime(" +$days day"));
|
||||
}
|
||||
$tur->expiration = $expiration;
|
||||
$tur->status = "on";
|
||||
$tur->save();
|
||||
App::setToken($stoken, $id);
|
||||
if($status=='off'){
|
||||
if ($tur['routers'] != 'radius') {
|
||||
$mikrotik = Mikrotik::info($tur['routers']);
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$router = $tur['routers'];
|
||||
}
|
||||
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
||||
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
||||
if ($tur['routers'] == 'radius') {
|
||||
Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']);
|
||||
} else {
|
||||
if ($tur['type'] == 'Hotspot') {
|
||||
Mikrotik::addHotspotUser($client, $p, $c);
|
||||
} else if ($tur['type'] == 'PPPOE') {
|
||||
Mikrotik::addPpoeUser($client, $p, $c);
|
||||
}
|
||||
}
|
||||
}
|
||||
r2(U . 'plan', 's', "Extend until $expiration");
|
||||
break;
|
||||
default:
|
||||
$ui->display('a404.tpl');
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/plan.js"></script>');
|
||||
$ui->assign('_title', Lang::T('Customer'));
|
||||
$search = _post('search');
|
||||
if ($search != '') {
|
||||
$query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query, ['search' => $search]);
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
||||
$d = Paginator::findMany($query);
|
||||
}
|
||||
run_hook('view_list_billing'); #HOOK
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('search', $search);
|
||||
$ui->display('plan.tpl');
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"Customer": "Pelanggan",
|
||||
"Lists": "Daftar",
|
||||
"Location": "Lokasi",
|
||||
"Services": "Jasa",
|
||||
"Services": "Layanan",
|
||||
"Active_Users": "Pengguna Aktif",
|
||||
"Vouchers": "Vouchers",
|
||||
"Refill_Customer": "Isi Ulang Pelanggan",
|
||||
@ -47,7 +47,7 @@
|
||||
"Payment_Gateway": "Gerbang pembayaran",
|
||||
"Plugin_Manager": "Manajer Plugin",
|
||||
"Logs": "Log",
|
||||
"Community": "Masyarakat",
|
||||
"Community": "Komunitas",
|
||||
"Income_Today": "Pendapatan Hari Ini",
|
||||
"View_Reports": "Lihat Laporan",
|
||||
"Income_This_Month": "Penghasilan Bulan Ini",
|
||||
@ -210,5 +210,48 @@
|
||||
"Settings_Saved_Successfully": "Pengaturan Berhasil Disimpan",
|
||||
"Edit_Service_Plan": "Edit Paket Layanan",
|
||||
"Tax_Rates_will_be_added": "Tarif Pajak akan ditambahkan",
|
||||
"Data_Updated_Successfully": "Data Berhasil Diperbarui"
|
||||
"Data_Updated_Successfully": "Data Berhasil Diperbarui",
|
||||
"All_Transactions_at_Date": "Semua Transaksi pada Tanggal",
|
||||
"Export_for_Print": "Ekspor untuk Cetak",
|
||||
"Export_to_PDF": "Ekspor ke PDF",
|
||||
"Total_Income": "Jumlah pemasukan",
|
||||
"extend": "memperpanjang",
|
||||
"New_Router": "Router Baru",
|
||||
"IP_Address": "Alamat IP",
|
||||
"Description": "Keterangan",
|
||||
"Extend_Postpaid_Expiration": "Perpanjang Masa Kedaluwarsa Pascabayar",
|
||||
"Allow_Extend": "Izinkan Perpanjang",
|
||||
"Extend_Days": "Perpanjang Hari",
|
||||
"Confirmation_Message": "Pesan konfirmasi",
|
||||
"Buy_Balance": "Beli Saldo",
|
||||
"Buy_Package": "Beli Paket",
|
||||
"Order_History": "Riwayat Pesanan",
|
||||
"Your_Account_Information": "Informasi Akun Anda",
|
||||
"Password": "Kata sandi",
|
||||
"Service_Type": "Jenis Layanan",
|
||||
"Disable_auto_renewal_": "Nonaktifkan perpanjangan otomatis?",
|
||||
"Auto_Renewal_On": "Perpanjangan Otomatis Aktif",
|
||||
"Personal": "Pribadi",
|
||||
"Login_Status": "Status Masuk",
|
||||
"Deactivate": "Menonaktifkan",
|
||||
"Transfer_Balance": "Transfer Saldo",
|
||||
"Are_You_Sure_": "Apa kamu yakin?",
|
||||
"Send_your_balance_": "Kirim saldo Anda?",
|
||||
"Recharge_a_friend": "Isi ulang teman",
|
||||
"Voucher_Activation": "Aktivasi Voucher",
|
||||
"Order_Package": "Paket Pesanan",
|
||||
"Your_account_not_connected_to_internet": "Akun Anda tidak terhubung ke internet",
|
||||
"Confirm": "Mengonfirmasi",
|
||||
"Name": "Nama",
|
||||
"Email": "Surel",
|
||||
"Plan": "Rencana",
|
||||
"Total": "Total",
|
||||
"Date": "Tanggal",
|
||||
"Sales": "Penjualan",
|
||||
"Full_Name": "Nama lengkap",
|
||||
"Finish": "Menyelesaikan",
|
||||
"Resend": "Kirim ulang",
|
||||
"Additional_Cost": "Biaya tambahan",
|
||||
"Extend": "Memperpanjang",
|
||||
"expired": "kedaluwarsa"
|
||||
}
|
@ -213,6 +213,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-heading">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
|
||||
class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
{Lang::T('Extend Postpaid Expiration')}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Allow Extend')}</label>
|
||||
<div class="col-md-6">
|
||||
<select name="extend_expired" id="extend_expired" class="form-control text-muted">
|
||||
<option value="0">No</option>
|
||||
<option value="1" {if $_c['extend_expired']}selected="selected" {/if}>Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-block col-md-4">Customer can request to extend expirations</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Extend Days')}</label>
|
||||
<div class="col-md-6">
|
||||
<input type="text" class="form-control" name="extend_days" placeholder="3" value="{$_c['extend_days']}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Confirmation Message')}</label>
|
||||
<div class="col-md-6">
|
||||
<textarea type="text" rows="4" class="form-control" name="extend_confirmation" placeholder="i agree to extends and will paid full after this">{$_c['extend_confirmation']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-heading">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
|
||||
|
@ -67,12 +67,14 @@
|
||||
<td>{$ds['routers']}</td>
|
||||
<td>
|
||||
<a href="{$_url}plan/edit/{$ds['id']}"
|
||||
class="btn btn-warning btn-xs">{Lang::T('Edit')}</a>
|
||||
class="btn btn-warning btn-xs" style="color: black;">{Lang::T('Edit')}</a>
|
||||
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
|
||||
<a href="{$_url}plan/delete/{$ds['id']}" id="{$ds['id']}"
|
||||
onclick="return confirm('{Lang::T('Delete')}?')"
|
||||
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/if}
|
||||
<a href="javascript:extend('{$ds['id']}')"
|
||||
class="btn btn-info btn-xs">{Lang::T('extend')}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
@ -85,5 +87,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function extend(idP){
|
||||
var res = prompt("Extend for many days?", "3");
|
||||
if(res){
|
||||
if(confirm("Extend for "+res+" days?")){
|
||||
window.location.href = "{$_url}plan/extend/"+idP+"/"+res+"&stoken={App::getToken()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{include file="sections/footer.tpl"}
|
@ -178,12 +178,19 @@
|
||||
<tr>
|
||||
<td class="small text-primary text-uppercase text-normal">
|
||||
{if $_bill['status'] == 'on'}
|
||||
<a href="{$_url}home&deactivate={$_bill['id']}" onclick="return confirm('{Lang::T('Deactivate')}?')"
|
||||
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
<a href="{$_url}home&deactivate={$_bill['id']}"
|
||||
onclick="return confirm('{Lang::T('Deactivate')}?')" class="btn btn-danger btn-xs"><i
|
||||
class="glyphicon glyphicon-trash"></i></a>
|
||||
{/if}
|
||||
</td>
|
||||
<td class="small row">
|
||||
<a class="btn btn-primary pull-right btn-sm" href="{$_url}home&recharge={$_bill['id']}&stoken={App::getToken()}"
|
||||
{if $_bill['status'] != 'on' && $_bill['prepaid'] != 'yes' && $_c['extend_expired']}
|
||||
<a class="btn btn-warning text-black btn-sm"
|
||||
href="{$_url}home&extend={$_bill['id']}&stoken={App::getToken()}"
|
||||
onclick="return confirm('{str_replace("\n","\\n",str_replace("\r","",$_c['extend_confirmation']))}?')">{Lang::T('Extend')}</a>
|
||||
{/if}
|
||||
<a class="btn btn-primary pull-right btn-sm"
|
||||
href="{$_url}home&recharge={$_bill['id']}&stoken={App::getToken()}"
|
||||
onclick="return confirm('{Lang::T('Recharge')}?')">{Lang::T('Recharge')}</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user