diff --git a/CHANGELOG.md b/CHANGELOG.md index da5b8e45..725e801c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ # CHANGELOG +## 2024.4.23 + +- Fix Pagination Voucher +- Fix Languange Translation +- Fix Alert Confirmation for requesting Extend +- Send Telegram Notification when Customer request to extend expiration +- prepaid users export list by @freeispradius +- fix show voucher by @agstrxyz + ## 2024.4.21 - Restore old cron diff --git a/system/controllers/customers.php b/system/controllers/customers.php index ebcad67b..e3e69bad 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -25,7 +25,7 @@ switch ($action) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); } - + $cs = ORM::for_table('tbl_customers') ->select('tbl_customers.id', 'id') ->select('tbl_customers.username', 'username') @@ -37,7 +37,7 @@ switch ($action) { ->select('service_type') ->order_by_asc('tbl_customers.id') ->find_array(); - + $h = false; set_time_limit(-1); header('Pragma: public'); @@ -46,7 +46,7 @@ switch ($action) { header("Content-type: text/csv"); header('Content-Disposition: attachment;filename="phpnuxbill_customers_' . date('Y-m-d_H_i') . '.csv"'); header('Content-Transfer-Encoding: binary'); - + $headers = [ 'id', 'username', @@ -57,12 +57,12 @@ switch ($action) { 'balance', 'service_type', ]; - + if (!$h) { echo '"' . implode('","', $headers) . "\"\n"; $h = true; } - + foreach ($cs as $c) { $row = [ $c['id'], @@ -78,75 +78,75 @@ switch ($action) { } break; //case csv-prepaid can be moved later to (plan.php) php file dealing with prepaid users - case 'csv-prepaid': - if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { - _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); - } - - $cs = ORM::for_table('tbl_customers') - ->select('tbl_customers.id', 'id') - ->select('tbl_customers.username', 'username') - ->select('fullname') - ->select('address') - ->select('phonenumber') - ->select('email') - ->select('balance') - ->select('service_type') - ->select('namebp') - ->select('routers') - ->select('status') - ->select('method', 'Payment') - ->join('tbl_user_recharges', array('tbl_customers.id', '=', 'tbl_user_recharges.customer_id')) - ->order_by_asc('tbl_customers.id') - ->find_array(); - - $h = false; - set_time_limit(-1); - header('Pragma: public'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header("Content-type: text/csv"); - header('Content-Disposition: attachment;filename="phpnuxbill_prepaid_users' . date('Y-m-d_H_i') . '.csv"'); - header('Content-Transfer-Encoding: binary'); - - $headers = [ - 'id', - 'username', - 'fullname', - 'address', - 'phonenumber', - 'email', - 'balance', - 'service_type', - 'namebp', - 'routers', - 'status', - 'Payment' + case 'csv-prepaid': + if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { + _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); + } + + $cs = ORM::for_table('tbl_customers') + ->select('tbl_customers.id', 'id') + ->select('tbl_customers.username', 'username') + ->select('fullname') + ->select('address') + ->select('phonenumber') + ->select('email') + ->select('balance') + ->select('service_type') + ->select('namebp') + ->select('routers') + ->select('status') + ->select('method', 'Payment') + ->join('tbl_user_recharges', array('tbl_customers.id', '=', 'tbl_user_recharges.customer_id')) + ->order_by_asc('tbl_customers.id') + ->find_array(); + + $h = false; + set_time_limit(-1); + header('Pragma: public'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header("Content-type: text/csv"); + header('Content-Disposition: attachment;filename="phpnuxbill_prepaid_users' . date('Y-m-d_H_i') . '.csv"'); + header('Content-Transfer-Encoding: binary'); + + $headers = [ + 'id', + 'username', + 'fullname', + 'address', + 'phonenumber', + 'email', + 'balance', + 'service_type', + 'namebp', + 'routers', + 'status', + 'Payment' + ]; + + if (!$h) { + echo '"' . implode('","', $headers) . "\"\n"; + $h = true; + } + + foreach ($cs as $c) { + $row = [ + $c['id'], + $c['username'], + $c['fullname'], + $c['address'], + $c['phonenumber'], + $c['email'], + $c['balance'], + $c['service_type'], + $c['namebp'], + $c['routers'], + $c['status'], + $c['Payment'] ]; - - if (!$h) { - echo '"' . implode('","', $headers) . "\"\n"; - $h = true; - } - - foreach ($cs as $c) { - $row = [ - $c['id'], - $c['username'], - $c['fullname'], - $c['address'], - $c['phonenumber'], - $c['email'], - $c['balance'], - $c['service_type'], - $c['namebp'], - $c['routers'], - $c['status'], - $c['Payment'] - ]; - echo '"' . implode('","', $row) . "\"\n"; - } - break; + echo '"' . implode('","', $row) . "\"\n"; + } + break; case 'add': if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) { _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 41fd1f95..7b1c387f 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -132,7 +132,7 @@ switch ($action) { $using = _post('using'); $stoken = _post('stoken'); - if(!empty(App::getTokenValue($stoken))){ + if (!empty(App::getTokenValue($stoken))) { $username = App::getTokenValue($stoken); $in = ORM::for_table('tbl_transactions')->where('username', $username)->order_by_desc('id')->find_one(); Package::createInvoice($in); @@ -325,18 +325,13 @@ switch ($action) { case 'voucher': $ui->assign('_title', Lang::T('Vouchers')); - $limit = 10; - $page = _get('p', 0); - $pageNow = $page * $limit; $search = _req('search'); if ($search != '') { if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { - $d = ORM::for_table('tbl_plans')->where('enabled', '1') + $query = ORM::for_table('tbl_plans')->where('enabled', '1') ->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) - ->where_like('tbl_voucher.code', '%' . $search . '%') - ->offset($pageNow) - ->limit($limit) - ->findArray(); + ->where_like('tbl_voucher.code', '%' . $search . '%'); + $d = Paginator::findMany($query, ["search" => $search]); } else if ($admin['user_type'] == 'Agent') { $sales = []; $sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray(); @@ -344,21 +339,17 @@ switch ($action) { $sales[] = $s['id']; } $sales[] = $admin['id']; - $d = ORM::for_table('tbl_plans') + $query = ORM::for_table('tbl_plans') ->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) ->where_in('generated_by', $sales) - ->where_like('tbl_voucher.code', '%' . $search . '%') - ->offset($pageNow) - ->limit($limit) - ->findArray(); + ->where_like('tbl_voucher.code', '%' . $search . '%'); + $d = Paginator::findMany($query, ["search" => $search]); } } else { if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { - $d = ORM::for_table('tbl_plans')->where('enabled', '1') - ->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) - ->offset($pageNow) - ->limit($limit) - ->findArray(); + $query = ORM::for_table('tbl_plans')->where('enabled', '1') + ->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')); + $d = Paginator::findMany($query); } else if ($admin['user_type'] == 'Agent') { $sales = []; $sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray(); @@ -366,12 +357,10 @@ switch ($action) { $sales[] = $s['id']; } $sales[] = $admin['id']; - $d = ORM::for_table('tbl_plans') + $query = ORM::for_table('tbl_plans') ->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) - ->where_in('generated_by', $sales) - ->offset($pageNow) - ->limit($limit) - ->findArray(); + ->where_in('generated_by', $sales); + $d = Paginator::findMany($query); } } // extract admin @@ -581,6 +570,7 @@ switch ($action) { } else if ($voucher_format == 'rand') { $code = Lang::randomUpLowCase($code); } + die($code); $d = ORM::for_table('tbl_voucher')->create(); $d->type = $type; $d->routers = $server; @@ -743,15 +733,15 @@ switch ($action) { $id = $routes[2]; $days = $routes[3]; $stoken = $_GET['stoken']; - if(App::getTokenValue($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()){ + if (strtotime($tur['expiration'] . ' ' . $tur['time']) > time()) { // not expired - $expiration = date('Y-m-d', strtotime($tur['expiration']." +$days day")); - }else{ + $expiration = date('Y-m-d', strtotime($tur['expiration'] . " +$days day")); + } else { //expired $expiration = date('Y-m-d', strtotime(" +$days day")); } @@ -759,7 +749,7 @@ switch ($action) { $tur->status = "on"; $tur->save(); App::setToken($stoken, $id); - if($status=='off'){ + if ($status == 'off') { if ($tur['routers'] != 'radius') { $mikrotik = Mikrotik::info($tur['routers']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); diff --git a/ui/ui/plan.tpl b/ui/ui/plan.tpl index 67704fa0..bb27d8aa 100644 --- a/ui/ui/plan.tpl +++ b/ui/ui/plan.tpl @@ -75,7 +75,7 @@ {/if} {if $ds['status']=='off' && $_c['extend_expired']} {Lang::T('extend')} + class="btn btn-info btn-xs">{Lang::T('Extend')} {/if} diff --git a/ui/ui/voucher.tpl b/ui/ui/voucher.tpl index b106630f..f1392b7a 100644 --- a/ui/ui/voucher.tpl +++ b/ui/ui/voucher.tpl @@ -16,31 +16,34 @@
{if $ds['status'] neq '1'} - {Lang::T('View')} {/if} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])} @@ -105,4 +107,4 @@ -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/version.json b/version.json index 8d38957f..83503b76 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.4.21" + "version": "2024.4.23" } \ No newline at end of file |