FIX_datatable = new helper + new js + new css

This commit is contained in:
sanjeev.p 2026-04-18 18:06:43 +05:30
parent 0f35747f12
commit 1263a149b5
29 changed files with 2193 additions and 158 deletions

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* Batch-list style column widths: px from max character count (same formula as batch_list.php).
*
* @param array<int, string> $headerLabels
* @param array<int, int> $maxLenPerCol Same length as $headerLabels
* @param array<int, int> $minPx
* @param array<int, int> $maxPx
* @return array<int, int>
*/
function nhance_dt_column_widths_px(array $headerLabels, array $maxLenPerCol, array $minPx, array $maxPx): array
{
$n = count($headerLabels);
$out = [];
for ($i = 0; $i < $n; $i++) {
$chars = max($maxLenPerCol[$i] ?? 0, mb_strlen($headerLabels[$i]));
$px = (int) round($chars * 7.0 + 26);
$out[] = min(
(int) ($maxPx[$i] ?? 640),
max((int) ($minPx[$i] ?? 48), $px)
);
}
return $out;
}

View File

@ -1,3 +1,27 @@
<?php
helper('datatable_view');
$aim_header_labels = [
'Advertisement Image Name', 'Client Name', 'Client Short Name', 'Status', 'Action',
];
$aim_col_count = count($aim_header_labels);
$aim_col_max_len = array_fill(0, $aim_col_count, 0);
for ($i = 0; $i < $aim_col_count; $i++) {
$aim_col_max_len[$i] = mb_strlen($aim_header_labels[$i]);
}
$addImageList = $addImageList ?? [];
foreach ($addImageList as $row) {
$aim_col_max_len[0] = max($aim_col_max_len[0], mb_strlen((string) ($row['name'] ?? '')));
$c1 = ($row['client_id'] ?? 0) != 0 ? (string) ($row['client_name'] ?? '') : '-';
$aim_col_max_len[1] = max($aim_col_max_len[1], mb_strlen($c1));
$c2 = ($row['client_id'] ?? 0) != 0 ? (string) ($row['short_name'] ?? '') : '-';
$aim_col_max_len[2] = max($aim_col_max_len[2], mb_strlen($c2));
$aim_col_max_len[3] = max($aim_col_max_len[3], mb_strlen((string) ($row['status'] ?? '')));
$aim_col_max_len[4] = max($aim_col_max_len[4], 4);
}
$aim_col_min_px = [120, 140, 120, 88, 72];
$aim_col_max_px = [400, 400, 240, 140, 88];
$aim_col_width_px = nhance_dt_column_widths_px($aim_header_labels, $aim_col_max_len, $aim_col_min_px, $aim_col_max_px);
?>
<style>
.col-12{
@ -6,6 +30,45 @@
.dataTables_length label {height: 21px !important;}
<?php for ($i = 0; $i < $aim_col_count; $i++) : ?>
#add-image-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#add-image-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $aim_col_width_px[$i] ?>px;
width: <?= (int) $aim_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#add-image-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $aim_col_width_px[$i] ?>px;
max-width: <?= (int) $aim_col_width_px[$i] ?>px;
min-width: <?= (int) $aim_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#add-image-list-table tbody td:nth-child(1),
#add-image-list-table tbody td:nth-child(2),
#add-image-list-table tbody td:nth-child(3),
#add-image-list-table tbody td:nth-child(4) {
overflow: hidden;
text-overflow: ellipsis;
}
#add-image-list-table tbody td:nth-child(5) {
overflow: visible;
text-overflow: clip;
}
#add-image-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#add-image-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="client_list">
@ -22,7 +85,7 @@
</div> -->
<!-- <table data-custom-table-css="table" class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
id="tickets-table"> -->
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="add-image-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Advertisement Image Name&nbsp;</th>
@ -338,7 +401,8 @@
$('#add_image_id').val('');
$('#client_id').val(null).trigger('change');
$('#advertise_image').val('');
table = $('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
table = $('#add-image-list-table').DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-1'f><'col-sm-11 text-right'B>>" + // Filter left, button right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
@ -372,15 +436,22 @@
next: '►'
}
},
paging: true
});
paging: true,
columnDefs: [
<?php for ($i = 0; $i < $aim_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $aim_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function applyBottomRowDropup() {
if (!table) return;
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
$('#tickets-table tbody tr').removeClass('nh-force-dropup');
$('#tickets-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#add-image-list-table tbody tr').removeClass('nh-force-dropup');
$('#add-image-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
const targetCount = Math.min(2, currentRows.length);
for (let i = 0; i < targetCount; i++) {
@ -392,7 +463,7 @@
}
applyBottomRowDropup();
$('#tickets-table').on('draw.dt', applyBottomRowDropup);
$('#add-image-list-table').on('draw.dt', applyBottomRowDropup);
});
// ✅ Define your modal function separately

View File

@ -1,3 +1,41 @@
<?php
helper('datatable_view');
$bds_header_labels = [
'S.No', 'Renewal Month', 'Issuer', 'Policy No', 'Policy', 'Insurer Name', 'Insurer Branch', 'Insured', 'Client Type', 'Business Type',
'Date of Issue', 'Policy Start Date', 'Policy Expiry Date', 'Vehicle No', 'Lead Status',
];
$bds_col_count = count($bds_header_labels);
$bds_col_max_len = array_fill(0, $bds_col_count, 0);
for ($i = 0; $i < $bds_col_count; $i++) {
$bds_col_max_len[$i] = mb_strlen($bds_header_labels[$i]);
}
$renewal_data = $renewal_data ?? [];
$issuer = $issuer ?? [];
$client_type = $client_type ?? [];
foreach ($renewal_data as $index => $row) {
$bds_col_max_len[0] = max($bds_col_max_len[0], mb_strlen((string) ($index + 1)));
$rm = empty($row['policy_end_date']) ? ' - ' : date('M-Y', strtotime((string) $row['policy_end_date']));
$bds_col_max_len[1] = max($bds_col_max_len[1], mb_strlen($rm));
$bds_col_max_len[2] = max($bds_col_max_len[2], mb_strlen((string) ($issuer[$row['issuer']] ?? ' - ')));
$bds_col_max_len[3] = max($bds_col_max_len[3], mb_strlen((string) ($row['policy_no'] ?? ' - ')));
$bds_col_max_len[4] = max($bds_col_max_len[4], mb_strlen((string) ($row['policy_type'] ?? ' - ')));
$bds_col_max_len[5] = max($bds_col_max_len[5], mb_strlen((string) ($row['insurer_name'] ?? ' - ')));
$bds_col_max_len[6] = max($bds_col_max_len[6], mb_strlen((string) ($row['insurer_branch_name'] ?? ' - ')));
$bds_col_max_len[7] = max($bds_col_max_len[7], mb_strlen((string) ($row['client_name'] ?? ' - ')));
$bds_col_max_len[8] = max($bds_col_max_len[8], mb_strlen((string) ($client_type[$row['client_type'] ?? ''] ?? '-')));
$bds_col_max_len[9] = max($bds_col_max_len[9], mb_strlen((string) ($row['revenue_type'] ?? ' - ')));
$bds_col_max_len[10] = max($bds_col_max_len[10], mb_strlen(empty($row['policy_issue_date']) ? '' : date('d/m/Y', strtotime((string) $row['policy_issue_date']))));
$bds_col_max_len[11] = max($bds_col_max_len[11], mb_strlen(empty($row['policy_start_date']) ? '' : date('d/m/Y', strtotime((string) $row['policy_start_date']))));
$bds_col_max_len[12] = max($bds_col_max_len[12], mb_strlen(empty($row['policy_end_date']) ? '' : date('d/m/Y', strtotime((string) $row['policy_end_date']))));
$bds_col_max_len[13] = max($bds_col_max_len[13], mb_strlen((string) ($row['vehicle_no'] ?? ' - ')));
$bds_col_max_len[14] = max($bds_col_max_len[14], mb_strlen((string) ucfirst((string) ($row['lead_status'] ?? ' - '))));
}
$bds_col_min_px = array_fill(0, $bds_col_count, 80);
$bds_col_min_px[0] = 48;
$bds_col_max_px = array_fill(0, $bds_col_count, 360);
$bds_col_max_px[0] = 64;
$bds_col_width_px = nhance_dt_column_widths_px($bds_header_labels, $bds_col_max_len, $bds_col_min_px, $bds_col_max_px);
?>
<style>
.table th,
.table td {
@ -18,6 +56,38 @@ table.dataTable tbody td {
</style>
<style>
<?php for ($i = 0; $i < $bds_col_count; $i++) : ?>
#bds-renewal-report-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#bds-renewal-report-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $bds_col_width_px[$i] ?>px;
width: <?= (int) $bds_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#bds-renewal-report-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $bds_col_width_px[$i] ?>px;
max-width: <?= (int) $bds_col_width_px[$i] ?>px;
min-width: <?= (int) $bds_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#bds-renewal-report-list-table tbody td {
overflow: hidden;
text-overflow: ellipsis;
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#bds-renewal-report-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="col-12" id="inception_list">
<div class="card">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
@ -28,7 +98,7 @@ table.dataTable tbody td {
</div> -->
<div>
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<table data-custom-table-css="table" data-nhance-list-dt="1" id="bds-renewal-report-list-table" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>
@ -83,7 +153,7 @@ table.dataTable tbody td {
<?php foreach($renewal_data as $index => $row) { ?>
<tr>
<td><?php echo $index+1; ?></td>
<td><?php echo empty($row['policy_end_date']) ? ' - ' : date('M-Y', strtotime($row['policy_end_date'])); ?>
<td><?php echo empty($row['policy_end_date']) ? ' - ' : date('M-Y', strtotime($row['policy_end_date'])); ?></td>
<td><?php echo $issuer[$row['issuer']] ?? ' - '; ?></td>
<td><?php echo $row['policy_no'] ?? ' - '; ?></td>
<td><?php echo $row['policy_type'] ?? ' - '; ?></td>
@ -114,11 +184,11 @@ table.dataTable tbody td {
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
var ticketsTable = $('#bds-renewal-report-list-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhBdsRenewalTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -163,7 +233,14 @@ $(document).ready(function() {
paging: true, // Enable pagination
pageLength: 20, // Set default number of rows per page (optional)
ordering: true,
});
columnDefs: [
<?php for ($i = 0; $i < $bds_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $bds_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhBdsRenewalTable);
} else {
console.error("Table atet found.");
}

View File

@ -1,3 +1,34 @@
<?php
helper('datatable_view');
$cdm_header_labels = [
'S.No', 'Client Name', 'Insurer Name', 'Insurer Branch Name', 'Opening Date', 'CD Account No', 'Opening Amount', 'Date/User', 'Action',
];
$cdm_col_count = count($cdm_header_labels);
$cdm_col_max_len = array_fill(0, $cdm_col_count, 0);
for ($i = 0; $i < $cdm_col_count; $i++) {
$cdm_col_max_len[$i] = mb_strlen($cdm_header_labels[$i]);
}
$CD_Master_Data = $CD_Master_Data ?? [];
foreach ($CD_Master_Data as $index => $row) {
$cdm_col_max_len[0] = max($cdm_col_max_len[0], mb_strlen((string) ($index + 1)));
$clientCell = ($row['client_name'] ?? '') . '( ' . ($row['short_name'] ?? '') . ' )';
$cdm_col_max_len[1] = max($cdm_col_max_len[1], mb_strlen($clientCell));
$cdm_col_max_len[2] = max($cdm_col_max_len[2], mb_strlen((string) ($row['insurer_name'] ?? '')));
$cdm_col_max_len[3] = max($cdm_col_max_len[3], mb_strlen((string) ($row['insurer_branch_name'] ?? '')));
$od = ! empty($row['opening_date']) ? date('d-m-Y', strtotime((string) $row['opening_date'])) : '';
$cdm_col_max_len[4] = max($cdm_col_max_len[4], mb_strlen($od));
$cdm_col_max_len[5] = max($cdm_col_max_len[5], mb_strlen((string) ($row['cd_ac_no'] ?? '')));
$cdm_col_max_len[6] = max($cdm_col_max_len[6], mb_strlen((string) ($row['opening_bal'] ?? '')));
$du = ! empty($row['created_at'])
? (date('d-M-Y h:i A', strtotime((string) $row['created_at'])) . ' by ' . ($row['user_name'] ?? ''))
: '';
$cdm_col_max_len[7] = max($cdm_col_max_len[7], mb_strlen($du));
$cdm_col_max_len[8] = max($cdm_col_max_len[8], 4);
}
$cdm_col_min_px = [48, 140, 120, 140, 100, 120, 100, 200, 72];
$cdm_col_max_px = [64, 400, 320, 360, 120, 200, 160, 480, 88];
$cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_len, $cdm_col_min_px, $cdm_col_max_px);
?>
<style>
.col-12 {
@ -13,6 +44,44 @@
</style>
<style>
<?php for ($i = 0; $i < $cdm_col_count; $i++) : ?>
#scroll-horizontal-datatable_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#scroll-horizontal-datatable thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $cdm_col_width_px[$i] ?>px;
width: <?= (int) $cdm_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#scroll-horizontal-datatable tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $cdm_col_width_px[$i] ?>px;
max-width: <?= (int) $cdm_col_width_px[$i] ?>px;
min-width: <?= (int) $cdm_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#scroll-horizontal-datatable tbody td:not(:last-child) {
overflow: hidden;
text-overflow: ellipsis;
}
#scroll-horizontal-datatable tbody td:last-child {
overflow: visible;
text-overflow: clip;
}
#scroll-horizontal-datatable tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#scroll-horizontal-datatable thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
@ -28,7 +97,7 @@
</div>
</div> -->
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table mb-0 nowrap" cellspacing="0">
<table data-custom-table-css="table" data-nhance-list-dt="1" id="scroll-horizontal-datatable" class="table mb-0 nowrap" cellspacing="0">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
@ -80,8 +149,8 @@
$(document).ready(function() {
var table = $('#scroll-horizontal-datatable').DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var table = $('#scroll-horizontal-datatable').DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
@ -141,7 +210,12 @@
},
paging: true,
pageLength: 10,
order: [[0, 'desc']]
order: [[0, 'desc']],
columnDefs: [
<?php for ($i = 0; $i < $cdm_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $cdm_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
// scrollX: true,
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
@ -169,7 +243,9 @@
// searchPlaceholder: "Search..."
// },
// paging: true,
});
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function applyBottomRowDropup() {
if (!table) return;

View File

@ -1,3 +1,72 @@
<?php
helper('datatable_view');
$cd_header_labels = ['Insurer Name', 'Insurer Branch Name', 'CD Account Number', 'Current Balance', 'Action'];
$cd_col_count = count($cd_header_labels);
$cd_col_max_len = array_fill(0, $cd_col_count, 0);
for ($i = 0; $i < $cd_col_count; $i++) {
$cd_col_max_len[$i] = mb_strlen($cd_header_labels[$i]);
}
$balances = $balances ?? [];
$clientData = $clientData ?? [];
foreach ($clientData as $value) {
$cd_col_max_len[0] = max($cd_col_max_len[0], mb_strlen((string) ($value->insurer_name ?? '')));
$cd_col_max_len[1] = max($cd_col_max_len[1], mb_strlen((string) ($value->insurer_branch_name ?? '')));
$cd_col_max_len[2] = max($cd_col_max_len[2], mb_strlen((string) ($value->cd_master_account_no ?? '')));
$insurerId = $value->insurer_id;
$cd_ac_pk = $value->cd_ac_pk;
$balStr = 'N/A';
if (isset($balances[$insurerId . '-' . $cd_ac_pk])) {
$balStr = (string) ($balances[$insurerId . '-' . $cd_ac_pk]->balance ?? '');
}
$balDisplay = '₹ ' . $balStr;
$cd_col_max_len[3] = max($cd_col_max_len[3], mb_strlen($balDisplay));
$cd_col_max_len[4] = max($cd_col_max_len[4], mb_strlen('View Deposit'));
}
$cd_col_min_px = [100, 120, 120, 100, 120];
$cd_col_max_px = [240, 280, 280, 200, 160];
$cd_col_width_px = nhance_dt_column_widths_px($cd_header_labels, $cd_col_max_len, $cd_col_min_px, $cd_col_max_px);
?>
<style>
<?php for ($i = 0; $i < $cd_col_count; $i++) : ?>
#client-deposit-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#client-deposit-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $cd_col_width_px[$i] ?>px;
width: <?= (int) $cd_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#client-deposit-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $cd_col_width_px[$i] ?>px;
max-width: <?= (int) $cd_col_width_px[$i] ?>px;
min-width: <?= (int) $cd_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#client-deposit-list-table tbody td:nth-child(1),
#client-deposit-list-table tbody td:nth-child(2),
#client-deposit-list-table tbody td:nth-child(3),
#client-deposit-list-table tbody td:nth-child(4) {
overflow: hidden;
text-overflow: ellipsis;
}
#client-deposit-list-table tbody td:nth-child(5) {
overflow: visible;
text-overflow: clip;
}
#client-deposit-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#client-deposit-list-table_wrapper .dataTables_scrollHead table thead th,
#client-deposit-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<script>
var pageHideMainNavTitle = true;
var pageTitle = 'Client Deposit - <?= $clientName[0]["client_name"]; ?>';
@ -22,7 +91,7 @@
</div> ->
</div> -->
<div class="table-responsive">
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="client-deposit-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Insurer Name&nbsp;</th>
@ -73,7 +142,8 @@
<script>
$(document).ready(function() {
$('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
var nhDepositTable = $('#client-deposit-list-table').DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
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>>" +
@ -118,8 +188,15 @@ $(document).ready(function() {
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
columnDefs: [
<?php for ($i = 0; $i < $cd_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $cd_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
});
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhDepositTable);
$('.dataTables_length label').css('height', '21px');
})

View File

@ -1,4 +1,23 @@
<?php
helper('datatable_view');
$client_header_labels = ['S.No', 'Client Name', 'Account Manager', 'Action'];
$client_col_count = count($client_header_labels);
$client_col_max_len = array_fill(0, $client_col_count, 0);
for ($i = 0; $i < $client_col_count; $i++) {
$client_col_max_len[$i] = mb_strlen($client_header_labels[$i]);
}
$clientList = $clientList ?? [];
foreach ($clientList as $index => $row) {
$client_col_max_len[0] = max($client_col_max_len[0], mb_strlen((string) ($index + 1)));
$nameCell = trim((string) $row->client_name) . ' ( ' . trim((string) $row->short_name) . ' ) ';
$client_col_max_len[1] = max($client_col_max_len[1], mb_strlen($nameCell));
$client_col_max_len[2] = max($client_col_max_len[2], mb_strlen((string) ($row->account_managers ?? '')));
$client_col_max_len[3] = max($client_col_max_len[3], 4);
}
$client_col_min_px = [48, 120, 100, 52];
$client_col_max_px = [64, 520, 400, 72];
$client_col_width_px = nhance_dt_column_widths_px($client_header_labels, $client_col_max_len, $client_col_min_px, $client_col_max_px);
?>
<style>
/* .table th,
.table td {
@ -67,12 +86,12 @@ table.dataTable thead th {
.dataTables_length label {height: 21px !important;}
#tickets-table .btn-group.dropdown,
#tickets-table .dropdown {
#client-list-table .btn-group.dropdown,
#client-list-table .dropdown {
position: relative;
}
#tickets-table .dropdown-menu {
#client-list-table .dropdown-menu {
z-index: 30000 !important;
max-height: 170px;
overflow-y: auto;
@ -80,10 +99,54 @@ table.dataTable thead th {
scroll-behavior: smooth;
}
#tickets-table .dropdown-menu.show {
#client-list-table .dropdown-menu.show {
z-index: 30000 !important;
}
<?php for ($i = 0; $i < $client_col_count; $i++) : ?>
#client-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#client-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $client_col_width_px[$i] ?>px;
width: <?= (int) $client_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#client-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $client_col_width_px[$i] ?>px;
max-width: <?= (int) $client_col_width_px[$i] ?>px;
min-width: <?= (int) $client_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#client-list-table tbody td:nth-child(1),
#client-list-table tbody td:nth-child(2),
#client-list-table tbody td:nth-child(3) {
overflow: hidden;
text-overflow: ellipsis;
}
#client-list-table tbody td:nth-child(4) {
overflow: visible;
text-overflow: clip;
}
#client-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#client-list-table_wrapper .dataTables_scrollHead table thead th,
#client-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#client-list-table .dropdown-toggle.btn-sm {
padding: 4px 9px !important;
font-size: 13px;
line-height: 1.2;
}
@ -104,7 +167,7 @@ table.dataTable thead th {
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add</a>
</div> -->
<!-- </div>-->
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table table-hover mb-0 nowrap w-100 m-0 table-centered" cellspacing="0" id="client-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
@ -194,7 +257,7 @@ table.dataTable thead th {
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
const table = document.getElementById("client-list-table");
// Create custom dropdown
function createCustomDropdown(row) {
@ -319,7 +382,8 @@ table.dataTable thead th {
var table;
$(document).ready(function()
{
table = $('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
table = $('#client-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'<'col-sm-5'i><'col-sm-7'p>>",
@ -378,7 +442,14 @@ $(document).ready(function()
},
paging: true ,
// pagingType: 'full_numbers'
});
columnDefs: [
<?php for ($i = 0; $i < $client_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $client_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
// $(".datatable-buttons").prepend(`
// <label class="switch">
@ -427,7 +498,7 @@ $('#toggleButtons').on('change', function() {
// Client list specific guard: keep action menu above table header
// and always show from the top (prevents first item from appearing hidden).
$(document).on('show.bs.dropdown', '#tickets-table tbody .dropdown', function () {
$(document).on('show.bs.dropdown', '#client-list-table tbody .dropdown', function () {
var $dd = $(this);
var $menu = $dd.children('.dropdown-menu');
var $row = $dd.closest('tr');
@ -453,7 +524,7 @@ $(document).on('show.bs.dropdown', '#tickets-table tbody .dropdown', function ()
}
});
$(document).on('hidden.bs.dropdown', '#tickets-table tbody .dropdown', function () {
$(document).on('hidden.bs.dropdown', '#client-list-table tbody .dropdown', function () {
var $dd = $(this);
$dd.removeClass('dropup');
$dd.children('.dropdown-menu').scrollTop(0).css('z-index', '');

View File

@ -81,7 +81,131 @@
</style>
<?php $pro_rata_total = 0; $gst_total = 0 ?>
<?php
helper('datatable_view');
$getData = $getData ?? null;
$emp_show_client_branch = isset($getData) && $getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != '' || $getData['emp_name'] != '' || $getData['status'] != '');
$emp_show_branch = isset($getData) && $getData['client_id'] != '0' && $getData['branch_id'] == '0';
$emp_header_labels = ['S.No'];
if ($emp_show_client_branch) {
$emp_header_labels[] = 'Client/Branch';
}
if ($emp_show_branch) {
$emp_header_labels[] = 'Branch';
}
$emp_header_labels = array_merge($emp_header_labels, [
'Name', 'EMP Code', 'Relationship', 'Gender', 'Email', 'Mobile', 'Date of Birth',
'Policy name', 'Insurer name', 'TPA ID', 'Risk ID', 'Policy status',
'(₹)Sum Insured', '(₹)Premium', '(₹)Pro Rata Premium', '(₹)GST', 'Action',
]);
$emp_col_count = count($emp_header_labels);
$emp_col_max_len = array_fill(0, $emp_col_count, 0);
for ($i = 0; $i < $emp_col_count; $i++) {
$emp_col_max_len[$i] = mb_strlen($emp_header_labels[$i]);
}
if (isset($employees)) {
foreach ($employees as $key => $employee) {
$ci = 0;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($key + 1)));
$ci++;
if ($emp_show_client_branch) {
$cb = ($employee['client_short_name'] ?? '') . ' - ' . ($employee['client_branch_name'] ?? '');
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen($cb));
$ci++;
}
if ($emp_show_branch) {
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['client_branch_name'] ?? '')));
$ci++;
}
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['name'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['emp_code'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['relationship'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['gender'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['email_corporate'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['mobile'] ?? '')));
$ci++;
$dobStr = '';
if (! empty($employee['dob'])) {
$dobStr = date('d/m/Y', strtotime((string) $employee['dob']));
}
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen($dobStr));
$ci++;
$polStr = (isset($employee['policy_type']) ? $employee['policy_type'] : '') . ' - ' . (isset($employee['policy_no']) ? $employee['policy_no'] : '');
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen($polStr));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['insurer_short_name'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['tpa_id'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['uhid'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) ($employee['status'] ?? '')));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) format_indian_number($employee['basic_cover_si'] ?? 0)));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) format_indian_number($employee['premium'] ?? 0)));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) format_indian_number($employee['rata_premimum'] ?? 0)));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], mb_strlen((string) format_indian_number($employee['gst'] ?? 0)));
$ci++;
$emp_col_max_len[$ci] = max($emp_col_max_len[$ci], 4);
}
}
$emp_col_max_len[$emp_col_count - 6] = max($emp_col_max_len[$emp_col_count - 6], mb_strlen('Total'));
$emp_col_min_px = array_fill(0, $emp_col_count, 80);
$emp_col_max_px = array_fill(0, $emp_col_count, 360);
$emp_col_min_px[0] = 48;
$emp_col_max_px[0] = 72;
$emp_col_min_px[$emp_col_count - 1] = 72;
$emp_col_max_px[$emp_col_count - 1] = 96;
$emp_col_width_px = nhance_dt_column_widths_px($emp_header_labels, $emp_col_max_len, $emp_col_min_px, $emp_col_max_px);
$pro_rata_total = 0;
$gst_total = 0;
?>
<style>
<?php for ($i = 0; $i < $emp_col_count; $i++) : ?>
#employee-data-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#employee-data-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $emp_col_width_px[$i] ?>px;
width: <?= (int) $emp_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#employee-data-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $emp_col_width_px[$i] ?>px;
max-width: <?= (int) $emp_col_width_px[$i] ?>px;
min-width: <?= (int) $emp_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#employee-data-list-table tbody td:not(:last-child) {
overflow: hidden;
text-overflow: ellipsis;
}
#employee-data-list-table tbody td:last-child {
overflow: visible;
text-overflow: clip;
}
#employee-data-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#employee-data-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="client_list">
<div class="col-12">
@ -92,7 +216,7 @@
<h4 style="position: relative;">Employees</h4>
</div>
</div>
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="employee-data-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
@ -347,11 +471,11 @@
})
$(document).ready(function() {
var ticketsTable = $('#tickets-table');
var ticketsTable = $('#employee-data-list-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhEmpDataTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -394,8 +518,15 @@
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 25 // Set default number of rows per page (optional)
});
pageLength: 25, // Set default number of rows per page (optional)
columnDefs: [
<?php for ($i = 0; $i < $emp_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $emp_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhEmpDataTable);
} else {
console.error("Table not found.");
}
@ -871,7 +1002,7 @@
}
$('#tickets-table tbody').on('click', 'td', function () {
$('#employee-data-list-table tbody').on('click', 'td', function () {
const colIndex = this.cellIndex;
const rowIndex = this.parentElement.rowIndex - 1; // minus header
console.log('Row:', rowIndex, 'Column:', colIndex);

View File

@ -1,3 +1,29 @@
<?php
$end_header_labels = ['S.No', 'Name/code', 'Policy name', 'Endorsement ID', 'Insurer name', 'Remarks', 'Endorsement Type', 'Status', 'Action'];
$end_col_count = count($end_header_labels);
$end_col_max_len = array_fill(0, $end_col_count, 0);
for ($i = 0; $i < $end_col_count; $i++) {
$end_col_max_len[$i] = mb_strlen($end_header_labels[$i]);
}
$employees = $employees ?? [];
foreach ($employees as $key => $employee) {
$end_col_max_len[0] = max($end_col_max_len[0], mb_strlen((string) ($key + 1)));
$end_col_max_len[1] = max($end_col_max_len[1], mb_strlen(trim((string) ($employee['name'] ?? '')) . '( ' . trim((string) ($employee['emp_code'] ?? '')) . ' )'));
$policyLine = (isset($employee['policy_type']) ? (string) $employee['policy_type'] : '') . ' - ' . (isset($employee['policy_no']) ? (string) $employee['policy_no'] : '');
$end_col_max_len[2] = max($end_col_max_len[2], mb_strlen($policyLine));
$end_col_max_len[3] = max($end_col_max_len[3], mb_strlen((string) ($employee['endorsement_id'] ?? '')));
$end_col_max_len[4] = max($end_col_max_len[4], mb_strlen((string) ($employee['insurer_short_name'] ?? '')));
$end_col_max_len[5] = max($end_col_max_len[5], mb_strlen((string) ($employee['remarks'] ?? '')));
$act = $employee['actions'] ?? '';
$actionLabel = $act === 'c' ? 'Correction' : ($act === 'si' ? 'SI Enhancement' : ($act === 'd' ? 'Deletion' : (string) $act));
$end_col_max_len[6] = max($end_col_max_len[6], mb_strlen($actionLabel));
$end_col_max_len[7] = max($end_col_max_len[7], mb_strlen((string) ($employee['status'] ?? '')));
$end_col_max_len[8] = max($end_col_max_len[8], 4);
}
$end_col_min_px = [48, 120, 160, 110, 120, 120, 120, 96, 52];
$end_col_max_px = [64, 280, 400, 200, 240, 360, 200, 160, 72];
$end_col_width_px = nhance_dt_column_widths_px($end_header_labels, $end_col_max_len, $end_col_min_px, $end_col_max_px);
?>
<style>
.table th,
.table td {
@ -61,6 +87,49 @@
flex-shrink: 0;
gap: 10px;
}
<?php for ($i = 0; $i < $end_col_count; $i++) : ?>
#endorsement-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#endorsement-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $end_col_width_px[$i] ?>px;
width: <?= (int) $end_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#endorsement-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $end_col_width_px[$i] ?>px;
max-width: <?= (int) $end_col_width_px[$i] ?>px;
min-width: <?= (int) $end_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#endorsement-list-table tbody td:nth-child(1),
#endorsement-list-table tbody td:nth-child(2),
#endorsement-list-table tbody td:nth-child(3),
#endorsement-list-table tbody td:nth-child(4),
#endorsement-list-table tbody td:nth-child(5),
#endorsement-list-table tbody td:nth-child(6),
#endorsement-list-table tbody td:nth-child(7),
#endorsement-list-table tbody td:nth-child(8) {
overflow: hidden;
text-overflow: ellipsis;
}
#endorsement-list-table tbody td:nth-child(9) {
overflow: visible;
text-overflow: clip;
}
#endorsement-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#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">
@ -124,7 +193,7 @@
</div>
</div> -->
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="endorsement-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
@ -625,7 +694,8 @@
$(document).ready(function() {
$('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
var nhEndorsementTable = $('#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'<'col-sm-5'i><'col-sm-7'p>>",
@ -689,12 +759,18 @@
},
paging: true,
// pagingType: 'full_numbers'
columnDefs: [{
type: 'scientific',
targets: 0
} // Apply custom sorting type to the first column
columnDefs: [
<?php for ($i = 0; $i < $end_col_count; $i++) : ?>
<?php if ($i === 0) : ?>
{ targets: 0, width: '<?= (int) $end_col_width_px[0] ?>px', type: 'scientific' },
<?php else : ?>
{ targets: <?= $i ?>, width: '<?= (int) $end_col_width_px[$i] ?>px' },
<?php endif; ?>
<?php endfor; ?>
],
});
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhEndorsementTable);

View File

@ -1,3 +1,28 @@
<?php
helper('datatable_view');
$ex_header_labels = ['S.No', 'Client', 'Policy No', 'Description', 'Approved By', 'Amount', 'Expense Date', 'Action'];
$ex_col_count = count($ex_header_labels);
$ex_col_max_len = array_fill(0, $ex_col_count, 0);
for ($i = 0; $i < $ex_col_count; $i++) {
$ex_col_max_len[$i] = mb_strlen($ex_header_labels[$i]);
}
$expenses = $expenses ?? [];
foreach ($expenses as $index => $row) {
$ex_col_max_len[0] = max($ex_col_max_len[0], mb_strlen((string) ($index + 1)));
$cl = ($row['client_name'] ?? '') . (! empty($row['short_name']) ? ' (' . $row['short_name'] . ')' : '');
$ex_col_max_len[1] = max($ex_col_max_len[1], mb_strlen($cl));
$ex_col_max_len[2] = max($ex_col_max_len[2], mb_strlen((string) ($row['policy_no'] ?? '')));
$ex_col_max_len[3] = max($ex_col_max_len[3], mb_strlen((string) ($row['description'] ?? '')));
$ex_col_max_len[4] = max($ex_col_max_len[4], mb_strlen((string) ($row['approved_by_name'] ?? '')));
$ex_col_max_len[5] = max($ex_col_max_len[5], mb_strlen(number_format((float) ($row['amount'] ?? 0), 2)));
$ed = ! empty($row['expense_date']) ? date('d-m-Y', strtotime((string) $row['expense_date'])) : '';
$ex_col_max_len[6] = max($ex_col_max_len[6], mb_strlen($ed));
$ex_col_max_len[7] = max($ex_col_max_len[7], 4);
}
$ex_col_min_px = [48, 140, 120, 160, 120, 96, 110, 72];
$ex_col_max_px = [64, 360, 280, 400, 240, 140, 140, 88];
$ex_col_width_px = nhance_dt_column_widths_px($ex_header_labels, $ex_col_max_len, $ex_col_min_px, $ex_col_max_px);
?>
<style>
.truncate {
@ -30,6 +55,50 @@
</style>
<style>
<?php for ($i = 0; $i < $ex_col_count; $i++) : ?>
#expense-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#expense-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $ex_col_width_px[$i] ?>px;
width: <?= (int) $ex_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#expense-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $ex_col_width_px[$i] ?>px;
max-width: <?= (int) $ex_col_width_px[$i] ?>px;
min-width: <?= (int) $ex_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#expense-table tbody td:nth-child(1),
#expense-table tbody td:nth-child(2),
#expense-table tbody td:nth-child(3),
#expense-table tbody td:nth-child(4),
#expense-table tbody td:nth-child(5),
#expense-table tbody td:nth-child(6),
#expense-table tbody td:nth-child(7) {
overflow: hidden;
text-overflow: ellipsis;
}
#expense-table tbody td:nth-child(8) {
overflow: visible;
text-overflow: clip;
}
#expense-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#expense-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="expense_module">
<div class="col-12">
<div class="card">
@ -494,8 +563,8 @@
maxDate: new Date(),
});
$('#expense-table').DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhExpenseTable = $('#expense-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>>",
@ -569,8 +638,15 @@
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
}
});
},
columnDefs: [
<?php for ($i = 0; $i < $ex_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $ex_col_width_px[$i] ?>px' },
<?php endfor; ?>
]
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhExpenseTable);
$('.dataTables_length label').css('height', '21px');

View File

@ -34,12 +34,80 @@
</style>
<?php
helper('datatable_view');
$faq_header_labels = ['S.No.', 'Category', 'Question', 'Status', 'Action'];
$faq_col_count = count($faq_header_labels);
$faq_col_max_len = array_fill(0, $faq_col_count, 0);
for ($i = 0; $i < $faq_col_count; $i++) {
$faq_col_max_len[$i] = mb_strlen($faq_header_labels[$i]);
}
$faq_list_rows = $faq_list ?? [];
$faq_sl = 0;
foreach ($faq_list_rows as $row) {
++$faq_sl;
$faq_col_max_len[0] = max($faq_col_max_len[0], mb_strlen((string) $faq_sl));
$category = $row['category'] ? $row['category'] : 'N/A';
$catDisp = (strlen($category) > 50) ? substr($category, 0, 50) . '...' : $category;
$faq_col_max_len[1] = max($faq_col_max_len[1], mb_strlen($catDisp));
$question_text = $row['question'] ? strip_tags($row['question']) : 'N/A';
$qDisp = (strlen($question_text) > 50) ? substr($question_text, 0, 50) . '...' : $question_text;
$faq_col_max_len[2] = max($faq_col_max_len[2], mb_strlen($qDisp));
$faq_st = (isset($row['is_active']) && (int) $row['is_active'] === 1) ? 'Active' : 'In-Active';
$faq_col_max_len[3] = max($faq_col_max_len[3], mb_strlen($faq_st));
$faq_col_max_len[4] = max($faq_col_max_len[4], 4);
}
$faq_col_min_px = [48, 100, 200, 88, 72];
$faq_col_max_px = [64, 280, 480, 120, 88];
$faq_col_width_px = nhance_dt_column_widths_px($faq_header_labels, $faq_col_max_len, $faq_col_min_px, $faq_col_max_px);
?>
<style>
<?php for ($i = 0; $i < $faq_col_count; $i++) : ?>
#faq-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#faq-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $faq_col_width_px[$i] ?>px;
width: <?= (int) $faq_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#faq-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $faq_col_width_px[$i] ?>px;
max-width: <?= (int) $faq_col_width_px[$i] ?>px;
min-width: <?= (int) $faq_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#faq-list-table tbody td:nth-child(1),
#faq-list-table tbody td:nth-child(2),
#faq-list-table tbody td:nth-child(3),
#faq-list-table tbody td:nth-child(4) {
overflow: hidden;
text-overflow: ellipsis;
}
#faq-list-table tbody td:nth-child(5) {
overflow: visible;
text-overflow: clip;
}
#faq-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#faq-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="user-table">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="faq-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.&nbsp;</th>
@ -223,9 +291,9 @@
$('#answer').parsley().validate();
});
var ticketsTable = $('#user-table');
var table = ticketsTable.DataTable({
scrollX: true,
var ticketsTable = $('#faq-list-table');
nhanceListDataTableBeforeInit();
var table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -276,7 +344,14 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $faq_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $faq_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function placeActionDropdown($toggle) {
const $group = $toggle.closest('.btn-group.dropdown');
@ -297,7 +372,7 @@
}
}
$('#user-table').on('show.bs.dropdown', '.table-action-cell .dropdown-toggle', function () {
$('#faq-list-table').on('show.bs.dropdown', '.table-action-cell .dropdown-toggle', function () {
const $toggle = $(this);
const $scrollBody = $toggle.closest('.dataTables_scrollBody');
@ -309,7 +384,7 @@
placeActionDropdown($toggle);
});
$('#user-table').on('hide.bs.dropdown', '.table-action-cell .dropdown-toggle', function () {
$('#faq-list-table').on('hide.bs.dropdown', '.table-action-cell .dropdown-toggle', function () {
const $scrollBody = $(this).closest('.dataTables_scrollBody');
const prevOverflowY = $scrollBody.data('prev-overflow-y');
if ($scrollBody.length) {
@ -318,7 +393,7 @@
});
ticketsTable.on('draw.dt', function () {
$('#user-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#faq-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
});
});

View File

@ -1,8 +1,72 @@
<?php
helper('datatable_view');
$fec_header_labels = ['S.No.', 'Type', 'Content Section', 'Heading', 'Status', 'Action'];
$fec_col_count = count($fec_header_labels);
$fec_col_max_len = array_fill(0, $fec_col_count, 0);
for ($i = 0; $i < $fec_col_count; $i++) {
$fec_col_max_len[$i] = mb_strlen($fec_header_labels[$i]);
}
$fec_rows = $data['fe_list'] ?? [];
$fec_sl = 0;
foreach ($fec_rows as $row) {
++$fec_sl;
$fec_col_max_len[0] = max($fec_col_max_len[0], mb_strlen((string) $fec_sl));
$fec_col_max_len[1] = max($fec_col_max_len[1], mb_strlen((string) ($row['type'] ?? '')));
$fec_col_max_len[2] = max($fec_col_max_len[2], mb_strlen((string) ($row['content_section'] ?? '')));
$fec_col_max_len[3] = max($fec_col_max_len[3], mb_strlen((string) ($row['heading'] ?? '')));
$fec_st = (isset($row['is_active']) && (int) $row['is_active'] === 1) ? 'Active' : 'In-Active';
$fec_col_max_len[4] = max($fec_col_max_len[4], mb_strlen($fec_st));
$fec_col_max_len[5] = max($fec_col_max_len[5], 4);
}
$fec_col_min_px = [48, 88, 120, 140, 88, 72];
$fec_col_max_px = [64, 200, 360, 480, 120, 88];
$fec_col_width_px = nhance_dt_column_widths_px($fec_header_labels, $fec_col_max_len, $fec_col_min_px, $fec_col_max_px);
?>
<style>
.col-12 {
max-width: 98% !important;
}
.dataTables_length label {height: 21px !important;}
<?php for ($i = 0; $i < $fec_col_count; $i++) : ?>
#frontend-content-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#frontend-content-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $fec_col_width_px[$i] ?>px;
width: <?= (int) $fec_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#frontend-content-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $fec_col_width_px[$i] ?>px;
max-width: <?= (int) $fec_col_width_px[$i] ?>px;
min-width: <?= (int) $fec_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#frontend-content-list-table tbody td:nth-child(1),
#frontend-content-list-table tbody td:nth-child(2),
#frontend-content-list-table tbody td:nth-child(3),
#frontend-content-list-table tbody td:nth-child(4),
#frontend-content-list-table tbody td:nth-child(5) {
overflow: hidden;
text-overflow: ellipsis;
}
#frontend-content-list-table tbody td:nth-child(6) {
overflow: visible;
text-overflow: clip;
}
#frontend-content-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#frontend-content-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -10,7 +74,7 @@
<div class="col-12">
<div class="card">
<div class="card-body">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="user-table">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="frontend-content-list-table">
<thead class="bg-light">
<tr>
<!-- `content` `notes` -->
@ -268,9 +332,9 @@
$('#notes').parsley().validate();
});
var ticketsTable = $('#user-table');
table = ticketsTable.DataTable({
scrollX: true,
var ticketsTable = $('#frontend-content-list-table');
nhanceListDataTableBeforeInit();
table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -322,14 +386,21 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $fec_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $fec_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function applyBottomRowDropup() {
if (!table) return;
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
$('#user-table tbody tr').removeClass('nh-force-dropup');
$('#user-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#frontend-content-list-table tbody tr').removeClass('nh-force-dropup');
$('#frontend-content-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
const targetCount = Math.min(2, currentRows.length);
for (let i = 0; i < targetCount; i++) {
@ -340,7 +411,7 @@
}
}
applyBottomRowDropup();
$('#user-table').on('draw.dt', applyBottomRowDropup);
$('#frontend-content-list-table').on('draw.dt', applyBottomRowDropup);
});
$('.close').click(function(){ resetValues(); })
@ -691,7 +762,7 @@
</script>
<!-- <script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("user-table");
const table = document.getElementById("frontend-content-list-table");
// Create custom dropdown
function createCustomDropdown(row) {

View File

@ -1,3 +1,30 @@
<?php
helper('datatable_view');
$hr_header_labels = ['S.No', 'File name', 'Client', 'Client Branch', 'Policy', 'Event', 'User/Time', 'Status', 'Action'];
$hr_col_count = count($hr_header_labels);
$hr_col_max_len = array_fill(0, $hr_col_count, 0);
for ($i = 0; $i < $hr_col_count; $i++) {
$hr_col_max_len[$i] = mb_strlen($hr_header_labels[$i]);
}
$fileList = $fileList ?? [];
foreach ($fileList as $key => $file) {
$hr_col_max_len[0] = max($hr_col_max_len[0], mb_strlen((string) ($key + 1)));
$hr_col_max_len[1] = max($hr_col_max_len[1], mb_strlen((string) ($file['file_name'] ?? '')));
$hr_col_max_len[2] = max($hr_col_max_len[2], mb_strlen((string) ($file['short_name'] ?? '')));
$hr_col_max_len[3] = max($hr_col_max_len[3], mb_strlen((string) ($file['branch_name'] ?? '')));
$hr_col_max_len[4] = max($hr_col_max_len[4], mb_strlen((string) ($file['policy_no'] ?? '')));
$hr_col_max_len[5] = max($hr_col_max_len[5], mb_strlen((string) ($file['file_action'] ?? '')));
$userTimePlain = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd M Y h:i A')
. ' by '
. (string) ($file['first_name'] ?? '');
$hr_col_max_len[6] = max($hr_col_max_len[6], mb_strlen($userTimePlain));
$hr_col_max_len[7] = max($hr_col_max_len[7], mb_strlen((string) ($file['status'] ?? '')));
$hr_col_max_len[8] = max($hr_col_max_len[8], 4);
}
$hr_col_min_px = [48, 120, 88, 96, 120, 88, 200, 96, 52];
$hr_col_max_px = [64, 480, 240, 240, 360, 200, 520, 200, 72];
$hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len, $hr_col_min_px, $hr_col_max_px);
?>
<style>
.table th,
.table td {
@ -53,6 +80,39 @@
background-color: #e0e0e0;
}
<?php for ($i = 0; $i < $hr_col_count; $i++) : ?>
#hr_tickets_table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#hr_tickets_table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $hr_col_width_px[$i] ?>px;
width: <?= (int) $hr_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#hr_tickets_table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $hr_col_width_px[$i] ?>px;
max-width: <?= (int) $hr_col_width_px[$i] ?>px;
min-width: <?= (int) $hr_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#hr_tickets_table tbody td:nth-child(1),
#hr_tickets_table tbody td:nth-child(2),
#hr_tickets_table tbody td:nth-child(3),
#hr_tickets_table tbody td:nth-child(4),
#hr_tickets_table tbody td:nth-child(5),
#hr_tickets_table tbody td:nth-child(6),
#hr_tickets_table tbody td:nth-child(7),
#hr_tickets_table tbody td:nth-child(8) {
overflow: hidden;
text-overflow: ellipsis;
}
#hr_tickets_table tbody td:nth-child(9) {
overflow: visible;
text-overflow: clip;
}
</style>
<div class="tab-pane fade" id="HR-DOC-tab">
@ -439,9 +499,8 @@
if (window.hrFileTableInstance) {
return;
}
window.hrFileTableInstance = $('#hr_tickets_table').DataTable({
scrollX: false,
autoWidth: false,
nhanceListDataTableBeforeInit();
window.hrFileTableInstance = $('#hr_tickets_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'<'col-sm-5'i><'col-sm-7'p>>",
@ -480,7 +539,14 @@
},
paging: true,
ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $hr_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $hr_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(window.hrFileTableInstance);
$('.dataTables_filter input').css({
'background': '#F0F0F0',
'border': 'none',

View File

@ -1,3 +1,31 @@
<?php
helper('datatable_view');
$isl_header_labels = [' ', 'Insurer', 'Month', 'Statement sno', 'Filename', 'Line items', 'File status', 'Invoice status', 'User/Time', 'Action'];
$isl_col_count = count($isl_header_labels);
$isl_col_max_len = array_fill(0, $isl_col_count, 0);
for ($i = 0; $i < $isl_col_count; $i++) {
$isl_col_max_len[$i] = mb_strlen($isl_header_labels[$i]);
}
$insurer_statement_list = $insurer_statement_list ?? [];
$invoice_status_array = $invoice_status_array ?? [];
foreach ($insurer_statement_list as $row) {
$isl_col_max_len[0] = max($isl_col_max_len[0], 2);
$isl_col_max_len[1] = max($isl_col_max_len[1], mb_strlen((string) (($row['short_name'] ?? '') . '-' . ($row['branch_code'] ?? ''))));
$isl_col_max_len[2] = max($isl_col_max_len[2], mb_strlen((string) change_date_format($row['month'] ?? '', 'Y-m-d', 'M-Y')));
$isl_col_max_len[3] = max($isl_col_max_len[3], mb_strlen((string) ($row['stmt_sno'] ?? '')));
$isl_col_max_len[4] = max($isl_col_max_len[4], mb_strlen((string) ($row['file_name'] ?? '')));
$isl_col_max_len[5] = max($isl_col_max_len[5], mb_strlen((string) ($row['line_items'] ?? '')));
$isl_col_max_len[6] = max($isl_col_max_len[6], mb_strlen((string) ($row['file_status'] ?? '')));
$invLabel = isset($invoice_status_array[$row['invoice_status'] ?? '']) ? (string) $invoice_status_array[$row['invoice_status']] : ' - ';
$isl_col_max_len[7] = max($isl_col_max_len[7], mb_strlen($invLabel));
$ut = change_date_format($row['created_at'] ?? '', 'Y-m-d H:i:s', 'd M Y h:i A') . ' by ' . ($row['first_name'] ?? '');
$isl_col_max_len[8] = max($isl_col_max_len[8], mb_strlen($ut));
$isl_col_max_len[9] = max($isl_col_max_len[9], 4);
}
$isl_col_min_px = [40, 120, 88, 88, 120, 72, 88, 120, 200, 72];
$isl_col_max_px = [56, 320, 120, 140, 480, 120, 160, 200, 560, 88];
$isl_col_width_px = nhance_dt_column_widths_px($isl_header_labels, $isl_col_max_len, $isl_col_min_px, $isl_col_max_px);
?>
<style>
.table th,
.table td {
@ -179,6 +207,52 @@
}
</style>
<style>
<?php for ($i = 0; $i < $isl_col_count; $i++) : ?>
#insurer-statement-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#insurer-statement-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $isl_col_width_px[$i] ?>px;
width: <?= (int) $isl_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#insurer-statement-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $isl_col_width_px[$i] ?>px;
max-width: <?= (int) $isl_col_width_px[$i] ?>px;
min-width: <?= (int) $isl_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#insurer-statement-list-table tbody td:nth-child(1),
#insurer-statement-list-table tbody td:nth-child(2),
#insurer-statement-list-table tbody td:nth-child(3),
#insurer-statement-list-table tbody td:nth-child(4),
#insurer-statement-list-table tbody td:nth-child(5),
#insurer-statement-list-table tbody td:nth-child(6),
#insurer-statement-list-table tbody td:nth-child(7),
#insurer-statement-list-table tbody td:nth-child(8),
#insurer-statement-list-table tbody td:nth-child(9) {
overflow: hidden;
text-overflow: ellipsis;
}
#insurer-statement-list-table tbody td:nth-child(10) {
overflow: visible;
text-overflow: clip;
}
#insurer-statement-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#insurer-statement-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 class="row" id="inception_list">
@ -187,7 +261,7 @@
<div class="card-body">
<div class="table-responsive">
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table table-striped mb-0 nowrap" cellspacing="0" id="insurer-statement-list-table">
<thead class="bg-light">
<tr>
<th class="no-sort"></th>
@ -540,7 +614,7 @@
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("tickets-table");
const table = document.getElementById("insurer-statement-list-table");
// Create custom dropdown
function createCustomDropdown(row) {
@ -1773,7 +1847,8 @@
// Initialize DataTable
// Change Comment: Added dom and buttons properties to arrange search, switch, and upload button on a single line, similar to client_list.php.
const table = $('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
const table = $('#insurer-statement-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>>",
@ -1803,8 +1878,15 @@
`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
}
});
},
columnDefs: [
<?php for ($i = 0; $i < $isl_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $isl_col_width_px[$i] ?>px' },
<?php endfor; ?>
]
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
// Change Comment: Prepending the 'Failed Status' switch to the DataTable's button container to group it with other controls.
$(".datatable-buttons").prepend(`

View File

@ -56,12 +56,17 @@ table.dataTable tbody td { padding: 4px 4px !important; }
</style>
<script>
var pageHideMainNavTitle = true;
var pageTitle = 'Invoice Details';
var pageBackButton = '<a href="javascript:void(0);" onclick="history.back();" class="topbar-icon-btn" title="Back"><i class="ri-arrow-left-s-line"></i></a>';
</script>
<!-- ---- HTML structure remains mostly same ---- -->
<div class="row" id="invoices_details">
<div class="row mt-3" id="invoices_details" style="margin-top:42px !important;">
<div class="col-12">
<div id="invoices_accordion" class="ml-3">
<div class="card mb-1">
<h4 class="m-1">
<!-- <h4 class="m-1">
<a href="#" onclick="history.back(); return false;">
<i style="font-size: 18px;" class="mdi mdi-chevron-left" title="Back"></i>
</a>
@ -70,7 +75,7 @@ table.dataTable tbody td { padding: 4px 4px !important; }
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h4>
</h4> -->
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#invoices_accordion">
<div class="card-body" style="padding-bottom: unset;">

View File

@ -1,3 +1,22 @@
<?php
helper('datatable_view');
$kyc_header_labels = ['Name', 'Action'];
$kyc_col_count = count($kyc_header_labels);
$kyc_col_max_len = array_fill(0, $kyc_col_count, 0);
for ($i = 0; $i < $kyc_col_count; $i++) {
$kyc_col_max_len[$i] = mb_strlen($kyc_header_labels[$i]);
}
$kycList = $kycList ?? [];
if (is_array($kycList)) {
foreach ($kycList as $row) {
$kyc_col_max_len[0] = max($kyc_col_max_len[0], mb_strlen((string) ($row['name'] ?? '')));
$kyc_col_max_len[1] = max($kyc_col_max_len[1], 4);
}
}
$kyc_col_min_px = [160, 72];
$kyc_col_max_px = [480, 88];
$kyc_col_width_px = nhance_dt_column_widths_px($kyc_header_labels, $kyc_col_max_len, $kyc_col_min_px, $kyc_col_max_px);
?>
<style>
.custom-dropdown-menu {
@ -40,6 +59,44 @@
}
.dataTables_length label {height: 21px !important;}
</style>
<style>
<?php for ($i = 0; $i < $kyc_col_count; $i++) : ?>
#kyc-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#kyc-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $kyc_col_width_px[$i] ?>px;
width: <?= (int) $kyc_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#kyc-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $kyc_col_width_px[$i] ?>px;
max-width: <?= (int) $kyc_col_width_px[$i] ?>px;
min-width: <?= (int) $kyc_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#kyc-list-table tbody td:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
#kyc-list-table tbody td:last-child {
overflow: visible;
text-overflow: clip;
}
#kyc-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#kyc-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="kyc_list">
<div class="col-12">
<div class="card">
@ -50,7 +107,7 @@
</div>
</div> -->
<table data-custom-table-css="table" class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
id="tickets-table">
id="kyc-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Name</th>
@ -83,7 +140,7 @@
<!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
const table = document.getElementById("kyc-list-table");
// Create custom dropdown
function createCustomDropdown(row) {
@ -174,7 +231,8 @@
$(document).ready(function(){
$('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
var nhKycTable = $('#kyc-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>>" +
@ -221,12 +279,19 @@
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true ,
});
columnDefs: [
<?php for ($i = 0; $i < $kyc_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $kyc_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhKycTable);
})
const btnExport = document.querySelector("#btnExport");
const tableElement = document.querySelector("#tickets-table");
const tableElement = document.querySelector("#kyc-list-table");
btnExport.addEventListener("click", () => {
const obj = new csvExport(tableElement);

View File

@ -100,11 +100,17 @@
var $ = jQuery;
// Global defaults for all list pages unless overridden in a specific view.
// Use horizontal scroll (scrollX) instead of Responsive (+/- child rows).
// scrollY + scrollCollapse split thead/tbody and misalign columns vs headers (see batch_list).
// Wide tables: rely on .table-responsive; set scrollX: true on a page only if required.
$.extend(true, $.fn.dataTable.defaults, {
scrollX: true,
scrollY: '55vh',
scrollCollapse: true,
scrollX: false,
scrollY: false,
scrollCollapse: false,
bScrollCollapse: false,
/* Hungarian names — copied into oScroll before the wrapper is built (preInit.dt is too late). */
sScrollX: "",
sScrollY: "",
sScrollXInner: "",
autoWidth: false,
pageLength: 10,
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
@ -116,7 +122,9 @@
}
});
// Per-table init can still pass responsive: true; force off so every list uses scrollX, not +/- rows.
// responsive: false for all tables (row-collapse mode off).
// Note: preInit.dt runs *after* pb() in DT 1.10.x, so it cannot disable scroll split; use sScrollX/sScrollY
// in defaults + nhanceMergeListDataTableOptions instead.
$(document).on('preInit.dt', function (e, settings) {
if (settings && settings.oInit) {
settings.oInit.responsive = false;
@ -181,6 +189,9 @@
})();
</script>
<!-- Shared list DataTable helpers (batch_list-style: scroll/align/columns.adjust) -->
<script src="<?= base_url() . "public"; ?>/assets/js/pages/nhance-list-datatable.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/moment/min/moment.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-daterangepicker/daterangepicker.js"></script>

View File

@ -1,3 +1,55 @@
<?php
helper('datatable_view');
/* Column widths from max data length (same approach as batch_list.php → stable TH/TD alignment). */
$leads_header_labels = [
'S.No', 'Opportunity Type', 'Issuer', 'Client Type', 'Client / Branch',
'Entity Type', 'Branch Name', 'Branch Code', 'Contact Person Name', 'Contact Person Mobile',
'Policy Type', 'Status', 'Action',
];
$leads_col_count = count($leads_header_labels);
$leads_col_max_len = array_fill(0, $leads_col_count, 0);
for ($i = 0; $i < $leads_col_count; $i++) {
$leads_col_max_len[$i] = mb_strlen($leads_header_labels[$i]);
}
$lead_type = $lead_type ?? [];
$issuer = $issuer ?? [];
$client_type = $client_type ?? [];
$lead_status = $lead_status ?? [];
$lead_data_list = $lead_data_list ?? [];
if (! empty($lead_data_list) && is_array($lead_data_list)) {
foreach ($lead_data_list as $index => $row) {
$leads_col_max_len[0] = max($leads_col_max_len[0], mb_strlen((string) ($index + 1)));
$leads_col_max_len[1] = max($leads_col_max_len[1], mb_strlen((string) ($lead_type[$row['lead_type'] ?? ''] ?? '-')));
$leads_col_max_len[2] = max($leads_col_max_len[2], mb_strlen((string) ($issuer[$row['issuer'] ?? ''] ?? '-')));
$leads_col_max_len[3] = max($leads_col_max_len[3], mb_strlen((string) ($client_type[$row['client_type'] ?? ''] ?? '-')));
$clientBranch = (isset($row['client_type']) && (int) $row['client_type'] === 2)
? (string) ($row['client_name'] ?? '-')
: (string) (($row['client_short_name'] ?? '-') . ' - ' . ($row['branch_name'] ?? '-'));
$leads_col_max_len[4] = max($leads_col_max_len[4], mb_strlen($clientBranch));
$leads_col_max_len[5] = max($leads_col_max_len[5], mb_strlen((string) ($row['entity_type'] ?? '-')));
$leads_col_max_len[6] = max($leads_col_max_len[6], mb_strlen((string) ($row['branch_name'] ?? '-')));
$leads_col_max_len[7] = max($leads_col_max_len[7], mb_strlen((string) ($row['branch_code'] ?? '-')));
$leads_col_max_len[8] = max($leads_col_max_len[8], mb_strlen((string) ($row['contact_person_name'] ?? '-')));
$leads_col_max_len[9] = max($leads_col_max_len[9], mb_strlen((string) ($row['contact_person_mobile'] ?? '-')));
$leads_col_max_len[10] = max($leads_col_max_len[10], mb_strlen((string) ($row['policy_type'] ?? '-')));
$leads_col_max_len[11] = max($leads_col_max_len[11], mb_strlen((string) ($lead_status[$row['status'] ?? ''] ?? '-')));
$leads_col_max_len[12] = max($leads_col_max_len[12], 4);
}
}
$leads_col_min_px = [48, 72, 88, 72, 120, 88, 96, 72, 120, 100, 120, 96, 52];
$leads_col_max_px = [64, 220, 180, 140, 520, 200, 240, 120, 280, 130, 280, 200, 72];
$leads_col_width_px = [];
for ($i = 0; $i < $leads_col_count; $i++) {
$chars = max($leads_col_max_len[$i], mb_strlen($leads_header_labels[$i]));
$px = (int) round($chars * 7.0 + 26);
$leads_col_width_px[$i] = min(
$leads_col_max_px[$i],
max($leads_col_min_px[$i], $px)
);
}
?>
<style>
.col-12 {
max-width: 98% !important;
@ -116,6 +168,60 @@
.table-responsive {
overflow-x: auto !important;
}
/* Opportunities table: column widths from PHP (batch_list.php pattern) */
<?php for ($i = 0; $i < $leads_col_count; $i++) : ?>
#leads-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#leads-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $leads_col_width_px[$i] ?>px;
width: <?= (int) $leads_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#leads-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $leads_col_width_px[$i] ?>px;
max-width: <?= (int) $leads_col_width_px[$i] ?>px;
min-width: <?= (int) $leads_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#leads-list-table tbody td:nth-child(1),
#leads-list-table tbody td:nth-child(2),
#leads-list-table tbody td:nth-child(3),
#leads-list-table tbody td:nth-child(4),
#leads-list-table tbody td:nth-child(5),
#leads-list-table tbody td:nth-child(6),
#leads-list-table tbody td:nth-child(7),
#leads-list-table tbody td:nth-child(8),
#leads-list-table tbody td:nth-child(9),
#leads-list-table tbody td:nth-child(10),
#leads-list-table tbody td:nth-child(11),
#leads-list-table tbody td:nth-child(12) {
overflow: hidden;
text-overflow: ellipsis;
}
#leads-list-table tbody td:nth-child(13) {
overflow: visible;
text-overflow: clip;
}
#leads-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#leads-list-table_wrapper .dataTables_scrollHead table thead th,
#leads-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#leads-list-table .dropdown-toggle.btn-sm {
padding: 4px 9px !important;
font-size: 13px;
line-height: 1.2;
}
</style>
@ -134,7 +240,7 @@
</div>
<div>
<div class="table-responsive">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="tickets-table">
<table data-custom-table-css="table" class="table table-hover mb-0 nowrap w-100 table-centered m-0" cellspacing="0" id="leads-list-table">
<thead class="bg-light">
<tr>
@ -716,10 +822,11 @@
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#tickets-table');
var ticketsTable = $('#leads-list-table');
if (ticketsTable.length) {
table = ticketsTable.DataTable({
nhanceListDataTableBeforeInit();
table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -778,14 +885,21 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $leads_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $leads_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function applyBottomRowDropup() {
if (!table) return;
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
$('#tickets-table tbody tr').removeClass('nh-force-dropup');
$('#tickets-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#leads-list-table tbody tr').removeClass('nh-force-dropup');
$('#leads-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
const targetCount = Math.min(2, currentRows.length);
for (let i = 0; i < targetCount; i++) {

View File

@ -1,8 +1,66 @@
<?php
helper('datatable_view');
$nb_header_labels = ['S.No.', 'Branch Name', 'Action'];
$nb_col_count = count($nb_header_labels);
$nb_col_max_len = array_fill(0, $nb_col_count, 0);
for ($i = 0; $i < $nb_col_count; $i++) {
$nb_col_max_len[$i] = mb_strlen($nb_header_labels[$i]);
}
if (isset($data) && is_array($data)) {
$nb_sl = 0;
foreach ($data as $row) {
++$nb_sl;
$nb_col_max_len[0] = max($nb_col_max_len[0], mb_strlen((string) $nb_sl));
$nb_col_max_len[1] = max($nb_col_max_len[1], mb_strlen((string) ($row['branch_name'] ?? '')));
$nb_col_max_len[2] = max($nb_col_max_len[2], 4);
}
}
$nb_col_min_px = [48, 140, 72];
$nb_col_max_px = [64, 400, 88];
$nb_col_width_px = nhance_dt_column_widths_px($nb_header_labels, $nb_col_max_len, $nb_col_min_px, $nb_col_max_px);
?>
<style>
.dataTables_filter {
position: absolute;
}
.dataTables_length label {height: 21px !important;}
<?php for ($i = 0; $i < $nb_col_count; $i++) : ?>
#nhance-branch-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#nhance-branch-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $nb_col_width_px[$i] ?>px;
width: <?= (int) $nb_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#nhance-branch-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $nb_col_width_px[$i] ?>px;
max-width: <?= (int) $nb_col_width_px[$i] ?>px;
min-width: <?= (int) $nb_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#nhance-branch-list-table tbody td:nth-child(1),
#nhance-branch-list-table tbody td:nth-child(2) {
overflow: hidden;
text-overflow: ellipsis;
}
#nhance-branch-list-table tbody td:nth-child(3) {
overflow: visible;
text-overflow: clip;
}
#nhance-branch-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#nhance-branch-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -10,7 +68,7 @@
<div class="col-12">
<div class="card">
<div class="card-body">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="nhance-branch-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
@ -96,9 +154,9 @@
<script>
var table;
$(document).ready(function () {
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
var ticketsTable = $('#nhance-branch-list-table');
nhanceListDataTableBeforeInit();
table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -146,7 +204,14 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $nb_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $nb_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
});
$('.close').click(function(){

View File

@ -1,3 +1,34 @@
<?php
helper('datatable_view');
$or_header_labels = [
'S.No', 'Insurer', 'Insurer Branch', 'Statement Month', 'Statement No', 'Invoice No', 'Invoice Status',
'Invoice Date', 'Invoice Amount', 'Realization Amount', 'Outstanding Amount',
];
$or_col_count = count($or_header_labels);
$or_col_max_len = array_fill(0, $or_col_count, 0);
for ($i = 0; $i < $or_col_count; $i++) {
$or_col_max_len[$i] = mb_strlen($or_header_labels[$i]);
}
$outstanting_list = $outstanting_list ?? [];
foreach ($outstanting_list as $index => $row) {
$or_col_max_len[0] = max($or_col_max_len[0], mb_strlen((string) ($index + 1)));
$or_col_max_len[1] = max($or_col_max_len[1], mb_strlen((string) ($row['short_name'] ?? '')));
$or_col_max_len[2] = max($or_col_max_len[2], mb_strlen((string) ($row['branch_name'] ?? '')));
$or_col_max_len[3] = max($or_col_max_len[3], mb_strlen((string) change_date_format($row['month'] ?? '', 'Y-m-d', 'Y-m')));
$or_col_max_len[4] = max($or_col_max_len[4], mb_strlen((string) ($row['stmt_sno'] ?? '')));
$or_col_max_len[5] = max($or_col_max_len[5], mb_strlen((string) ($row['invoice_no'] ?? '')));
$or_col_max_len[6] = max($or_col_max_len[6], mb_strlen((string) (isset($row['invoice_status']) ? $row['invoice_status'] : ' - ')));
$or_col_max_len[7] = max($or_col_max_len[7], mb_strlen((string) change_date_format($row['invoice_date'] ?? '', 'Y-m-d', 'd-M-Y')));
$or_col_max_len[8] = max($or_col_max_len[8], mb_strlen((string) (isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00')));
$or_col_max_len[9] = max($or_col_max_len[9], mb_strlen((string) (isset($row['total_paid']) ? $row['total_paid'] : '0.00')));
$or_col_max_len[10] = max($or_col_max_len[10], mb_strlen((string) (isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00')));
}
$or_col_min_px = array_fill(0, $or_col_count, 88);
$or_col_min_px[0] = 48;
$or_col_max_px = array_fill(0, $or_col_count, 360);
$or_col_max_px[0] = 64;
$or_col_width_px = nhance_dt_column_widths_px($or_header_labels, $or_col_max_len, $or_col_min_px, $or_col_max_px);
?>
<style>
.table th,
.table td {
@ -84,6 +115,38 @@
}
</style>
<style>
<?php for ($i = 0; $i < $or_col_count; $i++) : ?>
#outstanding-report-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#outstanding-report-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $or_col_width_px[$i] ?>px;
width: <?= (int) $or_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#outstanding-report-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $or_col_width_px[$i] ?>px;
max-width: <?= (int) $or_col_width_px[$i] ?>px;
min-width: <?= (int) $or_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#outstanding-report-list-table tbody td {
overflow: hidden;
text-overflow: ellipsis;
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#outstanding-report-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">
@ -140,15 +203,17 @@
<div class="col-12" id="outstanding_list">
<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;">Outstanding Report</h4>
</div>
</div>
-->
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" >
<table data-custom-table-css="table" data-nhance-list-dt="1" id="outstanding-report-list-table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" >
<thead class="bg-light">
<tr>
<th><div class="column-header">S.No</div></th>
@ -210,11 +275,11 @@
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
var ticketsTable = $('#outstanding-report-list-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhOutstandingTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -290,8 +355,15 @@
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 25 // Set default number of rows per page (optional)
});
pageLength: 25, // Set default number of rows per page (optional)
columnDefs: [
<?php for ($i = 0; $i < $or_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $or_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhOutstandingTable);
} else {
console.error("Table not found.");
}

View File

@ -1,3 +1,26 @@
<?php
helper('datatable_view');
$pt_header_labels = ['Policy Type', 'Policy Long Name', 'BAP', 'Category', 'BAP Category', 'Action'];
$pt_col_count = count($pt_header_labels);
$pt_col_max_len = array_fill(0, $pt_col_count, 0);
for ($i = 0; $i < $pt_col_count; $i++) {
$pt_col_max_len[$i] = mb_strlen($pt_header_labels[$i]);
}
$policyList = $policyList ?? [];
if (is_array($policyList)) {
foreach ($policyList as $row) {
$pt_col_max_len[0] = max($pt_col_max_len[0], mb_strlen((string) ($row['policy_type'] ?: 'N/A')));
$pt_col_max_len[1] = max($pt_col_max_len[1], mb_strlen((string) ($row['long_name'] ?: 'N/A')));
$pt_col_max_len[2] = max($pt_col_max_len[2], mb_strlen((string) ($row['bap'] ?: 'N/A')));
$pt_col_max_len[3] = max($pt_col_max_len[3], mb_strlen((string) ($row['allocg'] ?: 'N/A')));
$pt_col_max_len[4] = max($pt_col_max_len[4], mb_strlen((string) ($row['alloci'] ?: 'N/A')));
$pt_col_max_len[5] = max($pt_col_max_len[5], 4);
}
}
$pt_col_min_px = [100, 140, 72, 100, 100, 72];
$pt_col_max_px = [240, 480, 120, 200, 200, 88];
$pt_col_width_px = nhance_dt_column_widths_px($pt_header_labels, $pt_col_max_len, $pt_col_min_px, $pt_col_max_px);
?>
<style>
.custom-dropdown-menu {
display: none;
@ -68,6 +91,48 @@
.dataTables_length label {height: 21px !important;}
</style>
<style>
<?php for ($i = 0; $i < $pt_col_count; $i++) : ?>
#policy-type-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#policy-type-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $pt_col_width_px[$i] ?>px;
width: <?= (int) $pt_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#policy-type-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $pt_col_width_px[$i] ?>px;
max-width: <?= (int) $pt_col_width_px[$i] ?>px;
min-width: <?= (int) $pt_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#policy-type-list-table tbody td:nth-child(1),
#policy-type-list-table tbody td:nth-child(2),
#policy-type-list-table tbody td:nth-child(3),
#policy-type-list-table tbody td:nth-child(4),
#policy-type-list-table tbody td:nth-child(5) {
overflow: hidden;
text-overflow: ellipsis;
}
#policy-type-list-table tbody td:nth-child(6) {
overflow: visible;
text-overflow: clip;
}
#policy-type-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#policy-type-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 class="row" id="policy_list">
<div class="col-12">
@ -87,7 +152,7 @@
</div>
</div> -->
<table data-custom-table-css="table" class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
id="tickets-table">
id="policy-type-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Policy Type</th>
@ -131,7 +196,7 @@
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("tickets-table");
const table = document.getElementById("policy-type-list-table");
// Create custom dropdown
function createCustomDropdown(row) {
@ -217,7 +282,8 @@
<script>
$(document).ready(function(){
$('#tickets-table').DataTable({
nhanceListDataTableBeforeInit();
var nhPolicyTypeTable = $('#policy-type-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'<'col-sm-5'i><'col-sm-7'p>>",
@ -267,13 +333,20 @@
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true ,
columnDefs: [
<?php for ($i = 0; $i < $pt_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $pt_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
});
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhPolicyTypeTable);
})
const btnExport = document.querySelector("#btnExport");
const tableElement = document.querySelector("#tickets-table");
const tableElement = document.querySelector("#policy-type-list-table");
btnExport.addEventListener("click", () => {
const obj = new csvExport(tableElement);

View File

@ -1,3 +1,29 @@
<?php
helper('datatable_view');
$pos_header_labels = ['S.No.', 'Manager', 'POS Name', 'POS Code', 'Email', 'Mobile', 'Status', 'Action'];
$pos_col_count = count($pos_header_labels);
$pos_col_max_len = array_fill(0, $pos_col_count, 0);
for ($i = 0; $i < $pos_col_count; $i++) {
$pos_col_max_len[$i] = mb_strlen($pos_header_labels[$i]);
}
$pos_list_rows = $data['pos_list'] ?? [];
$pos_sl = 0;
foreach ($pos_list_rows as $row) {
++$pos_sl;
$pos_col_max_len[0] = max($pos_col_max_len[0], mb_strlen((string) $pos_sl));
$pos_col_max_len[1] = max($pos_col_max_len[1], mb_strlen((string) ($row['manager_name'] ?? '')));
$pos_col_max_len[2] = max($pos_col_max_len[2], mb_strlen((string) ($row['name'] ?? '')));
$pos_col_max_len[3] = max($pos_col_max_len[3], mb_strlen((string) ($row['pos_code'] ?? '')));
$pos_col_max_len[4] = max($pos_col_max_len[4], mb_strlen((string) ($row['email'] ?? '')));
$pos_col_max_len[5] = max($pos_col_max_len[5], mb_strlen((string) ($row['mobile'] ?? '')));
$pos_status_txt = (isset($row['is_active']) && (int) $row['is_active'] === 1) ? 'Active' : 'In-Active';
$pos_col_max_len[6] = max($pos_col_max_len[6], mb_strlen($pos_status_txt));
$pos_col_max_len[7] = max($pos_col_max_len[7], 4);
}
$pos_col_min_px = [48, 96, 120, 96, 180, 100, 88, 72];
$pos_col_max_px = [64, 240, 280, 160, 360, 140, 120, 88];
$pos_col_width_px = nhance_dt_column_widths_px($pos_header_labels, $pos_col_max_len, $pos_col_min_px, $pos_col_max_px);
?>
<style>
.dataTables_filter {
position: absolute;
@ -29,6 +55,38 @@
color: #16181b !important;
cursor: pointer !important;
}
<?php for ($i = 0; $i < $pos_col_count; $i++) : ?>
#pos-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#pos-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $pos_col_width_px[$i] ?>px;
width: <?= (int) $pos_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#pos-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $pos_col_width_px[$i] ?>px;
max-width: <?= (int) $pos_col_width_px[$i] ?>px;
min-width: <?= (int) $pos_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#pos-list-table tbody td:nth-child(1),
#pos-list-table tbody td:nth-child(2),
#pos-list-table tbody td:nth-child(3),
#pos-list-table tbody td:nth-child(4),
#pos-list-table tbody td:nth-child(5),
#pos-list-table tbody td:nth-child(6),
#pos-list-table tbody td:nth-child(7) {
overflow: hidden;
text-overflow: ellipsis;
}
#pos-list-table tbody td:nth-child(8) {
overflow: visible;
text-overflow: clip;
}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -36,7 +94,7 @@
<div class="col-12">
<div class="card">
<div class="card-body">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="pos-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
@ -232,9 +290,9 @@
var table;
$(document).ready(function () {
$('#manager_id').select2();
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
var ticketsTable = $('#pos-list-table');
nhanceListDataTableBeforeInit();
table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -282,7 +340,14 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $pos_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $pos_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
});
$('.close').click(function(){
@ -534,7 +599,7 @@
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("user-table");
const table = document.getElementById("pos-list-table");
// Create custom dropdown
function createCustomDropdown(row) {

View File

@ -40,12 +40,14 @@ table.dataTable tbody td {
<div class="col-12" id="second_page">
<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;">BDS Report <span id="bds_title"></span></h4>
</div>
</div>
-->
<div class="table-responsive">
<div id="totals" class="d-flex flex-wrap gap-2 mb-2">

View File

@ -1,3 +1,46 @@
<?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 {
@ -77,6 +120,51 @@
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">
@ -138,7 +226,7 @@
<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="tickets-table">
<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&nbsp;</th>
@ -405,8 +493,8 @@
$(document).ready(function() {
var table = $('#tickets-table').DataTable({
scrollX: true,
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>>",
@ -469,19 +557,25 @@
},
paging: true,
// pagingType: 'full_numbers'
columnDefs: [{
type: 'scientific',
targets: 0
} // Apply custom sorting type to the first column
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();
$('#tickets-table tbody tr').removeClass('nh-force-dropup');
$('#tickets-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#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);
@ -494,7 +588,7 @@
}
applyBottomRowDropup();
$('#tickets-table').on('draw.dt', applyBottomRowDropup);
$('#retail-endorsement-list-table').on('draw.dt', applyBottomRowDropup);
});

View File

@ -1,6 +1,68 @@
<?php
helper('datatable_view');
$rto_header_labels = ['S.No.', 'RTO Office at', 'RTO Code', 'RTO State', 'Action'];
$rto_col_count = count($rto_header_labels);
$rto_col_max_len = array_fill(0, $rto_col_count, 0);
for ($i = 0; $i < $rto_col_count; $i++) {
$rto_col_max_len[$i] = mb_strlen($rto_header_labels[$i]);
}
if (isset($data) && is_array($data)) {
$rto_sl = 0;
foreach ($data as $row) {
++$rto_sl;
$rto_col_max_len[0] = max($rto_col_max_len[0], mb_strlen((string) $rto_sl));
$rto_col_max_len[1] = max($rto_col_max_len[1], mb_strlen((string) ($row['rto_name'] ?? '')));
$rto_col_max_len[2] = max($rto_col_max_len[2], mb_strlen((string) ($row['rto_code'] ?? '')));
$rto_col_max_len[3] = max($rto_col_max_len[3], mb_strlen((string) ($row['rto_state'] ?? '')));
$rto_col_max_len[4] = max($rto_col_max_len[4], 4);
}
}
$rto_col_min_px = [48, 140, 88, 120, 72];
$rto_col_max_px = [64, 400, 120, 200, 88];
$rto_col_width_px = nhance_dt_column_widths_px($rto_header_labels, $rto_col_max_len, $rto_col_min_px, $rto_col_max_px);
?>
<style>
.dataTables_filter {position: absolute;}
.dataTables_length label {height: 21px !important;}
<?php for ($i = 0; $i < $rto_col_count; $i++) : ?>
#rto-master-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#rto-master-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $rto_col_width_px[$i] ?>px;
width: <?= (int) $rto_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#rto-master-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $rto_col_width_px[$i] ?>px;
max-width: <?= (int) $rto_col_width_px[$i] ?>px;
min-width: <?= (int) $rto_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#rto-master-list-table tbody td:nth-child(1),
#rto-master-list-table tbody td:nth-child(2),
#rto-master-list-table tbody td:nth-child(3),
#rto-master-list-table tbody td:nth-child(4) {
overflow: hidden;
text-overflow: ellipsis;
}
#rto-master-list-table tbody td:nth-child(5) {
overflow: visible;
text-overflow: clip;
}
#rto-master-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#rto-master-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<!-- End ADD and EDIT Page HTML -->
@ -8,7 +70,7 @@
<div class="col-12">
<div class="card">
<div class="card-body">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="rto-master-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
@ -129,9 +191,9 @@
<script>
var table;
$(document).ready(function () {
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
var ticketsTable = $('#rto-master-list-table');
nhanceListDataTableBeforeInit();
table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -179,7 +241,14 @@
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
columnDefs: [
<?php for ($i = 0; $i < $rto_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $rto_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
});
$('.close').click(function(){

View File

@ -1,3 +1,50 @@
<?php
helper('datatable_view');
$thz_header_labels = [
'Ticket ID', 'Name', 'Policy Number', 'Ticket Type', 'Subject', 'Status', 'Assign To', 'Created At', 'Updated At',
];
$thz_col_count = count($thz_header_labels);
$thz_col_max_len = array_fill(0, $thz_col_count, 0);
for ($i = 0; $i < $thz_col_count; $i++) {
$thz_col_max_len[$i] = mb_strlen($thz_header_labels[$i]);
}
$ticket_data = $ticket_data ?? [];
foreach ($ticket_data as $row) {
$thz_col_max_len[0] = max($thz_col_max_len[0], mb_strlen((string) ($row['thz_id'] ?? '')));
$namePlain = (string) ($row['name'] ?? '');
if (! empty($row['empcode'])) {
$namePlain .= ' (' . $row['empcode'] . ')';
}
if (! empty($row['mobile'])) {
$namePlain .= ' ' . $row['mobile'];
}
$thz_col_max_len[1] = max($thz_col_max_len[1], mb_strlen($namePlain));
$pol = (! empty($row['policy_no']) && strtolower((string) $row['policy_no']) !== 'null') ? (string) $row['policy_no'] : 'N/A';
$thz_col_max_len[2] = max($thz_col_max_len[2], mb_strlen($pol));
$tt = $row['ticket_type'] ? (string) $row['ticket_type'] : 'N/A';
$thz_col_max_len[3] = max($thz_col_max_len[3], mb_strlen($tt));
$subject = $row['subject'] ? (string) $row['subject'] : 'N/A';
$subDisp = (strlen($subject) > 18) ? substr($subject, 0, 18) . '...' : $subject;
$thz_col_max_len[4] = max($thz_col_max_len[4], mb_strlen($subDisp));
$st = $row['status'] ? (string) $row['status'] : 'N/A';
$thz_col_max_len[5] = max($thz_col_max_len[5], mb_strlen($st));
$as = $row['assignee_name'] ? (string) $row['assignee_name'] : 'N/A';
$thz_col_max_len[6] = max($thz_col_max_len[6], mb_strlen($as));
$cr = '';
if (! empty($row['created_at'])) {
$cr = date('j M Y', strtotime((string) $row['created_at'])) . ' ' . date('h:i A', strtotime((string) $row['created_at']));
}
$thz_col_max_len[7] = max($thz_col_max_len[7], mb_strlen($cr));
$ur = '';
if (! empty($row['updated_at'])) {
$ur = date('j M Y', strtotime((string) $row['updated_at'])) . ' ' . date('h:i A', strtotime((string) $row['updated_at']));
}
$thz_col_max_len[8] = max($thz_col_max_len[8], mb_strlen($ur));
}
$thz_col_min_px = [72, 160, 120, 100, 120, 88, 120, 140, 140];
$thz_col_max_px = [120, 360, 280, 220, 400, 160, 280, 220, 220];
$thz_col_width_px = nhance_dt_column_widths_px($thz_header_labels, $thz_col_max_len, $thz_col_min_px, $thz_col_max_px);
?>
<style>
.table th,
.table td {
@ -51,6 +98,48 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why
</style>
<style>
<?php for ($i = 0; $i < $thz_col_count; $i++) : ?>
#thz-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#thz-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $thz_col_width_px[$i] ?>px;
width: <?= (int) $thz_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#thz-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $thz_col_width_px[$i] ?>px;
max-width: <?= (int) $thz_col_width_px[$i] ?>px;
min-width: <?= (int) $thz_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#thz-table tbody td:nth-child(1),
#thz-table tbody td:nth-child(2),
#thz-table tbody td:nth-child(3),
#thz-table tbody td:nth-child(4),
#thz-table tbody td:nth-child(5),
#thz-table tbody td:nth-child(6),
#thz-table tbody td:nth-child(7),
#thz-table tbody td:nth-child(8),
#thz-table tbody td:nth-child(9) {
overflow: hidden;
text-overflow: ellipsis;
}
#thz-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#thz-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="ticket_list">
<div class="col-12">
<div class="card">
@ -340,8 +429,8 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why
var ticketsTable = $('#thz-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhThzTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -395,8 +484,15 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why
},
paging: true,
pageLength: 10,
order: [[0, 'desc']]
});
order: [[0, 'desc']],
columnDefs: [
<?php for ($i = 0; $i < $thz_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $thz_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhThzTable);
} else {
console.error("Table not found.");
}

View File

@ -1,3 +1,37 @@
<?php
helper('datatable_view');
$vr_header_labels = [
'S.No', 'Client', 'Client Branch', 'Insurer', 'Insurer Branch', 'Policy Type', 'Policy No', 'Endorsement No',
'Premium', 'Statement Premium', 'Premium Variance', 'Expected Amount', 'Statement Amount', 'Variance',
];
$vr_col_count = count($vr_header_labels);
$vr_col_max_len = array_fill(0, $vr_col_count, 0);
for ($i = 0; $i < $vr_col_count; $i++) {
$vr_col_max_len[$i] = mb_strlen($vr_header_labels[$i]);
}
$varience_list = $varience_list ?? [];
foreach ($varience_list as $index => $row) {
$vr_col_max_len[0] = max($vr_col_max_len[0], mb_strlen((string) ($index + 1)));
$vr_col_max_len[1] = max($vr_col_max_len[1], mb_strlen((string) ($row['client_name'] ?? '')));
$vr_col_max_len[2] = max($vr_col_max_len[2], mb_strlen((string) ($row['client_branch_name'] ?? '')));
$vr_col_max_len[3] = max($vr_col_max_len[3], mb_strlen((string) ($row['insurer_name'] ?? '')));
$vr_col_max_len[4] = max($vr_col_max_len[4], mb_strlen((string) ($row['insurer_branch_name'] ?? '')));
$vr_col_max_len[5] = max($vr_col_max_len[5], mb_strlen((string) ($row['policy_type'] ?? '')));
$vr_col_max_len[6] = max($vr_col_max_len[6], mb_strlen((string) ($row['policy_no'] ?? '')));
$vr_col_max_len[7] = max($vr_col_max_len[7], mb_strlen((string) ($row['endorsement_no'] ?? '')));
$vr_col_max_len[8] = max($vr_col_max_len[8], mb_strlen((string) ($row['original_premium'] ?? '')));
$vr_col_max_len[9] = max($vr_col_max_len[9], mb_strlen((string) (isset($row['statement_premium']) ? $row['statement_premium'] : '0.00')));
$vr_col_max_len[10] = max($vr_col_max_len[10], mb_strlen((string) ($row['premium_variance_amt'] ?? '')));
$vr_col_max_len[11] = max($vr_col_max_len[11], mb_strlen((string) ($row['exp_amt'] ?? '')));
$vr_col_max_len[12] = max($vr_col_max_len[12], mb_strlen((string) (isset($row['statement_amount']) ? $row['statement_amount'] : '0.00')));
$vr_col_max_len[13] = max($vr_col_max_len[13], mb_strlen((string) (isset($row['variance_amt']) ? $row['variance_amt'] : '0.00')));
}
$vr_col_min_px = array_fill(0, $vr_col_count, 88);
$vr_col_min_px[0] = 48;
$vr_col_max_px = array_fill(0, $vr_col_count, 360);
$vr_col_max_px[0] = 64;
$vr_col_width_px = nhance_dt_column_widths_px($vr_header_labels, $vr_col_max_len, $vr_col_min_px, $vr_col_max_px);
?>
<style>
.table th,
.table td {
@ -168,6 +202,38 @@
.dataTables_length label {height: 21px !important;}
</style>
<style>
<?php for ($i = 0; $i < $vr_col_count; $i++) : ?>
#variance-report-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#variance-report-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $vr_col_width_px[$i] ?>px;
width: <?= (int) $vr_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#variance-report-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $vr_col_width_px[$i] ?>px;
max-width: <?= (int) $vr_col_width_px[$i] ?>px;
min-width: <?= (int) $vr_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#variance-report-list-table tbody td {
overflow: hidden;
text-overflow: ellipsis;
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#variance-report-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">
@ -278,14 +344,16 @@
<div class="col-12" id="varience_list">
<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;">Variance Report</h4>
</div>
</div>
-->
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<table data-custom-table-css="table" data-nhance-list-dt="1" id="variance-report-list-table" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No&nbsp;&nbsp;&nbsp;&nbsp;</th>
@ -357,10 +425,10 @@
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
var ticketsTable = $('#variance-report-list-table');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var nhVarianceTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
@ -432,8 +500,15 @@
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 25 // Set default number of rows per page (optional)
});
pageLength: 25, // Set default number of rows per page (optional)
columnDefs: [
<?php for ($i = 0; $i < $vr_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $vr_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhVarianceTable);
} else {
console.error("Table not found.");
}

View File

@ -31,6 +31,71 @@
</style>
<?php
helper('datatable_view');
$vm_header_labels = [
'S.No', 'Owner Type', 'Owner Name', 'RC Book No', 'Vehicle No', 'Vehicle type', 'Description', 'Action',
];
$vm_col_count = count($vm_header_labels);
$vm_col_max_len = array_fill(0, $vm_col_count, 0);
for ($i = 0; $i < $vm_col_count; $i++) {
$vm_col_max_len[$i] = mb_strlen($vm_header_labels[$i]);
}
$vehicle_Master_Data = $vehicle_Master_Data ?? [];
$vehicle_des = $vehicle_des ?? [];
foreach ($vehicle_Master_Data as $index => $row) {
$vm_col_max_len[0] = max($vm_col_max_len[0], mb_strlen((string) ($index + 1)));
$vm_col_max_len[1] = max($vm_col_max_len[1], mb_strlen((string) ($row['owner_type'] ?: 'N/A')));
$vm_col_max_len[2] = max($vm_col_max_len[2], mb_strlen((string) ($row['owner_name'] ?: 'N/A')));
$vm_col_max_len[3] = max($vm_col_max_len[3], mb_strlen((string) ($row['rc'] ?: 'N/A')));
$vm_col_max_len[4] = max($vm_col_max_len[4], mb_strlen((string) ($row['vehicle_no'] ?: 'N/A')));
$vm_col_max_len[5] = max($vm_col_max_len[5], mb_strlen((string) ($row['vehicle_type'] ?: 'N/A')));
$descLabel = $vehicle_des[$row['description']] ?? 'N/A';
$vm_col_max_len[6] = max($vm_col_max_len[6], mb_strlen((string) $descLabel));
$vm_col_max_len[7] = max($vm_col_max_len[7], 4);
}
$vm_col_min_px = [48, 88, 120, 100, 100, 100, 120, 72];
$vm_col_max_px = [64, 160, 280, 180, 180, 200, 320, 88];
$vm_col_width_px = nhance_dt_column_widths_px($vm_header_labels, $vm_col_max_len, $vm_col_min_px, $vm_col_max_px);
?>
<style>
<?php for ($i = 0; $i < $vm_col_count; $i++) : ?>
#scroll-horizontal-datatable_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#scroll-horizontal-datatable thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $vm_col_width_px[$i] ?>px;
width: <?= (int) $vm_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#scroll-horizontal-datatable tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $vm_col_width_px[$i] ?>px;
max-width: <?= (int) $vm_col_width_px[$i] ?>px;
min-width: <?= (int) $vm_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#scroll-horizontal-datatable tbody td:not(:last-child) {
overflow: hidden;
text-overflow: ellipsis;
}
#scroll-horizontal-datatable tbody td:last-child {
overflow: visible;
text-overflow: clip;
}
#scroll-horizontal-datatable tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#scroll-horizontal-datatable thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
@ -40,7 +105,7 @@
<h4 style="position: relative;">Vehicle Master</h4>
</div>
</div> -->
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table mb-0 nowrap" cellspacing="0">
<table data-custom-table-css="table" data-nhance-list-dt="1" id="scroll-horizontal-datatable" class="table mb-0 nowrap" cellspacing="0">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No&nbsp;</th>
@ -338,8 +403,8 @@ $(document).ready(function() {
var table = $('#scroll-horizontal-datatable');
if (table.length) {
var dataTable = table.DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
var dataTable = 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'<'col-sm-5'i><'col-sm-7'p>>",
@ -400,8 +465,15 @@ $(document).ready(function() {
},
paging: true,
pageLength: 10,
order: [[0, 'desc']]
});
order: [[0, 'desc']],
columnDefs: [
<?php for ($i = 0; $i < $vm_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $vm_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(dataTable);
function applyBottomRowDropup() {
if (!dataTable) return;

View File

@ -1,3 +1,25 @@
<?php
helper('datatable_view');
$vt_header_labels = ['Name', 'Email', 'Mobile No', 'Role', 'Status', 'Action'];
$vt_col_count = count($vt_header_labels);
$vt_col_max_len = array_fill(0, $vt_col_count, 0);
for ($i = 0; $i < $vt_col_count; $i++) {
$vt_col_max_len[$i] = mb_strlen($vt_header_labels[$i]);
}
$UserList = $UserList ?? [];
foreach ($UserList as $row) {
$vt_col_max_len[0] = max($vt_col_max_len[0], mb_strlen((string) ($row->first_name ?? '')));
$vt_col_max_len[1] = max($vt_col_max_len[1], mb_strlen((string) ($row->email ?? '')));
$vt_col_max_len[2] = max($vt_col_max_len[2], mb_strlen((string) ($row->mobile ?? '')));
$vt_col_max_len[3] = max($vt_col_max_len[3], mb_strlen((string) ($row->user_role ?? '')));
$vt_st = (isset($row->is_active) && (int) $row->is_active === 1) ? 'Active' : 'In-Active';
$vt_col_max_len[4] = max($vt_col_max_len[4], mb_strlen($vt_st));
$vt_col_max_len[5] = max($vt_col_max_len[5], 4);
}
$vt_col_min_px = [120, 180, 100, 120, 88, 72];
$vt_col_max_px = [280, 360, 140, 240, 120, 88];
$vt_col_width_px = nhance_dt_column_widths_px($vt_header_labels, $vt_col_max_len, $vt_col_min_px, $vt_col_max_px);
?>
<style>
/* body {
font-family: Arial, sans-serif;
@ -209,7 +231,7 @@
grid-template-columns: 1fr .4fr .5fr .2fr;
}
#user-table_filter input{ width:100%; }
#vehicle-type-list-table_filter input{ width:100%; }
button.dt-button,
button.dt-button:focus,
@ -298,6 +320,46 @@
}
.dataTables_length label {height: 21px !important;}
<?php for ($i = 0; $i < $vt_col_count; $i++) : ?>
#vehicle-type-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#vehicle-type-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $vt_col_width_px[$i] ?>px;
width: <?= (int) $vt_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#vehicle-type-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $vt_col_width_px[$i] ?>px;
max-width: <?= (int) $vt_col_width_px[$i] ?>px;
min-width: <?= (int) $vt_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#vehicle-type-list-table tbody td:nth-child(1),
#vehicle-type-list-table tbody td:nth-child(2),
#vehicle-type-list-table tbody td:nth-child(3),
#vehicle-type-list-table tbody td:nth-child(4),
#vehicle-type-list-table tbody td:nth-child(5) {
overflow: hidden;
text-overflow: ellipsis;
}
#vehicle-type-list-table tbody td:nth-child(6) {
overflow: visible;
text-overflow: clip;
}
#vehicle-type-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#vehicle-type-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
@ -311,7 +373,7 @@
<h4 style="position: relative;">Users</h4>
</div>
</div> -->
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="user-table">
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="vehicle-type-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.&nbsp;</th>
@ -759,8 +821,8 @@
allowInput: false,
});
table = $('#user-table').DataTable({
scrollX: true,
nhanceListDataTableBeforeInit();
table = $('#vehicle-type-list-table').DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-3'f><'col-sm-9'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
@ -854,7 +916,12 @@
}
],
paging: true,
pageLength: 10,
pageLength: 10,
columnDefs: [
<?php for ($i = 0; $i < $vt_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $vt_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
@ -892,14 +959,16 @@
loadPartner();
});
}
});
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table);
function applyBottomRowDropup() {
if (!table) return;
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
$('#user-table tbody tr').removeClass('nh-force-dropup');
$('#user-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
$('#vehicle-type-list-table tbody tr').removeClass('nh-force-dropup');
$('#vehicle-type-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);
@ -911,7 +980,7 @@
}
}
applyBottomRowDropup();
$('#user-table').on('draw.dt', applyBottomRowDropup);
$('#vehicle-type-list-table').on('draw.dt', applyBottomRowDropup);
$('#team').multiselect({

View File

@ -0,0 +1,111 @@
/**
* Shared list DataTable behavior (aligned with batch_list.php):
* - Temporarily neutralize scroll defaults during init
* - Force scrollX/Y/Collapse off, autoWidth/responsive false
* - Sync horizontal scroll between scrollHead and scrollBody when present
* - columns.adjust on draw, resize, and after first paint
*/
(function (window, $) {
"use strict";
if (typeof $ === "undefined" || !$ || !$.fn || !$.fn.DataTable) {
return;
}
var _savedDefaults = null;
window.nhanceListDataTableBeforeInit = function () {
_savedDefaults = {
scrollX: $.fn.dataTable.defaults.scrollX,
scrollY: $.fn.dataTable.defaults.scrollY,
scrollCollapse: $.fn.dataTable.defaults.scrollCollapse,
bScrollCollapse: $.fn.dataTable.defaults.bScrollCollapse,
sScrollX: $.fn.dataTable.defaults.sScrollX,
sScrollY: $.fn.dataTable.defaults.sScrollY,
sScrollXInner: $.fn.dataTable.defaults.sScrollXInner,
};
$.extend($.fn.dataTable.defaults, {
scrollX: false,
scrollY: false,
scrollCollapse: false,
bScrollCollapse: false,
sScrollX: "",
sScrollY: "",
sScrollXInner: "",
});
};
window.nhanceListDataTableAfterInit = function () {
if (_savedDefaults) {
$.extend($.fn.dataTable.defaults, _savedDefaults);
_savedDefaults = null;
}
};
window.nhanceListDataTableBaseInitComplete = function () {
return function () {
var api = this.api();
var $wrap = $(api.table().container());
var $body = $wrap.find(".dataTables_scrollBody");
var $head = $wrap.find(".dataTables_scrollHead");
if ($body.length && $head.length) {
$body.off("scroll.nhanceListHScroll").on("scroll.nhanceListHScroll", function () {
$head.scrollLeft($(this).scrollLeft());
});
$head.off("scroll.nhanceListHScroll").on("scroll.nhanceListHScroll", function () {
$body.scrollLeft($(this).scrollLeft());
});
}
};
};
/**
* Merge page-specific DataTable options with batch_list-style list defaults.
* User initComplete runs after base scroll sync.
*/
window.nhanceMergeListDataTableOptions = function (userOptions) {
userOptions = userOptions || {};
var userInit = userOptions.initComplete;
var merged = $.extend(true, {}, userOptions);
/* DataTables maps these to oScroll *before* pb()/tb() runs. CamelCase alone is not enough if
sScrollX/sScrollY were set via defaults, Hungarian options, or truthy strings. */
merged.scrollX = false;
merged.scrollY = false;
merged.scrollCollapse = false;
merged.sScrollX = "";
merged.sScrollY = "";
merged.sScrollXInner = "";
merged.bScrollCollapse = false;
merged.autoWidth = false;
merged.responsive = false;
if (merged.paging === undefined) {
merged.paging = true;
}
var baseInit = window.nhanceListDataTableBaseInitComplete();
merged.initComplete = function () {
baseInit.call(this);
if (typeof userInit === "function") {
userInit.call(this);
}
};
return merged;
};
window.nhanceListDataTableBindAdjust = function (dtApi) {
if (!dtApi || !dtApi.on) {
return;
}
var tid = $(dtApi.table().node()).attr("id") || "nhance_dt";
var resizeNs = "resize.nhanceListDt_" + tid;
dtApi.columns.adjust();
dtApi.on("draw.dt", function () {
dtApi.columns.adjust();
});
$(window).off(resizeNs).on(resizeNs, function () {
dtApi.columns.adjust();
});
setTimeout(function () {
dtApi.columns.adjust();
}, 0);
};
})(window, jQuery);