Skip to content
Snippets Groups Projects
Commit eae55cc5 authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Sebastian Pongratz
Browse files

Sales 1085161 feature buying center filters

parent 6c5c971f
No related branches found
No related tags found
No related merge requests found
Showing
with 230 additions and 2 deletions
import("KeywordRegistry_basic");
import("Sql_lib");
import("Contact_lib");
import("system.datetime");
import("system.logging");
import("Util_lib");
......@@ -50,6 +53,28 @@ function _get360Data(pContactId, pContextList)
var res = ContextUtils.getContextDataViaReadEntity(context, pContextList[context], filter, pContactId);
if(res.length > 0)
{
var roleObj = {}; //helper obejct
if(context == "Salesproject" && !ContactUtils.isOrganisation(pContactId))//we want to add the roles that contacts have in each salesproject to the description
{
var roles = newSelect(["OBJECTMEMBER.OBJECT_ROWID", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.MemberRole(), "MEMBERROLE")])
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.OBJECT_TYPE", "Salesproject")
.and("OBJECTMEMBER.CONTACT_ID", contactId)
.orderBy("OBJECTMEMBER.OBJECT_ROWID")
.table();
//one select outside of the for each for performance, we assign the roles to roleObj so we can add them in the for each accordingly
for (let i = 0; i < roles.length; i++)
{
var salesProjectId, role;
[salesProjectId, role] = roles[i];
if(!roleObj.hasOwnProperty(salesProjectId))
{
roleObj[salesProjectId] = [];
}
roleObj[salesProjectId].push(role)
}
}
res.forEach(function (row)
{
var uid = JSON.stringify({
......@@ -73,6 +98,23 @@ function _get360Data(pContactId, pContextList)
group = row[pContextList[context]["setGroupBy"]]
}
if(context == "Salesproject" && !ContactUtils.isOrganisation(pContactId))//add roles to the description
{
description = description + " | " + translate.text("Role") + ": "
if(roleObj.hasOwnProperty(salesProjectId))
{
var roles = roleObj[salesProjectId];
for (let i = 0; i < roles.length; i++)
{
if(i != 0)
{
description = description + ", ";
}
description = description + roles[i];
}
}
}
resultList.push([
uid, // UID
targetid, // TARGET_ID
......
......@@ -1789,6 +1789,21 @@
<filterConditionProcess>%aditoprj%/entity/Person_entity/recordcontainers/db/filterextensions/classification_filter/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype>
</filterExtension>
<filterExtension>
<name>Salesproject_filter</name>
<title>Salesproject</title>
<contentType>TEXT</contentType>
<filterValuesProcess>%aditoprj%/entity/Person_entity/recordcontainers/db/filterextensions/salesproject_filter/filterValuesProcess.js</filterValuesProcess>
<filterConditionProcess>%aditoprj%/entity/Person_entity/recordcontainers/db/filterextensions/salesproject_filter/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype>
</filterExtension>
<filterExtension>
<name>Role_filter</name>
<title>Salesproject: Role</title>
<filterValuesProcess>%aditoprj%/entity/Person_entity/recordcontainers/db/filterextensions/role_filter/filterValuesProcess.js</filterValuesProcess>
<filterConditionProcess>%aditoprj%/entity/Person_entity/recordcontainers/db/filterextensions/role_filter/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype>
</filterExtension>
</filterExtensions>
</dbRecordContainer>
<indexRecordContainer>
......
import("Sql_lib");
import("system.result");
import("system.vars");
var rawValue = vars.get("$local.rawvalue");
var operator = vars.get("$local.comparison");
var objectMemberSql = newSelect("OBJECTMEMBERID")
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.CONTACT_ID = CONTACT.CONTACTID")
.and("OBJECTMEMBER.OBJECT_TYPE", "Salesproject");
if(operator == "ISNOTNULL")
{
objectMemberSql = newSelect("OBJECTMEMBERID")
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.CONTACT_ID != CONTACT.CONTACTID")
.and("OBJECTMEMBER.OBJECT_TYPE", "Salesproject")
}
else if(operator != "ISNULL")
{
objectMemberSql = objectMemberSql.and("OBJECTMEMBER.MEMBERROLE", rawValue);
}
var condType = SqlBuilder.EXISTS();
if (operator != "EQUAL")
{
condType = SqlBuilder.NOT_EXISTS();
}
result.string(newWhere(null, objectMemberSql, condType));
\ No newline at end of file
import("Keyword_lib");
import("KeywordRegistry_basic");
import("system.result");
import("Sql_lib");
var roles = newSelect(["AB_KEYWORD_ENTRY.KEYID", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.MemberRole(), "AB_KEYWORD_ENTRY.KEYID")])
.from("AB_KEYWORD_ENTRY")
.where("AB_KEYWORD_ENTRY.AB_KEYWORD_CATEGORY_ID", "b3765719-9d07-41c4-a813-18bc9056db1a")
.and("AB_KEYWORD_ENTRY.ISACTIVE", "1")
.orderBy("AB_KEYWORD_ENTRY.SORTING")
.table();
result.object(roles);
\ No newline at end of file
import("Sql_lib");
import("system.result");
import("system.vars");
var rawValue = vars.get("$local.rawvalue");
var operator = vars.get("$local.comparison");
var objectMemberSql = newSelect("OBJECTMEMBERID")
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.CONTACT_ID = CONTACT.CONTACTID")
.and("OBJECTMEMBER.OBJECT_TYPE", "Salesproject");
if(operator == "ISNOTNULL")
{
objectMemberSql = newSelect("OBJECTMEMBERID")
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.CONTACT_ID != CONTACT.CONTACTID")
.and("OBJECTMEMBER.OBJECT_TYPE", "Salesproject")
}
else if(operator != "ISNULL")
{
objectMemberSql = objectMemberSql.and("OBJECTMEMBER.OBJECT_ROWID", rawValue);
}
var condType = SqlBuilder.EXISTS();
if (operator != "EQUAL")
{
condType = SqlBuilder.NOT_EXISTS();
}
result.string(newWhere(null, objectMemberSql, condType));
\ No newline at end of file
import("system.result");
import("Sql_lib");
var salesProjects = newSelect("SALESPROJECT.SALESPROJECTID, SALESPROJECT.PROJECTTITLE")
.from("SALESPROJECT")
.table();
result.object(salesProjects);
\ No newline at end of file
......@@ -1119,6 +1119,13 @@
<filterConditionProcess>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/filterextensions/competitor_filterextension/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype>
</filterExtension>
<filterExtensionSet>
<name>Member_filter</name>
<filterFieldsProcess>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/filterextensions/member_filter/filterFieldsProcess.js</filterFieldsProcess>
<filterValuesProcess>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/filterextensions/member_filter/filterValuesProcess.js</filterValuesProcess>
<filterConditionProcess>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/filterextensions/member_filter/filterConditionProcess.js</filterConditionProcess>
<filtertype>BASIC</filtertype>
</filterExtensionSet>
</filterExtensions>
</dbRecordContainer>
<indexRecordContainer>
......
import("Util_lib");
import("Sql_lib");
import("system.result");
import("system.vars");
var filterName = vars.get("$local.name");
var filterCond = vars.get("$local.condition");
var placeholder = vars.get("$local.columnPlaceholder");
replacement = placeholder.substring(placeholder.indexOf(".") + 1);
replacement = replacement.substring(0, replacement.indexOf("$"));
var filterRawValue = vars.get("$local.rawvalue");
var operator = vars.get("$local.operator2").trim();
var objectMemberSql = newSelect("OBJECTMEMBER.CONTACT_ID")
.from("OBJECTMEMBER")
.where("OBJECTMEMBER.OBJECT_TYPE", "Salesproject")
.and("OBJECTMEMBER.MEMBERROLE", replacement)
.and("OBJECTMEMBER.OBJECT_ROWID = SALESPROJECT.SALESPROJECTID");
if(operator != "IS NOT NULL" && operator != "IS NULL")
{
objectMemberSql = objectMemberSql.and("OBJECTMEMBER.CONTACT_ID", filterRawValue);
}
var condType = SqlBuilder.EXISTS();
if (operator == "IS NULL" || operator == "<>")//<> = NOT_EQUAL
{
condType = SqlBuilder.NOT_EXISTS();
}
result.string(newWhere(null, objectMemberSql, condType));
\ No newline at end of file
import("system.translate");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.result");
import("Sql_lib");
var roles = newSelect(["AB_KEYWORD_ENTRY.KEYID", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.MemberRole(), "AB_KEYWORD_ENTRY.KEYID")])
.from("AB_KEYWORD_ENTRY")
.where("AB_KEYWORD_ENTRY.AB_KEYWORD_CATEGORY_ID", "b3765719-9d07-41c4-a813-18bc9056db1a")
.and("AB_KEYWORD_ENTRY.ISACTIVE", "1")
.orderBy("AB_KEYWORD_ENTRY.SORTING")
.table();
var res = [];
for (var i = 0; i < roles.length; i++)
{
res.push({
name: roles[i][0],
title: translate.text("Role") + ": " + roles[i][1],
contentType: "TEXT",
hasDropDownValues: true,
isGroupable: false
});
}
result.string(JSON.stringify(res));
\ No newline at end of file
import("system.result");
import("Contact_lib");
import("Sql_lib");
var values = newSelect(["CONTACT.CONTACTID", ContactUtils.getResolvingDisplaySubSql("CONTACT.CONTACTID", true, true)])
.from(ContactUtils.getFullContactString())
.where("CONTACT.PERSON_ID is not null")
.table();
result.object(values);
\ No newline at end of file
......@@ -12119,6 +12119,10 @@ Bitte Datumseingabe prüfen</value>
<entry>
<key>9</key>
</entry>
<entry>
<key>Salesproject: Role</key>
<value>Vertriebsprojekt: Rolle</value>
</entry>
<entry>
<key>GroupTest</key>
</entry>
......
......@@ -72,9 +72,11 @@ function ContactUtils() {}
*
* @param {String} pContactIdField fieldname for the CONTACTID-condition as TABLEALIAS.COLUMNALIAS; e.g. TASK.EDITOR_CONTACT_ID
* @param {Boolean} [pIncludeOrganisation=true] false if the organisation shall not be included in the result string
* @param {Boolean} [pReturnOnlySelectExpression] returns only the selectExpression (renderer.asSql()) instead of using it to build the subSql
*
* @return {String} a subsql (without bracets) that can be played within an SQL
*/
ContactUtils.getResolvingDisplaySubSql = function(pContactIdField, pIncludeOrganisation)
ContactUtils.getResolvingDisplaySubSql = function(pContactIdField, pIncludeOrganisation, pReturnOnlySelectExpression)
{
var contact = Contact.createWithColumnPreset();
var rendererOptions;
......@@ -84,7 +86,11 @@ ContactUtils.getResolvingDisplaySubSql = function(pContactIdField, pIncludeOrgan
rendererOptions = ContactTitleRenderer.OPTIONS.IncludeOrganisation;
var renderer = new ContactTitleRenderer(contact, rendererOptions);
var selectExpression = renderer.asSql();
if(pReturnOnlySelectExpression)
{
return selectExpression;
}
//TODO: verify if there is a better solution for the usage of this as a displayValueExpression --> automatic use of #TITLE | waiting vor implementation
return "select " + selectExpression + "from CONTACT "
+ " left join PERSON on (PERSON.PERSONID = CONTACT.PERSON_ID) "
......
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