From 53dd96e5715284b8f7d0cdea03af849c88c215c9 Mon Sep 17 00:00:00 2001 From: "a.schindlbeck" <a.schindlbeck@adito.de> Date: Wed, 3 Apr 2019 11:14:01 +0200 Subject: [PATCH] Angebot neuanlage: Nur offene Vertriebsproj. mit passender Firma --- entity/Offer_entity/Offer_entity.aod | 8 ++++- .../entityfields/contact_id/onValueChange.js | 32 ++++++++++-------- .../children/contactid_param/valueProcess.js | 7 ++++ .../Salesproject_entity.aod | 30 +++++++++++++---- .../children/state_param/valueProcess.js | 4 +++ .../children/state_param/valueProcess.js | 5 +++ .../recordcontainers/db/conditionProcess.js | 33 ++++++++++++++----- process/Contact_lib/process.js | 5 ++- 8 files changed, 92 insertions(+), 32 deletions(-) create mode 100644 entity/Offer_entity/entityfields/salesprojects/children/contactid_param/valueProcess.js create mode 100644 entity/Salesproject_entity/entityfields/opensalesprojects/children/state_param/valueProcess.js create mode 100644 entity/Salesproject_entity/entityfields/salesprojectsopen/children/state_param/valueProcess.js diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index c1bf480be6..64409fcaa9 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -336,8 +336,14 @@ <dependency> <name>dependency</name> <entityName>Salesproject_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>openSalesprojects</fieldName> </dependency> + <children> + <entityParameter> + <name>ContactId_param</name> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/salesprojects/children/contactid_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> <entityField> <name>ADDRESS</name> diff --git a/entity/Offer_entity/entityfields/contact_id/onValueChange.js b/entity/Offer_entity/entityfields/contact_id/onValueChange.js index 96af6855c0..98ae338e18 100644 --- a/entity/Offer_entity/entityfields/contact_id/onValueChange.js +++ b/entity/Offer_entity/entityfields/contact_id/onValueChange.js @@ -1,14 +1,20 @@ -import("system.neon"); -import("system.vars"); -import("system.db"); -import("Util_lib"); -import("Entity_lib"); - -var contactid = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTACT_ID")); -if(contactid != "") -{ - var relData = db.array(db.ROW, "select LANGUAGE from CONTACT where CONTACTID = '" + contactid + "'"); - - if(relData[0] != "") - neon.setFieldValue("field.LANGUAGE", relData[0]); +import("system.logging"); +import("system.neon"); +import("system.vars"); +import("system.db"); +import("Util_lib"); +import("Entity_lib"); +import("Contact_lib"); + +var contactid = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTACT_ID")); +if(contactid != "") +{ + //Language Preset + var relData = db.array(db.ROW, "select LANGUAGE from CONTACT where CONTACTID = '" + contactid + "'"); + if(relData[0] != "") + neon.setFieldValue("field.LANGUAGE", relData[0]); + + // set $field.CONTATCT_ORG_ID per contactid + var orgid = ContactUtils.getPersOrgIds(contactid); + neon.setFieldValue("$field.CONTACT_ORG_ID", orgid[2]); } \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/salesprojects/children/contactid_param/valueProcess.js b/entity/Offer_entity/entityfields/salesprojects/children/contactid_param/valueProcess.js new file mode 100644 index 0000000000..2b24f74fc8 --- /dev/null +++ b/entity/Offer_entity/entityfields/salesprojects/children/contactid_param/valueProcess.js @@ -0,0 +1,7 @@ +import("system.logging"); +import("system.vars"); +import("system.result"); +import("Entity_lib"); + +var contact = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTACT_ORG_ID")); +result.string(contact); \ No newline at end of file diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index 556054ab8e..33b930ad5b 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -11,12 +11,6 @@ <entityProvider> <name>#PROVIDER</name> <dependencies> - <entityDependency> - <name>525fd920-ea50-45d6-97a8-20e0aaaa830c</name> - <entityName>Offer_entity</entityName> - <fieldName>Salesprojects</fieldName> - <isConsumer v="false" /> - </entityDependency> <entityDependency> <name>497657f7-ebd7-4c9c-b8ab-da447a1556e5</name> <entityName>Order_entity</entityName> @@ -521,6 +515,30 @@ </entityParameter> </children> </entityConsumer> + <entityProvider> + <name>openSalesprojects</name> + <fieldType>DEPENDENCY_IN</fieldType> + <dependencies> + <entityDependency> + <name>631f55f9-fb0f-4205-bdb8-6e3476268ab4</name> + <entityName>Offer_entity</entityName> + <fieldName>Salesprojects</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>State_param</name> + <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/opensalesprojects/children/state_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> + </children> + </entityProvider> + <entityParameter> + <name>State_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Salesproject_entity/entityfields/opensalesprojects/children/state_param/valueProcess.js b/entity/Salesproject_entity/entityfields/opensalesprojects/children/state_param/valueProcess.js new file mode 100644 index 0000000000..9074d4eece --- /dev/null +++ b/entity/Salesproject_entity/entityfields/opensalesprojects/children/state_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); + +//The Id for the salesproject state keyword OPEN +result.string("483bcaeb-1e5b-4772-b54e-7d7d8aa65712"); \ No newline at end of file diff --git a/entity/Salesproject_entity/entityfields/salesprojectsopen/children/state_param/valueProcess.js b/entity/Salesproject_entity/entityfields/salesprojectsopen/children/state_param/valueProcess.js new file mode 100644 index 0000000000..e593be26ec --- /dev/null +++ b/entity/Salesproject_entity/entityfields/salesprojectsopen/children/state_param/valueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); + + +//KeywordId for SalesprojectCompetitionState OPEN +result.string("25b0ac77-ef92-4809-802e-bb9d8782f865") \ No newline at end of file diff --git a/entity/Salesproject_entity/recordcontainers/db/conditionProcess.js b/entity/Salesproject_entity/recordcontainers/db/conditionProcess.js index 6500b695cd..a710bd959e 100644 --- a/entity/Salesproject_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Salesproject_entity/recordcontainers/db/conditionProcess.js @@ -1,9 +1,24 @@ -import("system.db"); -import("system.result"); -import("system.vars"); -import("Sql_lib"); - -result.string(db.translateCondition( - SqlCondition.begin() - .andPrepareVars("SALESPROJECT.CONTACT_ID", "$param.ContactId_param") - .build("1 = 1"))); \ No newline at end of file +import("system.logging"); +import("system.db"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); + +logging.log("state: " + vars.get("$param.State_param")); +logging.log("contact: " + vars.get("$param.ContactId_param")); + +if(vars.exists("$param.State_param") && vars.get("$param.State_param") && vars.exists("$param.ContactId_param") && vars.get("$param.ContactId_param")) +{ + result.string(db.translateCondition( + SqlCondition.begin() + .andPrepareVars("SALESPROJECT.CONTACT_ID", "$param.ContactId_param") + .andPrepareVars("SALESPROJECT.STATE", "$param.State_param") + .build("1 = 2"))); +} +else +{ + result.string(db.translateCondition( + SqlCondition.begin() + .andPrepareVars("SALESPROJECT.CONTACT_ID", "$param.ContactId_param") + .build("1 = 1"))); +} \ No newline at end of file diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index f4d5068268..9650bbacd2 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -190,7 +190,7 @@ ContactUtils.getContextByContactId = function(pContactId) * get the person- and org-id from a contact as array * * @param {String} pContactId - * @return {String[]} result as [persid, orgid] if one of them is null in the db, "" will be returned as the id. + * @return {String[]} result as [contactid, persid, orgid] if one of them is null in the db, "" will be returned as the id. */ ContactUtils.getPersOrgIds = function(pContactId) { @@ -201,8 +201,7 @@ ContactUtils.getPersOrgIds = function(pContactId) .buildSql("select CONTACTID, PERSON_ID, ORGANISATION_ID from CONTACT", "1=0")); } - - return ["", ""]; + return []; } /** -- GitLab