From 425e3a4401d228bb9decbf5e95a7aa06a8da4044 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Mon, 21 Apr 2025 12:16:28 +0100 Subject: [PATCH] feat: implement per-page entry selection for customer management with cookie support --- system/controllers/customers.php | 24 +++++++++++++++- ui/ui/admin/customers/list.tpl | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 05b153dd..49e4fce7 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -904,7 +904,29 @@ switch ($action) { fclose($fp); die(); } - $d = Paginator::findMany($query, ['search' => $search], 30, $append_url); + + if (!empty($_COOKIE['customer_per_page']) && $_COOKIE['customer_per_page'] != $config['customer_per_page']) { + $d = ORM::for_table('tbl_appconfig')->where('setting', 'customer_per_page')->find_one(); + if ($d) { + $d->value = $_COOKIE['customer_per_page']; + $d->save(); + } else { + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = 'customer_per_page'; + $d->value = $_COOKIE['customer_per_page']; + $d->save(); + } + } + if (!empty($config['customer_per_page']) && empty($_COOKIE['customer_per_page'])) { + $_COOKIE['customer_per_page'] = $config['customer_per_page']; + setcookie('customer_per_page', $config['customer_per_page'], time() + (86400 * 30), "/"); + } + + $ui->assign('cookie', $_COOKIE['customer_per_page']); + + $per_page = !empty($_COOKIE['customer_per_page']) ? $_COOKIE['customer_per_page'] : (!empty($config['customer_per_page']) ? $config['customer_per_page'] : '30'); + + $d = Paginator::findMany($query, ['search' => $search], $per_page, $append_url); $ui->assign('d', $d); $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); $ui->assign('filter', $filter); diff --git a/ui/ui/admin/customers/list.tpl b/ui/ui/admin/customers/list.tpl index 3d2ab3f0..0e7cc9d4 100644 --- a/ui/ui/admin/customers/list.tpl +++ b/ui/ui/admin/customers/list.tpl @@ -9,6 +9,32 @@ color: #333; cursor: pointer; } + + .form-group { + margin-bottom: 20px; + display: flex; + align-items: center; + } + + .form-group select { + margin-left: 10px; + margin-right: 10px; + } + + .page-item { + width: 100px; + display: block; + height: 34px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + color: #555; + background-color: #fff; + background-image: none; + border: 1px solid #ccc; + border-radius: 4px; + + }