diff --git a/entity/DocumentTemplate_entity/onValidation.js b/entity/DocumentTemplate_entity/onValidation.js index e1665301991f925940ff8bde6f09dfa13465bd83..f850a1f939181ed0a5a9656f0f0d0f165df2c7a8 100644 --- a/entity/DocumentTemplate_entity/onValidation.js +++ b/entity/DocumentTemplate_entity/onValidation.js @@ -1,3 +1,4 @@ +import("system.neon"); import("system.translate"); import("system.result"); import("system.logging"); @@ -6,7 +7,7 @@ import("Bulkmail_lib"); import("DocumentTemplate_lib"); import("KeywordRegistry_basic"); -if (vars.exists("$context.currentTemplateType")) +if (vars.exists("$context.currentTemplateType") && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)) { var kind = vars.get("$field.KIND"); var classification = vars.get("$field.CLASSIFICATION"); diff --git a/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod b/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod index 66768fb7f3e15a14ba0ddc984d193e7e7b88c4f7..a7667d4668dde4281af4a568b9686d083475cf8e 100644 --- a/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod +++ b/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod @@ -12,6 +12,7 @@ <title>Serial letter</title> <consumer>SerialLetters</consumer> <mandatory v="true" /> + <displayValueProcess>%aditoprj%/entity/SerialLetterAddRecipients_entity/entityfields/serialletter_id/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>UID</name> diff --git a/entity/SerialLetterAddRecipients_entity/entityfields/serialletter_id/displayValueProcess.js b/entity/SerialLetterAddRecipients_entity/entityfields/serialletter_id/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5e4cef21d24f9dd3b9ba81e081ed34d5b4fc4b3c --- /dev/null +++ b/entity/SerialLetterAddRecipients_entity/entityfields/serialletter_id/displayValueProcess.js @@ -0,0 +1,9 @@ +import("system.vars"); +import("Sql_lib"); +import("system.db"); +import("system.result"); + +if (vars.get("$this.value")) + result.string(db.cell(SqlCondition.begin().andPrepare("SERIALLETTER.SERIALLETTERID", vars.get("$this.value")).buildSql("select TITLE from SERIALLETTER"))); +else + result.string(""); \ No newline at end of file diff --git a/entity/SerialLetter_entity/SerialLetter_entity.aod b/entity/SerialLetter_entity/SerialLetter_entity.aod index bbde4a77c83d25a1faae5a6826995eac08c0165e..5d7d1cba1ee34e6575f89514b8adf6e1865cf41d 100644 --- a/entity/SerialLetter_entity/SerialLetter_entity.aod +++ b/entity/SerialLetter_entity/SerialLetter_entity.aod @@ -62,6 +62,16 @@ <entityName>DocumentTemplate_entity</entityName> <fieldName>DocumentTemplateProvider</fieldName> </dependency> + <children> + <entityParameter> + <name>DocumentTemplateType_param</name> + <valueProcess>%aditoprj%/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetype_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>DocumentTemplateTypeClassification_param</name> + <valueProcess>%aditoprj%/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetypeclassification_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> <entityField> <name>TITLE</name> diff --git a/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetype_param/valueProcess.js b/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetype_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..94ae123081d4978bc210d76f2569e8cbae5fbcf8 --- /dev/null +++ b/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetype_param/valueProcess.js @@ -0,0 +1,4 @@ +import("KeywordRegistry_basic"); +import("system.result"); + +result.string($KeywordRegistry.documentTemplateType$letter()); \ No newline at end of file diff --git a/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetypeclassification_param/valueProcess.js b/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetypeclassification_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..d817901f1b2467cec7d38865f9cc054ddadd2dcd --- /dev/null +++ b/entity/SerialLetter_entity/entityfields/templates/children/documenttemplatetypeclassification_param/valueProcess.js @@ -0,0 +1,4 @@ +import("KeywordRegistry_basic"); +import("system.result"); + +result.string($KeywordRegistry.documentTemplateTypeCategory$serial()); \ No newline at end of file diff --git a/entity/SerialLetter_entity/onValidation.js b/entity/SerialLetter_entity/onValidation.js index cba89e9b139da610054db633d9559be56882d402..ffb5740ed04599b2851d96fd4ff6aef611f0b05b 100644 --- a/entity/SerialLetter_entity/onValidation.js +++ b/entity/SerialLetter_entity/onValidation.js @@ -1,7 +1,8 @@ +import("system.neon"); import("system.result"); import("system.vars"); import("DocumentTemplate_lib"); [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATE_ID"), new FileUpload(vars.get("$field.bindata"))); -if (type != DocumentTemplate.types.ODT) - result.string(DocumentTemplate.serialLetterODTOnlyMessage()) \ No newline at end of file +if (type != DocumentTemplate.types.ODT && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)) + result.string(DocumentTemplate.serialLetterODTOnlyMessage()); \ No newline at end of file diff --git a/process/DocumentTemplate_lib/process.js b/process/DocumentTemplate_lib/process.js index 13ac7fa68124fa8c5f9b4a5b8179c5f190300e7a..06cad8e03caad7752f0a33f01ded45f040774a3b 100644 --- a/process/DocumentTemplate_lib/process.js +++ b/process/DocumentTemplate_lib/process.js @@ -308,7 +308,7 @@ DocumentTemplate.prototype.getReplacedContent = function (pReplacements, pEncode return emlContent; } case DocumentTemplate.types.HTML: - // replaces ä, ö, ü, ... with html escape signs + // replaces ä, ö, ü, ... with html escape signs for (let i in pReplacements) pReplacements[i] = text.text2html(pReplacements[i], false); case DocumentTemplate.types.TXT: @@ -397,6 +397,10 @@ DocumentTemplate.prototype.getSerialLetterByContactIds = function (pContactIds, { if (this.type == DocumentTemplate.types.ODT) { + let replacements = TemplateHelper._getReplacementsByContactIds(this, pContactIds); + let replaceArray = []; + for (let i = 0, l = pContactIds.length; i < l; i++) + replaceArray.push(replacements[pContactIds[i]]); return TemplateHelper._getReplacedODT(this, replaceArray, pTableData); } @@ -849,4 +853,4 @@ DocumentTemplateUtils.getContentType = function (pTemplateId, pFileUpload) } return type; -} +} \ No newline at end of file