From e4171e135b212346a2308b897a478c03f85538df Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 5 Mar 2026 12:06:30 +0530 Subject: [PATCH] Implement dynamic header and table color functionality --- .../PrintTemplates/PrintStyleDCToInvoice4.jsx | 66 +++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice4.jsx b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice4.jsx index 432edc1..a7d6803 100644 --- a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice4.jsx +++ b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice4.jsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useSelector } from "react-redux"; -import { GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; +import { GloabalDCtoInvoiceFieldDetails, GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; import { dateFormatChange1 } from "../../../Services/Others"; const PrintStyleDCToInvoice4 = ({ invoiceData, preference, printDatas }) => { @@ -18,7 +18,7 @@ const PrintStyleDCToInvoice4 = ({ 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; @@ -54,6 +54,35 @@ const PrintStyleDCToInvoice4 = ({ invoiceData, preference, printDatas }) => { maxHeight: "97vh" }); + 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 HeaderSection = () => ( <>
{ DCNo={DCNo} InvoiceDate={InvoiceDate} VehicleNo={VehicleNo} + headerStyle={headerStyle} /> ); const renderFooter = () => ( -
+
{(notesText || termsAndConditions || signature || printGreeting?.SettingValue === "Y") && ( <> {notesText &&

{notesText}

} @@ -114,13 +144,14 @@ const PrintStyleDCToInvoice4 = ({ invoiceData, preference, printDatas }) => { >
{(chunkIndex === 0 || formatTheme) && } - + {isLastPage && <>

{ ) : (
- +

( -
+const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo,headerStyle }) => ( +
{branch?.CompName}
{branch?.Address1}-{branch?.City}-{branch?.Zip}
@@ -182,7 +214,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%" }, { label: "Product", key: "ProdName", width: "20%", align: 'center' }, @@ -197,7 +229,7 @@ const ProductTable = ({ data }) => { <> - + {columns.map(col => ( ))} @@ -205,7 +237,17 @@ const ProductTable = ({ data }) => { {data.map((prod, index) => ( - + @@ -221,8 +263,8 @@ const ProductTable = ({ data }) => { ); }; -const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -
+const Summary = ({ TotalAmount, TaxAmount, GrandTotal,netAmountStyle }) => ( +
Subtotal :
{col.label}
{index + 1} {prod.ProdName} {prod.ProdVariantName}