diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php
index d5f74a89..96a3f30b 100644
--- a/app/Views/report_bds.php
+++ b/app/Views/report_bds.php
@@ -176,40 +176,166 @@ $(document).ready(function() {
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',
+ // customize: function(xlsx) {
+ // var sheet = xlsx.xl.worksheets['sheet1.xml'];
+ // var total = 0;
+
+ // // 🔹 Force column K (11) and L (12) as string
+ // $('row c[r^="K"], row c[r^="L"]', sheet).attr('t', 'inlineStr');
+
+ // // 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) and 10th index (11th column)
+ // if (j === 9 || j === 10) {
+ // data.body[i][j] = '\u200C' + data.body[i][j];
+ // }
+ // }
+ // }
+ // }
+ // }
+ // ],
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'Policy-Tranction-BDS-List',
+ customizeData: function (data) {
+ for (var i = 0; i < data.body.length; i++) {
+ for (var j = 0; j < data.body[i].length; j++) {
+ // force text format by prefixing a tab
+ data.body[i][j] = '\t' + data.body[i][j];
+ }
+ }
+ }
},
{
extend: 'excel',
text: 'Excel',
title: 'Policy-Tranction-BDS-List',
- customize: function(xlsx) {
+ // customize: function (xlsx) {
+ // var sheet = xlsx.xl.worksheets['sheet1.xml'];
+ // var total = 0;
+
+ // // 🔹 Force column K (11) and L (12) as string
+ // // $('row c[r^="K"], row c[r^="L"]', sheet).attr('t', 'inlineStr');
+ // // 🔹 Convert column K (11th) & L (12th) to inline string
+ // $('row c[r^="K"], row c[r^="L"]', sheet).each(function () {
+ // var cell = $(this);
+ // console.log(cell);
+ // var val = cell.find('v').text(); // get value
+ // if (val) {
+ // cell.attr('t', 'inlineStr'); // mark as text
+ // cell.remove('v'); // remove
+ // cell.append('' + val + ''); // replace with inline string
+ // }
+ // });
+
+ // // Calculate total in AB (28th column)
+ // $('row c[r^="AB"]', sheet).each(function () {
+ // var value = parseFloat($('v', this).text());
+ // if (!isNaN(value)) {
+ // total += value;
+ // }
+ // });
+
+ // // Append total row
+ // var lastRow = $('row:last', sheet);
+ // var rowIndex = parseInt(lastRow.attr('r')) + 2;
+ // var totalRow = '' +
+ // 'Total' +
+ // '' + total.toFixed(2) + '' +
+ // '
';
+
+ // $(sheet).find('sheetData').append(totalRow);
+ // },
+ customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
- // 🔹 Force column K (11) and L (12) as string
- $('row c[r^="K"], row c[r^="L"]', sheet).attr('t', 'inlineStr');
+ function forceAsText(cell) {
+ var val = cell.find('v').text();
+ if (val) {
+ // Remove old
+ cell.find('v').remove();
- // 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;
+ // Force as inline string
+ cell.attr('t', 'inlineStr');
+ cell.append('' + val + '');
}
+ }
+
+ function forceAsTextPreserveOriginal(cell) {
+ // Get the original cell value from the cell's text content
+ var vElement = cell.find('v');
+ if (vElement.length > 0) {
+ var originalValue = vElement.text();
+
+ // Remove the element
+ vElement.remove();
+
+ // Set cell type to inline string and preserve the original value
+ cell.attr('t', 'inlineStr');
+ cell.append('' + originalValue + '');
+ }
+ }
+
+ // 🔹 Force K column as text (working correctly)
+ $('row c[r^="K"]', sheet).each(function () {
+ forceAsText($(this));
});
- // Get the last row index and append the total row
+ // 🔹 Force L column as text with better preservation
+ $('row c[r^="L"]', sheet).each(function () {
+ forceAsTextPreserveOriginal($(this));
+ });
+
+ // 🔹 Calculate total in AB (28th column)
+ $('row c[r^="AB"] v', sheet).each(function () {
+ var value = parseFloat($(this).text());
+ if (!isNaN(value)) total += value;
+ });
+
+ // 🔹 Append total row
var lastRow = $('row:last', sheet);
- var rowIndex = parseInt(lastRow.attr('r')) + 2; // Find the next row index
+ var rowIndex = parseInt(lastRow.attr('r')) + 2;
var totalRow = '' +
- 'Total' + // Insert "Total" in AA
- '' + total.toFixed(2) + '' + // Insert sum in AB
+ 'Total' +
+ '' + total.toFixed(2) + '' +
'
';
- // Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
@@ -218,8 +344,8 @@ $(document).ready(function() {
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) and 10th index (11th column)
- if (j === 9 || j === 10) {
+ // Force 10th (index 9) & 11th (index 10) as text
+ if (j === 9 || j === 10 || j === 11 || j === 12 ) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
@@ -227,6 +353,7 @@ $(document).ready(function() {
}
}
],
+
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."