130 lines
5.8 KiB
PHP
Executable File
130 lines
5.8 KiB
PHP
Executable File
<?php include('layout/header.php'); ?>
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<h4 class="page-title">Clilent List</h4>
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class=""> <a href="<?= base_url() . "new_client/0"; ?>" class="btn btn-primary waves-effect"> Add Client</a></li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<!-- <h4 class="header-title">Business List</h4> -->
|
|
<table id="datatable-client" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
|
|
<thead>
|
|
<tr>
|
|
<th>Client Name</th>
|
|
<th>Mobile</th>
|
|
<th>Email</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($client as $index => $value) :
|
|
if ($value['isactive'] == 1) : ?>
|
|
<tr class="client_tr_<?php echo $index+1; ?>">
|
|
<td><?= $value['client_name']; ?></td>
|
|
<td><?= $value['mobile_no']; ?></td>
|
|
<td><?= $value['email']; ?></td>
|
|
<td>
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a href="<?= "new_client/" . $value['client_id']; ?>" class="dropdown-item edit-button" onclick="datatableClient('client_tr_<?php echo $index+1; ?>')"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
|
<a href="<?= "delete_client/" . $value['client_id']; ?>" class="dropdown-item delete-button"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle" style="font-size: 20px;"></i>Delete</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php endif?>
|
|
<?php endforeach; ?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- end table-responsive-->
|
|
</div>
|
|
</div> <!-- end card -->
|
|
</div> <!-- end col -->
|
|
</div>
|
|
<?php include('layout/footer.php'); ?>
|
|
|
|
<script>
|
|
var datatable_client ='';
|
|
$(document).ready(function() {
|
|
|
|
datatable_client = $('#datatable-client').DataTable({
|
|
"order": [[0, 'asc']],
|
|
"dom": 'Bfrtip',
|
|
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
|
{extend: 'print',title: 'Products',text: 'Print',},
|
|
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
|
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
|
"language": {
|
|
"search": "Search: " // Customize search label
|
|
},
|
|
});
|
|
console.log(datatable_client);
|
|
|
|
|
|
//Start DataTable Paging is session is set
|
|
var savedPage = sessionStorage.getItem('currentPage');
|
|
var hightlight_tr = sessionStorage.getItem('hightlight_tr');
|
|
console.log(savedPage);
|
|
console.log(hightlight_tr);
|
|
// Ensure savedPage is a number
|
|
savedPage = parseInt(savedPage);
|
|
// Check if savedPage is not null and adjust if necessary
|
|
if (savedPage !== null && !isNaN(savedPage)) {
|
|
// Check if the saved page number is within the bounds of the current DataTable
|
|
var totalPages = datatable_client.page.info().pages; // Total number of pages in the DataTable
|
|
if (savedPage >= totalPages) {
|
|
// adjust to the last page of the DataTable
|
|
savedPage = totalPages > 0 ? totalPages - 1 : 0;
|
|
}
|
|
// Move DataTable to the saved page and draw
|
|
datatable_client.page(savedPage).draw(false);
|
|
|
|
// Select the highlighted row
|
|
var $row = $('.' + hightlight_tr);
|
|
|
|
// Smoothly scroll to the row and center it in the viewport
|
|
$('html, body').animate({
|
|
scrollTop: $row.offset().top - ($(window).height() / 2) + ($row.height() / 2)
|
|
}, 500, function() {
|
|
|
|
// After focusing, change background color
|
|
$row.css('background', '#faf6ca');
|
|
|
|
// Remove background color after 4 seconds
|
|
setTimeout(function() {
|
|
$row.css('background', '');
|
|
}, 4000);
|
|
});
|
|
}
|
|
sessionStorage.removeItem('currentPage');
|
|
sessionStorage.removeItem('hightlight_tr');
|
|
//End DataTable Paging is session is set
|
|
|
|
|
|
|
|
});
|
|
|
|
function datatableClient(value) {
|
|
console.log("---------------");
|
|
console.log(value);
|
|
|
|
var currentPage = datatable_client.page.info().page;
|
|
sessionStorage.setItem('currentPage', currentPage);
|
|
sessionStorage.setItem('hightlight_tr', value);
|
|
|
|
}
|
|
</script>
|