From 594d7f85d36a00f88e087afcf57123548ceb0272 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 5 Mar 2026 12:09:39 +0530 Subject: [PATCH] Implement dynamic header and table color functionality --- .../PrintTemplates/PrintStyleDCToInvoice7.jsx | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice7.jsx b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice7.jsx index f14334f..f1dee48 100644 --- a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice7.jsx +++ b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice7.jsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useSelector } from "react-redux"; -import { GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; // Fix typo if needed +import { GloabalDCtoInvoiceFieldDetails, GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; // Fix typo if needed import { dateFormatChange1 } from "../../../Services/Others"; const PrintStyleDCToInvoice7 = ({ invoiceData, preference, printDatas }) => { @@ -18,7 +18,7 @@ const PrintStyleDCToInvoice7 = ({ invoiceData, preference, printDatas }) => { VehicleNo } = invoiceData; - const fieldDetails = useSelector(GloabalFieldDetails); + const fieldDetails = useSelector(GloabalDCtoInvoiceFieldDetails); const signature = fieldDetails?.["signature"]; const termsAndConditions = fieldDetails?.["terms&conditions"]; const termsAndConditionsData = printDatas?.TermsandConditions; @@ -53,8 +53,35 @@ const PrintStyleDCToInvoice7 = ({ invoiceData, preference, printDatas }) => { maxHeight: "98vh" }); + let printColors = printDatas?.PrintColors; + const headerColor = printColors?.find(obj => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find(obj => obj.tableHeaderColor)?.tableHeaderColor; + const tableBodyColor = printColors?.find(obj => obj.tableBodyColor)?.tableBodyColor; + const footerColor = printColors?.find(obj => obj.footerColor)?.footerColor; + const netAmtColor = printColors?.find(obj => obj.netAmtColor)?.netAmtColor; + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + } + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + } + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + } + const rowtypeStyle = tableBodyColor?.rowType; + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + } + const netAmountStyle = { + backgroundColor: netAmtColor?.background, + color: netAmtColor?.font, + } const renderFooter = () => ( -
+
{(notesText || termsAndConditions || signature || printGreeting?.SettingValue === "Y") && ( <> {notesText &&

{notesText}

} @@ -95,6 +122,7 @@ const PrintStyleDCToInvoice7 = ({ invoiceData, preference, printDatas }) => { DCNo={DCNo} InvoiceDate={InvoiceDate} VehicleNo={VehicleNo} + headerStyle={headerStyle} /> ); @@ -245,13 +273,14 @@ const PrintStyleDCToInvoice7 = ({ invoiceData, preference, printDatas }) => { >
{(chunkIndex === 0 || formatTheme) && } - + {isLastPage && ( <>
{ ) : (
- +
@@ -288,12 +318,12 @@ export default PrintStyleDCToInvoice7; // COMPONENTS -const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo }) => ( -
+const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo,headerStyle }) => ( +
********************************************************
-
+
{branch?.CompName}
{branch?.Address1}-{branch?.City}-{branch?.Zip}
Mobile : {branch?.BrMobile}
@@ -316,7 +346,7 @@ const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo }) => (
); -const ProductTable = ({ data }) => { +const ProductTable = ({ data,tableHeaderStyle,tableBodyStyle,rowtypeStyle }) => { const columns = [ { label: "S.No", key: "sno", width: "5%", align: 'center' }, { label: "Product", key: "ProdName", width: "35%", align: 'center' }, @@ -328,9 +358,10 @@ const ProductTable = ({ data }) => { ]; return ( - + //
+
- + {columns.map(col => ( ))} @@ -338,7 +369,18 @@ const ProductTable = ({ data }) => { {data.map((prod, index) => ( - + @@ -353,8 +395,8 @@ const ProductTable = ({ data }) => { ); }; -const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -
+const Summary = ({ TotalAmount, TaxAmount, GrandTotal,netAmountStyle }) => ( +
Subtotal: ₹ {TotalAmount.toFixed(2)}
Tax Amount: ₹ {TaxAmount.toFixed(2)}
{col.label}
{index + 1} {prod.ProdName} {prod.ProdVariantName}