Skip to content
Snippets Groups Projects
Commit 976f9fbd authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

show commrestriction warnings in organisation

parent b84ebb2e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -1048,6 +1048,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>
......@@ -1239,6 +1245,10 @@
<isLookupFilter 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>
......
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());
}
import("Contact_lib");
import("system.result");
result.string(ContactUtils.getActiveCommRestrictionsSubselect());
\ No newline at end of file
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
......@@ -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>
......
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.datetime");
import("system.translate");
import("system.neon");
......@@ -451,7 +453,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)
{
return newSelect("CONTACTID")
.from("CONTACT")
......@@ -460,6 +462,41 @@ ContactUtils.hasCommRestriction = function (pContactId, pMedium, pStartDate)
.cell() != "";
}
/**
* 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment