From 41dd9779f576d0f2f19cc4b1f8eb0dbc7377fd0f Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Wed, 12 Aug 2020 14:27:09 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201059218][Besuchsvorschlag=20kann=20in=20QS=20nicht=20gel?=
 =?UTF-8?q?=C3=B6scht=20werden]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../VisitPlanEmployeeWeek_entity.aod                   |  1 +
 .../VisitPlanEmployeeWeek_entity/grantDeleteProcess.js | 10 ++++++++++
 .../recordcontainers/jdito/onDelete.js                 | 10 ++++++++++
 .../VisitPlanEmployeeWeekPreview_view.aod              |  1 -
 4 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 entity/VisitPlanEmployeeWeek_entity/grantDeleteProcess.js

diff --git a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
index 531c1918d2..07aec7a835 100644
--- a/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
+++ b/entity/VisitPlanEmployeeWeek_entity/VisitPlanEmployeeWeek_entity.aod
@@ -4,6 +4,7 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/documentation.adoc</documentation>
   <title>Visitplan Weekly Overview</title>
+  <grantDeleteProcess>%aditoprj%/entity/VisitPlanEmployeeWeek_entity/grantDeleteProcess.js</grantDeleteProcess>
   <iconId>VAADIN:CAR</iconId>
   <image>VAADIN:CAR</image>
   <recordContainer>db</recordContainer>
diff --git a/entity/VisitPlanEmployeeWeek_entity/grantDeleteProcess.js b/entity/VisitPlanEmployeeWeek_entity/grantDeleteProcess.js
new file mode 100644
index 0000000000..c5a2db6695
--- /dev/null
+++ b/entity/VisitPlanEmployeeWeek_entity/grantDeleteProcess.js
@@ -0,0 +1,10 @@
+import("system.vars");
+import("system.result");
+import("Entity_lib");
+
+var id = vars.get("$field.VISITPLANEMPLOYEEWEEKID")
+var canDelete = new HasLinkedObjectTester()
+    .andNoEntityRows("VisitPlanEntry_entity", "Entries", {Entries_param : id})
+    .validate();
+    
+result.string(canDelete)
\ No newline at end of file
diff --git a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
index 053a7f39e0..a507271c67 100644
--- a/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
+++ b/entity/VisitPlanEntry_entity/recordcontainers/jdito/onDelete.js
@@ -1,6 +1,16 @@
+import("system.vars");
+import("Calendar_lib");
 import("system.neon");
 import("Sql_lib");
 import("system.db");
 
+var id = vars.get("$field.APPOINTMENT_ID") //deletes appointmententries (+ the linked Objects) if an appointment has been made
+
+new SqlBuilder(SqlUtils.getSystemAlias()).whereIfSet("ASYS_CALENDARBACKEND.ELEMENTUID", id)
+    .deleteData();
+    
+newWhereIfSet("AB_APPOINTMENTLINK.APPOINTMENT_ID", id)
+    .deleteData();
+
 newWhereIfSet("VISITPLANENTRY.VISITPLANENTRYID", "$field.UID")
     .deleteData();
\ No newline at end of file
diff --git a/neonView/VisitPlanEmployeeWeekPreview_view/VisitPlanEmployeeWeekPreview_view.aod b/neonView/VisitPlanEmployeeWeekPreview_view/VisitPlanEmployeeWeekPreview_view.aod
index 7c1d4abf3b..7e053c7391 100644
--- a/neonView/VisitPlanEmployeeWeekPreview_view/VisitPlanEmployeeWeekPreview_view.aod
+++ b/neonView/VisitPlanEmployeeWeekPreview_view/VisitPlanEmployeeWeekPreview_view.aod
@@ -4,7 +4,6 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <size>SMALL</size>
   <isOverlay v="false" />
-  <overlayOrientation>PORTRAIT</overlayOrientation>
   <layout>
     <headerFooterLayout>
       <name>layout</name>
-- 
GitLab