From e20a8d215ddbb365621db07b3e7028723a2e3e31 Mon Sep 17 00:00:00 2001
From: guillermo <guillermo@verdnatura.es>
Date: Thu, 7 Sep 2023 11:47:33 +0200
Subject: [PATCH] refs #5662 Add email modified-collection-volumetry

---
 .../assets/css/import.js                      | 12 +++++++++
 .../assets/css/style.css                      |  8 ++++++
 .../locale/en.yml                             |  3 +++
 .../locale/es.yml                             |  3 +++
 .../modified-collection-volumetry.html        | 15 +++++++++++
 .../modified-collection-volumetry.js          | 25 +++++++++++++++++++
 6 files changed, 66 insertions(+)
 create mode 100644 print/templates/email/modified-collection-volumetry/assets/css/import.js
 create mode 100644 print/templates/email/modified-collection-volumetry/assets/css/style.css
 create mode 100644 print/templates/email/modified-collection-volumetry/locale/en.yml
 create mode 100644 print/templates/email/modified-collection-volumetry/locale/es.yml
 create mode 100644 print/templates/email/modified-collection-volumetry/modified-collection-volumetry.html
 create mode 100755 print/templates/email/modified-collection-volumetry/modified-collection-volumetry.js

diff --git a/print/templates/email/modified-collection-volumetry/assets/css/import.js b/print/templates/email/modified-collection-volumetry/assets/css/import.js
new file mode 100644
index 0000000000..fec23d870d
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/assets/css/import.js
@@ -0,0 +1,12 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+    `${vnPrintPath}/common/css/spacing.css`,
+    `${vnPrintPath}/common/css/misc.css`,
+    `${vnPrintPath}/common/css/layout.css`,
+    `${vnPrintPath}/common/css/email.css`,
+    `${__dirname}/style.css`])
+    .mergeStyles();
diff --git a/print/templates/email/modified-collection-volumetry/assets/css/style.css b/print/templates/email/modified-collection-volumetry/assets/css/style.css
new file mode 100644
index 0000000000..5e006baa2b
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/assets/css/style.css
@@ -0,0 +1,8 @@
+.jsonSection {
+    text-align: left;
+    background-color: #e4e4e4;
+    padding: 25px;
+    margin-left: 60px;
+    margin-right: 60px;
+    border-radius: 25px;
+}
\ No newline at end of file
diff --git a/print/templates/email/modified-collection-volumetry/locale/en.yml b/print/templates/email/modified-collection-volumetry/locale/en.yml
new file mode 100644
index 0000000000..d29b5b8de6
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/locale/en.yml
@@ -0,0 +1,3 @@
+subject: Modified collection volumetry
+title: Modified collection volumetry
+description: Action performed
\ No newline at end of file
diff --git a/print/templates/email/modified-collection-volumetry/locale/es.yml b/print/templates/email/modified-collection-volumetry/locale/es.yml
new file mode 100644
index 0000000000..c271183b5d
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/locale/es.yml
@@ -0,0 +1,3 @@
+subject: Volumetría de colección modificada
+title: Volumetría de colección modificada
+description: Acción realizada
\ No newline at end of file
diff --git a/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.html b/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.html
new file mode 100644
index 0000000000..32ad19fd45
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.html
@@ -0,0 +1,15 @@
+<email-body v-bind="$props">
+    <div class="grid-row">
+        <div class="grid-block vn-pa-ml">
+            <div class="centered">
+                <h1>{{ $t('title') }}</h1>
+                <h3>{{ $t('description') }}:  <u>{{ data.action }}</u> <i> {{ `(${this.username})` }} </i></h3>
+                <div class="jsonSection">
+                    <span v-for="(value, key) in data" v-if="key !== 'action' && key !== 'userFk'">
+                        <b> {{ `${key}:` }} </b> {{ value }} <br>
+                    </span>
+                </div>
+            </div>
+        </div>
+    </div>
+</email-body>
diff --git a/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.js b/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.js
new file mode 100755
index 0000000000..4345ead475
--- /dev/null
+++ b/print/templates/email/modified-collection-volumetry/modified-collection-volumetry.js
@@ -0,0 +1,25 @@
+const Component = require(`vn-print/core/component`);
+const emailBody = new Component('email-body');
+const models = require('vn-loopback/server/server').models;
+
+module.exports = {
+    name: 'modified-collection-volumetry',
+    components: {
+        'email-body': emailBody.build(),
+    },
+    async serverPrefetch() {
+        this.username = (this.data.userFk) ? await this.getUsername(this.data.userFk) : 'system';
+    },
+    methods: {
+        async getUsername(id) {
+            const account = await models.VnUser.findById(id);
+            return account.name;
+        }
+    },
+    props: {
+        data: {
+            type: Object,
+            required: true
+        }
+    }
+};