Skip to content
Snippets Groups Projects
Commit d6556efc authored by Dominik Lechner's avatar Dominik Lechner
Browse files

Added first version for adding campaignparticipant

parent 9b4f3f3f
No related branches found
No related tags found
No related merge requests found
......@@ -697,19 +697,16 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<name>DEPARTMENT</name>
<title>Department</title>
<possibleItemsProcess>%aditoprj%/entity/Person_entity/entityfields/department/possibleItemsProcess.js</possibleItemsProcess>
<newItemsAllowed v="true" />
</entityField>
<entityField>
<name>POSITION</name>
<title>Position</title>
<possibleItemsProcess>%aditoprj%/entity/Person_entity/entityfields/position/possibleItemsProcess.js</possibleItemsProcess>
<newItemsAllowed v="true" />
</entityField>
<entityField>
<name>CONTACTROLE</name>
<title>Contactrole</title>
<possibleItemsProcess>%aditoprj%/entity/Person_entity/entityfields/contactrole/possibleItemsProcess.js</possibleItemsProcess>
<newItemsAllowed v="true" />
</entityField>
<entityConsumer>
<name>OtherContacts</name>
......@@ -781,52 +778,13 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
<name>AttributeTree</name>
<title>Attribute Tree</title>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>AttributeRelationTree_entity</entityName>
<fieldName>TreeProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>ObjectType_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>DATE_NEW</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/date_new/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>USER_NEW</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/user_new/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>USER_EDIT</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/user_edit/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DATE_EDIT</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/date_edit/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DATE_NEW_CONTACT</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/date_new_contact/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>USER_NEW_CONTACT</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/user_new_contact/valueProcess.js</valueProcess>
</entityField>
<entityActionField>
<name>addToCampaign</name>
<fieldType>ACTION</fieldType>
<title>Add to Campaign</title>
<onActionProcess>%aditoprj%/entity/Person_entity/entityfields/addtocampaign/onActionProcess.js</onActionProcess>
<tooltip>Choose a campaign and a step to add the contact to a campaign</tooltip>
</entityActionField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.vars");
import("Campaign_lib");
CampaignUtils.addParticipants(vars.getString("$field.CONTACTID"));
\ No newline at end of file
......@@ -6,6 +6,10 @@
<country></country>
<variant></variant>
<keyValueMap>
<entry>
<key>Add to Campaign</key>
<value>Zu Kampagne hinzufügen</value>
</entry>
<entry>
<key>Company</key>
<value>Firma</value>
......@@ -130,6 +134,10 @@
<key>Days inactive</key>
<value>Tage inaktiv</value>
</entry>
<entry>
<key>Choose a campaign and a step to add the contact to a campaign</key>
<value>Wählen Sie eine Kampagne und eine Stufe aus um den Kontakt hinzuzufügen</value>
</entry>
<entry>
<key>Active</key>
<value>Aktiv</value>
......
import("system.db");
/*
* Fügt Mitglieder zu einer Kampagne hinzu.
*
* @param {String []} pParticipants req die RELATIONID
* @param {String} pCampaignID opt die ID der Kampagne
* @param {String} pStepID opt ID des Schritts
*
* @return {integer} Anzahl keine Email vorhanden
*/
function addParticipants( pParticipants, pCampaignID, pStepID )
import("Context_lib");
/**
* Methods for campaignmanagement.
* Do not create an instance of this!
*
* @class
*/
function CampaignUtils() {}
/**
* Add Contact (Person or Organistaion) to a Campaign
*
* @param {String} pRowIds req ContactIds
*/
CampaignUtils.addParticipants = function(pRowIds)
{
if ( pStepID == undefined )
pStepID = selectCampaignStep(pCampaignID);
if ( pCampaignID == "" || pStepID == null)
return 0;
var count = 0;
// aktuelle Anzahl - maximale Anzahl
var iscount = Number(db.cell("select count(*) from campaignparticipant where campaign_id = '" + pCampaignID + "'"));
var maxcount = db.cell("select max_participants from campaign where campaignid = '" + pCampaignID + "'");
if ( maxcount != "") maxcount = Number(maxcount); else maxcount = 9999999;
_CampaignUtils._createNew("CampaignParticipant", pRowIds)
}
var actdate = vars.getString("$sys.date");
var user = vars.getString("$sys.user");
var spalten = new Array("CAMPAIGNPARTICIPANTID", "RELATION_ID", "USER_NEW", "DATE_NEW", "CAMPAIGNSTEP_ID", "CAMPAIGN_ID");
var typen = db.getColumnTypes("CAMPAIGNPARTICIPANT", spalten);
var logcol = new Array("CAMPAIGN_ID", "STEP_ID", "RELATION_ID", "CAMPAIGNPARTICIPANT_ID", "DATE_NEW", "USER_NEW");
var logtyp = db.getColumnTypes("CAMPAIGNLOG", logcol);
var logvalue = new Array(pCampaignID, pStepID, 0, 0, actdate, user );
/**
* Methods for campaignmanagement.
* Do not create an instance of this!
*
* @ignore
* @class
*/
function _CampaignUtils() {}
for ( var i = 0; i < pParticipants.length; i++ )
_ActivityTaskUtils._createNew = function(pContext, pRowIds)
{
var params = {};
//TODO: pRowIds via JSON to add more then one participant
if (pRowIds)
{
if ( iscount < maxcount )
{
var newID = util.getNewUUID()
var werte = [ newID, pParticipants[i] , user, actdate, pStepID, pCampaignID ];
count += db.insertData("CAMPAIGNPARTICIPANT", spalten, typen, werte);
logvalue[2] = pParticipants[i];
logvalue[3] = newID;
db.insertData("CAMPAIGNLOG", logcol, logtyp, logvalue);
iscount++;
}
else
{
question.showMessage(translate.text("Die maximale Anzahl Teilnehmer ist erreicht!"));
break;
}
params["ObjectId_param"] = ContextUtils.getCurrentContextId();
params["RowId_param"] = pRowIds;
}
return count;
neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params);
}
/**
......
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