@@ -172,47 +204,9 @@ $(document).ready(function() {
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 = '
' +
- 'Total' + // Insert "Total" in AA
- '' + total.toFixed(2) +
- '' + // Insert sum in AB
- '
';
-
- // 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];
- }
- }
- }
- }
-
}
],
@@ -221,8 +215,57 @@ $(document).ready(function() {
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
- pageLength: 25, // Set default number of rows per page (optional)
+ pageLength: 20, // Set default number of rows per page (optional)
ordering: false,
+ footerCallback: function(row, data, start, end, display) {
+ var api = this.api();
+
+ // Helper function to parse numbers
+ var parseNumber = function(value) {
+ return typeof value === 'string'
+ ? parseFloat(value.replace(/[\$,]/g, ''))
+ : typeof value === 'number'
+ ? value
+ : 0;
+ };
+
+ // Define column groups for total calculations
+ var columnGroups = [
+ { policy: 2, premium: 3 },
+ { policy: 4, premium: 5},
+ { policy: 6, premium: 7 },
+ { policy: 8, premium: 9 },
+ { policy: 10, premium: 11 },
+ { policy: 12, premium: 13 },
+ { policy: 14, premium: 15 },
+ { policy: 16, premium: 17 },
+ { policy: 18, premium: 19 },
+ { policy: 20, premium: 21 }
+ ];
+
+ // Loop through each column group to calculate totals and update the footer
+ columnGroups.forEach(function(group) {
+ var totalPolicies = api
+ .column(group.policy)
+ .data()
+ .reduce(function(a, b) {
+ return parseNumber(a) + parseNumber(b);
+ }, 0);
+
+ var totalPremium = api
+ .column(group.premium)
+ .data()
+ .reduce(function(a, b) {
+ return parseNumber(a) + parseNumber(b);
+ }, 0);
+
+ // Update the footer
+ $(api.column(group.policy).footer()).html(totalPolicies.toLocaleString());
+ $(api.column(group.premium).footer()).html(
+ "₹ " + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })
+ );
+ });
+ }
});
} else {
console.error("Table atet found.");
diff --git a/app/Views/irda_bap_insurer_report_list.php b/app/Views/irda_bap_insurer_report_list.php
index 7a90870d..8ab3b8fc 100644
--- a/app/Views/irda_bap_insurer_report_list.php
+++ b/app/Views/irda_bap_insurer_report_list.php
@@ -94,7 +94,9 @@ table.dataTable tbody td {
Revenue |
+
+
@@ -149,6 +151,55 @@ table.dataTable tbody td {
+
+
+
+ |
+ Grand Total |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+ |
+ |
+ |
+
+
+
+
@@ -230,8 +281,68 @@ $(document).ready(function() {
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
- pageLength: 25, // Set default number of rows per page (optional)
+ pageLength: 20, // Set default number of rows per page (optional)
ordering: false,
+ footerCallback: function(row, data, start, end, display) {
+ var api = this.api();
+
+ // Helper function to parse numbers
+ var parseNumber = function(value) {
+ return typeof value === 'string'
+ ? parseFloat(value.replace(/[\$,]/g, ''))
+ : typeof value === 'number'
+ ? value
+ : 0;
+ };
+
+ // Define column groups for total calculations
+ var columnGroups = [
+ { policy: 2, premium: 3, revenue: 4 },
+ { policy: 5, premium: 6, revenue: 7 },
+ { policy: 8, premium: 9, revenue: 10 },
+ { policy: 11, premium: 12, revenue: 13 },
+ { policy: 14, premium: 15, revenue: 16 },
+ { policy: 17, premium: 18, revenue: 19 },
+ { policy: 20, premium: 21, revenue: 22 },
+ { policy: 23, premium: 24, revenue: 25 },
+ { policy: 26, premium: 27, revenue: 28 },
+ { policy: 29, premium: 30, revenue: 31 }
+ ];
+
+ // Loop through each column group to calculate totals and update the footer
+ columnGroups.forEach(function(group) {
+ var totalPolicies = api
+ .column(group.policy)
+ .data()
+ .reduce(function(a, b) {
+ return parseNumber(a) + parseNumber(b);
+ }, 0);
+
+ var totalPremium = api
+ .column(group.premium)
+ .data()
+ .reduce(function(a, b) {
+ return parseNumber(a) + parseNumber(b);
+ }, 0);
+
+ var totalRevenue = api
+ .column(group.revenue)
+ .data()
+ .reduce(function(a, b) {
+ return parseNumber(a) + parseNumber(b);
+ }, 0);
+
+ // Update the footer
+ $(api.column(group.policy).footer()).html(totalPolicies.toLocaleString());
+ $(api.column(group.premium).footer()).html(
+ "₹ " + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })
+ );
+ $(api.column(group.revenue).footer()).html(
+ "₹ " + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 })
+ );
+ });
+ }
+
});
} else {
console.error("Table atet found.");