diff --git a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod index deb48c07a60ab8c1040e1b8a9a99c82bd7ab82bd..f1b69e47f9e8372e9f0e52c5266d08b45affec1b 100644 --- a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod +++ b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod @@ -190,14 +190,14 @@ <name>ADVERTISINGBAN_ICON</name> <colorProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js</colorProcess> <contentType>IMAGE</contentType> - <valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js</displayValueProcess> </entityField> <entityConsumer> <name>ParticipantsCommRestiction</name> <dependency> <name>dependency</name> <entityName>CommRestriction_Entity</entityName> - <fieldName>PersonsCommRestriction</fieldName> + <fieldName>CommRestrictions</fieldName> </dependency> </entityConsumer> <entityConsumer> @@ -277,10 +277,6 @@ <name>CAMPAIGNPARTICIPANTID.displayValue</name> <recordfield>CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID</recordfield> </dbRecordFieldMapping> - <dbRecordFieldMapping> - <name>ADVERTISINGBAN.value</name> - <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban.value/expression.js</expression> - </dbRecordFieldMapping> <dbRecordFieldMapping> <name>STANDARD_PHONE_COMMUNICATION.displayValue</name> <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.displayvalue/expression.js</expression> @@ -289,6 +285,10 @@ <name>STANDARD_EMAIL_COMMUNICATION.displayValue</name> <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.displayvalue/expression.js</expression> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>ADVERTISINGBAN_ICON.value</name> + <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> </recordContainers> diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js index 3eb3a718c487bffa661a1be7118944382102d9ab..1bcf3daac52e4e4473b002a163317af1c88db283 100644 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js @@ -4,12 +4,10 @@ import("system.db"); import("system.vars"); import("system.neon"); import("Campaign_lib"); - -var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID")); -if(commres) +if(vars.get("$field.ADVERTISINGBAN_ICON") > 0) { - result.string(neon.PRIORITY_HIGH_COLOR); + result.string(neon.PRIORITY_MEDIUM_COLOR); } else { diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..837878d3b76182bb3c42d5b51b73c23349f95204 --- /dev/null +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js @@ -0,0 +1,12 @@ +import("system.result"); +import("system.vars"); + +// Now show warning always, if any commrestriction exists. No matter which medium the current step has. +if (vars.get("$field.ADVERTISINGBAN_ICON") == 0) +{ + result.string("VAADIN:CHECK"); +} +else +{ + result.string("VAADIN:WARNING"); +} \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js deleted file mode 100644 index 9fdd845ab16b3d16340afe51c363673a7942f1a6..0000000000000000000000000000000000000000 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js +++ /dev/null @@ -1,19 +0,0 @@ -import("system.vars"); -import("system.result"); -import("KeywordRegistry_basic"); -import("Keyword_lib"); -import("Sql_lib"); -import("system.db"); -import("Campaign_lib"); - -var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID")); - -if(commres) -{ - var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commres, $KeywordRegistry.communicationMediumCampaign()) - result.string(keywordAttributes.AdvertisingBanIcon); -} -else -{ - result.string("VAADIN:CHECK"); -} \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban.value/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban.value/expression.js deleted file mode 100644 index 6d7b0fbce0469fbb63c347dd3e019e50def57e25..0000000000000000000000000000000000000000 --- a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban.value/expression.js +++ /dev/null @@ -1,6 +0,0 @@ -import("system.result"); - -result.string("(select MEDIUM from CAMPAIGNSTEP \n\ - join COMMRESTRICTION on MEDIUM = STEPMEDIUM \n\ - where COMMRESTRICTION.CONTACT_ID = CAMPAIGNPARTICIPANT.CONTACT_ID \n\ - and CAMPAIGNSTEP.CAMPAIGNSTEPID = CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID)"); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..27052d9123b71810bd3c103ca52ea5926567dd69 --- /dev/null +++ b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js @@ -0,0 +1,11 @@ +import("system.vars"); +import("Contact_lib"); +import("Sql_lib"); +import("system.result"); + +// Now show warning always, if any commrestriction exists. No matter which medium the current step has. +result.string("(" + newSelect("count(*)") + .from("CONTACT") + .where("CONTACT.CONTACTID = CAMPAIGNPARTICIPANT.CONTACT_ID") + .and(newWhere(ContactUtils.getCommRestrictionCondition(undefined, false, vars.get("$sys.date")))) // TODO: the newWhere can be removed when getCommRestrictionCondition returns a sqlBuilder instead of a SqlCondition + .toString() + ")"); \ No newline at end of file diff --git a/entity/CommRestriction_Entity/CommRestriction_Entity.aod b/entity/CommRestriction_Entity/CommRestriction_Entity.aod index 1206a0b74a99ac029248d129684624d97f00820a..eb0611da15dc1f079e8ed713304b1f164fc31e3d 100644 --- a/entity/CommRestriction_Entity/CommRestriction_Entity.aod +++ b/entity/CommRestriction_Entity/CommRestriction_Entity.aod @@ -69,7 +69,7 @@ </children> </entityConsumer> <entityProvider> - <name>PersonsCommRestriction</name> + <name>CommRestrictions</name> <dependencies> <entityDependency> <name>b50e33cd-e20f-4bdf-b0ee-2ecdab921ffd</name> @@ -77,6 +77,12 @@ <fieldName>CommRestrictions</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>1108f15c-75e3-49a8-b1cd-03259bfbb8a0</name> + <entityName>Organisation_entity</entityName> + <fieldName>CommRestrictions</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> </entityProvider> <entityParameter> diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 49fe08a89b2c9df270e437a400d22dd61e76508d..1dec1aa85bef5a13dc275ea364fb088f5d318e70 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1070,6 +1070,26 @@ </entityParameter> </children> </entityConsumer> + <entityConsumer> + <name>CommRestrictions</name> + <dependency> + <name>dependency</name> + <entityName>CommRestriction_Entity</entityName> + <fieldName>CommRestrictions</fieldName> + </dependency> + <children> + <entityParameter> + <name>ContactId_param</name> + <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/commrestrictions/children/contactid_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityField> + <name>COMMRESTRICTIONS_ACTIVE</name> + <title>Commrestrictions</title> + <color>$priority-high-color</color> + <displayValueProcess>%aditoprj%/entity/Organisation_entity/entityfields/commrestrictions_active/displayValueProcess.js</displayValueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -1248,6 +1268,10 @@ <isFilterable v="true" /> <filtertype>BASIC</filtertype> </consumerMapping> + <dbRecordFieldMapping> + <name>COMMRESTRICTIONS_ACTIVE.value</name> + <expression>%aditoprj%/entity/Organisation_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> <filterExtensions> <filterExtensionSet> diff --git a/entity/Organisation_entity/entityfields/commrestrictions/children/contactid_param/valueProcess.js b/entity/Organisation_entity/entityfields/commrestrictions/children/contactid_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..08da3b121c951607015025c5ed6ea3ea8de1a4cb --- /dev/null +++ b/entity/Organisation_entity/entityfields/commrestrictions/children/contactid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.getString("$field.CONTACTID")); \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/commrestrictions_active/displayValueProcess.js b/entity/Organisation_entity/entityfields/commrestrictions_active/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7c4af0e4fa02778b34f7ee839230b0ca0d973da4 --- /dev/null +++ b/entity/Organisation_entity/entityfields/commrestrictions_active/displayValueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.translate"); +import("system.result"); + +if (vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim()) +{ + result.string(translate.text("No advertising by") + " " + vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim()); +} diff --git a/entity/Organisation_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js b/entity/Organisation_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..5c633cb5d6343c9ab5546304ab34410b8062adc5 --- /dev/null +++ b/entity/Organisation_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js @@ -0,0 +1,4 @@ +import("Contact_lib"); +import("system.result"); + +result.string(ContactUtils.getActiveCommRestrictionsSubselect()); \ No newline at end of file diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 9ccc4389ccb323a9c1a87cffdb1705c3d7d93dd5..be93a1f209dc0ca771a75e168a283e9f14b16091 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -801,7 +801,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <dependency> <name>dependency</name> <entityName>CommRestriction_Entity</entityName> - <fieldName>PersonsCommRestriction</fieldName> + <fieldName>CommRestrictions</fieldName> </dependency> <children> <entityParameter> @@ -1148,6 +1148,12 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <entityField> <name>LEAD_LEADID</name> </entityField> + <entityField> + <name>COMMRESTRICTIONS_ACTIVE</name> + <title>Commrestrictions</title> + <color>$priority-high-color</color> + <displayValueProcess>%aditoprj%/entity/Person_entity/entityfields/commrestrictions_active/displayValueProcess.js</displayValueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -1400,6 +1406,10 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <isFilterable v="true" /> <filtertype>BASIC</filtertype> </consumerMapping> + <dbRecordFieldMapping> + <name>COMMRESTRICTIONS_ACTIVE.value</name> + <expression>%aditoprj%/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> <filterExtensions> <filterExtensionSet> diff --git a/entity/Person_entity/entityfields/commrestrictions_active/displayValueProcess.js b/entity/Person_entity/entityfields/commrestrictions_active/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7c4af0e4fa02778b34f7ee839230b0ca0d973da4 --- /dev/null +++ b/entity/Person_entity/entityfields/commrestrictions_active/displayValueProcess.js @@ -0,0 +1,8 @@ +import("system.vars"); +import("system.translate"); +import("system.result"); + +if (vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim()) +{ + result.string(translate.text("No advertising by") + " " + vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim()); +} diff --git a/entity/Person_entity/recordcontainers/db/onDBInsert.js b/entity/Person_entity/recordcontainers/db/onDBInsert.js index ce609c6ee035ef5dea082e84402c305f31e68ffd..134d6e77fb05d74fd0c9b383bf4ce3023da7a739 100644 --- a/entity/Person_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Person_entity/recordcontainers/db/onDBInsert.js @@ -1,12 +1,8 @@ -import("system.translate"); -import("Employee_lib"); import("system.util"); -import("system.logging"); -import("system.vars"); +import("Sql_lib"); +import("system.db"); import("DataPrivacy_lib"); -import("DuplicateScanner_lib"); -import("system.notification"); -import("system.project"); +import("system.vars"); //let targetEntity = "Person_entity"; let contactId = vars.get("$local.uid"); diff --git a/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js b/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..5c633cb5d6343c9ab5546304ab34410b8062adc5 --- /dev/null +++ b/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js @@ -0,0 +1,4 @@ +import("Contact_lib"); +import("system.result"); + +result.string(ContactUtils.getActiveCommRestrictionsSubselect()); \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 6f7dae0b4a66b998a4a0d1c51c88bcf7e6d76523..4bda0f67b215bee07388df1e4af54935e6bc4dac 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -5915,6 +5915,12 @@ <entry> <key>File from this template could not be found anymore. Please go to the template and upload a new file.</key> </entry> + <entry> + <key>Commrestrictions</key> + </entry> + <entry> + <key>No advertising by</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 70a21bfacd568952c372ff46bc92f4f4fa6c6a26..01f7641510fd62bddde2e960607d42849e24a84c 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -7431,6 +7431,13 @@ <key>File from this template could not be found anymore. Please go to the template and upload a new file.</key> <value>Die Datei dieser Vorlage konnte nicht mehr gefunden werde. Bitte laden Sie bei der Dokumentvorlage eine neue Datei hoch.</value> </entry> + <entry> + <key>Commrestrictions</key> + </entry> + <entry> + <key>No advertising by</key> + <value>Keine Werbung durch</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index afc6d30b6aa2430100b7112ffd9e0e70378f5383..d77cfa098ac685b557befad1fcccb08b94a505f6 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -5965,6 +5965,12 @@ <entry> <key>File from this template could not be found anymore. Please go to the template and upload a new file.</key> </entry> + <entry> + <key>Commrestrictions</key> + </entry> + <entry> + <key>No advertising by</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonContext/Organisation/Organisation.aod b/neonContext/Organisation/Organisation.aod index bddc5f4e9dc436f799d3c90e933597a84c4d3a4c..59ce4ecbe8b6e1aa3e2e59b969ee09530c977c90 100644 --- a/neonContext/Organisation/Organisation.aod +++ b/neonContext/Organisation/Organisation.aod @@ -47,5 +47,9 @@ <name>51a18051-fcb8-4d90-9075-802fdce12f9c</name> <view>OrganisationTaskAppointment_view</view> </neonViewReference> + <neonViewReference> + <name>c72caf13-37cf-4af9-811d-832f43801369</name> + <view>OrganisationAttributeRestriction_view</view> + </neonViewReference> </references> </neonContext> diff --git a/neonView/OrganisationAttributeRestriction_view/OrganisationAttributeRestriction_view.aod b/neonView/OrganisationAttributeRestriction_view/OrganisationAttributeRestriction_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..d53d86c059ce89773f31a771cc4db3a4a6e21189 --- /dev/null +++ b/neonView/OrganisationAttributeRestriction_view/OrganisationAttributeRestriction_view.aod @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2"> + <name>OrganisationAttributeRestriction_view</name> + <title>Attributes</title> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <neonViewReference> + <name>8226fe7b-877b-4093-9fc4-dbe7d7f8a8ea</name> + <entityField>AttributeTree</entityField> + <view>AttributeRelationTree_view</view> + </neonViewReference> + <neonViewReference> + <name>2c260627-f087-4240-8a6d-e7aa25bbe812</name> + <entityField>CommRestrictions</entityField> + <view>CommRestrictionDrawer_view</view> + </neonViewReference> + </children> +</neonView> diff --git a/neonView/OrganisationMain_view/OrganisationMain_view.aod b/neonView/OrganisationMain_view/OrganisationMain_view.aod index b7faebeb1416f5b51f161b590ba7cf6814d84a67..ecf0ab98c9be2cb2b608bb6c969772074e35a916 100644 --- a/neonView/OrganisationMain_view/OrganisationMain_view.aod +++ b/neonView/OrganisationMain_view/OrganisationMain_view.aod @@ -46,9 +46,9 @@ <view>OrganisationTaskAppointment_view</view> </neonViewReference> <neonViewReference> - <name>ba50e069-06da-440e-b04a-5a686fcf5303</name> - <entityField>AttributeTree</entityField> - <view>AttributeRelationTree_view</view> + <name>486b4999-ac17-4560-9ce0-0f20a0028d02</name> + <entityField>#ENTITY</entityField> + <view>OrganisationAttributeRestriction_view</view> </neonViewReference> <neonViewReference> <name>eba90ed2-5e55-4cdb-9e0b-5a09feeb7536</name> diff --git a/neonView/OrganisationPreview_view/OrganisationPreview_view.aod b/neonView/OrganisationPreview_view/OrganisationPreview_view.aod index 9781eefd461fce6883e9c4368ab1de3fcd7f4a6b..6bbd645e75383d95e164e48c1b19e33abe05311e 100644 --- a/neonView/OrganisationPreview_view/OrganisationPreview_view.aod +++ b/neonView/OrganisationPreview_view/OrganisationPreview_view.aod @@ -17,6 +17,7 @@ <descriptionField>CUSTOMERCODE_DISPLAY_fieldGroup</descriptionField> <favoriteAction1>newActivity</favoriteAction1> <entityField>#ENTITY</entityField> + <informationField>COMMRESTRICTIONS_ACTIVE</informationField> </cardViewTemplate> <neonViewReference> <name>2cb11b4e-dd8e-419b-8fff-ef0852ef2641</name> diff --git a/neonView/PersonPreview_view/PersonPreview_view.aod b/neonView/PersonPreview_view/PersonPreview_view.aod index 3ba66814fe4c5c2d86f64a6af9eaf62d2c94707f..8d097377da82ef2158e81a896fff2ec330063bd4 100644 --- a/neonView/PersonPreview_view/PersonPreview_view.aod +++ b/neonView/PersonPreview_view/PersonPreview_view.aod @@ -17,6 +17,7 @@ <descriptionField>ORGANISATION_CONTACTID</descriptionField> <favoriteAction1>newActivity</favoriteAction1> <entityField>#ENTITY</entityField> + <informationField>COMMRESTRICTIONS_ACTIVE</informationField> </cardViewTemplate> <neonViewReference> <name>5a1b7683-2fec-4763-9b45-e4c7a18d70fd</name> @@ -36,6 +37,7 @@ <genericViewTemplate> <name>Info</name> <showDrawer v="true" /> + <hideEmptyFields v="true" /> <entityField>#ENTITY</entityField> <fields> <entityFieldLink> diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index 8430a18f3f8e117d4159a0f4ac264cdc611528e2..02dd4110fd7edd124453763cdb86d73f9c6d179a 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -1,3 +1,5 @@ +import("KeywordRegistry_basic"); +import("Keyword_lib"); import("system.datetime"); import("system.translate"); import("system.neon"); @@ -323,9 +325,9 @@ ContactUtils.getOrganisationContactId = function(pAnyContactId) { if (!pAnyContactId) return ""; - + var idSql = SqlCondition.begin() - .andPrepare("anyContact.CONTACTID", pAnyContactId, null, SqlUtils.getSingleColumnType("CONTACT", "CONTACTID")) + .andPrepare(["CONTACT", "CONTACTID", "anyContact"], pAnyContactId) .and("CONTACT.PERSON_ID is null") .buildSql("select CONTACT.CONTACTID \n\ from CONTACT\n\ @@ -456,10 +458,10 @@ ContactUtils.getDefaultAddressId = function(pContactId) /** * makes a SqlCondition that checks if there's (not) a commrestriction for a contact * - * @param {String} pMedium medium to check + * @param {String} [pMedium=undefined] medium to check if undefined, don't check it * @param {boolean} [pNoRestriction=false] if true, the condition gets every contact that has no * a commrestriction, otherwise every contact that has a commrestriction - * @param {String|Number} [pStartDate=current date] the start date of the commrestriction + * @param {String|Number} [pStartDate=current date] date to check against the start date of the commrestriction * * @return {SqlCondition} the condition */ @@ -471,11 +473,18 @@ ContactUtils.getCommRestrictionCondition = function (pMedium, pNoRestriction, pS .select("COMMRESTRICTIONID") .from("COMMRESTRICTION") .where(SqlCondition.begin() - .andPrepare("COMMRESTRICTION.MEDIUM", pMedium) + .andPrepareIfSet("COMMRESTRICTION.MEDIUM", pMedium) .andPrepare("COMMRESTRICTION.STARTDATE", pStartDate, "# <= ?") - .and("(COMMRESTRICTION.CONTACT_ID = CONTACT.CONTACTID or COMMRESTRICTION.CONTACT_ID = CONTACT.PERSON_ID)") + .and(SqlCondition.begin() + // check contactid + .or("COMMRESTRICTION.CONTACT_ID = CONTACT.CONTACTID") + // or the contact id of the organisation + .or("COMMRESTRICTION.CONTACT_ID = (select orgContact.CONTACTID from CONTACT anyContact \n\ + join CONTACT orgContact on anyContact.ORGANISATION_ID = orgContact.ORGANISATION_ID \n\ + and orgContact.PERSON_ID is null where anyContact.CONTACTID = CONTACT.CONTACTID)") + ) .build("1=2")); - + var cond = "exists"; if (pNoRestriction) cond = "not " + cond; @@ -491,7 +500,7 @@ ContactUtils.getCommRestrictionCondition = function (pMedium, pNoRestriction, pS * * @return {Boolean} true, if the contact has a commrestriction, otherwise false */ -ContactUtils.hasCommRestriction = function (pContactId, pMedium, pStartDate) +ContactUtils.hasCommRestriction = function(pContactId, pMedium, pStartDate) { var query = SqlCondition.begin() .andPrepare("CONTACT.CONTACTID", pContactId) @@ -501,6 +510,41 @@ ContactUtils.hasCommRestriction = function (pContactId, pMedium, pStartDate) return db.cell(query) != "0"; } +/** + * returns a sql subselect which concatenates all commrestriction displayvalues (translated). + * The select needs the CONTACT.CONTACTID column. + * + * @return {String} the resulting subselect + */ +ContactUtils.getActiveCommRestrictionsSubselect = function() +{ + var mediumList = KeywordUtils.getEntryNamesAndIdsByContainer($KeywordRegistry.communicationMediumCampaign()); + var sqlMasking = new SqlMaskingUtils(); + + var parts = []; + + var orgContactSubselect = newSelect("orgContact.CONTACTID") + .from("CONTACT anyContact") + .join("CONTACT orgContact", newWhere("anyContact.ORGANISATION_ID = orgContact.ORGANISATION_ID") + .and("orgContact.PERSON_ID IS NULL")) + .where("anyContact.CONTACTID = CONTACT.CONTACTID") + + mediumList.forEach(function(pMedium) + { + var subquery = newSelect("COMMRESTRICTION.MEDIUM, COMMRESTRICTIONID") + .from("COMMRESTRICTION") + .where("COMMRESTRICTION.MEDIUM", pMedium[0]) + .and("COMMRESTRICTION.STARTDATE", vars.get("$sys.date"), "# <= ?") + .and(newWhere() + .or("COMMRESTRICTION.CONTACT_ID = CONTACT.CONTACTID") + .or("COMMRESTRICTION.CONTACT_ID", orgContactSubselect)); + + parts.push("case when exists(" + subquery.toString() + ") then '" + pMedium[1] + "' else '' end"); + }) + + return sqlMasking.concat(parts, ", ", false); +} + /** * object for handling of a single contact * provides static- and instance-functions