Patch Update

customers list tables replaced with DataTables
This commit is contained in:
Focuslinkstech 2024-04-03 23:39:31 +01:00
parent f77c96f3c3
commit 5db8df0c3e
2 changed files with 67 additions and 82 deletions

View File

@ -512,19 +512,11 @@ switch ($action) {
break; break;
default: default:
$search = _post('search');
run_hook('list_customers'); #HOOK run_hook('list_customers'); #HOOK
if ($search != '') {
$query = ORM::for_table('tbl_customers')
->where_raw("(`username` LIKE '%$search%' OR `fullname` LIKE '%$search%' OR `phonenumber` LIKE '%$search%' OR `email` LIKE '%$search%')")
->order_by_asc('username');
$d = Paginator::findMany($query, ['search' => $search]);
} else {
$query = ORM::for_table('tbl_customers')->order_by_asc('username');
$d = Paginator::findMany($query);
}
$ui->assign('search', htmlspecialchars($search)); $query = ORM::for_table('tbl_customers')->order_by_asc('username');
$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('d', $d);
$ui->display('customers.tpl'); $ui->display('customers.tpl');
break; break;

View File

@ -1,31 +1,33 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<style>
.dataTables_wrapper .dataTables_paginate .paginate_button {
display: inline-block;
padding: 5px 10px;
margin-right: 5px;
border: 1px solid #ccc;
background-color: #fff;
color: #333;
cursor: pointer;
}
</style>
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary"> <div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading"> <div class="panel-heading">
{if in_array($_admin['user_type'],['SuperAdmin','Admin'])} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])}
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}customers/csv" <a class="btn btn-primary btn-xs" title="save" href="{$_url}customers/csv"
onclick="return confirm('This will export to CSV?')"><span class="glyphicon glyphicon-download" onclick="return confirm('This will export to CSV?')"><span class="glyphicon glyphicon-download"
aria-hidden="true"></span> CSV</a> aria-hidden="true"></span> CSV</a>
</div> </div>
{/if} {/if}
{Lang::T('Manage Contact')} {Lang::T('Manage Contact')}
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px"> <div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
<div class="col-md-8"> <div class="col-md-8">
<form id="site-search" method="post" action="{$_url}customers/">
<div class="input-group">
<input type="text" id="search-input" name="search" value="{$search}"
class="form-control" placeholder="{Lang::T('Search')}...">
<div class="input-group-btn">
<button class="btn btn-success" type="submit"><span
class="fa fa-search"></span></button>
</div>
</div>
</form>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<a href="{$_url}customers/add" class="btn btn-primary btn-block"><i class="ion ion-android-add"> <a href="{$_url}customers/add" class="btn btn-primary btn-block"><i class="ion ion-android-add">
@ -33,14 +35,14 @@
</div>&nbsp; </div>&nbsp;
</div> </div>
<div class="table-responsive table_mobile"> <div class="table-responsive table_mobile">
<table class="table table-bordered table-striped table-condensed"> <table id="customerTable" class="table table-bordered table-striped table-condensed">
<thead> <thead>
<tr> <tr>
<th>{Lang::T('Username')}</th> <th>{Lang::T('Username')}</th>
<th>{Lang::T('Account Type')}</th> <th>{Lang::T('Account Type')}</th>
<th>{Lang::T('Full Name')}</th> <th>{Lang::T('Full Name')}</th>
<th>{Lang::T('Balance')}</th> <th>{Lang::T('Balance')}</th>
<th width="120px"></th> <th>{Lang::T('Contact')}</th>
<th>{Lang::T('Package')}</th> <th>{Lang::T('Package')}</th>
<th>{Lang::T('Service Type')}</th> <th>{Lang::T('Service Type')}</th>
<th>{Lang::T('Created On')}</th> <th>{Lang::T('Created On')}</th>
@ -49,71 +51,62 @@
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $d as $ds}
<tr> <tr>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'" <td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor:pointer;">{$ds['username']}</td> style="cursor:pointer;">{$ds['username']}</td>
<td>{$ds['account_type']}</td> <td>{$ds['account_type']}</td>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'" <td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor: pointer;">{$ds['fullname']}</td> style="cursor: pointer;">{$ds['fullname']}</td>
<td>{Lang::moneyFormat($ds['balance'])}</td> <td>{Lang::moneyFormat($ds['balance'])}</td>
<td align="center"> <td align="center">
{if $ds['phonenumber']} {if $ds['phonenumber']}
<a href="tel:{$ds['phonenumber']}" class="btn btn-default btn-xs" <a href="tel:{$ds['phonenumber']}" class="btn btn-default btn-xs"
title="{$ds['phonenumber']}"><i class="glyphicon glyphicon-earphone"></i></a> title="{$ds['phonenumber']}"><i class="glyphicon glyphicon-earphone"></i></a>
{/if} {/if}
{if $ds['email']} {if $ds['email']}
<a href="mailto:{$ds['email']}" class="btn btn-default btn-xs" <a href="mailto:{$ds['email']}" class="btn btn-default btn-xs"
title="{$ds['email']}"><i class="glyphicon glyphicon-envelope"></i></a> title="{$ds['email']}"><i class="glyphicon glyphicon-envelope"></i></a>
{/if} {/if}
{if $ds['coordinates']} {if $ds['coordinates']}
<a href="https://www.google.com/maps/dir//{$ds['coordinates']}/" target="_blank" class="btn btn-default btn-xs" <a href="https://www.google.com/maps/dir//{$ds['coordinates']}/" target="_blank"
title="{$ds['coordinates']}"><i class="glyphicon glyphicon-map-marker"></i></a> class="btn btn-default btn-xs" title="{$ds['coordinates']}"><i
{/if} class="glyphicon glyphicon-map-marker"></i></a>
</td> {/if}
<td align="center" api-get-text="{$_url}autoload/customer_is_active/{$ds['id']}"> </td>
<span class="label label-default">&bull;</span> <td align="center" api-get-text="{$_url}autoload/customer_is_active/{$ds['id']}">
</td> <span class="label label-default">&bull;</span>
<td>{$ds['service_type']}</td> </td>
<td>{Lang::dateTimeFormat($ds['created_at'])}</td> <td>{$ds['service_type']}</td>
<td align="center"> <td>{Lang::dateTimeFormat($ds['created_at'])}</td>
<a href="{$_url}customers/view/{$ds['id']}" id="{$ds['id']}" <td align="center">
style="margin: 0px; color:black" <a href="{$_url}customers/view/{$ds['id']}" id="{$ds['id']}"
class="btn btn-success btn-xs">&nbsp;&nbsp;{Lang::T('View')}&nbsp;&nbsp;</a> style="margin: 0px; color:black"
<a href="{$_url}customers/edit/{$ds['id']}" id="{$ds['id']}" class="btn btn-success btn-xs">&nbsp;&nbsp;{Lang::T('View')}&nbsp;&nbsp;</a>
style="margin: 0px; color:black" <a href="{$_url}customers/edit/{$ds['id']}" id="{$ds['id']}"
class="btn btn-info btn-xs">&nbsp;&nbsp;{Lang::T('Edit')}&nbsp;&nbsp;</a> style="margin: 0px; color:black"
<a href="{$_url}plan/recharge/{$ds['id']}" id="{$ds['id']}" style="margin: 0px;" class="btn btn-info btn-xs">&nbsp;&nbsp;{Lang::T('Edit')}&nbsp;&nbsp;</a>
class="btn btn-primary btn-xs">{Lang::T('Recharge')}</a> <a href="{$_url}plan/recharge/{$ds['id']}" id="{$ds['id']}" style="margin: 0px;"
</td> class="btn btn-primary btn-xs">{Lang::T('Recharge')}</a>
</tr> </td>
</tr>
{/foreach} {/foreach}
</tbody> </tbody>
</table> </table>
</div> </div>
{include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script> <script>
// Functionality to filter table rows based on admin input var $j = jQuery.noConflict();
document.addEventListener('DOMContentLoaded', function() {
var searchInput = document.getElementById('search-input');
var tableRows = document.querySelectorAll('tbody tr');
searchInput.addEventListener('input', function() { $j(document).ready(function () {
var searchText = this.value.toLowerCase(); $j('#customerTable').DataTable({
"pagingType": "full_numbers"
tableRows.forEach(function(row) {
var rowData = row.textContent.toLowerCase();
if (rowData.includes(searchText)) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
}); });
}); });
</script> </script>