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

Kleine Fehler beim Hinzufügen von Organisationen durch eine Serienaktion behoben.

Logausgaben entfernt
parent a6e86218
No related branches found
No related tags found
No related merge requests found
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");
......@@ -22,7 +16,6 @@ var isUpdate = vars.get("$field.isUpdate");
var participantCondition = "";
var messageString = "";
var resultValue = "false";
//logging.log("selectedCampaignId -> " + selectedCampaignId);
if(selectedCampaignId != '')
{
......@@ -68,14 +61,17 @@ if(selectedCampaignId != '')
else
{
participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition;
logging.log("im isOperationValid -> ");
let useRightJoinToGetOrgs = "false";
if(targetTable == "ORGANISATION")
{
useRightJoinToGetOrgs = "true";
//Necessary because organisations don't have a personid'
participantCondition += " and PERSON.PERSONID is NULL"
}
countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition, isUpdate, useRightJoinToGetOrgs);
logging.log("countParticipantsToAdd -> " + countParticipantsToAdd);
/*
* If the update mode is active, the goal is to move participants between steps.
......@@ -90,14 +86,9 @@ if(selectedCampaignId != '')
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, participantCondition, useRightJoinToGetOrgs);
//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";
......@@ -119,11 +110,8 @@ if(selectedCampaignId != '')
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.logging");
import("system.vars");
import("system.db");
import("system.util");
......@@ -23,7 +22,6 @@ if(participantRowIds != null && participantRowIds.length > 0)
if(isUpdate == "false")
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds);
logging.log("contactIdsToHandle by rowIds -> " + contactIdsToHandle);
_handleRowIds(contactIdsToHandle);
}
else
......@@ -40,7 +38,10 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition)
let useRightJoinToGetOrgs = "false";
if(pTargetTableName == "ORGANISATION")
{
useRightJoinToGetOrgs = "true";
pCondition += " and PERSON.PERSONID is NULL"
}
/*
* If it's an update of participants, get the participants defined by the condition in the selected campaign
......@@ -56,7 +57,6 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition)
else
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs);
logging.log("contactIdsToHandle -> " + contactIdsToHandle);
_handleRowIds(contactIdsToHandle);
}
......@@ -82,7 +82,7 @@ function _handleRowIds(pParticipantRowIds)
let statementArray = [];
let logArray = [];
logging.log("pParticipantRowIds -> " + pParticipantRowIds);
for (participant in pParticipantRowIds)
{
let campaignParticipantLogId = util.getNewUUID();
......@@ -116,10 +116,8 @@ function _handleRowIds(pParticipantRowIds)
statementArray.push(["CAMPAIGNPARTICIPANT", cols, null, valsCampaignParticipant]);
}
}
logging.log("statementArray -> " + statementArray);
if(isUpdate == "true")
{
logging.log("vor db.updates??? -> ");
db.updates(statementArray)
}
else
......
import("system.logging");
import("system.vars");
import("system.neon");
import("Campaign_lib");
......@@ -15,7 +14,6 @@ if(sysSelection.length > 0) //selektierte IDs als Array
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
import("system.logging");
import("system.vars");
import("system.neon");
import("Campaign_lib");
......@@ -13,14 +12,11 @@ var sysSelection = vars.get("$sys.selection");
if(sysSelection.length > 0) //selektierte IDs als Array
{
logging.log("sysSelection -> " + sysSelection);
CampaignUtils.addParticipantsByRowIds(JSON.stringify(sysSelection), "PERSON");
}
else
{
let sysFilter = vars.get("$sys.filter");//todo change name
logging.log("sysFilter -> " + sysFilter);
logging.log("asdasd sysFilter.condition -> " + sysFilter.condition);
CampaignUtils.addParticipantsByCondition(JSON.stringify(sysFilter), "PERSON");
}
\ No newline at end of file
......@@ -43,13 +43,13 @@ CampaignUtils.addParticipantsByRowIds = function(pRowIds, pSourceTableName)
*/
CampaignUtils.addParticipantsByCondition = function(pCondition, pSourceTableName)
{
logging.log(" asdf-> " + pCondition);
_CampaignUtils._openAddParticipantContext("CampaignAddParticipants", pCondition,
"campaignParticipantsCondition_param", "CampaignAddParticipantsEdit_view", pSourceTableName);
}
/**
* todo
* Gets the campaign name per Id
* @return Name of a campaign, empty string if no campaign could be found for the id
*/
CampaignUtils.getCampaignNameById = function(pCampaignId)
{
......@@ -61,7 +61,8 @@ CampaignUtils.getCampaignNameById = function(pCampaignId)
}
/**
* todo
* Gets the campaign step name per Id
* @return Name of a campaignstep, empty string if no step could be found for the id
*/
CampaignUtils.getCampaignStepNameById = function(pCampaignStepId)
{
......@@ -73,7 +74,8 @@ CampaignUtils.getCampaignStepNameById = function(pCampaignStepId)
}
/**
* todo
* The current count of participants in the given campaignstep
* @return count of participants, 0 if no campaignstep could be found for the id
*/
CampaignUtils.getParticipantCountForStep = function(pCampaignStepId)
{
......@@ -85,7 +87,8 @@ CampaignUtils.getParticipantCountForStep = function(pCampaignStepId)
}
/**
* todo
* The current count of participants in the given campaign
* @return count of participants, 0 if no campaign could be found for the id
*/
CampaignUtils.getParticipantCount = function(pCampaignId)
{
......@@ -97,7 +100,8 @@ CampaignUtils.getParticipantCount = function(pCampaignId)
}
/**
* todo
* The max participants value for the given campaignstep
* @return max count of participants, 0 if no campaignstep could be found for the id
*/
CampaignUtils.getMaxParticipantCountForStep = function(pCampaignStepId)
{
......@@ -108,9 +112,6 @@ CampaignUtils.getMaxParticipantCountForStep = function(pCampaignStepId)
return _CampaignUtils._loadSingleValueFromDb(selectQuery, conditionField, pCampaignStepId, defaultValue);
}
/**
* todo
*/
CampaignUtils.getStepCount = function(pCampaignId)
{
let selectQuery = "select count(*) from CAMPAIGNSTEP";
......@@ -120,9 +121,6 @@ CampaignUtils.getStepCount = function(pCampaignId)
return _CampaignUtils._loadSingleValueFromDb(selectQuery, conditionField, pCampaignId, defaultValue);
}
/**
* todo
*/
CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId)
{
let selectQuery = "select CAMPAIGN.STATE from CAMPAIGN";
......@@ -134,9 +132,6 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId)
return KeywordUtils.getViewValue(campaignState, statusId);
}
/**
* todo
*/
CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId, pCampaignParticipantId)
{
let colsCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames();
......@@ -147,17 +142,11 @@ CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId
return (rows == 1);
}
/**
* todo
*/
CampaignUtils.getParticipantLogInsertColumnNames = function()
{
return ["CAMPAIGNPARTICIPANT_ID", "CAMPAIGN_ID", "CAMPAIGNSTEP_ID", "CAMPAIGNPARTICIPANTLOGID", "USER_NEW", "DATE_NEW"];
}
/**
* todo
*/
CampaignUtils.openSetCampaignStepViewByRowIds = function(pParticipantIds, pCampaignId, pCampaignStepId)
{
var params = {};
......@@ -169,9 +158,6 @@ CampaignUtils.openSetCampaignStepViewByRowIds = function(pParticipantIds, pCampa
neon.openContext("CampaignAddParticipants", "CampaignAddParticipantsEdit_view", null, neon.OPERATINGSTATE_NEW, params);
}
/**
* todo
*/
CampaignUtils.openSetCampaignStepViewByCondition = function(pCondition, pCampaignId, pCampaignStepId)
{
var params = {};
......@@ -208,9 +194,6 @@ CampaignUtils.openNewCampaignView = function()
neon.openContext("Campaign", "CampaignEdit_view", null, neon.OPERATINGSTATE_NEW, params);
}
/**
* todo
*/
CampaignUtils.getDefaultCampaignStep = function(pCampaignId)
{
let selectQuery = "select CAMPAIGNSTEPID from CAMPAIGNSTEP " +
......@@ -221,9 +204,6 @@ CampaignUtils.getDefaultCampaignStep = function(pCampaignId)
return db.cell(selectQuery)
}
/**
* todo
*/
CampaignUtils.getCampaignStartDate = function(pCapmaignId)
{
let campaignIdCondition = SqlCondition.begin()
......@@ -231,9 +211,6 @@ CampaignUtils.getCampaignStartDate = function(pCapmaignId)
return db.cell(campaignIdCondition.buildSql("SELECT DATE_START, SORTING FROM CAMPAIGNSTEP", "1=2", "order by SORTING ASC"));
}
/**
* todo
*/
CampaignUtils.getCampaignEndDate = function(pCapmaignId)
{
let campaignIdCondition = SqlCondition.begin()
......@@ -242,9 +219,6 @@ CampaignUtils.getCampaignEndDate = function(pCapmaignId)
return db.cell(campaignIdCondition.buildSql("SELECT DATE_END, SORTING FROM CAMPAIGNSTEP", "1=2", "order by SORTING DESC"));
}
/**
* todo
*/
CampaignUtils.getMaxParticipantsValidationMessage = function()
{
//todo how/where should this text be stored?
......@@ -330,8 +304,6 @@ CampaignUtils.GetParticipantsAlreadyAddedCountByRowId = function(pWhereCondition
+ " where " + pWhereCondition + " AND"
+ " " + pRowIdsComparisonField + " IN " + rowIdsAsRay;
logging.log("GetParticipantsAlreadyInStepCountByRowId query -> " + query);
return db.cell(query)
}
......@@ -351,8 +323,6 @@ CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondi
if(pCondition != "")
query += " and " + pCondition;
logging.log("GetParticipantsAlreadyAddedCountByCondition query -> " + query);
return db.cell(query)
}
......@@ -385,7 +355,7 @@ CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCon
if(pCondition != "")
query += " and " + pCondition;
logging.log("GetContactIdsNotInCampaignByCondition -> " + query);
return db.array(db.COLUMN, query);
}
......@@ -402,7 +372,7 @@ CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondit
+ " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID"
+ " where " + pCondition
+ " and CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + pCampaignId + "'";
logging.log("GetContactIdsInCampaignByCondition -> " + GetContactIdsInCampaignByCondition);
return db.array(db.COLUMN, query);
}
......@@ -423,7 +393,6 @@ CampaignUtils.GetContactCountByCondition = function(pCondition, pLookInCampaignO
if(pCondition != "")
query += " where " + pCondition;
logging.log("GetContactCountByCondition -> " + query);
return db.cell(query);
}
......@@ -481,9 +450,6 @@ _CampaignUtils._openAddParticipantContext = function(pContext, pTargetDataExpres
neon.openContext(pContext, null, null, neon.OPERATINGSTATE_NEW, params);
}
/**
* todo
*/
_CampaignUtils._convertToSqlValuesList = function(pValuesArray)
{
let rowIds = "(";
......@@ -497,9 +463,6 @@ _CampaignUtils._convertToSqlValuesList = function(pValuesArray)
return rowIds;
}
/**
* todo
*/
_CampaignUtils._loadSingleValueFromDb = function(pSelectQuery, pConditionField, pConditionValue, pDefaultValue)
{
let res = pDefaultValue;
......
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