diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 3b02dce3..6160ab20 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -439,7 +439,7 @@ switch ($action) { $plan = _req('plan'); $status = _req('status'); $batch_name = _req('batch_name'); - + $ui->assign('batch_name', $batch_name); $ui->assign('router', $router); $ui->assign('customer', $customer); @@ -470,6 +470,27 @@ switch ($action) { $query->where('tbl_voucher.batch_name', $batch_name); } + if (!empty($_COOKIE['per-page']) && $_COOKIE['per-page'] != $config['voucher_per_page']) { + $d = ORM::for_table('tbl_appconfig')->where('setting', 'voucher_per_page')->find_one(); + if ($d) { + $d->value = $_COOKIE['per-page']; + $d->save(); + } else { + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'voucher_per_page'; + $d->value = $_COOKIE['per-page']; + $d->save(); + } + } + if (!empty($config['voucher_per_page']) && empty($_COOKIE['per-page'])) { + $_COOKIE['per-page'] = $config['voucher_per_page']; + setcookie('per-page', $config['voucher_per_page'], time() + (86400 * 30), "/"); + } + + $ui->assign('cookie', $_COOKIE['per-page']); + + $per_page = (!empty($_COOKIE['per-page']) && $_COOKIE['per-page'] != $config['voucher_per_page']) ? $_COOKIE['per-page'] : '10'; + $append_url = "&search=" . urlencode($search) . "&router=" . urlencode($router) . "&customer=" . urlencode($customer) . "&plan=" . urlencode($plan) . "&status=" . urlencode($status); // option customers @@ -508,7 +529,7 @@ switch ($action) { $query->where_in('generated_by', $sales); } } - $d = Paginator::findMany($query, ["search" => $search], 10, $append_url); + $d = Paginator::findMany($query, ["search" => $search], $per_page, $append_url); // extract admin $admins = []; foreach ($d as $k) { diff --git a/ui/ui/admin/voucher/list.tpl b/ui/ui/admin/voucher/list.tpl index 04c8381a..c0fafa8e 100644 --- a/ui/ui/admin/voucher/list.tpl +++ b/ui/ui/admin/voucher/list.tpl @@ -1,4 +1,31 @@ {include file="sections/header.tpl"} +
@@ -32,13 +59,15 @@
- +
- {foreach $routers as $r} @@ -48,7 +77,8 @@
- {foreach $batches as $batch}
- {foreach $plans as $p} @@ -79,7 +110,8 @@
- {foreach $customers as $c} @@ -90,13 +122,14 @@
-
@@ -107,6 +140,19 @@
  +
+ Show + + entries +
@@ -281,5 +327,13 @@ checkbox.checked = this.checked; } }); + + function changePerPage(select) { + setCookie('per-page', select.value, 365); + setTimeout(() => { + location.reload(); + }, 1000); + console.log('Entries per page changed to: ' + select.value); + } {include file="sections/footer.tpl"} \ No newline at end of file