Skip to content
Snippets Groups Projects
Commit 67ebc2a8 authored by Alexander Vögl's avatar Alexander Vögl Committed by Sebastian Listl
Browse files

[Projekt: Entwicklung - xRM][TicketNr.: 1068591][Kampagnenplanung - Bearbeiten...

[Projekt: Entwicklung - xRM][TicketNr.: 1068591][Kampagnenplanung - Bearbeiten - Verschieben von Stufen]
parent 65ba5b34
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("JditoFilter_lib");
import("system.util");
import("system.db");
......@@ -26,34 +27,47 @@ if (isMariaDB)
columnName = "\`NAME\`";
}
var stepsRows = stepCondition.select("CAMPAIGNSTEPID, CAMPAIGNSTEP."+ columnName + ", CAMPAIGNSTEP.PREDECESSORSTEP_ID,"
stepCondition.select("CAMPAIGNSTEPID, CAMPAIGNSTEP."+ columnName + ", CAMPAIGNSTEP.PREDECESSORSTEP_ID,"
+ " CAMPAIGNSTEP.DESCRIPTION, CAMPAIGNSTEP.DATE_START, CAMPAIGNSTEP.DATE_END, CAMPAIGNID, CAMPAIGN."+ columnName +", CAMPAIGN.STATUS")
.from("CAMPAIGN")
.join("CAMPAIGNSTEP", "CAMPAIGN.CAMPAIGNID = CAMPAIGNSTEP.CAMPAIGN_ID")
.orderBy("SORTING")
.table();
.join("CAMPAIGNSTEP", "CAMPAIGN.CAMPAIGNID = CAMPAIGNSTEP.CAMPAIGN_ID");
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
stepCondition.and("CAMPAIGNSTEP.CAMPAIGNSTEPID", vars.get("$local.idvalues"), SqlBuilder.IN());
stepsRows = stepsRows.map(function ([stepId, stepName, predecessorId, desc, stepStartDate, stepEndDate, campaignId, campaignName, campaignStatus])
var stepsRows = stepCondition.orderBy("SORTING").table();
//this can happen when not a CampaignStep, but a Campaign node was selected
if(stepsRows.length == 0 && vars.get("$local.idvalues") && newSelect("count(*)").from("CAMPAIGN").where("CAMPAIGN.CAMPAIGNID", vars.get("$local.idvalues")).cell() > 0)
{
if (!campaignRows[campaignId])
{
let startDate = CampaignUtils.getCampaignStartDate(campaignId);
let endDate = CampaignUtils.getCampaignEndDate(campaignId);
campaignRows[campaignId] = [campaignId, campaignName, null, null, startDate, endDate, campaignId, TARGET_CONTEXT_ROOT_ELEMENT, campaignStatus];
}
stepIds[stepId] = true;
return [stepId, stepName, predecessorId || campaignId, desc, stepStartDate, stepEndDate, campaignId, TARGET_CONTEXT_ELEMENT, campaignStatus];
});
stepsRows = [[vars.get("$local.idvalues"), "", "", "", "", "", vars.get("$local.idvalues"), "", ""]]
}
//replace all predecessor ids that are not in the tree with the campaign id
stepsRows.forEach(function (row)
if(!vars.get("$local.idvalues"))
{
if (!(stepIds[row[2]]))
row[2] = row[6];
});
stepsRows = stepsRows.map(function ([stepId, stepName, predecessorId, desc, stepStartDate, stepEndDate, campaignId, campaignName, campaignStatus])
{
if (!campaignRows[campaignId])
{
let startDate = CampaignUtils.getCampaignStartDate(campaignId);
let endDate = CampaignUtils.getCampaignEndDate(campaignId);
campaignRows[campaignId] = [campaignId, campaignName, null, null, startDate, endDate, campaignId, TARGET_CONTEXT_ROOT_ELEMENT, campaignStatus];
}
stepIds[stepId] = true;
return [stepId, stepName, predecessorId || campaignId, desc, stepStartDate, stepEndDate, campaignId, TARGET_CONTEXT_ELEMENT, campaignStatus];
});
//convert the object to an array
campaignRows = Object.keys(campaignRows).map(function (id) {return campaignRows[id];});
//replace all predecessor ids that are not in the tree with the campaign id
stepsRows.forEach(function (row)
{
if (!(stepIds[row[2]]))
row[2] = row[6];
});
result.object(campaignRows.concat(stepsRows))
//convert the object to an array
campaignRows = Object.keys(campaignRows).map(function (id) {return campaignRows[id];});
stepsRows = campaignRows.concat(stepsRows);
}
result.object(stepsRows);
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