From fc362275fc87c1f1c0e2544b8a494ad44a490953 Mon Sep 17 00:00:00 2001 From: Carolin Wimmer <c.wimmer@adito.de> Date: Mon, 2 Nov 2020 14:56:22 +0100 Subject: [PATCH] [Projekt: Crowd-Development / Besuch vor Ort][TicketNr.: 1066738][[aus Schmalz] Besuchsvorschlag anlegen] --- .../VisitPlanEmployeeWeek_entity.aod | 1 + .../entityfields/week/onValidation.js | 22 ++++++ .../VisitRecommendation_entity.aod | 6 +- .../contact_id/displayValueProcess.js | 5 ++ .../entityfields/contact_id/stateProcess.js | 7 -- .../contact_person_id/displayValueProcess.js | 5 ++ .../contact_person_id/stateProcess.js | 7 -- .../entityfields/due_date/valueProcess.js | 69 +++++++++++-------- .../responsible/displayValueProcess.js | 6 ++ .../entityfields/responsible/valueProcess.js | 7 ++ .../_____LANGUAGE_EXTRA.aod | 6 ++ .../_____LANGUAGE_de/_____LANGUAGE_de.aod | 8 +++ .../_____LANGUAGE_en/_____LANGUAGE_en.aod | 6 ++ 13 files changed, 112 insertions(+), 43 deletions(-) create mode 100644 entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js create mode 100644 entity/VisitRecommendation_entity/entityfields/contact_id/displayValueProcess.js delete mode 100644 entity/VisitRecommendation_entity/entityfields/contact_id/stateProcess.js create mode 100644 entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js delete mode 100644 entity/VisitRecommendation_entity/entityfields/contact_person_id/stateProcess.js create mode 100644 entity/VisitRecommendation_entity/entityfields/responsible/displayValueProcess.js create mode 100644 entity/VisitRecommendation_entity/entityfields/responsible/valueProcess.js diff --git a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod index 63130c5f63d..ef198c6a746 100644 --- a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod +++ b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod @@ -27,6 +27,7 @@ <title>Week</title> <dropDownProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/dropDownProcess.js</dropDownProcess> <valueProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/valueProcess.js</valueProcess> + <onValidation>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js</onValidation> </entityField> <entityField> <name>INFO</name> diff --git a/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js b/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js new file mode 100644 index 00000000000..cff756f7130 --- /dev/null +++ b/entity/VisitPlanEmployeeWeek_entity/entityfields/week/onValidation.js @@ -0,0 +1,22 @@ +import("system.result"); +import("Sql_lib"); +import("Employee_lib"); +import("system.logging"); +import("system.datetime"); +import("system.vars"); +import("system.eMath"); + + +var year = eMath.absInt(vars.get("$field.YEAR")); +var week = vars.get("$local.value"); +var user = EmployeeUtils.getCurrentContactId(); + +var weekEntry = newSelect("VISITPLANEMPLOYEEWEEKID") + .from("VISITPLANEMPLOYEEWEEK") + .where("VISITPLANEMPLOYEEWEEK.VISITPLAN_YEAR", year) + .and("VISITPLANEMPLOYEEWEEK.VISITPLAN_WEEK", week) + .and("VISITPLANEMPLOYEEWEEK.CONTACT_ID", user) + .cell(); + +if(weekEntry) + result.string("Weekplan already exists!"); \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod index caeb768e66a..1751833285f 100644 --- a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod +++ b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod @@ -32,8 +32,8 @@ <groupable v="false" /> <linkedContext>Organisation</linkedContext> <mandatory v="true" /> - <stateProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_id/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_id/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_id/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>UID</name> @@ -167,8 +167,8 @@ <description></description> <consumer>PersonConsumer</consumer> <groupable v="true" /> - <stateProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_person_id/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_person_id/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js</displayValueProcess> </entityField> <entityProvider> <name>#PROVIDER_AGGREGATES</name> @@ -198,6 +198,8 @@ <consumer>Employees</consumer> <groupable v="true" /> <mandatory v="true" /> + <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/responsible/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/responsible/displayValueProcess.js</displayValueProcess> </entityField> <entityConsumer> <name>Employees</name> diff --git a/entity/VisitRecommendation_entity/entityfields/contact_id/displayValueProcess.js b/entity/VisitRecommendation_entity/entityfields/contact_id/displayValueProcess.js new file mode 100644 index 00000000000..e91b4843534 --- /dev/null +++ b/entity/VisitRecommendation_entity/entityfields/contact_id/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("Contact_lib"); +import("system.result"); + +result.string(ContactUtils.getFullTitleByContactId(vars.get("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/contact_id/stateProcess.js b/entity/VisitRecommendation_entity/entityfields/contact_id/stateProcess.js deleted file mode 100644 index 7092871f22e..00000000000 --- a/entity/VisitRecommendation_entity/entityfields/contact_id/stateProcess.js +++ /dev/null @@ -1,7 +0,0 @@ -import("system.logging"); -import("system.neon"); -import("system.result"); -import("system.vars"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$param.ContactId_param") && vars.exists("$param.ContactId_param")) - result.string(neon.COMPONENTSTATE_INVISIBLE) \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js b/entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js new file mode 100644 index 00000000000..2b20cde46f7 --- /dev/null +++ b/entity/VisitRecommendation_entity/entityfields/contact_person_id/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("Contact_lib"); +import("system.result"); + +result.string(ContactUtils.getFullTitleByContactId(vars.get("$field.CONTACT_PERSON_ID"))); \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/contact_person_id/stateProcess.js b/entity/VisitRecommendation_entity/entityfields/contact_person_id/stateProcess.js deleted file mode 100644 index 07f9475d016..00000000000 --- a/entity/VisitRecommendation_entity/entityfields/contact_person_id/stateProcess.js +++ /dev/null @@ -1,7 +0,0 @@ -import("system.logging"); -import("system.neon"); -import("system.result"); -import("system.vars"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$param.ContactIdPerson_param") && vars.exists("$param.ContactIdPerson_param")) - result.string(neon.COMPONENTSTATE_INVISIBLE) \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/due_date/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/due_date/valueProcess.js index 82886507c61..eac3244b03a 100644 --- a/entity/VisitRecommendation_entity/entityfields/due_date/valueProcess.js +++ b/entity/VisitRecommendation_entity/entityfields/due_date/valueProcess.js @@ -1,27 +1,42 @@ -//import("Sql_lib"); -//import("Employee_lib"); -//import("system.neon"); -//import("system.vars"); -//import("system.result"); -// -// -//if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null) -//{ -// var contactidResp = vars.get("$field.RESPONSIBLE") -// var maturity = newSelect("ATTRIBUTE_NAME") -// .from("AB_ATTRIBUTERELATION") -// .join("AB_ATTRIBUTE", "AB_ATTRIBUTEID = ID_VALUE") -// .where("AB_ATTRIBUTE_ID", "e8770b60-160c-466e-af57-4f90bd6e02d7") -// .and("OBJECT_ROWID", contactidResp); -// -// var due_date = new Date(); -// switch(maturity) -// { -// case "2 Weeks": -// due_date.setDate(d.getDate() + 14); -// break; -// case "" -// } -// -// result.string(); -//} \ No newline at end of file +import("system.datetime"); +import("system.logging"); +import("Sql_lib"); +import("Employee_lib"); +import("system.neon"); +import("system.vars"); +import("system.result"); + + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null) +{ + var contactidResp = vars.get("$field.RESPONSIBLE") + var maturity = newSelect("AB_ATTRIBUTE.ATTRIBUTE_NAME") + .from("AB_ATTRIBUTERELATION") + .join("AB_ATTRIBUTE", "AB_ATTRIBUTE.AB_ATTRIBUTEID = AB_ATTRIBUTERELATION.ID_VALUE") + .where("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID", "e8770b60-160c-466e-af57-4f90bd6e02d7") + .and("AB_ATTRIBUTERELATION.OBJECT_ROWID", contactidResp) + .cell(); + + var due_date = new Date(); +//d.setDate(d.getDate() + 50); + switch(maturity) + { + case "2 Weeks": + due_date =due_date.setDate(due_date.getDate() + 14); + logging.log("2"); + break; + case "1 Month": + due_date = due_date.setMonth(due_date.getMonth() + 1); + logging.log("1") + break; + case "6 Months": + due_date = due_date.setMonth(due_date.getMonth() + 6); + logging.log("6") + break; + case "12 Months": + due_date = due_date.setMonth(due_date.getMonth() + 12); + logging.log("12") + break; + } + result.string(due_date); +} \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/responsible/displayValueProcess.js b/entity/VisitRecommendation_entity/entityfields/responsible/displayValueProcess.js new file mode 100644 index 00000000000..46777a8ba61 --- /dev/null +++ b/entity/VisitRecommendation_entity/entityfields/responsible/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("Contact_lib"); +import("system.result"); + + +result.string(ContactUtils.getFullTitleByContactId(vars.get("$field.RESPONSIBLE"), false)); \ No newline at end of file diff --git a/entity/VisitRecommendation_entity/entityfields/responsible/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/responsible/valueProcess.js new file mode 100644 index 00000000000..1b25b343bc1 --- /dev/null +++ b/entity/VisitRecommendation_entity/entityfields/responsible/valueProcess.js @@ -0,0 +1,7 @@ +import("system.neon"); +import("system.vars"); +import("Employee_lib"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && (vars.get("$this.value") == null || vars.get("$this.value") == undefined)) + result.string(EmployeeUtils.getCurrentContactId()) \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index e7857d64b64..fe35570b170 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -7296,6 +7296,12 @@ <entry> <key>2 Weeks</key> </entry> + <entry> + <key>Calendar week</key> + </entry> + <entry> + <key>Weekplan already exists!</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 6b96b2f3c12..8c0dce1efc3 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -9509,6 +9509,10 @@ Bitte Datumseingabe prüfen</value> <key>Responsible Department</key> <value>zuständige Abteilung</value> </entry> + <entry> + <key>Weekplan already exists!</key> + <value>Wochenplan existiert bereits!</value> + </entry> <entry> <key>Shows the different conversion rates of the sales project phases</key> <value>zeigt die unterschiedlichen Umrechnungsraten der vertriebsprojektphasen</value> @@ -9668,15 +9672,19 @@ Bitte Datumseingabe prüfen</value> </entry> <entry> <key>12 Months</key> + <value>12 Monate</value> </entry> <entry> <key>6 Months</key> + <value>6 Monate</value> </entry> <entry> <key>1 Month</key> + <value>1 Monat</value> </entry> <entry> <key>2 Weeks</key> + <value>2 Wochen</value> </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 25a9a85803e..a5011c8bcd7 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -7377,6 +7377,12 @@ <entry> <key>2 Weeks</key> </entry> + <entry> + <key>Calendar week</key> + </entry> + <entry> + <key>Weekplan already exists!</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> -- GitLab