595 lines
27 KiB
PHP
Executable File
595 lines
27 KiB
PHP
Executable File
<?php
|
||
helper('datatable_view');
|
||
$ret_header_labels = [
|
||
'S.No', 'Policy number', 'Endorsement Number', 'Description', 'Client', 'Insurer name',
|
||
'Agent', 'Mananger', 'Created At', 'Status', 'Action',
|
||
];
|
||
$ret_col_count = count($ret_header_labels);
|
||
$ret_col_max_len = array_fill(0, $ret_col_count, 0);
|
||
for ($i = 0; $i < $ret_col_count; $i++) {
|
||
$ret_col_max_len[$i] = mb_strlen($ret_header_labels[$i]);
|
||
}
|
||
$employees = $employees ?? [];
|
||
$ret_sl = 0;
|
||
foreach ($employees as $employee) {
|
||
++$ret_sl;
|
||
$ret_col_max_len[0] = max($ret_col_max_len[0], mb_strlen((string) $ret_sl));
|
||
$ret_col_max_len[1] = max($ret_col_max_len[1], mb_strlen((string) ($employee['policy_number'] ?? '')));
|
||
$ret_col_max_len[2] = max($ret_col_max_len[2], mb_strlen((string) ($employee['endorsement_no'] ?? '')));
|
||
$ret_col_max_len[3] = max($ret_col_max_len[3], mb_strlen((string) ($employee['endorsement_description'] ?? '')));
|
||
$clientCell = ! empty($employee['client_name'])
|
||
? ($employee['client_name'] . ' ( ' . ($employee['client_short_name'] ?? '') . ' ) ')
|
||
: 'N/A';
|
||
$ret_col_max_len[4] = max($ret_col_max_len[4], mb_strlen($clientCell));
|
||
$insCell = ! empty($employee['insurer_name'])
|
||
? ($employee['insurer_name'] . ' ( ' . ($employee['insurer_short_name'] ?? '') . ' ) ')
|
||
: 'N/A';
|
||
$ret_col_max_len[5] = max($ret_col_max_len[5], mb_strlen($insCell));
|
||
$ret_col_max_len[6] = max($ret_col_max_len[6], mb_strlen((string) ($employee['agent_name'] ?? 'N/A')));
|
||
$ret_col_max_len[7] = max($ret_col_max_len[7], mb_strlen((string) ($employee['manager_name'] ?? 'N/A')));
|
||
$createdPlain = '';
|
||
if (! empty($employee['created_at'])) {
|
||
$createdPlain = date('j F Y', strtotime((string) $employee['created_at']))
|
||
. ' '
|
||
. date('h:i A', strtotime((string) $employee['created_at']));
|
||
}
|
||
$ret_col_max_len[8] = max($ret_col_max_len[8], mb_strlen($createdPlain));
|
||
$ret_col_max_len[9] = max($ret_col_max_len[9], mb_strlen((string) ($employee['status'] ?? '')));
|
||
$ret_col_max_len[10] = max($ret_col_max_len[10], 4);
|
||
}
|
||
$ret_col_min_px = [48, 100, 120, 120, 140, 140, 96, 96, 140, 96, 72];
|
||
$ret_col_max_px = [64, 200, 220, 400, 400, 360, 240, 240, 220, 160, 80];
|
||
$ret_col_width_px = nhance_dt_column_widths_px($ret_header_labels, $ret_col_max_len, $ret_col_min_px, $ret_col_max_px);
|
||
?>
|
||
<style>
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
|
||
position: relative;
|
||
left: 79px;
|
||
}
|
||
|
||
.emp_data_model {
|
||
font-size: 17px;
|
||
/* keep fixed size */
|
||
color: #555 !important;
|
||
cursor: pointer;
|
||
transition: transform 0.2s, color 0.2s;
|
||
/* smooth hover effect */
|
||
display: inline-block;
|
||
/* important for transform */
|
||
}
|
||
|
||
.emp_data_model:hover {
|
||
color: #00999E !important;
|
||
transform: scale(1.5);
|
||
}
|
||
.dataTables_length label {height: 21px !important;}
|
||
.filter-sidebar {
|
||
height: 100%;
|
||
width: 0;
|
||
position: fixed;
|
||
z-index: 1001;
|
||
top: 0;
|
||
right: 0;
|
||
background-color: #f8f9fa;
|
||
overflow-x: hidden;
|
||
transition: 0.5s;
|
||
box-shadow: -2px 0 5px rgba(0,0,0,0.1);
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.filter-sidebar-header {
|
||
padding: 15px 20px;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
border-bottom: 1px solid #dee2e6;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.filter-sidebar-header .closebtn {
|
||
font-size: 28px;
|
||
text-decoration: none;
|
||
color: #6c757d;
|
||
}
|
||
|
||
.filter-sidebar .closebtn:hover {
|
||
color: #000;
|
||
}
|
||
|
||
.filter-sidebar-content {
|
||
padding: 20px;
|
||
flex-grow: 1;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.filter-sidebar-footer {
|
||
padding: 15px 20px;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
border-top: 1px solid #dee2e6;
|
||
flex-shrink: 0;
|
||
gap: 10px;
|
||
}
|
||
|
||
<?php for ($i = 0; $i < $ret_col_count; $i++) : ?>
|
||
#retail-endorsement-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
|
||
#retail-endorsement-list-table thead th:nth-child(<?= $i + 1 ?>) {
|
||
min-width: <?= (int) $ret_col_width_px[$i] ?>px;
|
||
width: <?= (int) $ret_col_width_px[$i] ?>px;
|
||
box-sizing: border-box;
|
||
vertical-align: middle;
|
||
overflow: visible !important;
|
||
}
|
||
#retail-endorsement-list-table tbody td:nth-child(<?= $i + 1 ?>) {
|
||
width: <?= (int) $ret_col_width_px[$i] ?>px;
|
||
max-width: <?= (int) $ret_col_width_px[$i] ?>px;
|
||
min-width: <?= (int) $ret_col_width_px[$i] ?>px;
|
||
box-sizing: border-box;
|
||
vertical-align: middle;
|
||
}
|
||
<?php endfor; ?>
|
||
#retail-endorsement-list-table tbody td:nth-child(1),
|
||
#retail-endorsement-list-table tbody td:nth-child(2),
|
||
#retail-endorsement-list-table tbody td:nth-child(3),
|
||
#retail-endorsement-list-table tbody td:nth-child(4),
|
||
#retail-endorsement-list-table tbody td:nth-child(5),
|
||
#retail-endorsement-list-table tbody td:nth-child(6),
|
||
#retail-endorsement-list-table tbody td:nth-child(7),
|
||
#retail-endorsement-list-table tbody td:nth-child(8),
|
||
#retail-endorsement-list-table tbody td:nth-child(9),
|
||
#retail-endorsement-list-table tbody td:nth-child(10) {
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
#retail-endorsement-list-table tbody td:nth-child(11) {
|
||
overflow: visible;
|
||
text-overflow: clip;
|
||
}
|
||
#retail-endorsement-list-table tbody td {
|
||
padding: 5px 11px !important;
|
||
font-size: 13px;
|
||
line-height: 1.25;
|
||
}
|
||
#retail-endorsement-list-table thead th {
|
||
padding: 5px 2.35rem 5px 11px !important;
|
||
font-size: 13px;
|
||
line-height: 1.25;
|
||
}
|
||
</style>
|
||
|
||
<div class="container-fluid-min">
|
||
<div id="filter-sidebar" class="filter-sidebar">
|
||
<div class="filter-sidebar-header">
|
||
<h4 class="m-0">Filter</h4>
|
||
<a href="javascript:void(0)" class="closebtn" onclick="closeFilterNav()">×</a>
|
||
</div>
|
||
<div class="filter-sidebar-content">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label>Client</label> <br />
|
||
<select class="form-control" id="clients">
|
||
<option value="0">Select</option>
|
||
<?php foreach ($client as $key => $value) { ?>
|
||
<option value="<?= $value['id'] ?>" <?= (($getData['client_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
|
||
<?= $value['client_name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label>Insurer</label> <br />
|
||
<select class="form-control" id="insurer">
|
||
<option value="0">Select</option>
|
||
<?php foreach ($insurer as $key => $value) { ?>
|
||
<option value="<?= $value['id'] ?>" <?= (($getData['insurer_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
|
||
<?= $value['name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label>Status</label> <br />
|
||
<select class="form-control" id="status1">
|
||
<option value="0">Select</option>
|
||
<?php foreach ($status as $key => $value) { ?>
|
||
<option value="<?= $key ?>" <?= (($getData['status'] ?? '') == $key) ? 'selected' : '' ?>>
|
||
<?= $value ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="filter-sidebar-footer">
|
||
<a href="<?= base_url("employee/retail-endorsement-list"); ?>" class="btn btn-secondary" >Clear</a>
|
||
<a href="<?= base_url("employee/retail-endorsement-list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);closeFilterNav();">Submit</a>
|
||
</div>
|
||
</div>
|
||
<div class="row" id="client_list">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<!-- <div class="row" style="padding-bottom: 10px;">
|
||
<div class="col-6" style="align-self: center;">
|
||
<h4 style="position: relative;">Endorsement</h4>
|
||
</div>
|
||
</div> -->
|
||
<table data-custom-table-css="table" class="table table-hover m-0 table-centered w-100" cellspacing="0" id="retail-endorsement-list-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">S.No </th>
|
||
<th class="font-weight-medium">Policy number </th>
|
||
<th class="font-weight-medium">Endorsement Number </th>
|
||
<th class="font-weight-medium">Description </th>
|
||
<th class="font-weight-medium">Client </th>
|
||
<th class="font-weight-medium">Insurer name </th>
|
||
<th class="font-weight-medium">Agent </th>
|
||
<th class="font-weight-medium">Mananger </th>
|
||
<th class="font-weight-medium">Created At </th>
|
||
<th class="font-weight-medium">Status </th>
|
||
<th class="font-weight-medium text-center">Action </th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="font-12">
|
||
<?php
|
||
if (isset($employees)) {
|
||
foreach ($employees as $key => $employee) { ?>
|
||
<tr>
|
||
<td><b><?php echo ($key + 1) ?></b></td>
|
||
<td><?php echo $employee['policy_number'] ?></td>
|
||
<td><?php echo $employee['endorsement_no'] ?></td>
|
||
<td class="text-center"><?php echo $employee['endorsement_description'] ?></td>
|
||
<td><?php echo $employee['client_name'] ? $employee['client_name'] . ' ( ' . $employee['client_short_name'] . ' ) ' : 'N/A' ?></td>
|
||
<td><?php echo $employee['insurer_name'] ? $employee['insurer_name'] . ' ( ' . $employee['insurer_short_name'] . ' ) ' : 'N/A' ?></td>
|
||
<td><?php echo $employee['agent_name'] ?? 'N/A' ?></td>
|
||
<td><?php echo $employee['manager_name'] ?? 'N/A' ?></td>
|
||
<td><?php if (!empty($employee['created_at'])):
|
||
$cd = date("j/F/Y", strtotime($employee['created_at']));
|
||
$ct = date("h:i A", strtotime($employee['created_at']));
|
||
echo $cd . "<br><span class='time'> " . $ct . "</span>";
|
||
endif; ?></td>
|
||
<td><?php if ($employee['status'] == 'open') {
|
||
echo '<span class="badge badge-primary">' . $employee['status'] . '</span>';
|
||
} elseif ($employee['status'] == 'inprogress') {
|
||
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
|
||
} elseif ($employee['status'] == 'complete') {
|
||
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
|
||
}
|
||
?>
|
||
</td>
|
||
<td class="table-action-cell">
|
||
<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 class="dropdown-item emp_data_model" href="#" data-id="<?php echo $employee['id'] ?>" data-eno="<?php echo $employee['endorsement_no'] ?>" data-status="<?php echo $employee['status'] ?>" data-toggle="modal" data-target="#centermodal">
|
||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php }
|
||
} ?>
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal fade font-color-black " id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<form id="retailEndorsementForm">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title title-text" id="myCenterModalLabel" style="font-size:27px !important">Edit Endorsement Details <span id="heading"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body">
|
||
<div class="form-row">
|
||
<input type="hidden" id="edit_id" name="id">
|
||
<input type="hidden" id="updated_by" name="updated_by" value="<?= get_session_userid(); ?>">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="endorsement_no" class="sub-title-text ">Endorsement Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="endorsement_no" placeholder="Enter Endorsement Number" name="endorsement_no" required>
|
||
</div>
|
||
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="edit_status" class="sub-title-text ">Status<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="edit_status" name="status" required>
|
||
<option value="">Select Status</option>
|
||
<?php foreach ($status as $key => $value) { ?>
|
||
<option value="<?= $key ?>"><?= $value ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal-footer">
|
||
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit" onclick="submitRetailEndorsement(event)">Save</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<script>
|
||
function openRetailEndrosementFilterNav() {
|
||
document.getElementById("filter-sidebar").style.width = "350px";
|
||
}
|
||
|
||
function closeFilterNav() {
|
||
document.getElementById("filter-sidebar").style.width = "0";
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
// Initialize select2
|
||
$("#clients").select2();
|
||
$("#insurer").select2();
|
||
});
|
||
|
||
var client_id = '<?= $getData['client_id'] ?? '' ?>';
|
||
var insurer_id = '<?= $getData['insurer_id'] ?? '' ?>';
|
||
var status_id = '<?= $getData['status'] ?? '' ?>';
|
||
|
||
$(window).on("load", function() {
|
||
console.log("window loaded");
|
||
});
|
||
|
||
|
||
// Function to convert object to query parameters
|
||
function objectToQueryString(obj) {
|
||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||
}
|
||
|
||
function fetchEmpolyeeList(event) {
|
||
event.preventDefault(); // Prevent default action
|
||
|
||
var client_id = $('#clients').val();
|
||
var insurer_id = $('#insurer').val();
|
||
var status = $('#status1').val();
|
||
|
||
var queryParams = {
|
||
client_id: client_id,
|
||
insurer_id: insurer_id,
|
||
status: status,
|
||
};
|
||
|
||
const queryString = objectToQueryString(queryParams);
|
||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||
// console.log(apiURL);
|
||
window.location.href = apiURL;
|
||
|
||
}
|
||
|
||
$('.emp_data_model').click(function() {
|
||
var id = $(this).data('id');
|
||
var eno = $(this).data('eno');
|
||
var status = $(this).data('status');
|
||
// console.log(val);
|
||
fetchRetailEndorsementData(id, eno, status)
|
||
|
||
});
|
||
|
||
$(document).on('click', '.emp_data_model', function() {
|
||
|
||
var id = $(this).attr('data-id');
|
||
var eno = $(this).attr('data-eno');
|
||
var status = $(this).attr('data-status');
|
||
|
||
fetchRetailEndorsementData(id, eno, status);
|
||
});
|
||
|
||
function submitRetailEndorsement(e) {
|
||
e.preventDefault(); // stop normal form submit
|
||
var form = document.getElementById("retailEndorsementForm");
|
||
var id = form.querySelector("[name='id']").value;
|
||
var formData = new FormData(form);
|
||
form.classList.remove('was-validated');
|
||
var btn = document.getElementById("btnSubmit");
|
||
btn.disabled = true;
|
||
btn.innerText = "Saving...";
|
||
|
||
var endorsement_no = document.getElementById('endorsement_no').value.trim();
|
||
var edit_status = document.getElementById('edit_status').value.trim();
|
||
|
||
if (endorsement_no === "" || edit_status === "") {
|
||
toastr.warning('Please fill all required fields.', 'Warning');
|
||
form.classList.add('was-validated');
|
||
return;
|
||
}
|
||
|
||
$.ajax({
|
||
url: "<?= base_url('/employee/retail-endorsement-save') ?>",
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
if (response.status === "success") {
|
||
toastr.success(response.message, 'Success');
|
||
$('.emp_data_model').modal('hide');
|
||
form.reset();
|
||
window.location.href = "<?= base_url('/employee/retail-endorsement-list') ?>";
|
||
} else {
|
||
toastr.error(response.message, 'Error');
|
||
}
|
||
},
|
||
error: function(xhr) {
|
||
console.error(xhr.responseText);
|
||
if (xhr.status === 400) {
|
||
let response = JSON.parse(xhr.responseText);
|
||
let errorMessages = "";
|
||
let seenMessages = []; // Array to store unique messages
|
||
if (response.errors) {
|
||
$.each(response.errors, function (field, message) {
|
||
if (!seenMessages.includes(message)) {
|
||
errorMessages += `• ${message}<br>`;
|
||
seenMessages.push(message); // Mark this message as "seen"
|
||
}
|
||
});
|
||
toastr.error(errorMessages, 'Validation Error', { "allowHtml": true });
|
||
} else {
|
||
toastr.warning(response.message || 'Validation failed', 'Warning');
|
||
}
|
||
|
||
} else if (xhr.status === 403) {
|
||
let response = JSON.parse(xhr.responseText);
|
||
toastr.error(response.message, 'Security Policy');
|
||
} else if (xhr.status === 500) {
|
||
toastr.error('Something went wrong . Please try again later.', 'Server Error');
|
||
} else {
|
||
toastr.error('An unexpected error occurred. Please try again later.', 'Error');
|
||
}
|
||
},
|
||
complete: function() {
|
||
btn.disabled = false;
|
||
btn.innerText = "Save";
|
||
}
|
||
});
|
||
}
|
||
|
||
function fetchRetailEndorsementData(id, eno, status) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
var form = document.getElementById('retailEndorsementForm');
|
||
form.reset();
|
||
|
||
$("#edit_id").val(id);
|
||
$("#endorsement_no").val(eno);
|
||
$("#edit_status").val(status);
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 200);
|
||
}
|
||
|
||
|
||
$(document).ready(function() {
|
||
|
||
nhanceListDataTableBeforeInit();
|
||
var table = $('#retail-endorsement-list-table').DataTable(nhanceMergeListDataTableOptions({
|
||
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||
"<'row'<'col-sm-12'tr>>" +
|
||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||
buttons: [
|
||
{
|
||
text: '<i class="mdi mdi-filter"></i><span class="btn-custom"> Filter </span>',
|
||
className: 'btn app-btn-primary mr-2',
|
||
action: function (e, dt, node, config) {
|
||
openRetailEndrosementFilterNav();
|
||
},
|
||
attr: {
|
||
id: 'openRetailEndrosementFilterNav'
|
||
}
|
||
},
|
||
{
|
||
extend: 'collection',
|
||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||
className: 'btn app-btn-secondary ',
|
||
buttons: [{
|
||
extend: 'csv',
|
||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||
className: 'app-btn-primary ',
|
||
title: 'Retail-Endorsement-List',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)',
|
||
format: {
|
||
body: function(data, row, column, node) {
|
||
// Convert data to string to avoid scientific notation in CSV
|
||
if (!isNaN(data) && parseFloat(data) > 1e20) {
|
||
return `'${data}`;
|
||
}
|
||
return data.toString(); // Ensures all data is treated as strings
|
||
}
|
||
}
|
||
}
|
||
}, ]
|
||
}],
|
||
initComplete: function(settings, json) {
|
||
$('.my_class').css({
|
||
"position": "relative",
|
||
"left": "15px"
|
||
});
|
||
},
|
||
language: {
|
||
search: `
|
||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||
_INPUT_
|
||
<i class="mdi mdi-magnify datatable-search-icon"
|
||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||
</div>`,
|
||
searchPlaceholder: "Search",
|
||
emptyTable: '<div class="text-center text-muted">No Data found</div>',
|
||
paginate: {
|
||
previous: '◄',
|
||
next: '►'
|
||
}
|
||
},
|
||
paging: true,
|
||
// pagingType: 'full_numbers'
|
||
columnDefs: [
|
||
<?php for ($i = 0; $i < $ret_col_count; $i++) : ?>
|
||
<?php if ($i === 0) : ?>
|
||
{ targets: 0, width: '<?= (int) $ret_col_width_px[0] ?>px', type: 'scientific' },
|
||
<?php else : ?>
|
||
{ targets: <?= $i ?>, width: '<?= (int) $ret_col_width_px[$i] ?>px' },
|
||
<?php endif; ?>
|
||
<?php endfor; ?>
|
||
],
|
||
}));
|
||
nhanceListDataTableAfterInit();
|
||
nhanceListDataTableBindAdjust(table);
|
||
|
||
function applyBottomRowDropup() {
|
||
if (!table) return;
|
||
|
||
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
|
||
$('#retail-endorsement-list-table tbody tr').removeClass('nh-force-dropup');
|
||
$('#retail-endorsement-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
|
||
|
||
// Mark last two rows on current page to open action menu upward.
|
||
const targetCount = Math.min(2, currentRows.length);
|
||
for (let i = 0; i < targetCount; i++) {
|
||
const row = currentRows[currentRows.length - 1 - i];
|
||
if (!row) continue;
|
||
$(row).addClass('nh-force-dropup');
|
||
$(row).find('td.table-action-cell .btn-group.dropdown').addClass('dropup');
|
||
}
|
||
}
|
||
|
||
applyBottomRowDropup();
|
||
$('#retail-endorsement-list-table').on('draw.dt', applyBottomRowDropup);
|
||
|
||
|
||
});
|
||
</script>
|