From 350534edb6662514dc4e360c0edca1170067f858 Mon Sep 17 00:00:00 2001 From: "d.buechler" <d.buechler@adito.de> Date: Wed, 3 Jul 2019 14:28:20 +0200 Subject: [PATCH] Condition + Selektion Serienaktion funktionieren nun bei den Personen und beim Updaten der Teilnehmer in der Teilnehmerliste. Integrieren ORGANISATION begonnen, Serienaktion wurde angepasst. --- .../isoperationvalid/valueProcess.js | 14 +++++++++++--- .../Organisation_entity/Organisation_entity.aod | 2 +- .../addtocampaignfromtable/onActionProcess.js | 12 +++++++++--- process/Campaign_lib/process.js | 16 +++++++++++----- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js index fb39eed20e0..471416a0f86 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js @@ -68,9 +68,17 @@ if(selectedCampaignId != '') else { participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; - - countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition); - + logging.log("im isOperationValid -> "); + countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition, isUpdate); + logging.log("countParticipantsToAdd -> " + countParticipantsToAdd); + + /* + * If the update mode is active, the goal is to move participants between steps. + * therefore the check if the affected participants already are added to a particluar step has to be on the step level. + * + * If not, participants are to be added. It has to be checked if a participant is in a campaign, regardless of the particular + * step because one participant can be in a campaign just once. + */ if(isUpdate == "true") whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'"; else diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index ac2e0d37071..4ea751da805 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -774,7 +774,7 @@ <title>Add to Campaign</title> <onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js</onActionProcess> <isObjectAction v="false" /> - <isSelectionAction v="true" /> + <isSelectionAction v="false" /> <iconId>NEON:GROUP_APPOINTMENT</iconId> <tooltip>Add the selection to a campaign</tooltip> <tooltipProcess>%aditoprj%/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/tooltipProcess.js</tooltipProcess> diff --git a/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js b/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js index 8ae8d45bb07..c9b89f86a88 100644 --- a/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js +++ b/entity/Organisation_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js @@ -2,14 +2,20 @@ import("system.vars"); import("system.neon"); import("Campaign_lib"); -var sysSelection = vars.getString("sys.selection"); +var sysSelection = vars.get("$sys.selection"); +/* + * If there's a selection only those are ought to be added. + * Otherwise the filter gets checked, if a filter has beed set, the condition + * is used to determine the objects to be added. + * If no selection has been set, all objects will be added. + */ if(sysSelection.length > 0) //selektierte IDs als Array { - CampaignUtils.addParticipantsByRowIds(sysSelection, "ORGANISATION"); + CampaignUtils.addParticipantsByRowIds(JSON.stringify(sysSelection), "ORGANISATION"); } else { let sysFilter = vars.get("$sys.filter");//todo change name - CampaignUtils.addParticipantsByCondition(sysFilter.condition, "ORGANISATION"); + CampaignUtils.addParticipantsByCondition(JSON.stringify(sysFilter), "ORGANISATION"); } \ No newline at end of file diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 9fc534013e2..e16e5b948a2 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -343,8 +343,10 @@ CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondi + " left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)" + " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID" + " where " + pWhereCondition - + " and " + pCondition; + if(pCondition != "") + query += " and " + pCondition; + logging.log("GetParticipantsAlreadyAddedCountByCondition query -> " + query); return db.cell(query) @@ -369,11 +371,13 @@ CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCon + " join CONTACT on (CONTACT.PERSON_ID = PERSON.PERSONID)" + " join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID)" + " left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)" - + " where " + pCondition - + " and CONTACT.CONTACTID not in" + + " where CONTACT.CONTACTID not in" + " (select CAMPAIGNPARTICIPANT.CONTACT_ID from CAMPAIGNPARTICIPANT where" + " CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')"; + if(pCondition != "") + query += " and " + pCondition; + return db.array(db.COLUMN, query); } @@ -390,13 +394,15 @@ CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondit return db.array(db.COLUMN, query); } -CampaignUtils.GetContactCountByCondition = function(pCondition) +CampaignUtils.GetContactCountByCondition = function(pCondition, pLookInCampaignOnly) { let query = "select count(*) from PERSON" + " join CONTACT on (CONTACT.PERSON_ID = PERSON.PERSONID)" + " join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID)" + " left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)" - + " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID"; + + if(pLookInCampaignOnly == "true") + query += " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID"; if(pCondition != "") query += " where " + pCondition; -- GitLab