From cca7ad1df980b2782313ec54d969e13345adf699 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 6 Sep 2025 12:03:00 +0530 Subject: [PATCH] FIX_BDS_EXCEL_EXPORT_ISSE --- app/Controllers/EmployeeController.php | 24 ++++++++++++++++----- app/Views/report_bds.php | 29 +++++++++++++------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b4ea7b70..c5badc3b 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1532,16 +1532,30 @@ class EmployeeController extends AdminController $dompdf->loadHtml('' . $html); // remove the margin $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); - + // Set document title $dompdf->addInfo("Title", "E-Card"); $filename = 'ecard_' . date('Y-m-d_H-i-s') . '.pdf'; - if($mode == 1){ - $dompdf->stream($filename, ['Attachment' => false]); // Inline view - }else{ - $dompdf->stream($filename, ['Attachment' => true]); // Force download + // if($mode == 1){ + // $dompdf->stream($filename, ['Attachment' => false]); // Inline view + // }else{ + // $dompdf->stream($filename, ['Attachment' => true]); // Force download + // } + + if ($mode == 1) { + // Inline view + return $this->response + ->setHeader('Content-Type', 'application/pdf') + ->setHeader('Content-Disposition', 'inline; filename="' . $filename . '"') + ->setBody($dompdf->output()); + } else { + // Force download + return $this->response + ->setHeader('Content-Type', 'application/pdf') + ->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"') + ->setBody($dompdf->output()); } $this->myLogger->logme('error', 'generateIDCardForEmployee function completed successfully.'); diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 5978e44f..d5f74a89 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -190,6 +190,9 @@ $(document).ready(function() { 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 @@ -210,21 +213,19 @@ $(document).ready(function() { $(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]; - } - } - } -} - + 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]; + } + } + } + } } - ], language: { search: "_INPUT_",