diff --git a/app/index.html b/app/index.html index 0ce5ce6..50a7504 100644 --- a/app/index.html +++ b/app/index.html @@ -507,27 +507,23 @@ function buildForm() {
-
${t("payment")}
-
- - - ${t("payment-days")} +
${t("invoice-details-section")}
+
+
+
+
+
+
+ -
- - -
-
-
-
-
-
-
-
- -
-
-
+
+
@@ -562,23 +558,29 @@ function buildForm() {
-
${t("invoice-details-section")}
-
-
-
-
-
-
-
@@ -645,6 +647,9 @@ function fillChargeTo(v) { const f = (id, val) => { const el = document.getElementById(id); if (el) el.value = val ?? ""; }; const fields = document.getElementById("ct-fields"); + const bsec = document.getElementById("bank-section"); + if (bsec) bsec.style.display = v === "__other__" ? "" : "none"; + if (v === "" || v === "__other__") { if (v === "") ["ctn","ca1","ca2","ca3","ca4","cc","cph","cem","cvat","creg"].forEach(id => f(id, "")); fields?.classList.remove("locked"); @@ -1043,12 +1048,14 @@ function gatherData(renderLang) { const pTerm = parseInt(document.getElementById("pterm")?.value) || 0; const pPayBy = document.getElementById("paybydisp")?.textContent || ""; - const pAcct = g("pacct"); - const pIban = g("piban"); - const pBic = g("pbic"); - const pBadr1 = g("pbadr1"); - const pBadr2 = g("pbadr2"); - const pRef = g("pref"); + const bsecEl = document.getElementById("bank-section"); + const bankVis = bsecEl && bsecEl.style.display !== "none"; + const pAcct = bankVis ? g("pacct") : ""; + const pIban = bankVis ? g("piban") : ""; + const pBic = bankVis ? g("pbic") : ""; + const pBadr1 = bankVis ? g("pbadr1"): ""; + const pBadr2 = bankVis ? g("pbadr2"): ""; + const pRef = bankVis ? g("pref") : ""; const hasBank = !!(pAcct || pIban || pBic || pBadr1 || pRef); const hidePaymentOut = cfg["hide-payment-info"] === true || cfg["hide-payment-info"] === "yes"; @@ -1142,16 +1149,14 @@ function buildPreviewHTML() { ${sPh ? `

${h(td("sender-phone"))}: ${h(sPh)}

` : ""} ${sEm ? `

${h(td("sender-email"))}: ${h(sEm)}

` : ""}
-
-
${h(td("payment"))}
- ${pTerm > 0 ? `
${h(td("payment-terms"))}: ${pTerm} ${h(td("payment-days"))}${pPayBy ? ` — ${h(td("pay-by"))}: ${h(pPayBy)}` : ""}
` : ""} - ${showBank ? `
- ${pAcct ? `${h(td("account-holder"))}${h(pAcct)}` : ""} - ${pIban ? `${h(td("account-no"))}${h(pIban)}` : ""} - ${pBic ? `${h(td("bank-bic"))}${h(pBic)}` : ""} - ${pBadr1 || pBadr2 ? `${h(td("bank-address"))}${[pBadr1,pBadr2].filter(Boolean).map(l=>h(l)).join("
")}
` : ""} -
- ${pRef ? `
${h(td("payment-ref"))}: ${h(pRef)}
` : ""}` : ""} +
+

${h(td("invoice"))}

+ + ${iNo ? `` : ""} + ${iDate ? `` : ""} + ${pCode ? `` : ""} + ${iCur ? `` : ""} +
${h(td("invoice-no"))}${h(iNo)}
${h(td("invoice-date"))}${h(fmtDate(iDate))}
${h(td("project-code"))}${h(pCode)}
${h(td("invoice-currency"))}${h(iCur)}
${h(td("charge-to"))}
@@ -1165,14 +1170,16 @@ function buildPreviewHTML() { ${ctReg ? `${h(td("registration-no"))}: ${h(ctReg)}` : ""}
-
-

${h(td("invoice"))}

- - ${iNo ? `` : ""} - ${iDate ? `` : ""} - ${pCode ? `` : ""} - ${iCur ? `` : ""} -
${h(td("invoice-no"))}${h(iNo)}
${h(td("invoice-date"))}${h(fmtDate(iDate))}
${h(td("project-code"))}${h(pCode)}
${h(td("invoice-currency"))}${h(iCur)}
+
+
${h(td("payment"))}
+ ${pTerm > 0 ? `
${h(td("payment-terms"))}: ${pTerm} ${h(td("payment-days"))}${pPayBy ? ` — ${h(td("pay-by"))}: ${h(pPayBy)}` : ""}
` : ""} + ${showBank ? `
+ ${pAcct ? `${h(td("account-holder"))}${h(pAcct)}` : ""} + ${pIban ? `${h(td("account-no"))}${h(pIban)}` : ""} + ${pBic ? `${h(td("bank-bic"))}${h(pBic)}` : ""} + ${pBadr1 || pBadr2 ? `${h(td("bank-address"))}${[pBadr1,pBadr2].filter(Boolean).map(l=>h(l)).join("
")}
` : ""} +
+ ${pRef ? `
${h(td("payment-ref"))}: ${h(pRef)}
` : ""}` : ""}
@@ -1253,34 +1260,19 @@ function buildPDF() { fn(8); tc(107,114,128); tL(parts.join(" "), ML, ly); ly += 5; } - // ── Row 1 right: Payment ── - if (pTerm > 0 || showBank) { - fb(7); tc(107,114,128); tL(td("payment").toUpperCase(), XM_L, ry); ry += 5; - if (pTerm > 0) { - const ts = `${td("payment-terms")}: ${pTerm} ${td("payment-days")}${pPayBy ? ` ${td("pay-by")}: ${pPayBy}` : ""}`; - fn(8.5); tc(17,24,39); tL(ts, XM_L, ry); ry += 5; - } - if (showBank) { - const LLBL = 46; - const payRows = [ - pAcct ? [td("account-holder"), pAcct] : null, - pIban ? [td("account-no"), pIban] : null, - pBic ? [td("bank-bic"), pBic] : null, - (pBadr1||pBadr2) ? [td("bank-address"), [pBadr1,pBadr2].filter(Boolean).join(", ")] : null, - ].filter(Boolean); - payRows.forEach(([lbl, val]) => { - fn(8); tc(107,114,128); tL(lbl + ":", XM_L, ry); - fn(8.5); tc(17,24,39); - const wrapped = sp(val, LW - LLBL - 2); - wrapped.forEach((line, i) => tL(line, XM_L + LLBL, ry + i * 4)); - ry += Math.max(4.5, wrapped.length * 4); - }); - if (pRef) { - fn(8); tc(107,114,128); tL(td("payment-ref") + ":", XM_L, ry); - fb(8.5); tc(17,24,39); tL(pRef, XM_L + LLBL, ry); ry += 5; - } - } - } + // ── Row 1 right: INVOICE + meta ── + fb(24); tc(30,45,69); tR(td("invoice"), XR, ry); ry += 10; + const metaRows = [ + iNo ? [td("invoice-no"), iNo] : null, + iDate ? [td("invoice-date"), fmtDate(iDate)] : null, + pCode ? [td("project-code"), pCode] : null, + iCur ? [td("invoice-currency"), iCur] : null, + ].filter(Boolean); + metaRows.forEach(([lbl, val]) => { + fn(8.5); tc(107,114,128); tR(lbl + ":", XR - 42, ry); + fb(8.5); tc(17,24,39); tR(val, XR, ry); + ry += 5; + }); // Row 1 divider const row1Y = Math.max(ly, ry) + 4; @@ -1302,19 +1294,34 @@ function buildPDF() { if (ctParts.length) { fn(8); tc(107,114,128); tL(ctParts.join(" "), ML, ly2); ly2 += 5; } } - // ── Row 2 right: INVOICE + meta ── - fb(24); tc(30,45,69); tR(td("invoice"), XR, ry2); ry2 += 10; - const metaRows = [ - iNo ? [td("invoice-no"), iNo] : null, - iDate ? [td("invoice-date"), fmtDate(iDate)] : null, - pCode ? [td("project-code"), pCode] : null, - iCur ? [td("invoice-currency"), iCur] : null, - ].filter(Boolean); - metaRows.forEach(([lbl, val]) => { - fn(8.5); tc(107,114,128); tR(lbl + ":", XR - 42, ry2); - fb(8.5); tc(17,24,39); tR(val, XR, ry2); - ry2 += 5; - }); + // ── Row 2 right: Payment ── + if (pTerm > 0 || showBank) { + fb(7); tc(107,114,128); tL(td("payment").toUpperCase(), XM_L, ry2); ry2 += 5; + if (pTerm > 0) { + const ts = `${td("payment-terms")}: ${pTerm} ${td("payment-days")}${pPayBy ? ` ${td("pay-by")}: ${pPayBy}` : ""}`; + fn(8.5); tc(17,24,39); tL(ts, XM_L, ry2); ry2 += 5; + } + if (showBank) { + const LLBL = 46; + const payRows = [ + pAcct ? [td("account-holder"), pAcct] : null, + pIban ? [td("account-no"), pIban] : null, + pBic ? [td("bank-bic"), pBic] : null, + (pBadr1||pBadr2) ? [td("bank-address"), [pBadr1,pBadr2].filter(Boolean).join(", ")] : null, + ].filter(Boolean); + payRows.forEach(([lbl, val]) => { + fn(8); tc(107,114,128); tL(lbl + ":", XM_L, ry2); + fn(8.5); tc(17,24,39); + const wrapped = sp(val, LW - LLBL - 2); + wrapped.forEach((line, i) => tL(line, XM_L + LLBL, ry2 + i * 4)); + ry2 += Math.max(4.5, wrapped.length * 4); + }); + if (pRef) { + fn(8); tc(107,114,128); tL(td("payment-ref") + ":", XM_L, ry2); + fb(8.5); tc(17,24,39); tL(pRef, XM_L + LLBL, ry2); ry2 += 5; + } + } + } y = Math.max(ly2, ry2) + 5;