diff --git a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod index 739af475cf32f3e866ad3e7f5937df224dbb4712..447fef3d4393c2b2dc7924ab017ea3d896006850 100644 --- a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod +++ b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod @@ -7,7 +7,6 @@ <siblings> <element>CampaignParticipant_entity</element> </siblings> - <onValidation>%aditoprj%/entity/CampaignAddParticipants_entity/onValidation.js</onValidation> <recordContainer>datalessConfig</recordContainer> <entityFields> <entityProvider> diff --git a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js index da55ecfd803c8c1409ddc353064db1f037f49583..1b5987419561f447d26a0366fec02180e328d71d 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/onActionProcess.js @@ -40,7 +40,7 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition) let contactIdsToHandle = []; let useRightJoinToGetOrgs = "false"; - if(pTargetTableName == "ORGANISATION") + if(pTargetTableName == "Organisation") { useRightJoinToGetOrgs = "true"; pCondition += " and PERSON.PERSONID is NULL" @@ -96,23 +96,27 @@ function _handleRowIds(pParticipantRowIds, pCampaignId) let statementArray = []; let logArray = []; + let participantRowIds = pParticipantRowIds; + if(participantRowIds[0].length == 1) //pParticipantRowIds isn't parsed yet when the data has been selected, so we parse it here + participantRowIds = JSON.parse(pParticipantRowIds); - for (let participant in pParticipantRowIds) + + for (let participantRowId of participantRowIds) { let campaignParticipantLogId = util.getNewUUID(); if(isUpdate == "true") { - let oldCampaignStepId = oldStepIds[pParticipantRowIds[participant]] || ""; + let oldCampaignStepId = oldStepIds[participantRowId] || ""; let updatedValues = [newCampaignStepId, vars.get("$sys.user"), vars.get("$sys.date")]; - let condition = newWhere("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds[participant]) - .or("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", pParticipantRowIds[participant]); + let condition = newWhere("CAMPAIGNPARTICIPANT.CONTACT_ID", participantRowId) + .or("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", participantRowId); let valsCampaignParticipantLog = [ - pParticipantRowIds[participant], + participantRowId, campaignId, newCampaignStepId, campaignParticipantLogId, @@ -129,7 +133,7 @@ function _handleRowIds(pParticipantRowIds, pCampaignId) let campaignParticipantId = util.getNewUUID(); let valsCampaignParticipant = [ campaignParticipantId - , pParticipantRowIds[participant] + , participantRowId , campaignId , newCampaignStepId , vars.get("$sys.user") diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js index 512ffebcbe138c38a1bb1d1160217ff6fc6d8e69..915d12d13a1e2162e16c58f84573bb7246a0a7cd 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js @@ -63,7 +63,7 @@ if(selectedCampaignId != '') participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition; let useRightJoinToGetOrgs = "false"; - if(targetTable == "ORGANISATION") + if(targetTable == "Organisation") { useRightJoinToGetOrgs = "true"; diff --git a/entity/CampaignAddParticipants_entity/onValidation.js b/entity/CampaignAddParticipants_entity/onValidation.js deleted file mode 100644 index 26f9361c063cd11c177e8a1778ab28d1feda9bf6..0000000000000000000000000000000000000000 --- a/entity/CampaignAddParticipants_entity/onValidation.js +++ /dev/null @@ -1,8 +0,0 @@ -import("system.translate"); -import("system.vars"); -import("system.result"); - -if (vars.get("$field.isOperationValid") == "false") -{ - result.object(translate.text("no valid selection")); -} \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js b/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js index 81097eaaf9c8078380bb8851862b38e18fb1abf1..eca60a8c04b793163f4a408938ecd2c4d172cbbb 100644 --- a/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js +++ b/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js @@ -2,6 +2,6 @@ import("FilterviewMenuAction_lib"); import("system.vars"); import("system.result"); -var contactCount = vars.get("$sys.datarowcount"); +var orgCount = vars.get("$sys.datarowcount"); -result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(orgCount)); \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js b/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js index 98d07ed94330546f78f2e51c304d9e0faf664903..81097eaaf9c8078380bb8851862b38e18fb1abf1 100644 --- a/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js +++ b/entity/Organisation_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js @@ -4,4 +4,4 @@ import("system.result"); var contactCount = vars.get("$sys.datarowcount"); -FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js index 98d07ed94330546f78f2e51c304d9e0faf664903..81097eaaf9c8078380bb8851862b38e18fb1abf1 100644 --- a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js +++ b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtobulkmailfromtable/stateProcess.js @@ -4,4 +4,4 @@ import("system.result"); var contactCount = vars.get("$sys.datarowcount"); -FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js index 98d07ed94330546f78f2e51c304d9e0faf664903..81097eaaf9c8078380bb8851862b38e18fb1abf1 100644 --- a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js +++ b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtocampaignfromtable/stateProcess.js @@ -4,4 +4,4 @@ import("system.result"); var contactCount = vars.get("$sys.datarowcount"); -FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtoserialletter/stateProcess.js b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtoserialletter/stateProcess.js index 98d07ed94330546f78f2e51c304d9e0faf664903..81097eaaf9c8078380bb8851862b38e18fb1abf1 100644 --- a/entity/Person_entity/entityfields/filterviewactiongroup/children/addtoserialletter/stateProcess.js +++ b/entity/Person_entity/entityfields/filterviewactiongroup/children/addtoserialletter/stateProcess.js @@ -4,4 +4,4 @@ import("system.result"); var contactCount = vars.get("$sys.datarowcount"); -FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/filterviewactiongroup/children/export/stateProcess.js b/entity/Person_entity/entityfields/filterviewactiongroup/children/export/stateProcess.js index 98d07ed94330546f78f2e51c304d9e0faf664903..81097eaaf9c8078380bb8851862b38e18fb1abf1 100644 --- a/entity/Person_entity/entityfields/filterviewactiongroup/children/export/stateProcess.js +++ b/entity/Person_entity/entityfields/filterviewactiongroup/children/export/stateProcess.js @@ -4,4 +4,4 @@ import("system.result"); var contactCount = vars.get("$sys.datarowcount"); -FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount); \ No newline at end of file +result.string(FilterviewMenuActionUtils.getComponentStateByRowCount(contactCount)); \ No newline at end of file diff --git a/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod b/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod index 0de13f5543f8b6b4ba16bb8795868608aac3e1c8..1f64a27f201c688fb2ea1f074dadbb250790dfe9 100644 --- a/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod +++ b/entity/SerialLetterAddRecipients_entity/SerialLetterAddRecipients_entity.aod @@ -74,6 +74,9 @@ <name>#PROVIDER_AGGREGATES</name> <useAggregates v="true" /> </entityProvider> + <entityField> + <name>notAddedRecipients</name> + </entityField> </entityFields> <recordContainers> <datalessRecordContainer> diff --git a/entity/SerialLetterAddRecipients_entity/entityfields/recipientcontactids/valueProcess.js b/entity/SerialLetterAddRecipients_entity/entityfields/recipientcontactids/valueProcess.js index 385706891b99b737c6892b3b1f818cbf0a7c48f2..f88ef04fc2ef4102f84237cb282ba3c016a5ff08 100644 --- a/entity/SerialLetterAddRecipients_entity/entityfields/recipientcontactids/valueProcess.js +++ b/entity/SerialLetterAddRecipients_entity/entityfields/recipientcontactids/valueProcess.js @@ -1,3 +1,5 @@ +import("system.eMath"); +import("system.neon"); import("FilterviewMenuAction_lib"); import("Contact_lib"); import("system.result"); @@ -10,7 +12,7 @@ import("system.vars"); var selection = JSON.parse(vars.getString("$param.ContactIds_param")); var comingfrom = vars.getString("$param.comingFrom_param"); -var contactIds; +var contactIds = selection; if(!Array.isArray(selection)) //if selection is an array, data has been selected { @@ -24,8 +26,15 @@ var serialLetterId = vars.get("$field.SERIALLETTER_ID") var res; if (serialLetterId) - res = JSON.stringify(BulkMailUtils.filterNewRecipients(serialLetterId, contactIds)); +{ + res = SerialLetterUtils.filterNewRecipients(serialLetterId, contactIds); + neon.setFieldValue("$field.notAddedRecipients", eMath.subInt(contactIds.length, res.length)); + res = JSON.stringify(res); +} else +{ res = null; - + neon.setFieldValue("$field.notAddedRecipients", 0); +} + result.string(res); \ No newline at end of file diff --git a/entity/SerialLetterAddRecipients_entity/entityfields/recipientcountmessage/valueProcess.js b/entity/SerialLetterAddRecipients_entity/entityfields/recipientcountmessage/valueProcess.js index 2b4640522a0c4e9846c48c703bfb48d31a71490f..3b3d66c60e9357e9627c8085febffecddc04af20 100644 --- a/entity/SerialLetterAddRecipients_entity/entityfields/recipientcountmessage/valueProcess.js +++ b/entity/SerialLetterAddRecipients_entity/entityfields/recipientcountmessage/valueProcess.js @@ -4,11 +4,18 @@ import("system.vars"); var count = vars.getString("$field.recipientcount") var res = ""; +var resNotAdded = "\n\ +"; if (count && !vars.get("$sys.validationerrors")) { if (count == "0") res = translate.text("No new recipients found that can be added to the serial letter."); else + { res = translate.withArguments("%0 new recipients will be added to the serial letter.", [count]); + var notAdded = vars.get("$field.notAddedRecipients") + if (notAdded > 0) + resNotAdded += translate.withArguments("%0 of the chosen records are already recipients.", [notAdded]); + } } -result.string(res); \ No newline at end of file +result.string(res + resNotAdded); \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index ee5347bbdad31dc22668608f0cb8517374ce56db..70cdce02dc951c6b8b4724e37c5cfafd2c2fff06 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -7369,19 +7369,7 @@ <key>Mark all cached record containers as invalid</key> </entry> <entry> - <key>Current Recipients</key> - </entry> - <entry> - <key>Date (Month)</key> - </entry> - <entry> - <key>Date (Year)</key> - </entry> - <entry> - <key>Date (Day)</key> - </entry> - <entry> - <key>Grant new User Permission</key> + <key>%0 of the chosen records are already recipients.</key> </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 9e16a897b9bbdd4e31b1b7cccf42c11acf921a8a..cce78d3ebcbb26dcc370e0347f36f607dda7d1d5 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -8982,6 +8982,7 @@ Bitte Datumseingabe prüfen</value> </entry> <entry> <key>Add Recipients</key> + <value>Empfänger hinzufügen</value> </entry> <entry> <key>{SEND_MAIL}</key> @@ -9409,6 +9410,14 @@ Bitte Datumseingabe prüfen</value> <entry> <key>Grant new User Permission</key> </entry> + <entry> + <key>%0 of the chosen records are already recipients.</key> + <value>%0 der ausgewählten Datensätze sind schon Empfänger. + </value> + </entry> + <entry> + <key>export using the selected template</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 9aeb4aa1c6478d95c5c6b95a9f307e79b433b039..060014ed352937eb15b3d1dd92be7bb93f323641 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -7464,6 +7464,9 @@ <entry> <key>Grant new User Permission</key> </entry> + <entry> + <key>%0 of the chosen records are already recipients.</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonView/CampaignCostVariable_view/CampaignCostVariable_view.aod b/neonView/CampaignCostVariable_view/CampaignCostVariable_view.aod index 95a79e654d6cb9a4fe5a661811b9c8f5e05f3035..c29615b901e9d02f3a1e4ec26a3249bdcecaa4d3 100644 --- a/neonView/CampaignCostVariable_view/CampaignCostVariable_view.aod +++ b/neonView/CampaignCostVariable_view/CampaignCostVariable_view.aod @@ -14,6 +14,7 @@ <children> <treeTableViewTemplate> <name>CostTreeTable</name> + <entityField>#ENTITY</entityField> <defaultGroupFields> <element>CAMPAIGNSTEP_ID</element> </defaultGroupFields> diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js index 0715bd9e1ce5c6fcab1e43ae18fcbafd85e1572f..66bb5a869143fecbfd98f62ff9d4728e1c975e23 100644 --- a/process/Bulkmail_lib/process.js +++ b/process/Bulkmail_lib/process.js @@ -613,4 +613,28 @@ SerialLetterUtils.addParticipantsByCondition = function(pCondition, pSourceTable "ContactIds_param" : pCondition, "comingFrom_param" : pSourceTableName} neon.openContext("SerialLetterAddRecipients", "SerialLetterAddRecipientsEdit_view", null, neon.OPERATINGSTATE_VIEW, params); -} \ No newline at end of file +} + +/** + * Filters the given contactIds if they can be added as new recipients. + * Checks if a contact is already a recipient or if there is a advertising ban. + * + * @param {String} pSerialLetterId id of the seroal letter the contacts should be added to + * @param {String[]} pContactIds contacts to filter + * @return {String[]} contacts that can be added as recipients + */ +SerialLetterUtils.filterNewRecipients = function (pSerialLetterId, pContactIds) +{ + return newSelect("CONTACTID") + .from("CONTACT") + .whereIfSet("CONTACT.CONTACTID", pContactIds, SqlBuilder.IN()) + // only add contacts that aren't already recipients + .and(null, newSelect("LETTERRECIPIENTID") + .from("LETTERRECIPIENT") + .where("LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID") + .and("LETTERRECIPIENT.SERIALLETTER_ID", pSerialLetterId) + , SqlBuilder.NOT_EXISTS()) + // check if there's a commrestriction + .and(ContactUtils.getCommRestrictionCondition($KeywordRegistry.communicationMediumCampaign$mail(), true)) + .arrayColumn(); +} diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 2791c6b51fac53391ecb97ae14276ac935bb7305..7a2b2ead829e1d007bec8d5d6e47382c0d228b5b 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -502,15 +502,24 @@ CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondi */ CampaignUtils.GetContactIdsNotInCampaignByRowIds = function(pCampaignId, pParticipantRowIds) { - return newSelect("CONTACT.CONTACTID") - .from("CONTACT") - .where("CONTACT.CONTACTID", pParticipantRowIds, SqlBuilder.IN()) - .and("CONTACT.CONTACTID", - newSelect("CAMPAIGNPARTICIPANT.CONTACT_ID") - .from("CAMPAIGNPARTICIPANT") - .where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) - , SqlBuilder.NOT_IN()) - .arrayColumn(); + + var isNotOrg = newSelect("CONTACT.PERSON_ID").from("CONTACT").where("CONTACT.CONTACTID", pParticipantRowIds[0]).cell() + + var contactIds = newSelect("CAMPAIGNPARTICIPANT.CONTACT_ID") + .from("CAMPAIGNPARTICIPANT") + .where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) + .arrayColumn(); + if(contactIds.length <= 0) + contactIds = [""]; + var contactidsNotInCampaign = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.CONTACTID", pParticipantRowIds, SqlBuilder.IN()) + .and("CONTACT.CONTACTID", contactIds, SqlBuilder.NOT_IN()) + + if(!isNotOrg) + contactidsNotInCampaign = contactidsNotInCampaign.and("CONTACT.PERSON_ID is null") + + return contactidsNotInCampaign.arrayColumn(); } /** diff --git a/process/FilterviewMenuAction_lib/process.js b/process/FilterviewMenuAction_lib/process.js index 9dbcc8e25b9011540ed67392deab8b6d6488654d..ed2e0a71358d6ee12b5c7b9a966328f72422ab45 100644 --- a/process/FilterviewMenuAction_lib/process.js +++ b/process/FilterviewMenuAction_lib/process.js @@ -28,20 +28,21 @@ FilterviewMenuActionUtils.contactIdsFilter = function (pCondition) }; /** - * Generates an Array of all the organisationIds using the filtercondition + * Generates an Array of all the organisationContactIds using the filtercondition * * @param {String} pCondition the condition of the filter * - * @return {Array} all the organisationids (=contactIds of the organisations) limited by the filtercondition + * @return {Array} all the organisationContactIds (=contactIds of the organisations) limited by the filtercondition */ FilterviewMenuActionUtils.organisationIdsFilter = function (pCondition) { - let query = newSelect("distinct ORGANISATION.ORGANISATIONID").from("ORGANISATION"); + let query = newSelect("distinct CONTACT.CONTACTID").from("ORGANISATION") query.leftJoin("CONTACT", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID") .leftJoin("PERSON", "PERSON.PERSONID = CONTACT.PERSON_ID") .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID") - .where(pCondition); + .where(pCondition) + .and("CONTACT.PERSON_ID is null"); return query.arrayColumn(); };