Skip to content
Snippets Groups Projects
Commit 398438af authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Pool][TicketNr.: 1066739][Firma - Filter nach Englisch...

[Projekt: Entwicklung - Pool][TicketNr.: 1066739][Firma - Filter nach Englisch - Firmen, die noch nicht in Kampagne sind, werden nicht übernommen]
parent 322f0d46
No related branches found
No related tags found
No related merge requests found
......@@ -38,12 +38,12 @@ if (!vars.exists("$param.currentCampaignId_param") || !vars.get("$param.currentC
function _handleCondition(pCampaignId, pTargetTableName, pCondition)
{
var contactIdsToHandle = [];
var contextComingFrom = "Person";
var useRightJoinToGetOrgs = "false";
if(pTargetTableName == "ORGANISATION")
{
useRightJoinToGetOrgs = "true";
pCondition += " and PERSON.PERSONID is NULL"
pCondition += " and PERSON.PERSONID is NULL";
contextComingFrom = "Organisation";
}
/*
......@@ -55,10 +55,10 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition)
*/
if(isUpdate == "true")
{
contactIdsToHandle = CampaignUtils.GetContactIdsInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs)
contactIdsToHandle = CampaignUtils.GetContactIdsInCampaignByCondition(pCampaignId, pCondition);
}
else
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs);
contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, contextComingFrom);
_handleRowIds(contactIdsToHandle, pCampaignId);
}
......@@ -169,6 +169,4 @@ function _handleRowIds(pParticipantRowIds, pCampaignId)
if(logArray.length > 0)
db.inserts(logArray);
neon.refreshAll();
}
\ No newline at end of file
......@@ -5,4 +5,11 @@ import("system.vars");
if (vars.get("$sys.validationerrors"))
result.string(neon.COMPONENTSTATE_DISABLED);
else
result.string(neon.COMPONENTSTATE_EDITABLE);
\ No newline at end of file
{
var contactCount = JSON.parse(vars.get("$field.campaignparticipantContactIds")).length;
if (contactCount == 0)
result.string(neon.COMPONENTSTATE_DISABLED);
else
result.string(neon.COMPONENTSTATE_EDITABLE);
}
\ No newline at end of file
......@@ -22,14 +22,14 @@ if(vars.get("$field.CAMPAIGN_ID"))
else if(comingfrom == "Person")
filteredContactIds = FilterViewActionUtils.contactIdsFilter(selection)
contactIds = CampaignUtils.GetContactIdsNotInCampaignByCondition(vars.get("$field.CAMPAIGN_ID"), selection);
contactIds = CampaignUtils.GetContactIdsNotInCampaignByCondition(vars.get("$field.CAMPAIGN_ID"), selection, comingfrom);
}
else if(isUpdate)
{
if (vars.get("$param.campaignParticipantsCondition_param"))
{
contactIds = CampaignUtils.GetContactIdsNotInCampaignByCondition(vars.get("$field.CAMPAIGN_ID"), JSON.parse(vars.get("$param.campaignParticipantsCondition_param")).condition, false);
var contactFilterCondition = JSON.parse(vars.get("$param.campaignParticipantsCondition_param")).condition;
contactIds = CampaignUtils.GetContactIdsNotInCampaignByCondition(vars.get("$field.CAMPAIGN_ID"), contactFilterCondition, comingfrom);
}
else
{
......
......@@ -521,30 +521,34 @@ CampaignUtils.GetContactIdsNotInCampaignByRowIds = function(pCampaignId, pPartic
* The id of the campaign.<br>
* @param {String} pCondition (optional) <p>
* An condition which is used to limit the search contact results.<br>
* @param {Boolean} pRightJoinContacts <p>
* Case if its true, a prefix will used<br>
* to do a right join.<br>
* @param {String} [pOrigin=Organisation] <br/>
* id from which context we are coming from, e.g. "Person"
* @return {String[]} <p>
* The contact ids they arent in the campaign.<br>
*/
CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCondition, pRightJoinContacts)
CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCondition, pOrigin)
{
let query = newSelect("CONTACT.CONTACTID").from("PERSON");
var origin = pOrigin || "Organisation";
//subselect for excluding entries that are already in the campaign
var subselect = newSelect("CAMPAIGNPARTICIPANT.CONTACT_ID")
.from("CAMPAIGNPARTICIPANT")
.where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId);
if (pRightJoinContacts == "true")
query.rightJoin("CONTACT", "CONTACT.PERSON_ID = PERSON.PERSONID");
else
query.join("CONTACT", "CONTACT.PERSON_ID = PERSON.PERSONID");
.from("CAMPAIGNPARTICIPANT")
.where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId);
var query = newSelect("CONTACT.CONTACTID")
.from("CONTACT");
if (origin == "Person")
query.leftJoin("PERSON", "CONTACT.PERSON_ID = PERSON.PERSONID");
query.join("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID")
.leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID")
.where("CONTACT.CONTACTID",
subselect
, SqlBuilder.NOT_IN()
);
if (origin == "Organisation")
query.and("CONTACT.PERSON_ID is null");
//pCondition is always a contact related condition string and not a campaignparticipant related condition
if(pCondition != "")
......@@ -562,14 +566,11 @@ CampaignUtils.GetContactIdsNotInCampaignByCondition = function(pCampaignId, pCon
* @param {String} pCondition <p>
* The condition which shall be used, to<br>
* limit the search result.<br>
* @param {Boolean} [pRightJoinContacts=false] <p>
* Currently not used.<br>
* <p>
* @return {String[]} <p>
* The contact ids which are in the given<br>
* campaign.<br>
*/
CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondition, pRightJoinContacts)
CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondition)
{
let query = newSelect("CONTACT.CONTACTID").from("CONTACT");
......
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