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 index 2e544b656be1301c9cf5cf79664ba624b04af0b7..27052d9123b71810bd3c103ca52ea5926567dd69 100644 --- a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js +++ b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js @@ -7,5 +7,5 @@ import("system.result"); result.string("(" + newSelect("count(*)") .from("CONTACT") .where("CONTACT.CONTACTID = CAMPAIGNPARTICIPANT.CONTACT_ID") - .and(newWhere(ContactUtils.getCommRestrictionCondition(undefined, false, vars.get("$sys.date")))) + .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/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 045271f346c216e5096191d528780926216cb8e9..1dec1aa85bef5a13dc275ea364fb088f5d318e70 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1084,6 +1084,12 @@ </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> @@ -1262,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_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/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js b/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js index 183c051b3991475eb38a0d6e2b9df20219264072..5c633cb5d6343c9ab5546304ab34410b8062adc5 100644 --- a/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js +++ b/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js @@ -1,31 +1,4 @@ -import("system.vars"); +import("Contact_lib"); import("system.result"); -import("Sql_lib"); -import("Keyword_lib"); -import("KeywordRegistry_basic"); -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"); -}) - -result.string(sqlMasking.concat(parts, ", ", false)); \ No newline at end of file +result.string(ContactUtils.getActiveCommRestrictionsSubselect()); \ No newline at end of file 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/process/Contact_lib/process.js b/process/Contact_lib/process.js index 47e0a359f3e5940746e492209ac3c44598f5ec6a..de135042cea50176314d40d5b6a4b700c88018ad 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"); @@ -498,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) @@ -508,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