nhance/app/Views/irda_client_report_list.php

148 lines
5.1 KiB
PHP

<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<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;">Client Report </h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Insured</th>
<th>Policies</th>
<th>Premium</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
<?php foreach($data as $index => $row){ ?>
<tr>
<td ><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td ><?php echo $row['policy_count']; ?> </td>
<td ><?php echo $row['premium']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
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
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'IRDA-BAP-CLIENT-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'IRDA-BAP-CLIENT-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this)
.text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) +
2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex +
'"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) +
'</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
orthogonal: 'sort'
},
customizeData: function(data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// Check if the column is the 9th index (10th column)
if (j === 9) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
}
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
</script>