From ea0b9c906eab320bf59a28798205a12e7aa68687 Mon Sep 17 00:00:00 2001 From: Sophia Leierseder <s.leierseder@adito.de> Date: Wed, 19 Jun 2019 16:18:05 +0200 Subject: [PATCH] improvement icon comm restriction --- .../advertisingban_icon/colorProcess.js | 15 +++--- .../advertisingban_icon/valueProcess.js | 51 ++++--------------- process/Campaign_lib/process.js | 8 +++ 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js index 1a31540c51..6eb15be1cc 100644 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js @@ -1,19 +1,18 @@ +import("system.result"); import("Sql_lib"); import("system.db"); import("system.logging"); import("system.vars"); import("system.neon"); -import("system.result"); - -var stepmedium = db.cell(SqlCondition.begin() - .andPrepareVars("CAMPAIGNSTEP.CAMPAIGNSTEPID", "$field.CAMPAIGNSTEP_ID") - .buildSql("select STEPMEDIUM from CAMPAIGNSTEP", "1=2")); +import("Campaign_lib"); +//var commrescolor = CampaignUtils.checkforCommRestrictions(); + var commres = db.cell(SqlCondition.begin() .andPrepareVars("COMMRESTRICTION.CONTACT_ID", "$field.CONTACT_ID") - .andPrepareVars("COMMRESTRICTION.MEDIUM", stepmedium) - .buildSql("select MEDIUM from COMMRESTRICTION", "1=2")); - + .andPrepareVars("CAMPAIGNSTEP.CAMPAIGNSTEPID", "$field.CAMPAIGNSTEP_ID") + .buildSql("select MEDIUM from CAMPAIGNSTEP join COMMRESTRICTION on MEDIUM = STEPMEDIUM", "1=2")); + if(commres) { result.string(neon.PRIORITY_HIGH_COLOR); diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js index ca4ca2a02d..1f772f37e3 100644 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js @@ -1,50 +1,19 @@ +import("system.logging"); +import("system.result"); import("KeywordRegistry_basic"); import("Keyword_lib"); -import("system.result"); import("Sql_lib"); -import("system.logging"); -import("system.vars"); import("system.db"); +import("Campaign_lib"); -//var contact = vars.get("$field.CONTACT_ID"); - -var stepmedium = db.cell(SqlCondition.begin() - .andPrepareVars("CAMPAIGNSTEP.CAMPAIGNSTEPID", "$field.CAMPAIGNSTEP_ID") - .buildSql("select STEPMEDIUM from CAMPAIGNSTEP", "1=2")); - -//logging.log(stepmedium.toSource()); - -// commres is an array with all the keyword-IDs from a contacts comm restrictions -var commres = db.table(SqlCondition.begin() - .andPrepareVars("COMMRESTRICTION.CONTACT_ID", "$field.CONTACT_ID") - .andPrepareVars("COMMRESTRICTION.MEDIUM", stepmedium) - .buildSql("select MEDIUM from COMMRESTRICTION", "1=2")); - -//logging.log(commres.toSource()); - -var med; -var ban; - -for(var i = 0; i < commres.length; i++) +var commres = CampaignUtils.checkforCommRestrictions(); + +if(commres) { - if(commres[i] == stepmedium) - { - med = stepmedium - } -} - -if(med) -{ - var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(stepmedium, $KeywordRegistry.communicationMediumCampaign()) - ban = keywordAttributes.AdvertisingBanIcon; + var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commres, $KeywordRegistry.communicationMediumCampaign()) + result.string(keywordAttributes.AdvertisingBanIcon); } else { - ban = "VAADIN:CHECK"; -} - -result.string(ban) - - - - + result.string("VAADIN:CHECK"); +} \ No newline at end of file diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index c1a90cd8d8..ce5c723187 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -301,6 +301,14 @@ CampaignUtils.updateCampaignStep = function(pCampaignStepId, pDateStart, pDateEn db.updateData("CAMPAIGNSTEP", columnsToUpdate, null, newValues, campaignStepIdCondition) } +CampaignUtils.checkforCommRestrictions = function() +{ + return db.cell(SqlCondition.begin() + .andPrepareVars("COMMRESTRICTION.CONTACT_ID", "$field.CONTACT_ID") + .andPrepareVars("CAMPAIGNSTEP.CAMPAIGNSTEPID", "$field.CAMPAIGNSTEP_ID") + .buildSql("select MEDIUM from CAMPAIGNSTEP join COMMRESTRICTION on MEDIUM = STEPMEDIUM", "1=2")); +} + /** -- GitLab