Skip to content
Snippets Groups Projects
Commit 682f2701 authored by David Büchler's avatar David Büchler
Browse files

Die Serienaktion zum Hinzufügen von Teilnehmern zu einer Kampagne hat nun die...

Die Serienaktion zum Hinzufügen von Teilnehmern zu einer Kampagne hat nun die gleiche Ausgabe sowie das gleiche Verhalten beim Hinzufügen über die selection sowie die Condition.
Siblings wurden eingefügt
Serienaktion in der Teilnehmerliste in der Kampagne ist nun immer klickbar, nicht nur bei Selektion
parent 7dfc0efe
No related branches found
No related tags found
No related merge requests found
Showing
with 312 additions and 51 deletions
......@@ -31,11 +31,15 @@
<mandatory v="true" />
<state>EDITABLE</state>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/onValueChange.js</onValueChange>
</entityField>
<entityField>
<name>campaignParticipantMessage</name>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignparticipantmessage/valueProcess.js</valueProcess>
<onValueChangeTypes>
<element>PROCESS</element>
</onValueChangeTypes>
</entityField>
<entityParameter>
<name>campaignParticipantsRowIds_param</name>
......
import("Campaign_lib");
import("system.logging");
import("system.result");
import("system.translate");
import("system.vars");
//logging.log(" -> " + JSON.stringify(vars.getString("$param.campaignParticipantsRowIds_param")));
//var test = vars.getString("$param.campaignParticipantsRowIds_param");
//var campaignParticipantsAmount = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param")).length;
//var informationText = translate.text("participants will be added to the selected campaign step");
//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"));
//result.string(campaignParticipantsAmount + " " + informationText);
result.string("Message");
\ No newline at end of file
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
import("system.neon");
neon.refresh(["$field.campaignParticipantMessage"])
\ No newline at end of file
......@@ -7,7 +7,7 @@ import("Campaign_lib");
var cols = [];
var participantRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param"));
var participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param"));
var participantCondition = "";
var conditionSourceTableName = vars.getString("$param.dataSourceTableName_param");
var campaignId = vars.getString("$field.CAMPAIGN_ID");
......@@ -16,18 +16,40 @@ var isUpdate = vars.get("$field.isUpdate");
var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames();
if(participantRowIds.length > 0)
if(participantRowIds != null && participantRowIds.length > 0)
{
_handleRowIds(participantRowIds);
let contactIdsToHandle = participantRowIds;
if(isUpdate == "false")
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds);
logging.log("contactIdsToHandle by rowIds -> " + contactIdsToHandle);
_handleRowIds(contactIdsToHandle);
}
else
{
_handleCondition(participantCondition, conditionSourceTableName)
participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition;
_handleCondition(campaignId, conditionSourceTableName, participantCondition);
}
function _handleCondition(pCondition, pSourceTableName)
function _handleCondition(pCampaignId, pTargetTableName, pCondition)
{
//( UPPER( PERSON.SALUTATION ) = UPPER( 'Frau' )
let contactIdsToHandle = [];
/*
* If it's an update of participants, get the participants defined by the condition in the selected campaign
* 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.
*/
if(isUpdate == "true")
{
contactIdsToHandle = CampaignUtils.GetContactIdsInCampaignByCondition(pCampaignId, pCondition)
}
else
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition);
logging.log("contactIdsToHandle -> " + contactIdsToHandle);
_handleRowIds(contactIdsToHandle);
}
function _handleRowIds(pParticipantRowIds)
......@@ -52,6 +74,7 @@ function _handleRowIds(pParticipantRowIds)
let statementArray = [];
let logArray = [];
logging.log("pParticipantRowIds -> " + pParticipantRowIds);
for (participant in pParticipantRowIds)
{
let campaignParticipantLogId = util.getNewUUID();
......
......@@ -165,7 +165,7 @@
<title>Set campaign step</title>
<onActionProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js</onActionProcess>
<isObjectAction v="false" />
<isSelectionAction v="true" />
<isSelectionAction v="false" />
<iconId>NEON:GROUP_APPOINTMENT</iconId>
</entityActionField>
</children>
......@@ -181,40 +181,40 @@
<displayValueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/campaignstepmaxparticipantcount/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>ADVERTISINGBAN_ICON</name>
<colorProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js</colorProcess>
<contentType>IMAGE</contentType>
<stateProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js</valueProcess>
</entityField>
<entityConsumer>
<name>ParticipantsCommRestiction</name>
<dependency>
<name>dependency</name>
<entityName>CommRestriction_Entity</entityName>
<fieldName>PersonsCommRestriction</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContactId_param</name>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/participantscommrestiction/children/contactid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
<name>CommRestrictionIcon</name>
<dependency>
<name>dependency</name>
<entityName>KeywordAttribute_entity</entityName>
<fieldName>SpecificContainerKeyword</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContainerName_param</name>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/commrestrictionicon/children/containername_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<name>ADVERTISINGBAN_ICON</name>
<colorProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js</colorProcess>
<contentType>IMAGE</contentType>
<stateProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/valueProcess.js</valueProcess>
</entityField>
<entityConsumer>
<name>ParticipantsCommRestiction</name>
<dependency>
<name>dependency</name>
<entityName>CommRestriction_Entity</entityName>
<fieldName>PersonsCommRestriction</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContactId_param</name>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/participantscommrestiction/children/contactid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
<name>CommRestrictionIcon</name>
<dependency>
<name>dependency</name>
<entityName>KeywordAttribute_entity</entityName>
<fieldName>SpecificContainerKeyword</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContainerName_param</name>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/commrestrictionicon/children/containername_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.logging");
import("system.util");
import("system.db");
import("system.result");
......
......@@ -7,6 +7,7 @@
<siblings>
<element>CampaignPlanning_entity</element>
<element>CampaignParticipantChart_entity</element>
<element>Campaign_entity</element>
</siblings>
<contentTitleProcess>%aditoprj%/entity/CampaignStep_entity/contentTitleProcess.js</contentTitleProcess>
<onValidation>%aditoprj%/entity/CampaignStep_entity/onValidation.js</onValidation>
......
......@@ -6,6 +6,7 @@
<title>Campaign</title>
<siblings>
<element>CampaignPlanning_entity</element>
<element>CampaignStep_entity</element>
</siblings>
<contentTitleProcess>%aditoprj%/entity/Campaign_entity/contentTitleProcess.js</contentTitleProcess>
<afterUiInit>%aditoprj%/entity/Campaign_entity/afterUiInit.js</afterUiInit>
......
......@@ -835,7 +835,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<onActionProcess>%aditoprj%/entity/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/onActionProcess.js</onActionProcess>
<isMenuAction v="true" />
<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/Person_entity/entityfields/campaignactiongroup/children/addtocampaignfromtable/tooltipProcess.js</tooltipProcess>
......
import("system.logging");
import("system.vars");
import("system.neon");
import("Campaign_lib");
......@@ -8,14 +9,18 @@ import("Campaign_lib");
* is used to determine the objects to be added.
* If no selection has been set, all objects will be added.
*/
var sysSelection = vars.getString("$sys.selection");
var sysSelection = vars.get("$sys.selection");
if(sysSelection.length > 0) //selektierte IDs als Array
{
CampaignUtils.addParticipantsByRowIds(sysSelection, "PERSON");
logging.log("sysSelection -> " + sysSelection);
CampaignUtils.addParticipantsByRowIds(JSON.stringify(sysSelection), "PERSON");
}
else
{
let sysFilter = vars.get("$sys.filter");//todo change name
CampaignUtils.addParticipantsByCondition(sysFilter.condition, "PERSON");
logging.log("sysFilter -> " + sysFilter);
logging.log("asdasd sysFilter.condition -> " + sysFilter.condition);
CampaignUtils.addParticipantsByCondition(JSON.stringify(sysFilter), "PERSON");
}
\ No newline at end of file
......@@ -43,6 +43,7 @@ CampaignUtils.addParticipantsByRowIds = function(pRowIds, pSourceTableName)
*/
CampaignUtils.addParticipantsByCondition = function(pCondition, pSourceTableName)
{
logging.log(" asdf-> " + pCondition);
_CampaignUtils._openAddParticipantContext("CampaignAddParticipants", pCondition,
"campaignParticipantsCondition_param", "CampaignAddParticipantsEdit_view", pSourceTableName);
}
......@@ -309,7 +310,117 @@ 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)
{
let rowIdsAsRay = _CampaignUtils._convertToSqlValuesList(pParticipantRowIds);
let query = "SELECT COUNT(*) FROM CAMPAIGNPARTICIPANT"
+ " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "' AND"
+ " CAMPAIGNPARTICIPANT.CONTACT_ID IN " + rowIdsAsRay;
logging.log("GetParticipantsAlreadyInStepCountByRowId query -> " + query);
return db.cell(query)
}
CampaignUtils.GetParticipantsAlreadyInStepCountByCondition = function(pCampaignId, pTargetTableName, 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)
+ ")";
logging.log("query -> " + query);
return db.cell(query)
}
CampaignUtils.GetContactIdsNotInCampaignByRowIds = function(pCampaignId, pParticipantRowIds)
{
let rowIdsAsRay = _CampaignUtils._convertToSqlValuesList(pParticipantRowIds);
let query = "select CONTACT.CONTACTID from CONTACT"
+ " where CONTACT.CONTACTID in " + rowIdsAsRay
+ " and CONTACT.CONTACTID not in"
+ " (select CAMPAIGNPARTICIPANT.CONTACT_ID from CAMPAIGNPARTICIPANT"
+ " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')";
return db.array(db.COLUMN, query)
}
CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCondition)
{
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)"
+ " where " + pCondition
+ " and CONTACT.CONTACTID not in"
+ " (select CAMPAIGNPARTICIPANT.CONTACT_ID from CAMPAIGNPARTICIPANT where"
+ " CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')";
return db.array(db.COLUMN, query);
}
CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondition)
{
let query = "select CONTACT.CONTACTID, person.FIRSTNAME 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 + "')";
return db.array(db.COLUMN, query);
}
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)";
if(pCondition != "")
query += " where " + pCondition;
logging.log("GetContactCountByCondition -> " + query);
return db.cell(query);
}
/**
* Methods for campaignmanagement.
......@@ -320,6 +431,28 @@ CampaignUtils.checkforCommRestrictions = function()
*/
function _CampaignUtils() {}
_CampaignUtils._selectFromContactWithJoin = function(pSelectFields, pCampaignId, pWhereCondition)
{
let query = "select " + pSelectFields + " 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)";
if(pWhereCondition != "")
{
query += " where " + pWhereCondition;
query += " and CONTACT.CONTACTID not in"
+ " (select CONTACT_ID from CAMPAIGNPARTICIPANT"
+ " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')";
}
else
query += " where CONTACT.CONTACTID not in"
+ " (select CONTACT_ID from CAMPAIGNPARTICIPANT"
+ " where CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "')";
return query;
}
/**
* Open EditView to Add Participants to a Campaignstep
*
......@@ -343,6 +476,21 @@ _CampaignUtils._openAddParticipantContext = function(pContext, pTargetDataExpres
neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params);
}
/**
* todo
*/
_CampaignUtils._convertToSqlValuesList = function(pValuesArray)
{
let rowIds = "(";
for (i = 0; i < pValuesArray.length; i++)
{
rowIds += "'" + pValuesArray[i] + "'";
if(i < pValuesArray.length-1)
rowIds += ",";
}
rowIds += ")";
return rowIds;
}
/**
* todo
......
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