FIX_THE_ALIGNMENT
This commit is contained in:
parent
49c5881eba
commit
47efb8b69e
@ -1,12 +1,79 @@
|
||||
|
||||
<?php
|
||||
helper('datatable_view');
|
||||
$vd_header_labels = [
|
||||
'Date', 'Record Date', 'Unit', 'Policy', 'Endorsement No', 'Sub Type',
|
||||
'Credit', 'Debit', 'Balance', 'Description', 'User',
|
||||
];
|
||||
$vd_col_count = count($vd_header_labels);
|
||||
$vd_col_max_len = array_fill(0, $vd_col_count, 0);
|
||||
for ($i = 0; $i < $vd_col_count; $i++) {
|
||||
$vd_col_max_len[$i] = mb_strlen($vd_header_labels[$i]);
|
||||
}
|
||||
$depositdata = $depositdata ?? [];
|
||||
$subTypeOptions = $subTypeOptions ?? [];
|
||||
foreach ($depositdata as $row) {
|
||||
$vd_col_max_len[0] = max($vd_col_max_len[0], mb_strlen(date('d-M-Y h:i A', strtotime((string) $row->created_at))));
|
||||
$rec = ! empty($row->record_date) ? date('d-M-Y', strtotime((string) $row->record_date)) : '-';
|
||||
$vd_col_max_len[1] = max($vd_col_max_len[1], mb_strlen($rec));
|
||||
$vd_col_max_len[2] = max($vd_col_max_len[2], mb_strlen(trim((string) ($row->unit ?? ' - '))));
|
||||
$policyType = $row->policy_type ?? '';
|
||||
$policyNo = $row->policy_no ?? '';
|
||||
$policyCell = ($policyType || $policyNo) ? trim($policyType . ' - ' . $policyNo, ' -') : '-';
|
||||
$vd_col_max_len[3] = max($vd_col_max_len[3], mb_strlen($policyCell));
|
||||
$vd_col_max_len[4] = max($vd_col_max_len[4], mb_strlen(strip_tags((string) ($row->endorsement_no ?? '-'))));
|
||||
$subLabel = isset($subTypeOptions[$row->sub_type]) ? (string) $subTypeOptions[$row->sub_type] : '';
|
||||
$vd_col_max_len[5] = max($vd_col_max_len[5], mb_strlen($subLabel));
|
||||
$credit = ($row->transaction_type ?? '') === 'Credit' ? (string) ($row->amount ?? '-') : '-';
|
||||
$debit = ($row->transaction_type ?? '') === 'Debit' ? (string) ($row->amount ?? '-') : '-';
|
||||
$vd_col_max_len[6] = max($vd_col_max_len[6], mb_strlen($credit));
|
||||
$vd_col_max_len[7] = max($vd_col_max_len[7], mb_strlen($debit));
|
||||
$vd_col_max_len[8] = max($vd_col_max_len[8], mb_strlen((string) ($row->balance ?? '')));
|
||||
$vd_col_max_len[9] = max($vd_col_max_len[9], mb_strlen((string) ($row->description ?? '')));
|
||||
$vd_col_max_len[10] = max($vd_col_max_len[10], mb_strlen((string) ($row->username ?? '')));
|
||||
}
|
||||
$vd_col_min_px = [120, 100, 72, 160, 110, 88, 88, 88, 100, 140, 100];
|
||||
$vd_col_max_px = [200, 120, 120, 360, 160, 140, 120, 120, 140, 400, 200];
|
||||
$vd_col_width_px = nhance_dt_column_widths_px($vd_header_labels, $vd_col_max_len, $vd_col_min_px, $vd_col_max_px);
|
||||
?>
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
<?php for ($i = 0; $i < $vd_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) $vd_col_width_px[$i] ?>px;
|
||||
width: <?= (int) $vd_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) $vd_col_width_px[$i] ?>px;
|
||||
max-width: <?= (int) $vd_col_width_px[$i] ?>px;
|
||||
min-width: <?= (int) $vd_col_width_px[$i] ?>px;
|
||||
box-sizing: border-box;
|
||||
vertical-align: middle;
|
||||
}
|
||||
<?php endfor; ?>
|
||||
#scroll-horizontal-datatable tbody td {
|
||||
padding: 5px 11px !important;
|
||||
font-size: 13px;
|
||||
line-height: 1.25;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#scroll-horizontal-datatable_wrapper .dataTables_scrollHead table thead th,
|
||||
#scroll-horizontal-datatable thead th {
|
||||
padding: 5px 11px !important;
|
||||
font-size: 13px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
#scroll-horizontal-datatable_wrapper .dataTables_scrollHead table,
|
||||
#scroll-horizontal-datatable_wrapper .dataTables_scrollBody table {
|
||||
table-layout: fixed;
|
||||
width: 100% !important;
|
||||
}
|
||||
#List-page .card-body > .table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.deposit-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -123,7 +190,7 @@
|
||||
</div> -->
|
||||
|
||||
<div class="table-responsive">
|
||||
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="scroll-horizontal-datatable">
|
||||
<table data-custom-table-css="table" class="table mb-0 nowrap w-100" cellspacing="0" id="scroll-horizontal-datatable">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">Date</th>
|
||||
@ -154,11 +221,11 @@
|
||||
if ($policyType || $policyNo) {
|
||||
echo trim($policyType . ' - ' . $policyNo, ' -');
|
||||
} else {
|
||||
echo '<center> - </center>';
|
||||
echo '-';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $row->endorsement_no ?? '<center> - </center>'; ?></td>
|
||||
<td><?php echo $row->endorsement_no ?? '-'; ?></td>
|
||||
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
|
||||
</td>
|
||||
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : '-'; ?></td>
|
||||
@ -304,8 +371,8 @@
|
||||
allowInput: false,
|
||||
|
||||
});
|
||||
$('#scroll-horizontal-datatable').DataTable({
|
||||
scrollX: true,
|
||||
nhanceListDataTableBeforeInit();
|
||||
var vdDepositTable = $('#scroll-horizontal-datatable').DataTable(nhanceMergeListDataTableOptions({
|
||||
// dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
@ -400,8 +467,16 @@
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
ordering: false,
|
||||
paging: true
|
||||
});
|
||||
paging: true,
|
||||
autoWidth: false,
|
||||
columnDefs: [
|
||||
<?php for ($i = 0; $i < $vd_col_count; $i++) : ?>
|
||||
{ targets: <?= $i ?>, width: '<?= (int) $vd_col_width_px[$i] ?>px' },
|
||||
<?php endfor; ?>
|
||||
],
|
||||
}));
|
||||
nhanceListDataTableAfterInit();
|
||||
nhanceListDataTableBindAdjust(vdDepositTable);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user