From 1ab19bfe64e75d06e23185ceaa7d8a64f23723dc Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 20 May 2024 09:12:13 +0700 Subject: [PATCH] Add Filter by status in Customer List --- system/controllers/customers.php | 6 +++++- ui/ui/customers.tpl | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index b21ffd12..d3f6cd59 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -610,6 +610,7 @@ switch ($action) { run_hook('list_customers'); #HOOK $search = _post('search'); $order = _post('order', 'username'); + $filter = _post('filter', 'Active'); $orderby = _post('orderby', 'asc'); $order_pos = [ 'username' => 0, @@ -621,9 +622,10 @@ switch ($action) { if ($search != '') { $query = ORM::for_table('tbl_customers') ->whereRaw("username LIKE '%$search%' OR fullname LIKE '%$search%' OR address LIKE '%$search%' ". - "OR phonenumber LIKE '%$search%' OR email LIKE '%$search%' "); + "OR phonenumber LIKE '%$search%' OR email LIKE '%$search%' AND status='$filter'"); } else { $query = ORM::for_table('tbl_customers'); + $query->where("status", $filter); } if($orderby=='asc'){ $query->order_by_asc($order); @@ -633,6 +635,8 @@ switch ($action) { $d = $query->findMany(); $ui->assign('xheader', ''); $ui->assign('d', $d); + $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); + $ui->assign('filter', $filter); $ui->assign('search', $search); $ui->assign('order', $order); $ui->assign('order_pos', $order_pos[$order]); diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index 62c5a2e3..ac45892a 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -48,6 +48,16 @@ +
+
+ Status + +
+
@@ -56,14 +66,14 @@
- +
-