From 00ef7d0c133c3864c66f33ac4f71a09852c9469f Mon Sep 17 00:00:00 2001
From: Andre Loreth <a.loreth@adito.de>
Date: Tue, 18 Feb 2020 12:57:31 +0100
Subject: [PATCH] #1051579: Order: Implement OrderReminderReport_view

---
 entity/Order_entity/Order_entity.aod          |  4 +++
 .../reminder_report_data/valueProcess.js      |  9 +++++++
 .../OrderReminderReport_view.aod              | 17 +++++++++++++
 process/Order_lib/process.js                  | 25 +++++++++++++++----
 4 files changed, 50 insertions(+), 5 deletions(-)
 create mode 100644 entity/Order_entity/entityfields/reminder_report_data/valueProcess.js
 create mode 100644 neonView/OrderReminderReport_view/OrderReminderReport_view.aod

diff --git a/entity/Order_entity/Order_entity.aod b/entity/Order_entity/Order_entity.aod
index a6b28c020c..e1b6705179 100644
--- a/entity/Order_entity/Order_entity.aod
+++ b/entity/Order_entity/Order_entity.aod
@@ -952,6 +952,10 @@
       <iconId>VAADIN:CURLY_BRACKETS</iconId>
       <stateProcess>%aditoprj%/entity/Order_entity/entityfields/openadminview/stateProcess.js</stateProcess>
     </entityActionField>
+    <entityField>
+      <name>REMINDER_REPORT_DATA</name>
+      <valueProcess>%aditoprj%/entity/Order_entity/entityfields/reminder_report_data/valueProcess.js</valueProcess>
+    </entityField>
     <entityConsumer>
       <name>Organisations</name>
       <dependency>
diff --git a/entity/Order_entity/entityfields/reminder_report_data/valueProcess.js b/entity/Order_entity/entityfields/reminder_report_data/valueProcess.js
new file mode 100644
index 0000000000..35c5e637a9
--- /dev/null
+++ b/entity/Order_entity/entityfields/reminder_report_data/valueProcess.js
@@ -0,0 +1,9 @@
+import("system.result");
+import("system.vars");
+import("Order_lib");
+
+var reportData = OrderUtils.buildReminderReport(vars.get("$field.SALESORDERID"));
+
+if(reportData != null) {
+    result.string(reportData[1]);
+}
\ No newline at end of file
diff --git a/neonView/OrderReminderReport_view/OrderReminderReport_view.aod b/neonView/OrderReminderReport_view/OrderReminderReport_view.aod
new file mode 100644
index 0000000000..71398a6c8d
--- /dev/null
+++ b/neonView/OrderReminderReport_view/OrderReminderReport_view.aod
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.4">
+  <name>OrderReminderReport_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <reportViewTemplate>
+      <name>Report</name>
+      <reportData>REMINDER_REPORT_DATA</reportData>
+      <entityField>#ENTITY</entityField>
+    </reportViewTemplate>
+  </children>
+</neonView>
diff --git a/process/Order_lib/process.js b/process/Order_lib/process.js
index b4ef3fa6d0..fda69211f4 100644
--- a/process/Order_lib/process.js
+++ b/process/Order_lib/process.js
@@ -371,9 +371,14 @@ OrderUtils.openOrderReport = function (pOrderID)
     orderReport.openReport();
 }
 
-
-OrderUtils.openReminderReport = function (pOrderID)
-{    
+/**
+ * Will build the reminder report for the given order.
+ * 
+ * @param {String} pOrderID The ID of the order, for which the report shall be built.
+ * @return {Array} [filename, data]
+ */
+OrderUtils.buildReminderReport = function (pOrderID)
+{
     var reminderReport = new Report("Reminder_report");  
     
     var sqlUtil = new SqlMaskingUtils();
@@ -443,7 +448,7 @@ OrderUtils.openReminderReport = function (pOrderID)
 
 
     if (itemData.length == 0)
-        return;
+        return null;
     
     var fullPrice = 0;
     var itemSum = 0;
@@ -543,7 +548,17 @@ OrderUtils.openReminderReport = function (pOrderID)
            
         ])
         .add(itemData));
-    reminderReport.openReport();
+    return reminderReport.exportReport();
+}
+
+/**
+ * Opens the reminder report for the given order.
+ * 
+ * @param {String} pOrderID The ID of the order, for which the report shall be built.
+ */
+OrderUtils.openReminderReport = function (pOrderID)
+{
+    neon.openContext("Order", "OrderReminderReport_view", [pOrderID], neon.OPERATINGSTATE_VIEW, null);
 }
 
 
-- 
GitLab