diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 51503292..3b02dce3 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -438,6 +438,9 @@ switch ($action) { $customer = _req('customer'); $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); $ui->assign('status', $status); @@ -463,6 +466,10 @@ switch ($action) { $query->where('tbl_voucher.user', $customer); } + if (!empty($batch_name)) { + $query->where('tbl_voucher.batch_name', $batch_name); + } + $append_url = "&search=" . urlencode($search) . "&router=" . urlencode($router) . "&customer=" . urlencode($customer) . "&plan=" . urlencode($plan) . "&status=" . urlencode($status); // option customers @@ -478,7 +485,7 @@ switch ($action) { if ($search != '') { if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { - $query->where_like('tbl_voucher.code', '%' . $search . '%'); + $query->where_like('tbl_voucher.code', "%$search%"); } else if ($admin['user_type'] == 'Agent') { $sales = []; $sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray(); @@ -487,7 +494,7 @@ switch ($action) { } $sales[] = $admin['id']; $query->where_in('generated_by', $sales) - ->where_like('tbl_voucher.code', '%' . $search . '%'); + ->where_like('tbl_voucher.code', "%$search%"); } } else { if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { @@ -501,7 +508,7 @@ switch ($action) { $query->where_in('generated_by', $sales); } } - $d = $query->find_many(); + $d = Paginator::findMany($query, ["search" => $search], 10, $append_url); // extract admin $admins = []; foreach ($d as $k) { @@ -525,7 +532,13 @@ switch ($action) { } } - $ui->assign('xheader', ''); + $batches = ORM::for_table('tbl_voucher') + ->select('batch_name') + ->distinct() + ->where_not_equal('batch_name', '') + ->order_by_desc('created_at') + ->find_many(); + $ui->assign('batches', $batches); $ui->assign('admins', $admins); $ui->assign('d', $d); $ui->assign('search', $search); diff --git a/ui/ui/admin/voucher/list.tpl b/ui/ui/admin/voucher/list.tpl index 03aa8ac4..04c8381a 100644 --- a/ui/ui/admin/voucher/list.tpl +++ b/ui/ui/admin/voucher/list.tpl @@ -14,6 +14,7 @@ +
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])} @@ -26,7 +27,84 @@ {/if}  
- +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
  @@ -94,7 +172,6 @@ {/foreach}
-
@@ -107,14 +184,11 @@
+ {include file="pagination.tpl"}
- - - - - - {include file="sections/footer.tpl"} \ No newline at end of file