From c6b2cf00301582c3b7b7ef3e69943dba52d22302 Mon Sep 17 00:00:00 2001
From: "c.wimmer" <c.wimmer@cwimmer-nb.aditosoftware.local>
Date: Fri, 18 Dec 2020 16:52:31 +0100
Subject: [PATCH] 1068897

---
 entity/Organisation_entity/Organisation_entity.aod     |  4 ++++
 .../recordcontainers/db/conditionProcess.js            |  5 ++++-
 entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod |  6 ++++++
 .../children/onlyactive_param/valueProcess.js          |  3 +++
 .../VisitRecommendation_entity.aod                     | 10 ++++++++++
 .../children/onlyactive_param/valueProcess.js          |  3 +++
 .../children/onlyactive_param/valueProcess.js          |  3 +++
 7 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 entity/VisitPlanEntry_entity/entityfields/organisations/children/onlyactive_param/valueProcess.js
 create mode 100644 entity/VisitRecommendation_entity/entityfields/organisationconsumer/children/onlyactive_param/valueProcess.js
 create mode 100644 entity/VisitRecommendation_entity/entityfields/personconsumer/children/onlyactive_param/valueProcess.js

diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index 076fe1f621..1707c9025b 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -1436,6 +1436,10 @@
         <fieldName>FilterProvider</fieldName>
       </dependency>
     </entityConsumer>
+    <entityParameter>
+      <name>OnlyActive_param</name>
+      <expose v="true" />
+    </entityParameter>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js
index a38a50972c..284a5df816 100644
--- a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js
@@ -1,3 +1,4 @@
+import("KeywordRegistry_basic");
 import("Employee_lib");
 import("AttributeRegistry_basic");
 import("Attribute_lib");
@@ -40,7 +41,9 @@ if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedC
     var excludedContacts = JSON.parse(vars.getString("$param.ExcludedContactIds_param"));
     cond.andIfSet("CONTACT.CONTACTID", excludedContacts, SqlBuilder.NOT_IN())
 }
-
+if (vars.exists("$param.OnlyActive_param") && vars.get("$param.OnlyActive_param"))
+    cond.and("CONTACT.STATUS", $KeywordRegistry.contactStatus$active())
+    
 cond.andIfSet("ORGANISATION.KIND", "$param.OrganisationType_param");
 cond.andIfSet("CONTACT.CONTACTID", onlyShowContactIds, SqlBuilder.IN())
 
diff --git a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
index 56d2b015d2..911e30fab2 100644
--- a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
+++ b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod
@@ -121,6 +121,12 @@
     </entityActionGroup>
     <entityConsumer>
       <name>Organisations</name>
+      <children>
+        <entityParameter>
+          <name>OnlyActive_param</name>
+          <valueProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/organisations/children/onlyactive_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
       <dependency>
         <name>dependency</name>
         <entityName>Organisation_entity</entityName>
diff --git a/entity/VisitPlanEntry_entity/entityfields/organisations/children/onlyactive_param/valueProcess.js b/entity/VisitPlanEntry_entity/entityfields/organisations/children/onlyactive_param/valueProcess.js
new file mode 100644
index 0000000000..40effa0178
--- /dev/null
+++ b/entity/VisitPlanEntry_entity/entityfields/organisations/children/onlyactive_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(true);
\ No newline at end of file
diff --git a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
index 229cb5a19f..24e4568c65 100644
--- a/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
+++ b/entity/VisitRecommendation_entity/VisitRecommendation_entity.aod
@@ -99,6 +99,12 @@
     </entityConsumer>
     <entityConsumer>
       <name>OrganisationConsumer</name>
+      <children>
+        <entityParameter>
+          <name>OnlyActive_param</name>
+          <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/organisationconsumer/children/onlyactive_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
       <dependency>
         <name>dependency</name>
         <entityName>Organisation_entity</entityName>
@@ -118,6 +124,10 @@
           <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/personconsumer/children/orgid_param/valueProcess.js</valueProcess>
           <expose v="true" />
         </entityParameter>
+        <entityParameter>
+          <name>OnlyActive_param</name>
+          <valueProcess>%aditoprj%/entity/VisitRecommendation_entity/entityfields/personconsumer/children/onlyactive_param/valueProcess.js</valueProcess>
+        </entityParameter>
       </children>
       <dependency>
         <name>dependency</name>
diff --git a/entity/VisitRecommendation_entity/entityfields/organisationconsumer/children/onlyactive_param/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/organisationconsumer/children/onlyactive_param/valueProcess.js
new file mode 100644
index 0000000000..40effa0178
--- /dev/null
+++ b/entity/VisitRecommendation_entity/entityfields/organisationconsumer/children/onlyactive_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(true);
\ No newline at end of file
diff --git a/entity/VisitRecommendation_entity/entityfields/personconsumer/children/onlyactive_param/valueProcess.js b/entity/VisitRecommendation_entity/entityfields/personconsumer/children/onlyactive_param/valueProcess.js
new file mode 100644
index 0000000000..40effa0178
--- /dev/null
+++ b/entity/VisitRecommendation_entity/entityfields/personconsumer/children/onlyactive_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(true);
\ No newline at end of file
-- 
GitLab