From 4c4b8db9489d0e0e2af5454597ec2a49d0dd64c9 Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Fri, 18 Sep 2020 06:01:15 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201065068][Funktion=20zu=20Privat=20Person=20anlegen=20-=20Val?=
 =?UTF-8?q?idierung=20schl=C3=A4gt=20Fehl]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../organisation_contactid/onValidation.js    | 18 +++++--
 entity/Contact_entity/onValidation.js         |  3 +-
 .../_____LANGUAGE_EXTRA.aod                   | 48 +++++++++++++++++++
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     | 37 ++++++++++++++
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     | 10 ++--
 5 files changed, 107 insertions(+), 9 deletions(-)

diff --git a/entity/Contact_entity/entityfields/organisation_contactid/onValidation.js b/entity/Contact_entity/entityfields/organisation_contactid/onValidation.js
index 94865c1d50a..dafb8923029 100644
--- a/entity/Contact_entity/entityfields/organisation_contactid/onValidation.js
+++ b/entity/Contact_entity/entityfields/organisation_contactid/onValidation.js
@@ -5,9 +5,10 @@ import("system.db");
 import("system.vars");
 import("Entity_lib");
 import("Sql_lib");
+import("Organisation_lib");
 
 var personId = vars.getString("$field.PERSON_ID");
-var organisationId;
+var organisationId, validationMsg;
 var orgContactId = vars.get("$local.value");
 var organisationIds = ContactUtils.getPersOrgIds(orgContactId)
     
@@ -19,8 +20,19 @@ if (organisationIds.length > 0 && organisationIds[2])
     if (vars.get("$field.CONTACTID"))
         contactId = vars.get("$field.CONTACTID");
 
-    var validationMsg = ContactUtils.validateIfAlreadyExists(personId, organisationId, contactId);
+    validationMsg = ContactUtils.validateIfAlreadyExists(personId, organisationId, contactId);
     if (validationMsg)
         result.string(validationMsg);
 }
-
+else
+{
+    var privateCount = newSelect("count(*)")
+                                .from("CONTACT")
+                                .where("CONTACT.ORGANISATION_ID", OrgUtils.getPrivateOrganisationId())
+                                .and("CONTACT.CONTACTID", vars.get("$param.OwnContactId_param"))
+                                .cell();
+    if(privateCount > 0)
+        validationMsg = translate.text("A person can only have one private Contact.");
+    if(validationMsg)
+        result.string(validationMsg)
+}
\ No newline at end of file
diff --git a/entity/Contact_entity/onValidation.js b/entity/Contact_entity/onValidation.js
index ef3e299e677..6ba91bd9298 100644
--- a/entity/Contact_entity/onValidation.js
+++ b/entity/Contact_entity/onValidation.js
@@ -1,8 +1,9 @@
+import("Organisation_lib");
 import("system.vars");
 import("system.neon");
 
 //TODO: workaround till there exists somtehing that can be done "beforeSave"; a validation of the whole entity is done before saving so let's use this process at the moment
 if(!vars.get("$field.ORGANISATION_ID"))
 {
-    neon.setFieldValue("$field.ORGANISATION_ID", "0");
+    neon.setFieldValue("$field.ORGANISATION_ID", OrgUtils.getPrivateOrganisationId());
 }
\ No newline at end of file
diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
index a0cab0ed38f..b93533604a7 100644
--- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
+++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
@@ -7368,6 +7368,54 @@
     <entry>
       <key>Mark all cached record containers as invalid</key>
     </entry>
+    <entry>
+      <key>%0 of the chosen records are already recipients.</key>
+    </entry>
+    <entry>
+      <key>Set missing address locations</key>
+    </entry>
+    <entry>
+      <key>Set all address locations</key>
+    </entry>
+    <entry>
+      <key>Shows the number of Activities of the Grouped Fields</key>
+    </entry>
+    <entry>
+      <key>The status of the offer was changed to \"sent\".</key>
+    </entry>
+    <entry>
+      <key>Sales Staff Activity</key>
+    </entry>
+    <entry>
+      <key>Titel</key>
+    </entry>
+    <entry>
+      <key>Month</key>
+    </entry>
+    <entry>
+      <key>Responsible Department</key>
+    </entry>
+    <entry>
+      <key>Shows the different conversion rates of the sales project phases</key>
+    </entry>
+    <entry>
+      <key>FavoriteFilter_view</key>
+    </entry>
+    <entry>
+      <key>Salesproject Convertion Rates</key>
+    </entry>
+    <entry>
+      <key>The status of the order was changed to \"sent\".</key>
+    </entry>
+    <entry>
+      <key>Conversion Rate</key>
+    </entry>
+    <entry>
+      <key>AB_KEYWORD_ENTRYID</key>
+    </entry>
+    <entry>
+      <key>A person can only have one private Contact.</key>
+    </entry>
     <entry>
       <key>Linked in (Person)</key>
     </entry>
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index ab88dccfb93..3ca1a4994f7 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -2669,6 +2669,10 @@
       <key>Fiji</key>
       <value>Fidschi</value>
     </entry>
+    <entry>
+      <key>A person can only have one private Contact.</key>
+      <value>Eine Person kann nur einen privaten Kontakt haben.</value>
+    </entry>
     <entry>
       <key>Guinea</key>
       <value>Guinea</value>
@@ -9463,6 +9467,39 @@ Bitte Datumseingabe prüfen</value>
     <entry>
       <key>Xing (Person)</key>
     </entry>
+    <entry>
+      <key>Date must not be in the future</key>
+    </entry>
+    <entry>
+      <key>Shows the number of Activities of the Grouped Fields</key>
+    </entry>
+    <entry>
+      <key>Sales Staff Activity</key>
+    </entry>
+    <entry>
+      <key>Month</key>
+    </entry>
+    <entry>
+      <key>Responsible Department</key>
+    </entry>
+    <entry>
+      <key>Shows the different conversion rates of the sales project phases</key>
+    </entry>
+    <entry>
+      <key>Salesproject Convertion Rates</key>
+    </entry>
+    <entry>
+      <key>Date has to be in the selected calendar week!</key>
+    </entry>
+    <entry>
+      <key>50-99 D€</key>
+    </entry>
+    <entry>
+      <key>Conversion Rate</key>
+    </entry>
+    <entry>
+      <key>AB_KEYWORD_ENTRYID</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
 </language>
diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
index f9813732694..794e1fefaaf 100644
--- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
+++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
@@ -7453,19 +7453,19 @@
       <key>Current Recipients</key>
     </entry>
     <entry>
-      <key>Date (Month)</key>
+      <key>The status of the offer was changed to \"sent\".</key>
     </entry>
     <entry>
-      <key>Date (Year)</key>
+      <key>The status of the order was changed to \"sent\".</key>
     </entry>
     <entry>
-      <key>Date (Day)</key>
+      <key>Conversion Rate</key>
     </entry>
     <entry>
-      <key>Grant new User Permission</key>
+      <key>AB_KEYWORD_ENTRYID</key>
     </entry>
     <entry>
-      <key>%0 of the chosen records are already recipients.</key>
+      <key>A person can only have one private Contact.</key>
     </entry>
     <entry>
       <key>Linked in (Person)</key>
-- 
GitLab