From 0adece9c658ef90453fa574bcc2ff892c5c237bc Mon Sep 17 00:00:00 2001 From: "d.buechler" <d.buechler@adito.de> Date: Wed, 3 Jul 2019 10:55:23 +0200 Subject: [PATCH] =?UTF-8?q?Beim=20Updaten=20von=20Kampagnenteilnehmern=20w?= =?UTF-8?q?erden=20nun=20die=20gleichen=20Nachrichten=20angezeigt,=20wie?= =?UTF-8?q?=20beim=20Hinzuf=C3=BCgen.=20Die=20let=20condition=20im=20onIns?= =?UTF-8?q?ert=20wenn=20if(isUpdate=20=3D=3D=20"true")=20pr=C3=BCft=20nun?= =?UTF-8?q?=20sowohl=20auf=20die=20ContactId=20als=20auch=20die=20Particip?= =?UTF-8?q?antId.=20Dies=20kommt=20daher,=20dass=20an=20allen=20Stellen=20?= =?UTF-8?q?die=20ContactId=20genutzt=20wird,=20bis=20auf=20im=20FilterView?= =?UTF-8?q?=20der=20Teilnehmer.=20Hier=20wird=20immer=20die=20TeilnehmerId?= =?UTF-8?q?=20selektiert=20Update=20Action=20im=20CampaignParticipant=20en?= =?UTF-8?q?tity=20wurde=20um=20Filter-Condition=20Funktionalit=C3=A4t=20er?= =?UTF-8?q?weitert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CampaignAddParticipants_entity.aod | 4 + .../valueProcess.js | 88 ------------- .../isoperationvalid/valueProcess.js | 116 ++++++++++++++++++ .../recordcontainers/jdito/onInsert.js | 16 ++- .../onActionProcess.js | 14 ++- process/Campaign_lib/process.js | 77 +++++------- 6 files changed, 174 insertions(+), 141 deletions(-) create mode 100644 entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js diff --git a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod index ea28eb6426..0f5041a728 100644 --- a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod +++ b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod @@ -127,6 +127,10 @@ <name>dataSourceTableName_param</name> <expose v="true" /> </entityParameter> + <entityField> + <name>isOperationValid</name> + <valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js index b4015c5951..e69de29bb2 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js @@ -1,88 +0,0 @@ -import("Campaign_lib"); -import("system.logging"); -import("system.result"); -import("system.translate"); -import("system.vars"); - -//logging.log("campaignParticipantsRowIds_param -> " + vars.get("$param.campaignParticipantsRowIds_param")); -//logging.log("campaignParticipantsRowIds_param -> " + JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")).length); -//logging.log("campaignParticipantsRowIds_param -> " + vars.getString("$param.campaignParticipantsRowIds_param")); -//logging.log("campaignParticipantsCondition_param -> " + vars.getString("$param.campaignParticipantsCondition_param")); - -var campaignParticipantsAmount = 0; -var informationText = translate.text("participants will be added to the selected campaign step"); - -var targetTable = vars.get("$param.dataSourceTableName_param"); -var selectionRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")); -var selectedCampaignId = vars.get("$field.CAMPAIGN_ID"); -var selectedCampaignStepId = vars.get("$field.CAMPAIGNSTEP_ID"); - - -var participantCondition = ""; -var resultString = ""; -//logging.log("selectedCampaignId -> " + selectedCampaignId); - -if(selectedCampaignId == '') - result.string(resultString); -else -{ - /* - * First determines how many of the selected are already in the campaign - * If there are no valid participants at all or too many in respect of the - * selected steps max number of participants, nothing will be added. - * A message describing this situation will be written. - * - * If none of those criteria match, all participants are good to be added. - */ - var countParticipantsAlreadyInCampaign = 0; - var countParticipantsToAdd = 0; - var countValidParticipantsToAdd = 0; - //if theres a selection, we have to use it, otherwise use the condition - if(selectionRowIds != null && selectionRowIds.length > 0) - { - countParticipantsToAdd = selectionRowIds.length; - logging.log("selectedCampaignId -> " + selectedCampaignId); - countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyInStepCountByRowId(selectedCampaignId, selectionRowIds); - } - else - { - logging.log("campaignParticipantsCondition_param -> " + vars.getString("$param.campaignParticipantsCondition_param")); - participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; - countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition); - countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyInStepCountByCondition(selectedCampaignId, targetTable, participantCondition); - } - countValidParticipantsToAdd = countParticipantsToAdd - countParticipantsAlreadyInCampaign; - - logging.log("countParticipantsToAdd -> " + countParticipantsToAdd); - logging.log("countParticipantsAlreadyInCampaign -> " + countParticipantsAlreadyInCampaign); - logging.log("countValidParticipantsToAdd -> " + countValidParticipantsToAdd); - - if(countValidParticipantsToAdd <= 0) - { - resultString = "Alle selektierten Teilnehmer befinden sich bereits in der Stufe"; - } - else if(hasStepEnoughSlots(countValidParticipantsToAdd)) - { - resultString = countValidParticipantsToAdd + "/" + countParticipantsToAdd + " " + informationText; - - } - else - { - resultString = "Nicht genug Teilnehmerplätze für " - + countValidParticipantsToAdd + "/" + countParticipantsToAdd - + " Teilnehmern vorhanden"; - } - - result.string(resultString); -} - -function hasStepEnoughSlots(pCountToAdd) -{ -// logging.log(" selectedCampaignStepId-> " + selectedCampaignStepId); - let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId) - let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId) -// logging.log(" currentParticipants + pCountToAdd-> " + (parseInt(currentParticipants) + parseInt(pCountToAdd))); -// logging.log(" maxParticipants-> " + maxParticipants); -// logging.log(" (currentParticipants + pCountToAdd) <= maxParticipants-> " + ((currentParticipants + pCountToAdd) <= maxParticipants)); - return (parseInt(currentParticipants) + parseInt(pCountToAdd)) <= maxParticipants; -} \ No newline at end of file diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js new file mode 100644 index 0000000000..fb39eed20e --- /dev/null +++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js @@ -0,0 +1,116 @@ +import("Campaign_lib"); +import("system.logging"); +import("system.result"); +import("system.translate"); +import("system.vars"); +import("system.neon"); + +//logging.log("campaignParticipantsRowIds_param -> " + vars.get("$param.campaignParticipantsRowIds_param")); +//logging.log("campaignParticipantsRowIds_param -> " + JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")).length); +//logging.log("campaignParticipantsRowIds_param -> " + vars.getString("$param.campaignParticipantsRowIds_param")); +//logging.log("campaignParticipantsCondition_param -> " + vars.getString("$param.campaignParticipantsCondition_param")); + +var campaignParticipantsAmount = 0; +var informationText = translate.text("participants will be added to the selected campaign step"); + +var targetTable = vars.get("$param.dataSourceTableName_param"); +var selectionRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")); +var selectedCampaignId = vars.get("$field.CAMPAIGN_ID"); +var selectedCampaignStepId = vars.get("$field.CAMPAIGNSTEP_ID"); +var isUpdate = vars.get("$field.isUpdate"); + +var participantCondition = ""; +var messageString = ""; +var resultValue = "false"; +//logging.log("selectedCampaignId -> " + selectedCampaignId); + +if(selectedCampaignId != '') +{ + /* + * First determines how many of the selected are already in the campaign + * If there are no valid participants at all or too many in respect of the + * selected steps max number of participants, nothing will be added. + * A message describing this situation will be written. + * + * If none of those criteria match, all participants are good to be added. + */ + var countParticipantsAlreadyInCampaign = 0; + var countParticipantsToAdd = 0; + var countValidParticipantsToAdd = 0; + var whereCondition = ""; + var rowIdsComparisonField = ""; + + //if theres a selection, we have to use it, otherwise use the condition + if(selectionRowIds != null && selectionRowIds.length > 0) + { + countParticipantsToAdd = selectionRowIds.length; + + + /* + * The field against which will be checked, if the selection is already contained in the campaignStep + * depends on wether isUpdate is true or not. + * If true, the selected IDs are CampaignParticipantIds, otherwise contactIds. + * This happens because on true the action is called in the participants filterview to move participants + * between steps, on false new participants are in the process of being added to a step. + */ + if(isUpdate == "true") + { + rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID"; + whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'"; + } + else + { + rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CONTACT_ID"; + whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'"; + } + countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByRowId(whereCondition, rowIdsComparisonField, selectionRowIds); + } + else + { + participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; + + countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition); + + if(isUpdate == "true") + whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'"; + else + whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'"; + + countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, participantCondition); + //CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "'" + } + countValidParticipantsToAdd = countParticipantsToAdd - countParticipantsAlreadyInCampaign; + + logging.log("countParticipantsToAdd -> " + countParticipantsToAdd); + logging.log("countParticipantsAlreadyInCampaign -> " + countParticipantsAlreadyInCampaign); + logging.log("countValidParticipantsToAdd -> " + countValidParticipantsToAdd); + + if(countValidParticipantsToAdd <= 0) + { + messageString = "Alle selektierten Teilnehmer befinden sich bereits in der Stufe"; + } + else if(hasStepEnoughSlots(countValidParticipantsToAdd)) + { + messageString = countValidParticipantsToAdd + "/" + countParticipantsToAdd + " " + informationText; + resultValue = "true"; + } + else + { + messageString = "Nicht genug Teilnehmerplätze für " + + countValidParticipantsToAdd + "/" + countParticipantsToAdd + + " Teilnehmern vorhanden"; + } + neon.setFieldValue("$field.campaignParticipantMessage", messageString); + result.string(resultValue); +} + +function hasStepEnoughSlots(pCountToAdd) +{ +// logging.log(" selectedCampaignStepId-> " + selectedCampaignStepId); + let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId) + let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId) +// logging.log(" currentParticipants + pCountToAdd-> " + (parseInt(currentParticipants) + parseInt(pCountToAdd))); +// logging.log(" maxParticipants-> " + maxParticipants); +// logging.log(" (currentParticipants + pCountToAdd) <= maxParticipants-> " + ((currentParticipants + pCountToAdd) <= maxParticipants)); + return (parseInt(currentParticipants) + parseInt(pCountToAdd)) <= maxParticipants; +} \ No newline at end of file diff --git a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js index 6eeacc6b47..e571d933bc 100644 --- a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js +++ b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js @@ -19,8 +19,10 @@ var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumn if(participantRowIds != null && participantRowIds.length > 0) { let contactIdsToHandle = participantRowIds; + if(isUpdate == "false") contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds); + logging.log("contactIdsToHandle by rowIds -> " + contactIdsToHandle); _handleRowIds(contactIdsToHandle); } @@ -30,6 +32,8 @@ else _handleCondition(campaignId, conditionSourceTableName, participantCondition); } + + function _handleCondition(pCampaignId, pTargetTableName, pCondition) { let contactIdsToHandle = []; @@ -39,7 +43,7 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition) * Because they already are participants, no restrictions apply to the affected IDs. * * Otherwise the participants ought to be inserted. The only restriction right now is, hat the participants to be inserted - * musn't already be in this specific campaign. Therefore all IDs hat are defined by the condition and not in the campaign are selected. + * can't already be in this specific campaign. Therefore all IDs hat are defined by the condition and not in the campaign are selected. */ if(isUpdate == "true") { @@ -78,13 +82,14 @@ function _handleRowIds(pParticipantRowIds) for (participant in pParticipantRowIds) { let campaignParticipantLogId = util.getNewUUID(); + if(isUpdate == "true") { let updatedValues = [newCampaignStepId, vars.get("$sys.user"), vars.get("$sys.date")]; - let condition = "CAMPAIGNPARTICIPANTID = '" + pParticipantRowIds[participant] + "'"; + let condition = "CONTACT_ID = '" + pParticipantRowIds[participant] + "' OR CAMPAIGNPARTICIPANTID = '" + pParticipantRowIds[participant] + "'"; let valsCampaignParticipantLog = new Array(pParticipantRowIds[participant], campaignId, newCampaignStepId, campaignParticipantLogId, vars.get("$sys.user"), vars.get("$sys.date")); statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, updatedValues, condition]); @@ -107,9 +112,12 @@ function _handleRowIds(pParticipantRowIds) statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, valsCampaignParticipant]); } } - + logging.log("statementArray -> " + statementArray); if(isUpdate == "true") - db.updates(statementArray) + { + logging.log("vor db.updates??? -> "); + db.updates(statementArray) + } else db.inserts(statementArray); diff --git a/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js b/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js index 1b2aa9e9bb..15d7c2f29e 100644 --- a/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js @@ -1,11 +1,21 @@ +import("system.logging"); import("system.vars"); import("system.neon"); import("Campaign_lib"); -var sysSelection = vars.getString("$sys.selection"); +var sysSelection = vars.get("$sys.selection"); +var campaignId = vars.get("$field.CAMPAIGN_ID"); +var campaignStepId = vars.get("$field.CAMPAIGNSTEP_ID") if(sysSelection.length > 0) //selektierte IDs als Array { - CampaignUtils.openSetCampaignStepView(vars.getString("$sys.selection"), vars.get("$field.CAMPAIGN_ID"), vars.get("$field.CAMPAIGNSTEP_ID")); + CampaignUtils.openSetCampaignStepViewByRowIds(vars.getString("$sys.selection"), campaignId, campaignStepId); +} +else +{ + let sysFilter = vars.get("$sys.filter");//todo change name + logging.log("sysFilter -> " + sysFilter); + + CampaignUtils.openSetCampaignStepViewByCondition(JSON.stringify(sysFilter), campaignId, campaignStepId); } \ No newline at end of file diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 5fe24b9887..9fc534013e 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -158,7 +158,7 @@ CampaignUtils.getParticipantLogInsertColumnNames = function() /** * todo */ -CampaignUtils.openSetCampaignStepView = function(pParticipantIds, pCampaignId, pCampaignStepId) +CampaignUtils.openSetCampaignStepViewByRowIds = function(pParticipantIds, pCampaignId, pCampaignStepId) { var params = {}; params["campaignParticipantsRowIds_param"] = pParticipantIds; @@ -166,8 +166,20 @@ CampaignUtils.openSetCampaignStepView = function(pParticipantIds, pCampaignId, p params["currentCampaignStepId_param"] = pCampaignStepId; params["isUpdate_param"] = true; - + neon.openContext("CampaignAddParticipants", "CampaignAddParticipantsEdit_view", null, neon.OPERATINGSTATE_NEW, params); +} +/** + * todo + */ +CampaignUtils.openSetCampaignStepViewByCondition = function(pCondition, pCampaignId, pCampaignStepId) +{ + var params = {}; + params["campaignParticipantsCondition_param"] = pCondition; + params["currentCampaignId_param"] = pCampaignId; + params["currentCampaignStepId_param"] = pCampaignStepId; + params["isUpdate_param"] = true; + neon.openContext("CampaignAddParticipants", "CampaignAddParticipantsEdit_view", null, neon.OPERATINGSTATE_NEW, params); } @@ -310,60 +322,30 @@ CampaignUtils.checkforCommRestrictions = function() .buildSql("select MEDIUM from CAMPAIGNSTEP join COMMRESTRICTION on MEDIUM = STEPMEDIUM", "1=2")); } -//CampaignUtils.GetContactIdsNotInStepByRowIds = function(pCampaignId, pParticipantRowIds) -//{ -// //SELECT CAMPAIGNPARTICIPANTID FROM CAMPAIGNPARTICIPANT -// //WHERE CAMPAIGNPARTICIPANT.CONTACT_ID -// //IN ('4cc98357-25f3-462b-898c-440f9faf4b97','d5a2dc64-e503-4aed-a0c6-d54f49b8db87','45635aca-7971-43df-a683-c80c86cb58cc','1a67eaa7-21da-4a18-97ab-755ac5cb74f7') -// -// let rowIdsAsRay = _CampaignUtils._convertToSqlValuesList(pParticipantRowIds); -// -// let query = "SELECT CAMPAIGNPARTICIPANTID FROM CAMPAIGNPARTICIPANT" -// + " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "' AND" -// + " CAMPAIGNPARTICIPANT.CONTACT_ID NOT IN " + rowIdsAsRay; -// -// return db.array(db.COLUMN, query) -//} - -CampaignUtils.GetParticipantsAlreadyInStepCountByRowId = function(pCampaignId, pParticipantRowIds) +CampaignUtils.GetParticipantsAlreadyAddedCountByRowId = function(pWhereCondition, pRowIdsComparisonField, pParticipantRowIds) { let rowIdsAsRay = _CampaignUtils._convertToSqlValuesList(pParticipantRowIds); let query = "SELECT COUNT(*) FROM CAMPAIGNPARTICIPANT" - + " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "' AND" - + " CAMPAIGNPARTICIPANT.CONTACT_ID IN " + rowIdsAsRay; + + " where " + pWhereCondition + " AND" + + " " + pRowIdsComparisonField + " IN " + rowIdsAsRay; logging.log("GetParticipantsAlreadyInStepCountByRowId query -> " + query); return db.cell(query) } -CampaignUtils.GetParticipantsAlreadyInStepCountByCondition = function(pCampaignId, pTargetTableName, pCondition) +CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondition, pCondition) { - let targetIdField = "CONTACT.CONTACTID"; - - var joinCondition = ""; - if(pTargetTableName == "PERSON") - { - joinCondition = "PERSONID = PERSON_ID"; - } - else - { - joinCondition = "ORGANISATIONID = ORGANISATION_ID"; - } - - //select PERSON.* - //from CONTACT - //join PERSON on PERSONID = PERSON_ID - //where CONTACT.CONTACTID in ('d5a2dc64-e503-4aed-a0c6-d54f49b8db87','45635aca-7971-43df-a683-c80c86cb58cc','1a67eaa7-21da-4a18-97ab-755ac5cb74f7') - - let query = "select count(*) from CAMPAIGNPARTICIPANT" - + " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "' AND" - + " CAMPAIGNPARTICIPANT.CONTACT_ID in" - + " (" + _CampaignUtils._selectFromContactWithJoin(targetIdField, pTargetTableName, joinCondition, pCondition) - + ")"; + 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" + + " where " + pWhereCondition + + " and " + pCondition; - logging.log("query -> " + query); + logging.log("GetParticipantsAlreadyAddedCountByCondition query -> " + query); return db.cell(query) } @@ -397,13 +379,13 @@ CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCon CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondition) { - let query = "select CONTACT.CONTACTID, person.FIRSTNAME from PERSON" + let query = "select CONTACT.CONTACTID 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" + " where " + pCondition - + " and CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')"; + + " and CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "'"; return db.array(db.COLUMN, query); } @@ -413,7 +395,8 @@ CampaignUtils.GetContactCountByCondition = function(pCondition) 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 ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)" + + " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID"; if(pCondition != "") query += " where " + pCondition; -- GitLab