Add Filter by status in Customer List
This commit is contained in:
parent
5af514244c
commit
1ab19bfe64
@ -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', '<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">');
|
||||
$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]);
|
||||
|
@ -48,6 +48,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">Status</span>
|
||||
<select class="form-control" id="filter" name="filter">
|
||||
{foreach $statuses as $status}
|
||||
<option value="{$status}" {if $filter eq $status }selected{/if}>{Lang::T($status)}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">
|
||||
@ -56,14 +66,14 @@
|
||||
<input type="text" name="search" class="form-control"
|
||||
placeholder="{Lang::T('Search')}..." value="{$search}">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-success" type="submit">{Lang::T('Search')}</button>
|
||||
<button class="btn btn-primary" type="submit">{Lang::T('Search')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<a href="{$_url}customers/add" class="btn btn-primary btn-block"><i
|
||||
<div class="col-lg-1">
|
||||
<a href="{$_url}customers/add" class="btn btn-success text-black btn-block"><i
|
||||
class="ion ion-android-add">
|
||||
</i> {Lang::T('Add New Contact')}</a>
|
||||
</i> {Lang::T('Add')}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user