nhance/app/Views/bds_renewal_report_list.php

269 lines
13 KiB
PHP

<?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 {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.column-header {
margin-right: 10px; /* Adjust this value as needed */
}
table[data-custom-table-css="table"].dataTable thead th {
padding-right: 20px !important;
}
.dataTables_length label {height: 21px !important;}
</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;">
<!-- <div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Renewal Policy List</h4>
</div>
</div> -->
<div>
<div class="table-responsive">
<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>
<div class="column-header">S.No&nbsp;</div>
</th>
<th>
<div class="column-header">Renewal Month</div>
</th>
<th>
<div class="column-header">Issuer</div>
</th>
<th>
<div class="column-header">Policy No</div>
</th>
<th>
<div class="column-header">Policy</div>
</th>
<th>
<div class="column-header">Insurer Name</div>
</th>
<th>
<div class="column-header">Insurer Branch</div>
</th>
<th>
<div class="column-header">Insured</div>
</th>
<th>
<div class="column-header">Client Type</div>
</th>
<th>
<div class="column-header">Business Type</div>
</th>
<th>
<div class="column-header">Date of Issue </div>
</th>
<th>
<div class="column-header">Policy Start Date</div>
</th>
<th>
<div class="column-header">Policy Expiry Date</div>
</th>
<th>
<div class="column-header">Vehicle No</div>
</th>
<th>
<div class="column-header">Lead Status</div>
</th>
</tr>
</thead>
<tbody>
<?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>
<td><?php echo $issuer[$row['issuer']] ?? ' - '; ?></td>
<td><?php echo $row['policy_no'] ?? ' - '; ?></td>
<td><?php echo $row['policy_type'] ?? ' - '; ?></td>
<td><?php echo $row['insurer_name'] ?? ' - '; ?></td>
<td><?php echo $row['insurer_branch_name'] ?? ' - '; ?></td>
<td><?php echo $row['client_name'] ?? ' - ' ?></td>
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>
<td><?php echo $row['revenue_type'] ?? ' - ' ?></td>
<td><?php echo empty($row['policy_issue_date']) ? '' : date('d/m/Y', strtotime($row['policy_issue_date'])); ?>
</td>
<td><?php echo empty($row['policy_start_date']) ? '' : date('d/m/Y', strtotime($row['policy_start_date'])); ?>
</td>
<td><?php echo empty($row['policy_end_date']) ? '' : date('d/m/Y', strtotime($row['policy_end_date'])); ?>
</td>
<td><?php echo $row['vehicle_no'] ?? ' - ' ?></td>
<td><?php echo ucfirst($row['lead_status'] ?? ' - ') ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#bds-renewal-report-list-table');
if (ticketsTable.length) {
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
dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'Renewal-List',
},
{
extend: 'excel',
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
title: 'Renewal-List',
sheetName: 'Renewal-List',
exportOptions: {
orthogonal: 'sort'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
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.");
}
});
// Global DataTables defaults
$.extend(true, $.fn.dataTable.defaults, {
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true,
pageLength: 10,
ordering: false
});
</script>