nhance/app/Views/bds_report_bap_wise_data.php
2025-01-23 18:57:16 +05:30

139 lines
4.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">
<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;">Employees</h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap"> <thead class="bg-light">
<tr>
<th>Insurer</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
<?php foreach($bap_wise_data as $data): ?>
<tr>
<td><?= $data['bap'] ?></td>
<td><?= $data['Policies'] ?></td>
<td><?= $data['Premium'] ?></td>
<td><?= $data['Revenue'] ?></td>
</tr>
<?php endforeach?>
</tbody>
<tfoot>
<tr>
<th>Total Amount</th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Select the table and footer cells
const table = document.querySelector("#tickets-table");
const tbody = table.querySelector("tbody");
const footer = table.querySelector("tfoot tr");
let totalPolicies = 0;
let totalPremium = 0;
let totalRevenue = 0;
// Loop through each row in the table body and accumulate totals
tbody.querySelectorAll("tr").forEach(row => {
const policies = parseInt(row.cells[1].textContent) || 0;
const premium = parseFloat(row.cells[2].textContent.replace(/[^0-9.-]+/g, "")) || 0;
const revenue = parseFloat(row.cells[3].textContent.replace(/[^0-9.-]+/g, "")) || 0;
totalPolicies += policies;
totalPremium += premium;
totalRevenue += revenue;
});
// Append totals to the footer
footer.innerHTML = `
<th>Grand Total</th>
<th>${totalPolicies}</th>
<th>${totalPremium.toFixed(2)}</th>
<th>${totalRevenue.toFixed(2)}</th>
`;
});
</script>
<script>
$(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: 'Policy-Tranction-BDS-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'Policy-Tranction-BDS-List',
exportOptions: {
orthogonal: 'sort'
},
}
],
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>