From 474e42c9bd7d984bd9f112f153152e58616b3d5c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 22 Nov 2019 16:01:11 +0100 Subject: [PATCH 1/5] =?UTF-8?q?#1772=20informe=20consumo=20campa=C3=B1a=20?= =?UTF-8?q?email=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campaign-metrics/assets/css/import.js | 8 ++++ .../email/campaign-metrics/attachments.json | 2 + .../campaign-metrics/campaign-metrics.html | 46 +++++++++++++++++++ .../campaign-metrics/campaign-metrics.js | 41 +++++++++++++++++ .../email/campaign-metrics/locale/es.yml | 7 +++ 5 files changed, 104 insertions(+) create mode 100644 print/templates/email/campaign-metrics/assets/css/import.js create mode 100644 print/templates/email/campaign-metrics/attachments.json create mode 100644 print/templates/email/campaign-metrics/campaign-metrics.html create mode 100755 print/templates/email/campaign-metrics/campaign-metrics.js create mode 100644 print/templates/email/campaign-metrics/locale/es.yml diff --git a/print/templates/email/campaign-metrics/assets/css/import.js b/print/templates/email/campaign-metrics/assets/css/import.js new file mode 100644 index 000000000..b44d6bd37 --- /dev/null +++ b/print/templates/email/campaign-metrics/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/campaign-metrics/attachments.json b/print/templates/email/campaign-metrics/attachments.json new file mode 100644 index 000000000..32960f8ce --- /dev/null +++ b/print/templates/email/campaign-metrics/attachments.json @@ -0,0 +1,2 @@ +[ +] \ No newline at end of file diff --git a/print/templates/email/campaign-metrics/campaign-metrics.html b/print/templates/email/campaign-metrics/campaign-metrics.html new file mode 100644 index 000000000..238d80d4a --- /dev/null +++ b/print/templates/email/campaign-metrics/campaign-metrics.html @@ -0,0 +1,46 @@ + + + + + + {{ $t('subject') }} + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

{{ $t('title') }}

+

{{$t('dear')}},

+

{{$t('description')}}

+
+
+ +
+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/email/campaign-metrics/campaign-metrics.js b/print/templates/email/campaign-metrics/campaign-metrics.js new file mode 100755 index 000000000..f2104d825 --- /dev/null +++ b/print/templates/email/campaign-metrics/campaign-metrics.js @@ -0,0 +1,41 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'campaign-metrics', + async serverPrefetch() { + this.client = await this.fetchClient(this.clientId); + }, + methods: { + // fetchClient(clientId) { + // return db.findOne(` + // SELECT + // c.id, + // u.name AS userName, + // CONCAT(w.lastName, ' ', w.firstName) salesPersonName, + // w.phone AS salesPersonPhone, + // CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail + // FROM client c + // JOIN account.user u ON u.id = c.id + // LEFT JOIN worker w ON w.id = c.salesPersonFk + // LEFT JOIN account.user wu ON wu.id = w.userFk + // WHERE c.id = ?`, [clientId]); + // }, + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: { + clientId: { + required: true + }, + from: { + required: true + }, + to: { + required: true + } + } +}; diff --git a/print/templates/email/campaign-metrics/locale/es.yml b/print/templates/email/campaign-metrics/locale/es.yml new file mode 100644 index 000000000..e662ca614 --- /dev/null +++ b/print/templates/email/campaign-metrics/locale/es.yml @@ -0,0 +1,7 @@ +subject: Informe consumo campaña +title: Informe consumo campaña +dear: Estimado cliente +description: Con motivo de esta próxima campaña, me complace + relacionarle a continuación el consumo que nos consta en su cuenta para las + mismas fechas del año pasado. Espero le sea de utilidad para preparar su pedido. + Al mismo tiempo aprovecho la ocasión para saludarle cordialmente. From 0c0ae1426393f47ae1e3e4d1eb0e6b8206debb48 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 27 Nov 2019 16:00:42 +0100 Subject: [PATCH 2/5] =?UTF-8?q?#1903=20informe=20consumo=20campa=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print/common/css/layout.css | 2 +- print/core/filters/date.js | 1 + print/core/filters/index.js | 1 + print/core/filters/uppercase.js | 5 + .../email/campaign-metrics/attachments.json | 4 + .../campaign-metrics/assets/css/import.js | 9 ++ .../campaign-metrics/assets/css/style.css | 11 ++ .../campaign-metrics/campaign-metrics.html | 100 ++++++++++++++++++ .../campaign-metrics/campaign-metrics.js | 85 +++++++++++++++ .../reports/campaign-metrics/locale/es.yml | 13 +++ 10 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 print/core/filters/uppercase.js create mode 100644 print/templates/reports/campaign-metrics/assets/css/import.js create mode 100644 print/templates/reports/campaign-metrics/assets/css/style.css create mode 100644 print/templates/reports/campaign-metrics/campaign-metrics.html create mode 100755 print/templates/reports/campaign-metrics/campaign-metrics.js create mode 100644 print/templates/reports/campaign-metrics/locale/es.yml diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 8a3e79219..6be065a14 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -4,7 +4,7 @@ */ .grid { - font-family: Helvetica, Arial, sans-serif; + font-family: Arial, sans-serif; font-size: 16px !important; width: 100% } diff --git a/print/core/filters/date.js b/print/core/filters/date.js index 37b9dd16f..5762905e2 100644 --- a/print/core/filters/date.js +++ b/print/core/filters/date.js @@ -2,5 +2,6 @@ const Vue = require('vue'); const strftime = require('strftime'); Vue.filter('date', function(value, specifiers) { + console.log(value); return strftime(specifiers, value); }); diff --git a/print/core/filters/index.js b/print/core/filters/index.js index 96bfde72b..1d2eb182c 100644 --- a/print/core/filters/index.js +++ b/print/core/filters/index.js @@ -1,4 +1,5 @@ // Import global filters require('./date'); +require('./uppercase'); require('./currency'); require('./percentage'); diff --git a/print/core/filters/uppercase.js b/print/core/filters/uppercase.js new file mode 100644 index 000000000..a4a826070 --- /dev/null +++ b/print/core/filters/uppercase.js @@ -0,0 +1,5 @@ +const Vue = require('vue'); + +Vue.filter('uppercase', function(value) { + return value.toUpperCase(); +}); diff --git a/print/templates/email/campaign-metrics/attachments.json b/print/templates/email/campaign-metrics/attachments.json index 32960f8ce..3f6a93bb5 100644 --- a/print/templates/email/campaign-metrics/attachments.json +++ b/print/templates/email/campaign-metrics/attachments.json @@ -1,2 +1,6 @@ [ + { + "filename": "campaing-metrics", + "component": "campaign-metrics" + } ] \ No newline at end of file diff --git a/print/templates/reports/campaign-metrics/assets/css/import.js b/print/templates/reports/campaign-metrics/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/campaign-metrics/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/campaign-metrics/assets/css/style.css b/print/templates/reports/campaign-metrics/assets/css/style.css new file mode 100644 index 000000000..6e730869e --- /dev/null +++ b/print/templates/reports/campaign-metrics/assets/css/style.css @@ -0,0 +1,11 @@ +.column-oriented { + margin-top: 50px !important; +} + +.bottom-line > tr { + border-bottom: 1px solid #ccc; +} + +.bottom-line tr:nth-last-child() { + border-bottom: none; +} diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html new file mode 100644 index 000000000..5ab7c894b --- /dev/null +++ b/print/templates/reports/campaign-metrics/campaign-metrics.html @@ -0,0 +1,100 @@ + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+
+
+
+

{{$t('title')}}

+ + + + + + + + + + + + + + + +
{{$t('Client')}}{{client.id}}
{{$t('From')}}{{from | date('%d-%m-%Y')}}
{{$t('To')}}{{to | date('%d-%m-%Y')}}
+
+
+
+
+
{{$t('clientData')}}
+
+

{{client.socialName}}

+
+ {{client.street}} +
+
+ {{client.postcode}}, {{client.city}} ({{client.province}}) +
+
+ {{client.country}} +
+
+
+
+
+ + + + + + + + + + + + + + + +
{{$t('Code')}}{{$t('Quantity')}}{{$t('Concept')}}
{{sale.itemFk}}{{Math.trunc(sale.subtotal)}} + {{sale.concept}} {{sale.subName | uppercase}} +
+ {{sale.tag5}} + {{sale.value5}} + {{sale.tag6}} + {{sale.value6}} + {{sale.tag7}} + {{sale.value7}} +
+
+
+
+ +
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js new file mode 100755 index 000000000..81eede809 --- /dev/null +++ b/print/templates/reports/campaign-metrics/campaign-metrics.js @@ -0,0 +1,85 @@ +const Component = require(`${appPath}/core/component`); +const db = require(`${appPath}/core/database`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'campaign-metrics', + async serverPrefetch() { + // // te delete once form inputs get date ranges + // this.from = new Date(); + // this.from.setMonth(0); + // this.from.setDate(1); + // this.to = new Date(); + // this.to.setMonth(11); + // this.to.setDate(31); + // this.clientId = 101; + // // end of delete + + + this.client = await this.fetchClient(this.clientId); + + console.log(this.from, this.to); + this.sales = await this.fetchSales(this.clientId, this.from, this.to); + + if (!this.client) + throw new Error('Something went wrong'); + }, + methods: { + fetchClient(clientId) { + return db.findOne( + `SELECT + c.street, + c.socialName, + c.city, + c.postcode, + c.id, + c.name AS clientName, + p.name AS province, + co.country + FROM client c + JOIN province p ON c.provinceFk = p.id + JOIN country co ON c.countryFk = co.id + WHERE + c.id = ?`, [clientId]); + }, + fetchSales(clientId, from, to) { + return db.rawSql( + `SELECT + SUM(s.quantity) AS subtotal, + s.itemFk, + s.concept, + i.subName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE + t.clientFk = ? AND it.isPackaging = FALSE + AND DATE(t.shipped) BETWEEN ? AND ? + GROUP BY s.itemFk + ORDER BY i.typeFk , i.name , i.size`, [clientId, from, to]); + }, + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + clientId: { + required: true + }, + from: { + required: true + }, + to: { + required: true + } + } +}; diff --git a/print/templates/reports/campaign-metrics/locale/es.yml b/print/templates/reports/campaign-metrics/locale/es.yml new file mode 100644 index 000000000..67f65a652 --- /dev/null +++ b/print/templates/reports/campaign-metrics/locale/es.yml @@ -0,0 +1,13 @@ +title: Consumo de campaña +Client: Cliente +clientData: Datos del cliente +dated: Fecha +From: Desde +To: Hasta +concept: Concepto +client: Cliente {0} +Code: Código +Quantity: Cantidad +Stems: Tallos +Concept: Concepto +Tags: Etiquetas \ No newline at end of file From 8624a3db6887ffa938f643c078c08ffc351be8cb Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 27 Nov 2019 16:02:07 +0100 Subject: [PATCH 3/5] =?UTF-8?q?#1903=20informe=20consumo=20campa=C3=B1a=20?= =?UTF-8?q?removed=20comented=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reports/campaign-metrics/campaign-metrics.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js index 81eede809..dc8822faa 100755 --- a/print/templates/reports/campaign-metrics/campaign-metrics.js +++ b/print/templates/reports/campaign-metrics/campaign-metrics.js @@ -6,17 +6,6 @@ const reportFooter = new Component('report-footer'); module.exports = { name: 'campaign-metrics', async serverPrefetch() { - // // te delete once form inputs get date ranges - // this.from = new Date(); - // this.from.setMonth(0); - // this.from.setDate(1); - // this.to = new Date(); - // this.to.setMonth(11); - // this.to.setDate(31); - // this.clientId = 101; - // // end of delete - - this.client = await this.fetchClient(this.clientId); console.log(this.from, this.to); From f4e0d04b6425d6f90c03464dba8a038903665bae Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 27 Nov 2019 16:16:22 +0100 Subject: [PATCH 4/5] =?UTF-8?q?#1903=20informe=20consumo=20campa=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print/core/filters/date.js | 1 - .../reports/campaign-metrics/campaign-metrics.js | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/print/core/filters/date.js b/print/core/filters/date.js index 5762905e2..37b9dd16f 100644 --- a/print/core/filters/date.js +++ b/print/core/filters/date.js @@ -2,6 +2,5 @@ const Vue = require('vue'); const strftime = require('strftime'); Vue.filter('date', function(value, specifiers) { - console.log(value); return strftime(specifiers, value); }); diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js index dc8822faa..d4d613a61 100755 --- a/print/templates/reports/campaign-metrics/campaign-metrics.js +++ b/print/templates/reports/campaign-metrics/campaign-metrics.js @@ -6,9 +6,18 @@ const reportFooter = new Component('report-footer'); module.exports = { name: 'campaign-metrics', async serverPrefetch() { + // // te delete once form inputs get date ranges + this.from = new Date(); + this.from.setMonth(0); + this.from.setDate(1); + this.to = new Date(); + this.to.setMonth(11); + this.to.setDate(31); + // this.clientId = 101; + // // end of delete + this.client = await this.fetchClient(this.clientId); - console.log(this.from, this.to); this.sales = await this.fetchSales(this.clientId, this.from, this.to); if (!this.client) From 909fef5e86c4373aa80d338c8647f5bebbb9c4e1 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 28 Nov 2019 08:30:36 +0100 Subject: [PATCH 5/5] =?UTF-8?q?#1903=20informe=20consumo=20campa=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campaign-metrics/campaign-metrics.js | 20 +------------------ .../campaign-metrics/campaign-metrics.html | 10 +++++----- .../campaign-metrics/campaign-metrics.js | 17 ++++++---------- .../reports/campaign-metrics/locale/es.yml | 4 +--- 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/print/templates/email/campaign-metrics/campaign-metrics.js b/print/templates/email/campaign-metrics/campaign-metrics.js index f2104d825..cb01ca09e 100755 --- a/print/templates/email/campaign-metrics/campaign-metrics.js +++ b/print/templates/email/campaign-metrics/campaign-metrics.js @@ -4,25 +4,7 @@ const emailFooter = new Component('email-footer'); module.exports = { name: 'campaign-metrics', - async serverPrefetch() { - this.client = await this.fetchClient(this.clientId); - }, - methods: { - // fetchClient(clientId) { - // return db.findOne(` - // SELECT - // c.id, - // u.name AS userName, - // CONCAT(w.lastName, ' ', w.firstName) salesPersonName, - // w.phone AS salesPersonPhone, - // CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail - // FROM client c - // JOIN account.user u ON u.id = c.id - // LEFT JOIN worker w ON w.id = c.salesPersonFk - // LEFT JOIN account.user wu ON wu.id = w.userFk - // WHERE c.id = ?`, [clientId]); - // }, - }, + components: { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html index 5ab7c894b..5e4bc7d08 100644 --- a/print/templates/reports/campaign-metrics/campaign-metrics.html +++ b/print/templates/reports/campaign-metrics/campaign-metrics.html @@ -16,20 +16,20 @@
-
-

{{$t('title')}}

+

{{$t('title')}}

+
- + - + - + diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js index d4d613a61..f72069260 100755 --- a/print/templates/reports/campaign-metrics/campaign-metrics.js +++ b/print/templates/reports/campaign-metrics/campaign-metrics.js @@ -6,15 +6,8 @@ const reportFooter = new Component('report-footer'); module.exports = { name: 'campaign-metrics', async serverPrefetch() { - // // te delete once form inputs get date ranges - this.from = new Date(); - this.from.setMonth(0); - this.from.setDate(1); - this.to = new Date(); - this.to.setMonth(11); - this.to.setDate(31); - // this.clientId = 101; - // // end of delete + this.to = new Date(this.to); + this.from = new Date(this.from); this.client = await this.fetchClient(this.clientId); @@ -74,10 +67,12 @@ module.exports = { required: true }, from: { - required: true + required: true, + type: Date }, to: { - required: true + required: true, + type: Date } } }; diff --git a/print/templates/reports/campaign-metrics/locale/es.yml b/print/templates/reports/campaign-metrics/locale/es.yml index 67f65a652..df0c91971 100644 --- a/print/templates/reports/campaign-metrics/locale/es.yml +++ b/print/templates/reports/campaign-metrics/locale/es.yml @@ -4,10 +4,8 @@ clientData: Datos del cliente dated: Fecha From: Desde To: Hasta -concept: Concepto client: Cliente {0} Code: Código Quantity: Cantidad Stems: Tallos -Concept: Concepto -Tags: Etiquetas \ No newline at end of file +Concept: Concepto \ No newline at end of file
{{$t('Client')}}{{$t('Client')}} {{client.id}}
{{$t('From')}}{{$t('From')}} {{from | date('%d-%m-%Y')}}
{{$t('To')}}{{$t('To')}} {{to | date('%d-%m-%Y')}}