diff --git a/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java b/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java
index 30a9600..96965e4 100644
--- a/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java
+++ b/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java
@@ -146,6 +146,7 @@ public class Fooddistributionservice {
"pqm.q_english, " +
"pam.english_name, " +
"hm.si_name AS name, " +
+ "hm.permanent_location, " +
"dl.name AS raisedBy, " +
"pf.remarks AS pmcRemarks, " +
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', pf.image) AS videoLink, " +
diff --git a/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html
index 65b2d1f..5e31070 100644
--- a/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html
+++ b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html
@@ -168,6 +168,7 @@
CE Remarks |
CE Updated By |
Penalty Amount |
+ Combined Issue |
@@ -281,7 +282,8 @@
{ width: "120px", targets: 17 },
{ width: "220px", targets: 18 },
{ width: "150px", targets: 19 },
- { width: "150px", targets: 20 }
+ { width: "150px", targets: 20 },
+ { targets: 21, visible: false }
],
responsive: false,
scrollX: true,
@@ -294,6 +296,107 @@
dom: '<"d-flex justify-content-between align-items-center mb-3"lfB>rtip',
lengthMenu: [[10, 50, 100, -1], [10, 50, 100, "All"]],
buttons: [
+ {
+ extend: 'pdfHtml5',
+ text: ' Penalty PDF',
+ className: 'btn btn-warning btn-sm me-2',
+ orientation: 'portrait',
+ pageSize: 'A4',
+ title: function () {
+ function formatDDMMYYYY(d) {
+ if (!d) return '';
+ var p = d.split('-');
+ return p.length === 3 ? p[2] + '-' + p[1] + '-' + p[0] : d;
+ }
+ var fromStr = formatDDMMYYYY($('#fromDate').val());
+ var toStr = formatDDMMYYYY($('#toDate').val());
+ return 'NON COMPLIANCE- PENALTY DETAILS\n' + fromStr + ' to ' + toStr;
+ },
+ filename: function () {
+ var kitchen = $('#hubId option:selected').text().replace(/[^a-zA-Z0-9]/g, '_');
+ return 'Penalty_Details_' + kitchen + '_' + ($('#fromDate').val() || 'All') + '_to_' + ($('#toDate').val() || 'All');
+ },
+ exportOptions: {
+ stripHtml: false,
+ columns: [0, 1, 9, 21, 12, 20],
+ format: {
+ header: function (data, columnIdx) {
+ if (columnIdx === 0) return 'S.NO';
+ if (columnIdx === 1) return 'DATE';
+ if (columnIdx === 9) return 'KITCHEN NAME';
+ if (columnIdx === 21) return 'ISSUE';
+ if (columnIdx === 12) return 'EVIDENCE';
+ if (columnIdx === 20) return 'PENALTY';
+ return data;
+ },
+ body: function (data, row, column, node) {
+ if (typeof data === 'string' && data.indexOf('showMedia') !== -1) {
+ var match = data.match(/showMedia\('([^']+)'/);
+ if (match) return match[1];
+ }
+ if (typeof data === 'string' && data.indexOf('data-fulltext') !== -1) {
+ var match = data.match(/data-fulltext="([^"]+)"/);
+ if (match) return decodeURIComponent(match[1]);
+ }
+ var div = document.createElement("div");
+ div.innerHTML = data;
+ var text = div.textContent || div.innerText || "";
+
+ if (column === 0 && text) {
+ var num = parseInt(text);
+ if (!isNaN(num)) {
+ return (num < 10 ? '0' + num : num) + '.';
+ }
+ }
+ if (column === 1 && text && text !== '-') {
+ var parts = text.split('-');
+ if (parts.length === 3) {
+ if (parts[0].length === 4) {
+ var yy = parts[0].substring(2, 4);
+ return parts[2] + '.' + parts[1] + '.' + yy;
+ } else if (parts[2].length === 4) {
+ var yy = parts[2].substring(2, 4);
+ return parts[0] + '.' + parts[1] + '.' + yy;
+ }
+ }
+ }
+ if (column === 5 && text !== '-' && text !== 'Pending' && text !== '') {
+ return 'Rs. ' + text;
+ }
+ return text;
+ }
+ }
+ },
+ customize: function (doc) {
+ doc.styles.title = {
+ fontSize: 14,
+ bold: true,
+ alignment: 'center',
+ margin: [0, 0, 0, 10]
+ };
+ doc.styles.tableHeader.fontSize = 10;
+ doc.styles.tableHeader.alignment = 'left';
+ doc.defaultStyle.fontSize = 9;
+ doc.content[1].table.widths = ['8%', '12%', '15%', '35%', '20%', '10%'];
+ doc.content[1].table.dontBreakRows = true;
+
+ var rowCount = doc.content[1].table.body.length;
+ for (var i = 1; i < rowCount; i++) {
+ var evidenceCell = doc.content[1].table.body[i][4];
+ var urlText = typeof evidenceCell === 'object' ? evidenceCell.text : evidenceCell;
+ if (urlText && typeof urlText === 'string' && urlText.startsWith('http')) {
+ var wrapped = urlText.length > 30 ? urlText.split('').join('\u200B') : urlText;
+ doc.content[1].table.body[i][4] = {
+ text: wrapped,
+ link: urlText,
+ target: '_blank',
+ color: 'blue',
+ decoration: 'underline'
+ };
+ }
+ }
+ }
+ },
{
extend: 'excelHtml5',
text: ' Excel',
@@ -306,6 +409,7 @@
return 'Detailed_Food_Distribution_' + kitchen + '_' + ($('#fromDate').val() || 'All') + '_to_' + ($('#toDate').val() || 'All');
},
exportOptions: {
+ stripHtml: false,
format: {
body: function (data, row, column, node) {
if (typeof data === 'string' && data.indexOf('showMedia') !== -1) {
@@ -337,6 +441,7 @@
return 'Detailed_Food_Distribution_' + kitchen + '_' + ($('#fromDate').val() || 'All') + '_to_' + ($('#toDate').val() || 'All');
},
exportOptions: {
+ stripHtml: false,
format: {
body: function (data, row, column, node) {
if (typeof data === 'string' && data.indexOf('showMedia') !== -1) {
@@ -441,6 +546,8 @@
finalPenalty = '-';
}
+ var combinedIssue = (item.pmcRemarks && item.pmcRemarks !== '-' && item.pmcRemarks !== 'null' ? item.pmcRemarks : '-');
+
dataTable.row.add([
index + 1,
item.auditDate || '-',
@@ -451,7 +558,7 @@
item.audit_category || '-',
item.q_english || '-',
item.english_name || '-',
- item.name || '-',
+ item.permanent_location || item.name || '-',
item.raisedBy || '-',
formatRemark(item.pmcRemarks, 'PMC Remarks'),
imgBtn,
@@ -462,7 +569,8 @@
item.chief_engineer_status || '-',
formatRemark(item.chief_engineer_remarks, 'CE Remarks'),
item.chief_engineer || '-',
- finalPenalty
+ finalPenalty,
+ combinedIssue
]);
});
dataTable.draw();