AUDIT TRAIL FOR PRODUCT

<% let productData=Result[0] %>
Date <%= productData.dt %> Time <%= productData.tm %>
User Id <%= productData.UserId %> User Name <%= productData.UserName %>
Action <%= productData.Act %> <%- productData.Remark ? `Remark` : ''%> <%= productData.Remark %>
<% if(Result[0].Act != "Activate" && Result[0].Act != "Deactivate") { %> <% Result[0].OldProductDetail,'Result[0].OldProductDetail' %> <% if(Result[0].OldProductDetail || Result[0].NewProductDetail) { %> <%- include('Report_Component/Product_Audit/ProductDetail', {Result: Result[0]}) %> <% } %> <% if(Result[0].oldGIFile || Result[0].newGIFile) { %> <% if((Result[0].oldGIFile != 'NA') || (Result[0].newGIFile != 'NA' )) { %> <%- include('Report_Component/Product_Audit/SafetyGI', { Result: Result[0] }) %> <% } %> <% } %> <% if(Result[0].oldManuFile || Result[0].newManuFile) { %> <% if((Result[0].oldManuFile != 'NA') || (Result[0].newManuFile != 'NA' )) { %> <%- include('Report_Component/Product_Audit/ManufacturingProcessFlow', { Result: Result[0] }) %> <% } %> <% } %> <% if(Result[0].OldMaterial || Result[0].NewMaterial) { %> <% if((Result[0].OldMaterial != 'NA') || (Result[0].NewMaterial != 'NA')) { %> <%- include('Report_Component/Product_Audit/Material', {Result: Result[0]}) %> <% } %> <% } %> <% if(Result[0].oldStage || Result[0].newStage) { %> <%- include('Report_Component/Product_Audit/StageGI', {Result: Result[0], StageText : '' }) %> <% } %> <% function groupByStage(data) { const grouped = {}; if (!Array.isArray(data)) return grouped; // safety data.forEach(item => { if (!item.StageName) return; // ignore invalid items if (!grouped[item.StageName]) { grouped[item.StageName] = []; } grouped[item.StageName].push(item); }); return grouped; } %> <% if (Result[0].oldData || Result[0].newData) { %> <% let parsedDataNew = []; let parsedDataOld = []; try { parsedDataNew = Result[0].newData && Result[0].newData !== "NA" ? JSON.parse(Result[0].newData) : []; parsedDataOld = Result[0].oldData && Result[0].oldData !== "NA" ? JSON.parse(Result[0].oldData) : []; } catch (e) { console.error("Invalid JSON string:", e); } const newStage = groupByStage(parsedDataNew); const oldStage = groupByStage(parsedDataOld); %> <%- include('Report_Component/Product_Audit/CommonAuditNew', { newStage: newStage, oldStage: oldStage, Result: Result[0] }) %> <% } %> <% if(Result[0].old_verifyPRComment || Result[0].verifyPRComment) { %> <%- include('Report_Component/Product_Audit/auditComment', { Result: Result[0], StageText : Result[0].StageName, oldStep:Result[0].old_verifyPRComment, newStep: Result[0].verifyPRComment}) %> <% } %> <% if(Result[0].verifyQAComment || Result[0].old_verifyQAComment) { %> <%- include('Report_Component/Product_Audit/auditComment', {Result: Result[0], StageText :Result[0].StageName, oldStep: Result[0].old_verifyQAComment, newStep: Result[0].verifyQAComment}) %> <% } %> <% if(Result[0].verifyApprovedComment || Result[0].old_verifyApprovedComment) { %> <%- include('Report_Component/Product_Audit/auditComment', {Result: Result[0], StageText :Result[0].StageName, oldStep: Result[0].old_verifyApprovedComment, newStep:Result[0].verifyApprovedComment }) %> <% } %> <% } %>