From 37a7da614e088e43c6a7c61a83778bb1addeab77 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 27 Mar 2024 09:44:48 +0700 Subject: [PATCH] Fixing Pagination, more Simple --- system/autoload/Package.php | 5 +- system/autoload/Paginator.php | 171 ++++++++++++++++--------------- system/controllers/bandwidth.php | 11 +- system/controllers/customers.php | 36 ++----- system/controllers/dashboard.php | 11 +- system/controllers/logs.php | 22 ++-- system/controllers/order.php | 9 +- system/controllers/plan.php | 11 +- system/controllers/pool.php | 11 +- system/controllers/radius.php | 9 +- system/controllers/reports.php | 17 ++- system/controllers/routers.php | 11 +- system/controllers/services.php | 21 ++-- system/controllers/settings.php | 39 +++---- system/controllers/voucher.php | 6 +- ui/ui/pagination.tpl | 9 +- 16 files changed, 166 insertions(+), 233 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index de5ea9a4..3ab9645d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -44,6 +44,7 @@ class Package foreach ($bills as $k => $v) { $note .= $k . " : " . Lang::moneyFormat($v) . "\n"; } + $note .= $p['name_plan'] . " : " . Lang::moneyFormat($p['price']) . "\n"; } } @@ -520,7 +521,9 @@ class Package $t->plan_name = $p['name_plan']; if ($p['validity_unit'] == 'Period') { // Postpaid price always zero for first time - $t->price = 0 + $add_cost; + $note = ''; + $bills = []; + $t->price = 0; } else { $t->price = $p['price'] + $add_cost; } diff --git a/system/autoload/Paginator.php b/system/autoload/Paginator.php index bc8769fe..24766ae6 100644 --- a/system/autoload/Paginator.php +++ b/system/autoload/Paginator.php @@ -1,16 +1,16 @@ $url, 'page' => $page, 'pages' => $pages, - 'prev' => ($page>0) ? ($page-1): "0", - 'next' => ($page>= $lastpage) ? $lastpage : $page+1 + 'prev' => ($page > 0) ? ($page - 1) : "0", + 'next' => ($page >= $lastpage) ? $lastpage : $page + 1 ]; - return $result; + if ($ui) { + $ui->assign('paginator', $result); + } + return $query->offset($startpoint)->limit($per_page)->find_many(); } } + public static function build($table, $colVal = [], $query = '', $per_page = '10') { global $routes; + global $_L; $url = U . implode('/', $routes); $query = urlencode($query); $adjacents = "2"; @@ -99,60 +104,60 @@ class Paginator $limit = $per_page; $startpoint = ($page * $limit) - $limit; if ($lastpage >= 1) { - $pagination .= '