diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 185ee09762d0d66c7289361c6329b7c50d3de362..87e0fb2549fc590b44ab891428230979b8984d32 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -663,6 +663,11 @@ <title>Choose Header</title> <consumer>DocumentTemplateTexHeader</consumer> <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/choosentexheader/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/choosentexheader/valueProcess.js</valueProcess> + <onValueChange>%aditoprj%/entity/Offer_entity/entityfields/choosentexheader/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + </onValueChangeTypes> </entityField> <entityField> <name>OBJECT_ROWID</name> @@ -858,6 +863,11 @@ <title>Choose Footer</title> <consumer>DocumentTemplateTexFooter</consumer> <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/choosentexfooter/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/choosentexfooter/valueProcess.js</valueProcess> + <onValueChange>%aditoprj%/entity/Offer_entity/entityfields/choosentexfooter/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + </onValueChangeTypes> </entityField> <entityConsumer> <name>DocumentTemplateTexFooter</name> diff --git a/entity/Offer_entity/entityfields/choosentexfooter/onValueChange.js b/entity/Offer_entity/entityfields/choosentexfooter/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..ec9be1592840f8cccadf5dfaf997a07485354451 --- /dev/null +++ b/entity/Offer_entity/entityfields/choosentexfooter/onValueChange.js @@ -0,0 +1,16 @@ +import("system.db"); +import("system.util"); +import("Sql_lib"); +import("system.neon"); +import("system.vars"); + +if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW) +{ + var binaryId = newSelect("ID", SqlUtils.getBinariesAlias()) + .from("ASYS_BINARIES") + .whereIfSet("ASYS_BINARIES.ROW_ID", "$local.value") + .cell(true); + + if (binaryId) + neon.setFieldValue("$field.FOOTER", util.decodeBase64String(db.getBinaryContent(binaryId, SqlUtils.getBinariesAlias()))); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/choosentexfooter/valueProcess.js b/entity/Offer_entity/entityfields/choosentexfooter/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1a9d9b6168438e950a9e692c6c37eea8df9edd31 --- /dev/null +++ b/entity/Offer_entity/entityfields/choosentexfooter/valueProcess.js @@ -0,0 +1,6 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW) + result.string(""); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/choosentexheader/onValueChange.js b/entity/Offer_entity/entityfields/choosentexheader/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..333887d9be522309153aa7730f96b644cf53b5a0 --- /dev/null +++ b/entity/Offer_entity/entityfields/choosentexheader/onValueChange.js @@ -0,0 +1,16 @@ +import("system.db"); +import("system.util"); +import("Sql_lib"); +import("system.neon"); +import("system.vars"); + +if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW) +{ + var binaryId = newSelect("ID", SqlUtils.getBinariesAlias()) + .from("ASYS_BINARIES") + .whereIfSet("ASYS_BINARIES.ROW_ID", "$local.value") + .cell(true); + + if (binaryId) + neon.setFieldValue("$field.HEADER", util.decodeBase64String(db.getBinaryContent(binaryId, SqlUtils.getBinariesAlias()))); +} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/choosentexheader/valueProcess.js b/entity/Offer_entity/entityfields/choosentexheader/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1a9d9b6168438e950a9e692c6c37eea8df9edd31 --- /dev/null +++ b/entity/Offer_entity/entityfields/choosentexheader/valueProcess.js @@ -0,0 +1,6 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW) + result.string(""); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/footer/valueProcess.js b/entity/Offer_entity/entityfields/footer/valueProcess.js index c7d13ea380301efeadd70a5293ed03c5a06ff4bf..aa61a8823153ed22edf1c3351dcb0ab56079e924 100644 --- a/entity/Offer_entity/entityfields/footer/valueProcess.js +++ b/entity/Offer_entity/entityfields/footer/valueProcess.js @@ -12,14 +12,4 @@ else if(vars.get("$this.value")) result.string(vars.get("$this.value")); else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) - result.string("Vielen Dank!"); //TODO: translate - -if (vars.get("$field.ChoosenTEXFooter") != "") -{ - var binaryId = newSelect("ID", SqlUtils.getBinariesAlias()) - .from("ASYS_BINARIES") - .whereIfSet("ASYS_BINARIES.ROW_ID", "$field.ChoosenTEXFooter") - .cell(true); - if (binaryId) - result.string(util.decodeBase64String(db.getBinaryContent(binaryId, SqlUtils.getBinariesAlias()))); -} \ No newline at end of file + result.string("Vielen Dank!"); //TODO: translate \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/header/valueProcess.js b/entity/Offer_entity/entityfields/header/valueProcess.js index 65ab407aa9ddd39cea13f8b8fd2ee835fa27e42a..09e8e181f08509528e6a24305f9fb31a815af221 100644 --- a/entity/Offer_entity/entityfields/header/valueProcess.js +++ b/entity/Offer_entity/entityfields/header/valueProcess.js @@ -12,15 +12,4 @@ else if(vars.get("$this.value")) result.string(vars.get("$this.value")); else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) - result.string("Gerne bieten wir Ihnen wie folgt an:"); //TODO: translate - -if (vars.get("$field.ChoosenTEXHeader") != "") -{ - var binaryId = newSelect("ID", SqlUtils.getBinariesAlias()) - .from("ASYS_BINARIES") - .whereIfSet("ASYS_BINARIES.ROW_ID", "$field.ChoosenTEXHeader") - .cell(true); - - if (binaryId) - result.string(util.decodeBase64String(db.getBinaryContent(binaryId, SqlUtils.getBinariesAlias()))); -} \ No newline at end of file + result.string("Gerne bieten wir Ihnen wie folgt an:"); //TODO: translate \ No newline at end of file diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index a3bb020cc103539414f0df0c6b2e9a9f04b0594c..a59f4a93584778cf096cf19d54ffefd6e1288c01 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -16,6 +16,7 @@ import("PostalAddress_lib"); import("Neon_lib"); import("KeywordRegistry_basic"); import("Address_lib"); +import("DocumentTemplate_lib"); /** * Methods used by Offer. @@ -174,6 +175,9 @@ OfferUtils.openOfferReport = function (pOfferID) var vatsum = 0; var printDiscount = false; + var header = new DocumentTemplate(offerData[8], DocumentTemplate.types.PLAIN).getReplacedContentByContactId(offerData[1]); + var footer = new DocumentTemplate(offerData[14], DocumentTemplate.types.PLAIN).getReplacedContentByContactId(offerData[1]); + itemData = itemData.map(function (item) { //quantity * price @@ -206,8 +210,8 @@ OfferUtils.openOfferReport = function (pOfferID) item[4], //optional item[5], //itemposition item[6], //productcode - offerData[8], //header - offerData[14], //footer + header, //header + footer, //footer text.formatDouble(item[9], translate.text("#,##0"), true), //quantity text.formatDouble(item[10], translate.text("#,##0.00"), true), //price text.formatDouble(item[11], translate.text("0.00"), true), //discount