diff --git a/system/controllers/home.php b/system/controllers/home.php index 14aa5e03..0549a114 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -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) { diff --git a/system/controllers/plan.php b/system/controllers/plan.php index d5c73fa1..f7cf9299 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -60,23 +60,6 @@ switch ($action) { $log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]
"; } r2(U . 'plan/list', 's', $log); - case 'list': - $ui->assign('xfooter', ''); - $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', ''); + $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; } diff --git a/system/lan/indonesia.json b/system/lan/indonesia.json index 8610ec23..b1a213cb 100644 --- a/system/lan/indonesia.json +++ b/system/lan/indonesia.json @@ -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" } \ No newline at end of file diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index 32c17711..feb86f20 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -213,6 +213,37 @@ +
+
+ +
+ {Lang::T('Extend Postpaid Expiration')} +
+
+
+ +
+ +
+

Customer can request to extend expirations

+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ {include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/user-dashboard.tpl b/ui/ui/user-dashboard.tpl index daaa9b99..b540dffa 100644 --- a/ui/ui/user-dashboard.tpl +++ b/ui/ui/user-dashboard.tpl @@ -178,12 +178,19 @@ {if $_bill['status'] == 'on'} - + {/if} - {Lang::T('Extend')} + {/if} + {Lang::T('Recharge')}