From 9e0ab17d472935629d11689891e5cfe564bdd774 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 16 Oct 2019 08:39:45 +0200 Subject: [PATCH 01/18] removed prefetch --- print/lib/reportEngine.js | 21 ++++++++------------- print/report/rpt-receipt/index.js | 17 +++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/print/lib/reportEngine.js b/print/lib/reportEngine.js index 8c771c449..c95779592 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/reportEngine.js @@ -2,7 +2,6 @@ const Vue = require('vue'); const VueI18n = require('vue-i18n'); const renderer = require('vue-server-renderer').createRenderer(); const fs = require('fs-extra'); -// const pdf = require('phantom-html2pdf'); const pdf = require('html-pdf'); const juice = require('juice'); @@ -23,25 +22,21 @@ module.exports = { */ async render(name, ctx) { const component = require(`${this.path}/${name}`); - const result = await this.preFetch(component, ctx); + const i18n = new VueI18n({ locale: 'es', fallbackLocale: 'es', silentTranslationWarn: true }); const app = new Vue({i18n, - render: h => h(result.component)}); + render: h => h(component)}); + + Vue.set(component, 'test', 'asd1'); return renderer.renderToString(app); }, - /** - * Prefetch all component data from asyncData method - * - * @param {Object} orgComponent - Component object - * @param {Object} ctx - Request context - */ - async preFetch(orgComponent, ctx) { + /* async preFetch(orgComponent, ctx) { let component = Object.create(orgComponent); let mergedData = {}; let asyncData = {}; @@ -87,9 +82,9 @@ module.exports = { } return {component}; - }, + }, */ - async attachAssets(component) { + /* async attachAssets(component) { const localePath = `${this.path}/${component.name}/locale`; const templatePath = `${this.path}/${component.name}/index.html`; const stylePath = `${this.path}/${component.name}/assets/css/index`; @@ -100,7 +95,7 @@ module.exports = { component.i18n = require(localePath); component.template = juice.inlineContent(template, css, cssOptions); - }, + }, */ async toPdf(name, ctx) { const html = await this.render(name, ctx); diff --git a/print/report/rpt-receipt/index.js b/print/report/rpt-receipt/index.js index 7a173e6ee..a4f04ad34 100755 --- a/print/report/rpt-receipt/index.js +++ b/print/report/rpt-receipt/index.js @@ -4,12 +4,12 @@ const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { name: 'rpt-receipt', - /* serverPrefetch() { - console.log(arguments); - return new Promise(accept => { - this.client = this.getReceipt(); - }); - }, */ + serverPrefetch() { + console.log(this.test); + /* return new Promise(accept => { + this.client = this.fetchClient(); + }); */ + }, async asyncData(ctx, params) { Object.assign(this, this.methods); @@ -22,8 +22,8 @@ module.exports = { return {client, receipt}; }, created() { - if (this.client.locale) - this.$i18n.locale = this.client.locale; + /* if (this.client.locale) + this.$i18n.locale = this.client.locale; */ const embeded = []; this.files.map(file => { @@ -68,4 +68,5 @@ module.exports = { 'report-header': require('../report-header'), 'report-footer': require('../report-footer'), }, + template: '
asd
' }; From 0eaba04e528ee019984070290cac5a618138a1e4 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 24 Oct 2019 07:41:54 +0200 Subject: [PATCH 02/18] refactor --- print/config/print.json | 6 +- print/lib/config.js | 13 --- print/lib/database.js | 8 ++ print/lib/{reportEngine.js => report.js} | 109 ++++++++++++++---- print/lib/router.js | 88 ++++++++++---- .../claim-pickup-order/assets/css/index.js | 0 .../email}/claim-pickup-order/index.html | 0 .../email}/claim-pickup-order/index.js | 0 .../email}/claim-pickup-order/locale.js | 0 .../email}/client-lcr/assets/css/index.js | 0 .../email}/client-lcr/index.html | 0 .../email}/client-lcr/index.js | 0 .../email}/client-lcr/locale.js | 0 .../email}/client-welcome/assets/css/index.js | 0 .../email}/client-welcome/index.html | 0 .../email}/client-welcome/index.js | 0 .../email}/client-welcome/locale.js | 0 .../email}/delivery-note/assets/css/index.js | 0 .../email}/delivery-note/index.html | 0 .../email}/delivery-note/index.js | 0 .../email}/delivery-note/locale.js | 0 .../email}/driver-route/assets/css/index.js | 0 .../email}/driver-route/index.html | 0 .../email}/driver-route/index.js | 0 .../email}/driver-route/locale.js | 0 .../email}/email-footer/assets/css/index.js | 0 .../email}/email-footer/assets/css/style.css | 0 .../email-footer/assets/images/action.png | Bin .../email-footer/assets/images/facebook.png | Bin .../email-footer/assets/images/info.png | Bin .../email-footer/assets/images/instagram.png | Bin .../email-footer/assets/images/linkedin.png | Bin .../email-footer/assets/images/pinterest.png | Bin .../email-footer/assets/images/twitter.png | Bin .../email-footer/assets/images/youtube.png | Bin .../email}/email-footer/index.html | 0 .../email}/email-footer/index.js | 0 .../email}/email-footer/locale.js | 0 .../email}/email-header/assets/css/index.js | 0 .../email}/email-header/assets/css/style.css | 0 .../email-header/assets/images/email-logo.png | Bin .../email}/email-header/index.html | 0 .../email}/email-header/index.js | 0 .../email}/email-header/locale.js | 0 .../letter-debtor-nd/assets/css/index.js | 0 .../email}/letter-debtor-nd/index.html | 0 .../email}/letter-debtor-nd/index.js | 0 .../email}/letter-debtor-nd/locale.js | 0 .../letter-debtor-st/assets/css/index.js | 0 .../email}/letter-debtor-st/index.html | 0 .../email}/letter-debtor-st/index.js | 0 .../email}/letter-debtor-st/locale.js | 0 .../email}/payment-update/assets/css/index.js | 0 .../email}/payment-update/index.html | 0 .../email}/payment-update/index.js | 0 .../email}/payment-update/locale.js | 0 .../email}/printer-setup/assets/css/index.js | 0 .../printer-setup/assets/files/model.ezp | Bin .../printer-setup/assets/files/port.png | Bin .../email}/printer-setup/index.html | 0 .../email}/printer-setup/index.js | 0 .../email}/printer-setup/locale.js | 0 .../email}/sepa-core/assets/css/index.js | 0 .../email}/sepa-core/index.html | 0 .../email}/sepa-core/index.js | 0 .../email}/sepa-core/locale.js | 0 .../reports/receipt}/assets/css/index.js | 0 .../reports/receipt}/assets/css/style.css | 0 .../receipt}/assets/images/signature.png | Bin .../reports/receipt}/index.js | 42 +++---- .../reports/receipt}/locale.js | 0 .../reports/receipt/receipt.html} | 7 +- .../report-footer/assets/css/index.js | 0 .../report-footer/assets/css/style.css | 0 .../reports}/report-footer/index.html | 0 .../reports}/report-footer/index.js | 0 .../reports}/report-footer/locale.js | 0 .../report-header/assets/css/index.js | 0 .../report-header/assets/css/style.css | 0 .../assets/images/report-logo.png | Bin .../assets/images/report-logo.svg | 0 .../reports}/report-header/index.html | 0 .../reports}/report-header/index.js | 0 .../reports}/report-header/locale.js | 0 .../assets/css/index.js | 0 .../assets/css/style.css | 0 .../rpt-claim-pickup-order/index.html | 0 .../reports}/rpt-claim-pickup-order/index.js | 0 .../reports}/rpt-claim-pickup-order/locale.js | 0 .../rpt-delivery-note}/assets/css/index.js | 0 .../rpt-delivery-note/assets/css/style.css | 0 .../reports}/rpt-delivery-note/index.html | 0 .../reports}/rpt-delivery-note/index.js | 0 .../reports}/rpt-delivery-note/locale.js | 0 .../rpt-item-label}/assets/css/index.js | 0 .../rpt-item-label/assets/css/style.css | 0 .../reports}/rpt-item-label/index.html | 0 .../reports}/rpt-item-label/index.js | 0 .../reports/rpt-item-label}/locale.js | 0 .../reports}/rpt-item-label/options.json | 0 .../reports/rpt-lcr}/assets/css/index.js | 0 .../reports}/rpt-lcr/assets/css/style.css | 0 .../rpt-lcr}/assets/images/signature.png | Bin .../reports}/rpt-lcr/index.html | 0 .../reports}/rpt-lcr/index.js | 0 .../reports}/rpt-lcr/locale.js | 0 .../rpt-letter-debtor}/assets/css/index.js | 0 .../rpt-letter-debtor/assets/css/style.css | 0 .../reports}/rpt-letter-debtor/index.html | 0 .../reports}/rpt-letter-debtor/index.js | 0 .../reports}/rpt-letter-debtor/locale.js | 0 .../reports}/rpt-route/assets/css/index.js | 0 .../reports}/rpt-route/assets/css/style.css | 0 .../reports}/rpt-route/index.html | 0 .../reports}/rpt-route/index.js | 0 .../reports}/rpt-route/locale.js | 0 .../rpt-sepa-core/assets/css/index.js | 0 .../rpt-sepa-core/assets/css/style.css | 0 .../reports}/rpt-sepa-core/index.html | 0 .../reports}/rpt-sepa-core/index.js | 0 .../reports}/rpt-sepa-core/locale.js | 0 .../reports}/rpt-zone/assets/css/index.js | 0 .../reports}/rpt-zone/assets/css/style.css | 0 .../reports}/rpt-zone/index.html | 0 .../reports}/rpt-zone/index.js | 0 .../reports}/rpt-zone/locale.js | 0 .../sample-report/assets/css/index.js | 0 .../sample-report/assets/css/style.css | 0 .../reports}/sample-report/index.html | 0 .../reports}/sample-report/index.js | 0 .../reports}/sample-report/locale.js | 0 131 files changed, 179 insertions(+), 94 deletions(-) rename print/lib/{reportEngine.js => report.js} (58%) rename print/{report => templates/email}/claim-pickup-order/assets/css/index.js (100%) rename print/{report => templates/email}/claim-pickup-order/index.html (100%) rename print/{report => templates/email}/claim-pickup-order/index.js (100%) rename print/{report => templates/email}/claim-pickup-order/locale.js (100%) rename print/{report => templates/email}/client-lcr/assets/css/index.js (100%) rename print/{report => templates/email}/client-lcr/index.html (100%) rename print/{report => templates/email}/client-lcr/index.js (100%) rename print/{report => templates/email}/client-lcr/locale.js (100%) rename print/{report => templates/email}/client-welcome/assets/css/index.js (100%) rename print/{report => templates/email}/client-welcome/index.html (100%) rename print/{report => templates/email}/client-welcome/index.js (100%) rename print/{report => templates/email}/client-welcome/locale.js (100%) rename print/{report => templates/email}/delivery-note/assets/css/index.js (100%) rename print/{report => templates/email}/delivery-note/index.html (100%) rename print/{report => templates/email}/delivery-note/index.js (100%) rename print/{report => templates/email}/delivery-note/locale.js (100%) rename print/{report => templates/email}/driver-route/assets/css/index.js (100%) rename print/{report => templates/email}/driver-route/index.html (100%) rename print/{report => templates/email}/driver-route/index.js (100%) rename print/{report => templates/email}/driver-route/locale.js (100%) rename print/{report => templates/email}/email-footer/assets/css/index.js (100%) rename print/{report => templates/email}/email-footer/assets/css/style.css (100%) rename print/{report => templates/email}/email-footer/assets/images/action.png (100%) rename print/{report => templates/email}/email-footer/assets/images/facebook.png (100%) rename print/{report => templates/email}/email-footer/assets/images/info.png (100%) rename print/{report => templates/email}/email-footer/assets/images/instagram.png (100%) rename print/{report => templates/email}/email-footer/assets/images/linkedin.png (100%) rename print/{report => templates/email}/email-footer/assets/images/pinterest.png (100%) rename print/{report => templates/email}/email-footer/assets/images/twitter.png (100%) rename print/{report => templates/email}/email-footer/assets/images/youtube.png (100%) rename print/{report => templates/email}/email-footer/index.html (100%) rename print/{report => templates/email}/email-footer/index.js (100%) rename print/{report => templates/email}/email-footer/locale.js (100%) rename print/{report => templates/email}/email-header/assets/css/index.js (100%) rename print/{report => templates/email}/email-header/assets/css/style.css (100%) rename print/{report => templates/email}/email-header/assets/images/email-logo.png (100%) rename print/{report => templates/email}/email-header/index.html (100%) rename print/{report => templates/email}/email-header/index.js (100%) rename print/{report => templates/email}/email-header/locale.js (100%) rename print/{report => templates/email}/letter-debtor-nd/assets/css/index.js (100%) rename print/{report => templates/email}/letter-debtor-nd/index.html (100%) rename print/{report => templates/email}/letter-debtor-nd/index.js (100%) rename print/{report => templates/email}/letter-debtor-nd/locale.js (100%) rename print/{report => templates/email}/letter-debtor-st/assets/css/index.js (100%) rename print/{report => templates/email}/letter-debtor-st/index.html (100%) rename print/{report => templates/email}/letter-debtor-st/index.js (100%) rename print/{report => templates/email}/letter-debtor-st/locale.js (100%) rename print/{report => templates/email}/payment-update/assets/css/index.js (100%) rename print/{report => templates/email}/payment-update/index.html (100%) rename print/{report => templates/email}/payment-update/index.js (100%) rename print/{report => templates/email}/payment-update/locale.js (100%) rename print/{report => templates/email}/printer-setup/assets/css/index.js (100%) rename print/{report => templates/email}/printer-setup/assets/files/model.ezp (100%) rename print/{report => templates/email}/printer-setup/assets/files/port.png (100%) rename print/{report => templates/email}/printer-setup/index.html (100%) rename print/{report => templates/email}/printer-setup/index.js (100%) rename print/{report => templates/email}/printer-setup/locale.js (100%) rename print/{report => templates/email}/sepa-core/assets/css/index.js (100%) rename print/{report => templates/email}/sepa-core/index.html (100%) rename print/{report => templates/email}/sepa-core/index.js (100%) rename print/{report => templates/email}/sepa-core/locale.js (100%) rename print/{report/rpt-claim-pickup-order => templates/reports/receipt}/assets/css/index.js (100%) rename print/{report/rpt-receipt => templates/reports/receipt}/assets/css/style.css (100%) rename print/{report/rpt-lcr => templates/reports/receipt}/assets/images/signature.png (100%) rename print/{report/rpt-receipt => templates/reports/receipt}/index.js (54%) rename print/{report/rpt-item-label => templates/reports/receipt}/locale.js (100%) rename print/{report/rpt-receipt/index.html => templates/reports/receipt/receipt.html} (81%) rename print/{report => templates/reports}/report-footer/assets/css/index.js (100%) rename print/{report => templates/reports}/report-footer/assets/css/style.css (100%) rename print/{report => templates/reports}/report-footer/index.html (100%) rename print/{report => templates/reports}/report-footer/index.js (100%) rename print/{report => templates/reports}/report-footer/locale.js (100%) rename print/{report => templates/reports}/report-header/assets/css/index.js (100%) rename print/{report => templates/reports}/report-header/assets/css/style.css (100%) rename print/{report => templates/reports}/report-header/assets/images/report-logo.png (100%) rename print/{report => templates/reports}/report-header/assets/images/report-logo.svg (100%) rename print/{report => templates/reports}/report-header/index.html (100%) rename print/{report => templates/reports}/report-header/index.js (100%) rename print/{report => templates/reports}/report-header/locale.js (100%) rename print/{report/rpt-delivery-note => templates/reports/rpt-claim-pickup-order}/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-claim-pickup-order/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-claim-pickup-order/index.html (100%) rename print/{report => templates/reports}/rpt-claim-pickup-order/index.js (100%) rename print/{report => templates/reports}/rpt-claim-pickup-order/locale.js (100%) rename print/{report/rpt-item-label => templates/reports/rpt-delivery-note}/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-delivery-note/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-delivery-note/index.html (100%) rename print/{report => templates/reports}/rpt-delivery-note/index.js (100%) rename print/{report => templates/reports}/rpt-delivery-note/locale.js (100%) rename print/{report/rpt-lcr => templates/reports/rpt-item-label}/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-item-label/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-item-label/index.html (100%) rename print/{report => templates/reports}/rpt-item-label/index.js (100%) rename print/{report/rpt-receipt => templates/reports/rpt-item-label}/locale.js (100%) rename print/{report => templates/reports}/rpt-item-label/options.json (100%) rename print/{report/rpt-letter-debtor => templates/reports/rpt-lcr}/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-lcr/assets/css/style.css (100%) rename print/{report/rpt-receipt => templates/reports/rpt-lcr}/assets/images/signature.png (100%) rename print/{report => templates/reports}/rpt-lcr/index.html (100%) rename print/{report => templates/reports}/rpt-lcr/index.js (100%) rename print/{report => templates/reports}/rpt-lcr/locale.js (100%) rename print/{report/rpt-receipt => templates/reports/rpt-letter-debtor}/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-letter-debtor/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-letter-debtor/index.html (100%) rename print/{report => templates/reports}/rpt-letter-debtor/index.js (100%) rename print/{report => templates/reports}/rpt-letter-debtor/locale.js (100%) rename print/{report => templates/reports}/rpt-route/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-route/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-route/index.html (100%) rename print/{report => templates/reports}/rpt-route/index.js (100%) rename print/{report => templates/reports}/rpt-route/locale.js (100%) rename print/{report => templates/reports}/rpt-sepa-core/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-sepa-core/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-sepa-core/index.html (100%) rename print/{report => templates/reports}/rpt-sepa-core/index.js (100%) rename print/{report => templates/reports}/rpt-sepa-core/locale.js (100%) rename print/{report => templates/reports}/rpt-zone/assets/css/index.js (100%) rename print/{report => templates/reports}/rpt-zone/assets/css/style.css (100%) rename print/{report => templates/reports}/rpt-zone/index.html (100%) rename print/{report => templates/reports}/rpt-zone/index.js (100%) rename print/{report => templates/reports}/rpt-zone/locale.js (100%) rename print/{report => templates/reports}/sample-report/assets/css/index.js (100%) rename print/{report => templates/reports}/sample-report/assets/css/style.css (100%) rename print/{report => templates/reports}/sample-report/index.html (100%) rename print/{report => templates/reports}/sample-report/index.js (100%) rename print/{report => templates/reports}/sample-report/locale.js (100%) diff --git a/print/config/print.json b/print/config/print.json index 7ad2e1316..6a8d8b112 100755 --- a/print/config/print.json +++ b/print/config/print.json @@ -1,10 +1,14 @@ { "app": { "port": 3000, - "defaultLanguage": "es", "senderMail": "nocontestar@verdnatura.es", "senderName": "Verdnatura" }, + "i18n": { + "locale": "es", + "fallbackLocale": "es", + "silentTranslationWarn": true + }, "pdf": { "format": "A4", "border": "1.5cm", diff --git a/print/lib/config.js b/print/lib/config.js index 47e58ec77..d07d4f3fc 100644 --- a/print/lib/config.js +++ b/print/lib/config.js @@ -14,19 +14,6 @@ for (let configFile of configFiles) { Object.assign(config, require(configFile)); } -/* let proxyConf = {}; -let proxyFiles = [ - '../../nginx/config.yml', - `${configPath}/config.yml`, - `${configPath}/config.${env}.yml` -]; - -for (let proxyFile of proxyFiles) { - if (fs.existsSync(proxyFile)) - Object.assign(proxyConf, require(proxyFile)); -} */ - -// config.proxy = proxyConf; config.env = env; module.exports = config; diff --git a/print/lib/database.js b/print/lib/database.js index bd0e18c54..22d2f8c84 100644 --- a/print/lib/database.js +++ b/print/lib/database.js @@ -6,4 +6,12 @@ module.exports = { if (!this.pool) this.pool = mysql.createPool(config.mysql); }, + findOne(query, params) { + return this.pool.query(query, params).then(([rows]) => { + return rows[0]; + }); + }, + findFromDef() { + + } }; diff --git a/print/lib/reportEngine.js b/print/lib/report.js similarity index 58% rename from print/lib/reportEngine.js rename to print/lib/report.js index 3e634ae54..6cfaee4b4 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/report.js @@ -1,43 +1,107 @@ const Vue = require('vue'); const VueI18n = require('vue-i18n'); const renderer = require('vue-server-renderer').createRenderer(); -const fs = require('fs-extra'); + +const fs = require('fs'); const pdf = require('html-pdf'); const juice = require('juice'); -const config = require('./config'); +const path = require('path'); -Vue.use(VueI18n); +const config = require('./config'); +const reportsPath = '../templates/reports'; if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; -module.exports = { +Vue.use(VueI18n); + +class Report { + constructor(name, args) { + this.name = name; + this.args = args; + } + + get path() { + return `${reportsPath}/${this.name}`; + } + + get template() { + const templatePath = `${this.path}/${this.name}.html`; + const fullPath = path.resolve(__dirname, templatePath); + + return fs.readFileSync(fullPath, 'utf8'); + } + + get locale() { + + } + + get style() { + + } + + async render() { + const localePath = `${this.path}/locale`; + const stylePath = `${this.path}/assets/css/index`; + + const stylesheet = require(stylePath); + const component = require(this.path); + + component.i18n = require(localePath); + component.template = juice.inlineContent(this.template, stylesheet, { + inlinePseudoElements: true + }); + + const i18n = new VueI18n(config.i18n); + const app = new Vue({ + i18n: i18n, + render: h => h(component, { + props: this.args + }) + }); + + return renderer.renderToString(app); + } + + async toPdfStream() { + const template = await this.render(); + let options = config.pdf; + + const optionsPath = `${this.path}/options.json`; + if (fs.existsSync(optionsPath)) + options = Object.assign(options, require(optionsPath)); + + return new Promise(resolve => { + pdf.create(template, options).toStream((err, stream) => { + resolve(stream); + }); + }); + } +} + +module.exports = Report; + +/* module.exports = { path: `${appPath}/report`, - /** - * Renders a report component - * - * @param {String} name - Report name - * @param {Object} ctx - Request context - */ async render(name, ctx) { const component = require(`${this.path}/${name}`); - - const i18n = new VueI18n({ - locale: 'es', - fallbackLocale: 'es', - silentTranslationWarn: true + const i18n = new VueI18n(config.i18n); + const app = new Vue({ + i18n: i18n, + render: h => h(component, { + props: { + myProp: 'asd1' + } + }) }); - const app = new Vue({i18n, - render: h => h(component)}); - Vue.set(component, 'test', 'asd1'); return renderer.renderToString(app); }, - /* async preFetch(orgComponent, ctx) { + async preFetch(orgComponent, ctx) { let component = Object.create(orgComponent); let mergedData = {}; let asyncData = {}; @@ -83,9 +147,9 @@ module.exports = { } return {component}; - }, */ + }, - /* async attachAssets(component) { + async attachAssets(component) { const localePath = `${this.path}/${component.name}/locale`; const templatePath = `${this.path}/${component.name}/index.html`; const stylePath = `${this.path}/${component.name}/assets/css/index`; @@ -96,7 +160,7 @@ module.exports = { component.i18n = require(localePath); component.template = juice.inlineContent(template, css, cssOptions); - }, */ + }, async toPdf(name, ctx) { const html = await this.render(name, ctx); @@ -113,3 +177,4 @@ module.exports = { }); }, }; + */ diff --git a/print/lib/router.js b/print/lib/router.js index 59e8a5b74..eff4b5c9e 100644 --- a/print/lib/router.js +++ b/print/lib/router.js @@ -1,10 +1,65 @@ -const reportEngine = require('./reportEngine.js'); +const Report = require('./report'); const emailEngine = require('./emailEngine'); const express = require('express'); -const routes = require(`../config/routes.json`); +const path = require('path'); +const vue = require('vue'); + +const fs = require('fs'); +const templatesPath = path.resolve(__dirname, '../templates'); module.exports = app => { - this.path = `${appPath}/report`; + /** + * Serve static files + */ + const templatesDir = fs.readdirSync(templatesPath); + templatesDir.forEach(directory => { + const templateTypeDir = path.join(templatesPath, '/', directory); + const templates = fs.readdirSync(templateTypeDir); + + templates.forEach(templateName => { + const templateDir = path.join(templatesPath, '/', directory, '/', templateName); + const assetsDir = `${templateDir}/assets`; + + app.use(`/api/assets`, express.static(assetsDir)); + }); + }); + + app.get(`/api/report/:name`, async(req, res) => { + const args = Object.assign({}, req.body, req.query); + const report = new Report(req.params.name, args); + const stream = await report.toPdfStream(); + + res.setHeader('Content-type', 'application/pdf'); + stream.pipe(res); + }); + + /* app.get(`/api/email/${name}`, (request, response) => { + emailEngine.render(name, request).then(rendered => { + response.send(rendered.html); + }).catch(e => { + next(e); + }); + }); + + app.post(`/api/email/${name}`, (request, response, next) => { + emailEngine.toEmail(name, request).then(() => { + response.status(200).json({status: 200}); + }).catch(e => { + next(e); + }); + }); */ + + + /* routes.forEach(route => { + if (route.type === 'email') + registerEmail(route.name); + else if (route.type === 'report') + registerReport(route.name); + + const staticPath = this.path + `/${route.name}/assets`; + + }); */ + /** * Enables a report @@ -14,13 +69,13 @@ module.exports = app => { function registerReport(name) { if (!name) throw new Error('Report name required'); - app.get(`/api/report/${name}`, (request, response, next) => { - reportEngine.toPdf(name, request).then(stream => { - response.setHeader('Content-type', 'application/pdf'); - stream.pipe(response); - }).catch(e => { - next(e); - }); + app.get(`/api/report/${name}`, async(request, response) => { + const args = Object.assign({}, request.body, request.query); + const report = new Report(name, args); + const stream = await report.toPdf(); + + response.setHeader('Content-type', 'application/pdf'); + stream.pipe(response); }); } @@ -48,17 +103,4 @@ module.exports = app => { }); }); } - - /** - * Register routes - */ - routes.forEach(route => { - if (route.type === 'email') - registerEmail(route.name); - else if (route.type === 'report') - registerReport(route.name); - - const staticPath = this.path + `/${route.name}/assets`; - app.use(`/api/assets`, express.static(staticPath)); - }); }; diff --git a/print/report/claim-pickup-order/assets/css/index.js b/print/templates/email/claim-pickup-order/assets/css/index.js similarity index 100% rename from print/report/claim-pickup-order/assets/css/index.js rename to print/templates/email/claim-pickup-order/assets/css/index.js diff --git a/print/report/claim-pickup-order/index.html b/print/templates/email/claim-pickup-order/index.html similarity index 100% rename from print/report/claim-pickup-order/index.html rename to print/templates/email/claim-pickup-order/index.html diff --git a/print/report/claim-pickup-order/index.js b/print/templates/email/claim-pickup-order/index.js similarity index 100% rename from print/report/claim-pickup-order/index.js rename to print/templates/email/claim-pickup-order/index.js diff --git a/print/report/claim-pickup-order/locale.js b/print/templates/email/claim-pickup-order/locale.js similarity index 100% rename from print/report/claim-pickup-order/locale.js rename to print/templates/email/claim-pickup-order/locale.js diff --git a/print/report/client-lcr/assets/css/index.js b/print/templates/email/client-lcr/assets/css/index.js similarity index 100% rename from print/report/client-lcr/assets/css/index.js rename to print/templates/email/client-lcr/assets/css/index.js diff --git a/print/report/client-lcr/index.html b/print/templates/email/client-lcr/index.html similarity index 100% rename from print/report/client-lcr/index.html rename to print/templates/email/client-lcr/index.html diff --git a/print/report/client-lcr/index.js b/print/templates/email/client-lcr/index.js similarity index 100% rename from print/report/client-lcr/index.js rename to print/templates/email/client-lcr/index.js diff --git a/print/report/client-lcr/locale.js b/print/templates/email/client-lcr/locale.js similarity index 100% rename from print/report/client-lcr/locale.js rename to print/templates/email/client-lcr/locale.js diff --git a/print/report/client-welcome/assets/css/index.js b/print/templates/email/client-welcome/assets/css/index.js similarity index 100% rename from print/report/client-welcome/assets/css/index.js rename to print/templates/email/client-welcome/assets/css/index.js diff --git a/print/report/client-welcome/index.html b/print/templates/email/client-welcome/index.html similarity index 100% rename from print/report/client-welcome/index.html rename to print/templates/email/client-welcome/index.html diff --git a/print/report/client-welcome/index.js b/print/templates/email/client-welcome/index.js similarity index 100% rename from print/report/client-welcome/index.js rename to print/templates/email/client-welcome/index.js diff --git a/print/report/client-welcome/locale.js b/print/templates/email/client-welcome/locale.js similarity index 100% rename from print/report/client-welcome/locale.js rename to print/templates/email/client-welcome/locale.js diff --git a/print/report/delivery-note/assets/css/index.js b/print/templates/email/delivery-note/assets/css/index.js similarity index 100% rename from print/report/delivery-note/assets/css/index.js rename to print/templates/email/delivery-note/assets/css/index.js diff --git a/print/report/delivery-note/index.html b/print/templates/email/delivery-note/index.html similarity index 100% rename from print/report/delivery-note/index.html rename to print/templates/email/delivery-note/index.html diff --git a/print/report/delivery-note/index.js b/print/templates/email/delivery-note/index.js similarity index 100% rename from print/report/delivery-note/index.js rename to print/templates/email/delivery-note/index.js diff --git a/print/report/delivery-note/locale.js b/print/templates/email/delivery-note/locale.js similarity index 100% rename from print/report/delivery-note/locale.js rename to print/templates/email/delivery-note/locale.js diff --git a/print/report/driver-route/assets/css/index.js b/print/templates/email/driver-route/assets/css/index.js similarity index 100% rename from print/report/driver-route/assets/css/index.js rename to print/templates/email/driver-route/assets/css/index.js diff --git a/print/report/driver-route/index.html b/print/templates/email/driver-route/index.html similarity index 100% rename from print/report/driver-route/index.html rename to print/templates/email/driver-route/index.html diff --git a/print/report/driver-route/index.js b/print/templates/email/driver-route/index.js similarity index 100% rename from print/report/driver-route/index.js rename to print/templates/email/driver-route/index.js diff --git a/print/report/driver-route/locale.js b/print/templates/email/driver-route/locale.js similarity index 100% rename from print/report/driver-route/locale.js rename to print/templates/email/driver-route/locale.js diff --git a/print/report/email-footer/assets/css/index.js b/print/templates/email/email-footer/assets/css/index.js similarity index 100% rename from print/report/email-footer/assets/css/index.js rename to print/templates/email/email-footer/assets/css/index.js diff --git a/print/report/email-footer/assets/css/style.css b/print/templates/email/email-footer/assets/css/style.css similarity index 100% rename from print/report/email-footer/assets/css/style.css rename to print/templates/email/email-footer/assets/css/style.css diff --git a/print/report/email-footer/assets/images/action.png b/print/templates/email/email-footer/assets/images/action.png similarity index 100% rename from print/report/email-footer/assets/images/action.png rename to print/templates/email/email-footer/assets/images/action.png diff --git a/print/report/email-footer/assets/images/facebook.png b/print/templates/email/email-footer/assets/images/facebook.png similarity index 100% rename from print/report/email-footer/assets/images/facebook.png rename to print/templates/email/email-footer/assets/images/facebook.png diff --git a/print/report/email-footer/assets/images/info.png b/print/templates/email/email-footer/assets/images/info.png similarity index 100% rename from print/report/email-footer/assets/images/info.png rename to print/templates/email/email-footer/assets/images/info.png diff --git a/print/report/email-footer/assets/images/instagram.png b/print/templates/email/email-footer/assets/images/instagram.png similarity index 100% rename from print/report/email-footer/assets/images/instagram.png rename to print/templates/email/email-footer/assets/images/instagram.png diff --git a/print/report/email-footer/assets/images/linkedin.png b/print/templates/email/email-footer/assets/images/linkedin.png similarity index 100% rename from print/report/email-footer/assets/images/linkedin.png rename to print/templates/email/email-footer/assets/images/linkedin.png diff --git a/print/report/email-footer/assets/images/pinterest.png b/print/templates/email/email-footer/assets/images/pinterest.png similarity index 100% rename from print/report/email-footer/assets/images/pinterest.png rename to print/templates/email/email-footer/assets/images/pinterest.png diff --git a/print/report/email-footer/assets/images/twitter.png b/print/templates/email/email-footer/assets/images/twitter.png similarity index 100% rename from print/report/email-footer/assets/images/twitter.png rename to print/templates/email/email-footer/assets/images/twitter.png diff --git a/print/report/email-footer/assets/images/youtube.png b/print/templates/email/email-footer/assets/images/youtube.png similarity index 100% rename from print/report/email-footer/assets/images/youtube.png rename to print/templates/email/email-footer/assets/images/youtube.png diff --git a/print/report/email-footer/index.html b/print/templates/email/email-footer/index.html similarity index 100% rename from print/report/email-footer/index.html rename to print/templates/email/email-footer/index.html diff --git a/print/report/email-footer/index.js b/print/templates/email/email-footer/index.js similarity index 100% rename from print/report/email-footer/index.js rename to print/templates/email/email-footer/index.js diff --git a/print/report/email-footer/locale.js b/print/templates/email/email-footer/locale.js similarity index 100% rename from print/report/email-footer/locale.js rename to print/templates/email/email-footer/locale.js diff --git a/print/report/email-header/assets/css/index.js b/print/templates/email/email-header/assets/css/index.js similarity index 100% rename from print/report/email-header/assets/css/index.js rename to print/templates/email/email-header/assets/css/index.js diff --git a/print/report/email-header/assets/css/style.css b/print/templates/email/email-header/assets/css/style.css similarity index 100% rename from print/report/email-header/assets/css/style.css rename to print/templates/email/email-header/assets/css/style.css diff --git a/print/report/email-header/assets/images/email-logo.png b/print/templates/email/email-header/assets/images/email-logo.png similarity index 100% rename from print/report/email-header/assets/images/email-logo.png rename to print/templates/email/email-header/assets/images/email-logo.png diff --git a/print/report/email-header/index.html b/print/templates/email/email-header/index.html similarity index 100% rename from print/report/email-header/index.html rename to print/templates/email/email-header/index.html diff --git a/print/report/email-header/index.js b/print/templates/email/email-header/index.js similarity index 100% rename from print/report/email-header/index.js rename to print/templates/email/email-header/index.js diff --git a/print/report/email-header/locale.js b/print/templates/email/email-header/locale.js similarity index 100% rename from print/report/email-header/locale.js rename to print/templates/email/email-header/locale.js diff --git a/print/report/letter-debtor-nd/assets/css/index.js b/print/templates/email/letter-debtor-nd/assets/css/index.js similarity index 100% rename from print/report/letter-debtor-nd/assets/css/index.js rename to print/templates/email/letter-debtor-nd/assets/css/index.js diff --git a/print/report/letter-debtor-nd/index.html b/print/templates/email/letter-debtor-nd/index.html similarity index 100% rename from print/report/letter-debtor-nd/index.html rename to print/templates/email/letter-debtor-nd/index.html diff --git a/print/report/letter-debtor-nd/index.js b/print/templates/email/letter-debtor-nd/index.js similarity index 100% rename from print/report/letter-debtor-nd/index.js rename to print/templates/email/letter-debtor-nd/index.js diff --git a/print/report/letter-debtor-nd/locale.js b/print/templates/email/letter-debtor-nd/locale.js similarity index 100% rename from print/report/letter-debtor-nd/locale.js rename to print/templates/email/letter-debtor-nd/locale.js diff --git a/print/report/letter-debtor-st/assets/css/index.js b/print/templates/email/letter-debtor-st/assets/css/index.js similarity index 100% rename from print/report/letter-debtor-st/assets/css/index.js rename to print/templates/email/letter-debtor-st/assets/css/index.js diff --git a/print/report/letter-debtor-st/index.html b/print/templates/email/letter-debtor-st/index.html similarity index 100% rename from print/report/letter-debtor-st/index.html rename to print/templates/email/letter-debtor-st/index.html diff --git a/print/report/letter-debtor-st/index.js b/print/templates/email/letter-debtor-st/index.js similarity index 100% rename from print/report/letter-debtor-st/index.js rename to print/templates/email/letter-debtor-st/index.js diff --git a/print/report/letter-debtor-st/locale.js b/print/templates/email/letter-debtor-st/locale.js similarity index 100% rename from print/report/letter-debtor-st/locale.js rename to print/templates/email/letter-debtor-st/locale.js diff --git a/print/report/payment-update/assets/css/index.js b/print/templates/email/payment-update/assets/css/index.js similarity index 100% rename from print/report/payment-update/assets/css/index.js rename to print/templates/email/payment-update/assets/css/index.js diff --git a/print/report/payment-update/index.html b/print/templates/email/payment-update/index.html similarity index 100% rename from print/report/payment-update/index.html rename to print/templates/email/payment-update/index.html diff --git a/print/report/payment-update/index.js b/print/templates/email/payment-update/index.js similarity index 100% rename from print/report/payment-update/index.js rename to print/templates/email/payment-update/index.js diff --git a/print/report/payment-update/locale.js b/print/templates/email/payment-update/locale.js similarity index 100% rename from print/report/payment-update/locale.js rename to print/templates/email/payment-update/locale.js diff --git a/print/report/printer-setup/assets/css/index.js b/print/templates/email/printer-setup/assets/css/index.js similarity index 100% rename from print/report/printer-setup/assets/css/index.js rename to print/templates/email/printer-setup/assets/css/index.js diff --git a/print/report/printer-setup/assets/files/model.ezp b/print/templates/email/printer-setup/assets/files/model.ezp similarity index 100% rename from print/report/printer-setup/assets/files/model.ezp rename to print/templates/email/printer-setup/assets/files/model.ezp diff --git a/print/report/printer-setup/assets/files/port.png b/print/templates/email/printer-setup/assets/files/port.png similarity index 100% rename from print/report/printer-setup/assets/files/port.png rename to print/templates/email/printer-setup/assets/files/port.png diff --git a/print/report/printer-setup/index.html b/print/templates/email/printer-setup/index.html similarity index 100% rename from print/report/printer-setup/index.html rename to print/templates/email/printer-setup/index.html diff --git a/print/report/printer-setup/index.js b/print/templates/email/printer-setup/index.js similarity index 100% rename from print/report/printer-setup/index.js rename to print/templates/email/printer-setup/index.js diff --git a/print/report/printer-setup/locale.js b/print/templates/email/printer-setup/locale.js similarity index 100% rename from print/report/printer-setup/locale.js rename to print/templates/email/printer-setup/locale.js diff --git a/print/report/sepa-core/assets/css/index.js b/print/templates/email/sepa-core/assets/css/index.js similarity index 100% rename from print/report/sepa-core/assets/css/index.js rename to print/templates/email/sepa-core/assets/css/index.js diff --git a/print/report/sepa-core/index.html b/print/templates/email/sepa-core/index.html similarity index 100% rename from print/report/sepa-core/index.html rename to print/templates/email/sepa-core/index.html diff --git a/print/report/sepa-core/index.js b/print/templates/email/sepa-core/index.js similarity index 100% rename from print/report/sepa-core/index.js rename to print/templates/email/sepa-core/index.js diff --git a/print/report/sepa-core/locale.js b/print/templates/email/sepa-core/locale.js similarity index 100% rename from print/report/sepa-core/locale.js rename to print/templates/email/sepa-core/locale.js diff --git a/print/report/rpt-claim-pickup-order/assets/css/index.js b/print/templates/reports/receipt/assets/css/index.js similarity index 100% rename from print/report/rpt-claim-pickup-order/assets/css/index.js rename to print/templates/reports/receipt/assets/css/index.js diff --git a/print/report/rpt-receipt/assets/css/style.css b/print/templates/reports/receipt/assets/css/style.css similarity index 100% rename from print/report/rpt-receipt/assets/css/style.css rename to print/templates/reports/receipt/assets/css/style.css diff --git a/print/report/rpt-lcr/assets/images/signature.png b/print/templates/reports/receipt/assets/images/signature.png similarity index 100% rename from print/report/rpt-lcr/assets/images/signature.png rename to print/templates/reports/receipt/assets/images/signature.png diff --git a/print/report/rpt-receipt/index.js b/print/templates/reports/receipt/index.js similarity index 54% rename from print/report/rpt-receipt/index.js rename to print/templates/reports/receipt/index.js index a4f04ad34..93fdad6d5 100755 --- a/print/report/rpt-receipt/index.js +++ b/print/templates/reports/receipt/index.js @@ -1,25 +1,12 @@ const strftime = require('strftime'); -const database = require(`${appPath}/lib/database`); +const db = require(`${appPath}/lib/database`); const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { - name: 'rpt-receipt', - serverPrefetch() { - console.log(this.test); - /* return new Promise(accept => { - this.client = this.fetchClient(); - }); */ - }, - async asyncData(ctx, params) { - Object.assign(this, this.methods); - - const [[client]] = await this.fetchClient(params.receiptFk); - const [[receipt]] = await this.fetchReceipt(params.receiptFk); - - if (!receipt) - throw new UserException('No receipt data found'); - - return {client, receipt}; + name: 'receipt', + async serverPrefetch() { + this.client = await this.fetchClient(this.receiptId); + this.receipt = await this.fetchReceipt(this.receiptId); }, created() { /* if (this.client.locale) @@ -37,8 +24,8 @@ module.exports = { }; }, methods: { - fetchClient(receiptFk) { - return database.pool.query( + fetchClient(receiptId) { + return db.findOne( `SELECT c.id, c.socialName, @@ -46,10 +33,10 @@ module.exports = { FROM receipt r JOIN client c ON c.id = r.clientFk JOIN account.user u ON u.id = c.id - WHERE r.id = ?`, [receiptFk]); + WHERE r.id = ?`, [receiptId]); }, - fetchReceipt(receiptFk) { - return database.pool.query( + fetchReceipt(receiptId) { + return db.findOne( `SELECT r.id, r.amountPaid, @@ -58,15 +45,12 @@ module.exports = { r.companyFk FROM receipt r JOIN client c ON c.id = r.clientFk - WHERE r.id = ?`, [receiptFk]); + WHERE r.id = ?`, [receiptId]); } /* dated: () => { return strftime('%d-%m-%Y', new Date()); }, */ }, - components: { - 'report-header': require('../report-header'), - 'report-footer': require('../report-footer'), - }, - template: '
asd
' + template: '
{{client}}
', + props: ['userId', 'receiptId'] }; diff --git a/print/report/rpt-item-label/locale.js b/print/templates/reports/receipt/locale.js similarity index 100% rename from print/report/rpt-item-label/locale.js rename to print/templates/reports/receipt/locale.js diff --git a/print/report/rpt-receipt/index.html b/print/templates/reports/receipt/receipt.html similarity index 81% rename from print/report/rpt-receipt/index.html rename to print/templates/reports/receipt/receipt.html index 99058dd9c..f70c7ad00 100644 --- a/print/report/rpt-receipt/index.html +++ b/print/templates/reports/receipt/receipt.html @@ -17,12 +17,7 @@

-

{{$t('payed', [ - 'Silla', - receipt.payed.getDate(), - $t('months')[receipt.payed.getMonth()], - receipt.payed.getFullYear()]) - }} +

diff --git a/print/report/report-footer/assets/css/index.js b/print/templates/reports/report-footer/assets/css/index.js similarity index 100% rename from print/report/report-footer/assets/css/index.js rename to print/templates/reports/report-footer/assets/css/index.js diff --git a/print/report/report-footer/assets/css/style.css b/print/templates/reports/report-footer/assets/css/style.css similarity index 100% rename from print/report/report-footer/assets/css/style.css rename to print/templates/reports/report-footer/assets/css/style.css diff --git a/print/report/report-footer/index.html b/print/templates/reports/report-footer/index.html similarity index 100% rename from print/report/report-footer/index.html rename to print/templates/reports/report-footer/index.html diff --git a/print/report/report-footer/index.js b/print/templates/reports/report-footer/index.js similarity index 100% rename from print/report/report-footer/index.js rename to print/templates/reports/report-footer/index.js diff --git a/print/report/report-footer/locale.js b/print/templates/reports/report-footer/locale.js similarity index 100% rename from print/report/report-footer/locale.js rename to print/templates/reports/report-footer/locale.js diff --git a/print/report/report-header/assets/css/index.js b/print/templates/reports/report-header/assets/css/index.js similarity index 100% rename from print/report/report-header/assets/css/index.js rename to print/templates/reports/report-header/assets/css/index.js diff --git a/print/report/report-header/assets/css/style.css b/print/templates/reports/report-header/assets/css/style.css similarity index 100% rename from print/report/report-header/assets/css/style.css rename to print/templates/reports/report-header/assets/css/style.css diff --git a/print/report/report-header/assets/images/report-logo.png b/print/templates/reports/report-header/assets/images/report-logo.png similarity index 100% rename from print/report/report-header/assets/images/report-logo.png rename to print/templates/reports/report-header/assets/images/report-logo.png diff --git a/print/report/report-header/assets/images/report-logo.svg b/print/templates/reports/report-header/assets/images/report-logo.svg similarity index 100% rename from print/report/report-header/assets/images/report-logo.svg rename to print/templates/reports/report-header/assets/images/report-logo.svg diff --git a/print/report/report-header/index.html b/print/templates/reports/report-header/index.html similarity index 100% rename from print/report/report-header/index.html rename to print/templates/reports/report-header/index.html diff --git a/print/report/report-header/index.js b/print/templates/reports/report-header/index.js similarity index 100% rename from print/report/report-header/index.js rename to print/templates/reports/report-header/index.js diff --git a/print/report/report-header/locale.js b/print/templates/reports/report-header/locale.js similarity index 100% rename from print/report/report-header/locale.js rename to print/templates/reports/report-header/locale.js diff --git a/print/report/rpt-delivery-note/assets/css/index.js b/print/templates/reports/rpt-claim-pickup-order/assets/css/index.js similarity index 100% rename from print/report/rpt-delivery-note/assets/css/index.js rename to print/templates/reports/rpt-claim-pickup-order/assets/css/index.js diff --git a/print/report/rpt-claim-pickup-order/assets/css/style.css b/print/templates/reports/rpt-claim-pickup-order/assets/css/style.css similarity index 100% rename from print/report/rpt-claim-pickup-order/assets/css/style.css rename to print/templates/reports/rpt-claim-pickup-order/assets/css/style.css diff --git a/print/report/rpt-claim-pickup-order/index.html b/print/templates/reports/rpt-claim-pickup-order/index.html similarity index 100% rename from print/report/rpt-claim-pickup-order/index.html rename to print/templates/reports/rpt-claim-pickup-order/index.html diff --git a/print/report/rpt-claim-pickup-order/index.js b/print/templates/reports/rpt-claim-pickup-order/index.js similarity index 100% rename from print/report/rpt-claim-pickup-order/index.js rename to print/templates/reports/rpt-claim-pickup-order/index.js diff --git a/print/report/rpt-claim-pickup-order/locale.js b/print/templates/reports/rpt-claim-pickup-order/locale.js similarity index 100% rename from print/report/rpt-claim-pickup-order/locale.js rename to print/templates/reports/rpt-claim-pickup-order/locale.js diff --git a/print/report/rpt-item-label/assets/css/index.js b/print/templates/reports/rpt-delivery-note/assets/css/index.js similarity index 100% rename from print/report/rpt-item-label/assets/css/index.js rename to print/templates/reports/rpt-delivery-note/assets/css/index.js diff --git a/print/report/rpt-delivery-note/assets/css/style.css b/print/templates/reports/rpt-delivery-note/assets/css/style.css similarity index 100% rename from print/report/rpt-delivery-note/assets/css/style.css rename to print/templates/reports/rpt-delivery-note/assets/css/style.css diff --git a/print/report/rpt-delivery-note/index.html b/print/templates/reports/rpt-delivery-note/index.html similarity index 100% rename from print/report/rpt-delivery-note/index.html rename to print/templates/reports/rpt-delivery-note/index.html diff --git a/print/report/rpt-delivery-note/index.js b/print/templates/reports/rpt-delivery-note/index.js similarity index 100% rename from print/report/rpt-delivery-note/index.js rename to print/templates/reports/rpt-delivery-note/index.js diff --git a/print/report/rpt-delivery-note/locale.js b/print/templates/reports/rpt-delivery-note/locale.js similarity index 100% rename from print/report/rpt-delivery-note/locale.js rename to print/templates/reports/rpt-delivery-note/locale.js diff --git a/print/report/rpt-lcr/assets/css/index.js b/print/templates/reports/rpt-item-label/assets/css/index.js similarity index 100% rename from print/report/rpt-lcr/assets/css/index.js rename to print/templates/reports/rpt-item-label/assets/css/index.js diff --git a/print/report/rpt-item-label/assets/css/style.css b/print/templates/reports/rpt-item-label/assets/css/style.css similarity index 100% rename from print/report/rpt-item-label/assets/css/style.css rename to print/templates/reports/rpt-item-label/assets/css/style.css diff --git a/print/report/rpt-item-label/index.html b/print/templates/reports/rpt-item-label/index.html similarity index 100% rename from print/report/rpt-item-label/index.html rename to print/templates/reports/rpt-item-label/index.html diff --git a/print/report/rpt-item-label/index.js b/print/templates/reports/rpt-item-label/index.js similarity index 100% rename from print/report/rpt-item-label/index.js rename to print/templates/reports/rpt-item-label/index.js diff --git a/print/report/rpt-receipt/locale.js b/print/templates/reports/rpt-item-label/locale.js similarity index 100% rename from print/report/rpt-receipt/locale.js rename to print/templates/reports/rpt-item-label/locale.js diff --git a/print/report/rpt-item-label/options.json b/print/templates/reports/rpt-item-label/options.json similarity index 100% rename from print/report/rpt-item-label/options.json rename to print/templates/reports/rpt-item-label/options.json diff --git a/print/report/rpt-letter-debtor/assets/css/index.js b/print/templates/reports/rpt-lcr/assets/css/index.js similarity index 100% rename from print/report/rpt-letter-debtor/assets/css/index.js rename to print/templates/reports/rpt-lcr/assets/css/index.js diff --git a/print/report/rpt-lcr/assets/css/style.css b/print/templates/reports/rpt-lcr/assets/css/style.css similarity index 100% rename from print/report/rpt-lcr/assets/css/style.css rename to print/templates/reports/rpt-lcr/assets/css/style.css diff --git a/print/report/rpt-receipt/assets/images/signature.png b/print/templates/reports/rpt-lcr/assets/images/signature.png similarity index 100% rename from print/report/rpt-receipt/assets/images/signature.png rename to print/templates/reports/rpt-lcr/assets/images/signature.png diff --git a/print/report/rpt-lcr/index.html b/print/templates/reports/rpt-lcr/index.html similarity index 100% rename from print/report/rpt-lcr/index.html rename to print/templates/reports/rpt-lcr/index.html diff --git a/print/report/rpt-lcr/index.js b/print/templates/reports/rpt-lcr/index.js similarity index 100% rename from print/report/rpt-lcr/index.js rename to print/templates/reports/rpt-lcr/index.js diff --git a/print/report/rpt-lcr/locale.js b/print/templates/reports/rpt-lcr/locale.js similarity index 100% rename from print/report/rpt-lcr/locale.js rename to print/templates/reports/rpt-lcr/locale.js diff --git a/print/report/rpt-receipt/assets/css/index.js b/print/templates/reports/rpt-letter-debtor/assets/css/index.js similarity index 100% rename from print/report/rpt-receipt/assets/css/index.js rename to print/templates/reports/rpt-letter-debtor/assets/css/index.js diff --git a/print/report/rpt-letter-debtor/assets/css/style.css b/print/templates/reports/rpt-letter-debtor/assets/css/style.css similarity index 100% rename from print/report/rpt-letter-debtor/assets/css/style.css rename to print/templates/reports/rpt-letter-debtor/assets/css/style.css diff --git a/print/report/rpt-letter-debtor/index.html b/print/templates/reports/rpt-letter-debtor/index.html similarity index 100% rename from print/report/rpt-letter-debtor/index.html rename to print/templates/reports/rpt-letter-debtor/index.html diff --git a/print/report/rpt-letter-debtor/index.js b/print/templates/reports/rpt-letter-debtor/index.js similarity index 100% rename from print/report/rpt-letter-debtor/index.js rename to print/templates/reports/rpt-letter-debtor/index.js diff --git a/print/report/rpt-letter-debtor/locale.js b/print/templates/reports/rpt-letter-debtor/locale.js similarity index 100% rename from print/report/rpt-letter-debtor/locale.js rename to print/templates/reports/rpt-letter-debtor/locale.js diff --git a/print/report/rpt-route/assets/css/index.js b/print/templates/reports/rpt-route/assets/css/index.js similarity index 100% rename from print/report/rpt-route/assets/css/index.js rename to print/templates/reports/rpt-route/assets/css/index.js diff --git a/print/report/rpt-route/assets/css/style.css b/print/templates/reports/rpt-route/assets/css/style.css similarity index 100% rename from print/report/rpt-route/assets/css/style.css rename to print/templates/reports/rpt-route/assets/css/style.css diff --git a/print/report/rpt-route/index.html b/print/templates/reports/rpt-route/index.html similarity index 100% rename from print/report/rpt-route/index.html rename to print/templates/reports/rpt-route/index.html diff --git a/print/report/rpt-route/index.js b/print/templates/reports/rpt-route/index.js similarity index 100% rename from print/report/rpt-route/index.js rename to print/templates/reports/rpt-route/index.js diff --git a/print/report/rpt-route/locale.js b/print/templates/reports/rpt-route/locale.js similarity index 100% rename from print/report/rpt-route/locale.js rename to print/templates/reports/rpt-route/locale.js diff --git a/print/report/rpt-sepa-core/assets/css/index.js b/print/templates/reports/rpt-sepa-core/assets/css/index.js similarity index 100% rename from print/report/rpt-sepa-core/assets/css/index.js rename to print/templates/reports/rpt-sepa-core/assets/css/index.js diff --git a/print/report/rpt-sepa-core/assets/css/style.css b/print/templates/reports/rpt-sepa-core/assets/css/style.css similarity index 100% rename from print/report/rpt-sepa-core/assets/css/style.css rename to print/templates/reports/rpt-sepa-core/assets/css/style.css diff --git a/print/report/rpt-sepa-core/index.html b/print/templates/reports/rpt-sepa-core/index.html similarity index 100% rename from print/report/rpt-sepa-core/index.html rename to print/templates/reports/rpt-sepa-core/index.html diff --git a/print/report/rpt-sepa-core/index.js b/print/templates/reports/rpt-sepa-core/index.js similarity index 100% rename from print/report/rpt-sepa-core/index.js rename to print/templates/reports/rpt-sepa-core/index.js diff --git a/print/report/rpt-sepa-core/locale.js b/print/templates/reports/rpt-sepa-core/locale.js similarity index 100% rename from print/report/rpt-sepa-core/locale.js rename to print/templates/reports/rpt-sepa-core/locale.js diff --git a/print/report/rpt-zone/assets/css/index.js b/print/templates/reports/rpt-zone/assets/css/index.js similarity index 100% rename from print/report/rpt-zone/assets/css/index.js rename to print/templates/reports/rpt-zone/assets/css/index.js diff --git a/print/report/rpt-zone/assets/css/style.css b/print/templates/reports/rpt-zone/assets/css/style.css similarity index 100% rename from print/report/rpt-zone/assets/css/style.css rename to print/templates/reports/rpt-zone/assets/css/style.css diff --git a/print/report/rpt-zone/index.html b/print/templates/reports/rpt-zone/index.html similarity index 100% rename from print/report/rpt-zone/index.html rename to print/templates/reports/rpt-zone/index.html diff --git a/print/report/rpt-zone/index.js b/print/templates/reports/rpt-zone/index.js similarity index 100% rename from print/report/rpt-zone/index.js rename to print/templates/reports/rpt-zone/index.js diff --git a/print/report/rpt-zone/locale.js b/print/templates/reports/rpt-zone/locale.js similarity index 100% rename from print/report/rpt-zone/locale.js rename to print/templates/reports/rpt-zone/locale.js diff --git a/print/report/sample-report/assets/css/index.js b/print/templates/reports/sample-report/assets/css/index.js similarity index 100% rename from print/report/sample-report/assets/css/index.js rename to print/templates/reports/sample-report/assets/css/index.js diff --git a/print/report/sample-report/assets/css/style.css b/print/templates/reports/sample-report/assets/css/style.css similarity index 100% rename from print/report/sample-report/assets/css/style.css rename to print/templates/reports/sample-report/assets/css/style.css diff --git a/print/report/sample-report/index.html b/print/templates/reports/sample-report/index.html similarity index 100% rename from print/report/sample-report/index.html rename to print/templates/reports/sample-report/index.html diff --git a/print/report/sample-report/index.js b/print/templates/reports/sample-report/index.js similarity index 100% rename from print/report/sample-report/index.js rename to print/templates/reports/sample-report/index.js diff --git a/print/report/sample-report/locale.js b/print/templates/reports/sample-report/locale.js similarity index 100% rename from print/report/sample-report/locale.js rename to print/templates/reports/sample-report/locale.js From 443aa56fed080b0feb197f6dacd25c2147f49c80 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 29 Oct 2019 07:46:44 +0100 Subject: [PATCH 03/18] refactor --- modules/ticket/front/index/index.js | 1 + package-lock.json | 20 +- print/common/css/email.css | 4 + print/common/css/layout.css | 4 + print/common/css/misc.css | 4 + print/common/css/report.css | 4 + print/config/routes.json | 25 -- print/core/component.js | 103 ++++++++ .../email-footer/assets/css/style.css | 0 .../email-footer/assets/images/action.png | Bin .../email-footer/assets/images/facebook.png | Bin .../email-footer/assets/images/info.png | Bin .../email-footer/assets/images/instagram.png | Bin .../email-footer/assets/images/linkedin.png | Bin .../email-footer/assets/images/pinterest.png | Bin .../email-footer/assets/images/twitter.png | Bin .../email-footer/assets/images/youtube.png | Bin .../components/email-footer/attachments.json | 27 ++ .../email-footer/email-footer.html} | 16 +- .../components/email-footer/email-footer.js | 4 + .../components/email-footer/locale/es.yml | 19 ++ .../components/email-footer/locale/fr.yml | 19 ++ .../email-header/assets/css/style.css | 0 .../email-header/assets/images/email-logo.png | Bin .../components/email-header/attachments.json | 7 + .../components/email-header/email-header.html | 5 + .../components/email-header/email-header.js | 4 + .../report-footer/assets/css/style.css | 0 .../components/report-footer/locale/es.yml | 10 + .../components/report-footer/locale/fr.yml | 10 + .../components/report-footer/locale/pt.yml | 10 + .../report-footer/report-footer.html} | 0 .../report-footer/report-footer.js} | 0 .../report-header/assets/css/style.css | 0 .../assets/images/report-logo.png | Bin .../assets/images/report-logo.svg | 0 .../components/report-header/locale/es.yml | 5 + .../components/report-header/locale/pt.yml | 5 + .../report-header/report-header.html} | 0 .../report-header/report-header.js} | 0 print/{lib => core}/config.js | 0 print/{lib => core}/cssReader.js | 0 print/{lib => core}/database.js | 0 print/core/directives/index.js | 1 + print/{lib/emailEngine.js => core/email.js} | 101 ++++++-- .../{lib => core}/exceptions/userException.js | 0 print/core/filters/currency.js | 7 + print/core/filters/index.js | 1 + .../index.js => core/filters/translate.js} | 0 print/core/mixins/image-src.js | 15 ++ print/core/mixins/index.js | 2 + print/{lib => core}/report.js | 56 +---- print/{lib => core}/router.js | 49 +++- print/{lib => core}/smtp.js | 4 +- print/lib/mixins/text.js | 7 - print/package-lock.json | 27 ++ print/package.json | 1 + print/server.js | 11 +- .../claim-pickup-order/assets/css/email.css | 44 ++++ .../claim-pickup-order/assets/css/index.js | 7 - .../claim-pickup-order/assets/css/layout.css | 233 ++++++++++++++++++ .../claim-pickup-order/assets/css/misc.css | 47 ++++ .../email/claim-pickup-order/attachments.json | 3 + .../{index.html => claim-pickup-order.html} | 11 +- .../claim-pickup-order/claim-pickup-order.js | 39 +++ .../email/claim-pickup-order/index.js | 53 ---- .../email/claim-pickup-order/locale.js | 25 -- .../email/claim-pickup-order/locale/es.yml | 23 ++ .../email/client-welcome/assets/css/email.css | 1 + .../email/client-welcome/assets/css/index.js | 7 - .../client-welcome/assets/css/layout.css | 233 ++++++++++++++++++ .../email/client-welcome/assets/css/misc.css | 47 ++++ .../{index.html => client-welcome.html} | 21 +- .../{index.js => client-welcome.js} | 25 +- .../templates/email/client-welcome/locale.js | 55 ----- .../email/client-welcome/locale/es.yml | 55 +++++ .../email/delivery-note/assets/css/email.css | 44 ++++ .../email/delivery-note/assets/css/index.js | 7 - .../email/delivery-note/assets/css/layout.css | 233 ++++++++++++++++++ .../email/delivery-note/assets/css/misc.css | 47 ++++ .../email/delivery-note/attachments.json | 4 + .../{index.html => delivery-note.html} | 4 +- .../{index.js => delivery-note.js} | 21 +- print/templates/email/delivery-note/locale.js | 11 - .../email/delivery-note/locale/es.yml | 6 + .../email/email-footer/assets/css/index.js | 4 - print/templates/email/email-footer/index.js | 34 --- print/templates/email/email-footer/locale.js | 42 ---- .../email/email-header/assets/css/index.js | 4 - print/templates/email/email-header/index.html | 5 - print/templates/email/email-header/index.js | 22 -- print/templates/email/email-header/locale.js | 5 - .../email/printer-setup/assets/css/email.css | 44 ++++ .../email/printer-setup/assets/css/index.js | 7 - .../email/printer-setup/assets/css/layout.css | 233 ++++++++++++++++++ .../email/printer-setup/assets/css/misc.css | 47 ++++ .../email/printer-setup/attachments.json | 10 + print/templates/email/printer-setup/index.js | 55 ----- print/templates/email/printer-setup/locale.js | 59 ----- .../email/printer-setup/locale/es.yml | 50 ++++ .../email/printer-setup/options.json | 0 .../{index.html => printer-setup.html} | 16 +- .../email/printer-setup/printer-setup.js | 38 +++ .../claim-pickup-order/assets/css/layout.css | 233 ++++++++++++++++++ .../claim-pickup-order/assets/css/misc.css | 47 ++++ .../claim-pickup-order/assets/css/report.css | 14 ++ .../assets/css/style.css | 0 .../claim-pickup-order.html} | 3 +- .../claim-pickup-order.js} | 48 ++-- .../reports/claim-pickup-order/locale/es.yml | 15 ++ .../assets/css/index.js | 0 .../assets/css/style.css | 0 .../delivery-note.html} | 0 .../delivery-note.js} | 5 +- .../reports/delivery-note/locale/es.yml | 26 ++ .../reports/receipt/assets/css/layout.css | 1 + .../reports/receipt/assets/css/misc.css | 1 + .../reports/receipt/assets/css/report.css | 1 + print/templates/reports/receipt/locale.js | 24 -- print/templates/reports/receipt/locale/en.yml | 0 print/templates/reports/receipt/locale/es.yml | 17 ++ print/templates/reports/receipt/receipt.html | 7 +- .../reports/receipt/{index.js => receipt.js} | 15 +- .../reports/report-footer/assets/css/index.js | 6 - .../templates/reports/report-footer/locale.js | 32 --- .../reports/report-header/assets/css/index.js | 4 - .../templates/reports/report-header/locale.js | 16 -- .../assets/css/index.js | 8 - .../reports/rpt-claim-pickup-order/locale.js | 23 -- .../rpt-delivery-note/assets/css/index.js | 8 - .../reports/rpt-delivery-note/locale.js | 32 --- .../reports/rpt-sepa-core/locale/fr.yml | 38 +++ 132 files changed, 2419 insertions(+), 774 deletions(-) delete mode 100644 print/config/routes.json create mode 100644 print/core/component.js rename print/{templates/email => core/components}/email-footer/assets/css/style.css (100%) rename print/{templates/email => core/components}/email-footer/assets/images/action.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/facebook.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/info.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/instagram.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/linkedin.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/pinterest.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/twitter.png (100%) rename print/{templates/email => core/components}/email-footer/assets/images/youtube.png (100%) create mode 100644 print/core/components/email-footer/attachments.json rename print/{templates/email/email-footer/index.html => core/components/email-footer/email-footer.html} (67%) create mode 100755 print/core/components/email-footer/email-footer.js create mode 100644 print/core/components/email-footer/locale/es.yml create mode 100644 print/core/components/email-footer/locale/fr.yml rename print/{templates/email => core/components}/email-header/assets/css/style.css (100%) rename print/{templates/email => core/components}/email-header/assets/images/email-logo.png (100%) create mode 100644 print/core/components/email-header/attachments.json create mode 100644 print/core/components/email-header/email-header.html create mode 100755 print/core/components/email-header/email-header.js rename print/{templates/reports => core/components}/report-footer/assets/css/style.css (100%) create mode 100644 print/core/components/report-footer/locale/es.yml create mode 100644 print/core/components/report-footer/locale/fr.yml create mode 100644 print/core/components/report-footer/locale/pt.yml rename print/{templates/reports/report-footer/index.html => core/components/report-footer/report-footer.html} (100%) rename print/{templates/reports/report-footer/index.js => core/components/report-footer/report-footer.js} (100%) rename print/{templates/reports => core/components}/report-header/assets/css/style.css (100%) rename print/{templates/reports => core/components}/report-header/assets/images/report-logo.png (100%) rename print/{templates/reports => core/components}/report-header/assets/images/report-logo.svg (100%) create mode 100644 print/core/components/report-header/locale/es.yml create mode 100644 print/core/components/report-header/locale/pt.yml rename print/{templates/reports/report-header/index.html => core/components/report-header/report-header.html} (100%) rename print/{templates/reports/report-header/index.js => core/components/report-header/report-header.js} (100%) rename print/{lib => core}/config.js (100%) rename print/{lib => core}/cssReader.js (100%) rename print/{lib => core}/database.js (100%) create mode 100644 print/core/directives/index.js rename print/{lib/emailEngine.js => core/email.js} (62%) rename print/{lib => core}/exceptions/userException.js (100%) create mode 100644 print/core/filters/currency.js create mode 100644 print/core/filters/index.js rename print/{lib/filters/index.js => core/filters/translate.js} (100%) create mode 100644 print/core/mixins/image-src.js create mode 100644 print/core/mixins/index.js rename print/{lib => core}/report.js (74%) rename print/{lib => core}/router.js (71%) rename print/{lib => core}/smtp.js (86%) delete mode 100755 print/lib/mixins/text.js create mode 100644 print/templates/email/claim-pickup-order/assets/css/email.css delete mode 100644 print/templates/email/claim-pickup-order/assets/css/index.js create mode 100644 print/templates/email/claim-pickup-order/assets/css/layout.css create mode 100644 print/templates/email/claim-pickup-order/assets/css/misc.css create mode 100644 print/templates/email/claim-pickup-order/attachments.json rename print/templates/email/claim-pickup-order/{index.html => claim-pickup-order.html} (71%) create mode 100755 print/templates/email/claim-pickup-order/claim-pickup-order.js delete mode 100755 print/templates/email/claim-pickup-order/index.js delete mode 100644 print/templates/email/claim-pickup-order/locale.js create mode 100644 print/templates/email/claim-pickup-order/locale/es.yml create mode 120000 print/templates/email/client-welcome/assets/css/email.css delete mode 100644 print/templates/email/client-welcome/assets/css/index.js create mode 100644 print/templates/email/client-welcome/assets/css/layout.css create mode 100644 print/templates/email/client-welcome/assets/css/misc.css rename print/templates/email/client-welcome/{index.html => client-welcome.html} (71%) rename print/templates/email/client-welcome/{index.js => client-welcome.js} (67%) delete mode 100644 print/templates/email/client-welcome/locale.js create mode 100644 print/templates/email/client-welcome/locale/es.yml create mode 100644 print/templates/email/delivery-note/assets/css/email.css delete mode 100644 print/templates/email/delivery-note/assets/css/index.js create mode 100644 print/templates/email/delivery-note/assets/css/layout.css create mode 100644 print/templates/email/delivery-note/assets/css/misc.css create mode 100644 print/templates/email/delivery-note/attachments.json rename print/templates/email/delivery-note/{index.html => delivery-note.html} (80%) rename print/templates/email/delivery-note/{index.js => delivery-note.js} (69%) delete mode 100644 print/templates/email/delivery-note/locale.js create mode 100644 print/templates/email/delivery-note/locale/es.yml delete mode 100644 print/templates/email/email-footer/assets/css/index.js delete mode 100755 print/templates/email/email-footer/index.js delete mode 100644 print/templates/email/email-footer/locale.js delete mode 100644 print/templates/email/email-header/assets/css/index.js delete mode 100644 print/templates/email/email-header/index.html delete mode 100755 print/templates/email/email-header/index.js delete mode 100644 print/templates/email/email-header/locale.js create mode 100644 print/templates/email/printer-setup/assets/css/email.css delete mode 100644 print/templates/email/printer-setup/assets/css/index.js create mode 100644 print/templates/email/printer-setup/assets/css/layout.css create mode 100644 print/templates/email/printer-setup/assets/css/misc.css create mode 100644 print/templates/email/printer-setup/attachments.json delete mode 100755 print/templates/email/printer-setup/index.js delete mode 100644 print/templates/email/printer-setup/locale.js create mode 100644 print/templates/email/printer-setup/locale/es.yml create mode 100644 print/templates/email/printer-setup/options.json rename print/templates/email/printer-setup/{index.html => printer-setup.html} (70%) create mode 100755 print/templates/email/printer-setup/printer-setup.js create mode 100644 print/templates/reports/claim-pickup-order/assets/css/layout.css create mode 100644 print/templates/reports/claim-pickup-order/assets/css/misc.css create mode 100644 print/templates/reports/claim-pickup-order/assets/css/report.css rename print/templates/reports/{rpt-claim-pickup-order => claim-pickup-order}/assets/css/style.css (100%) rename print/templates/reports/{rpt-claim-pickup-order/index.html => claim-pickup-order/claim-pickup-order.html} (96%) rename print/templates/reports/{rpt-claim-pickup-order/index.js => claim-pickup-order/claim-pickup-order.js} (58%) create mode 100644 print/templates/reports/claim-pickup-order/locale/es.yml rename print/templates/reports/{receipt => delivery-note}/assets/css/index.js (100%) rename print/templates/reports/{rpt-delivery-note => delivery-note}/assets/css/style.css (100%) rename print/templates/reports/{rpt-delivery-note/index.html => delivery-note/delivery-note.html} (100%) rename print/templates/reports/{rpt-delivery-note/index.js => delivery-note/delivery-note.js} (98%) create mode 100644 print/templates/reports/delivery-note/locale/es.yml create mode 120000 print/templates/reports/receipt/assets/css/layout.css create mode 120000 print/templates/reports/receipt/assets/css/misc.css create mode 120000 print/templates/reports/receipt/assets/css/report.css delete mode 100644 print/templates/reports/receipt/locale.js create mode 100644 print/templates/reports/receipt/locale/en.yml create mode 100644 print/templates/reports/receipt/locale/es.yml rename print/templates/reports/receipt/{index.js => receipt.js} (82%) delete mode 100644 print/templates/reports/report-footer/assets/css/index.js delete mode 100644 print/templates/reports/report-footer/locale.js delete mode 100644 print/templates/reports/report-header/assets/css/index.js delete mode 100644 print/templates/reports/report-header/locale.js delete mode 100644 print/templates/reports/rpt-claim-pickup-order/assets/css/index.js delete mode 100644 print/templates/reports/rpt-claim-pickup-order/locale.js delete mode 100644 print/templates/reports/rpt-delivery-note/assets/css/index.js delete mode 100644 print/templates/reports/rpt-delivery-note/locale.js create mode 100644 print/templates/reports/rpt-sepa-core/locale/fr.yml diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 2a2f3a238..b566bbfc0 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -18,6 +18,7 @@ export default class Controller { this.$.balanceCreateDialog.show(); }, name: 'Payment on account...', always: true} ]; + console.log(this.$stateParams); } setBalanceCreateDialog() { diff --git a/package-lock.json b/package-lock.json index 7b4445337..cd41d3950 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4769,7 +4769,7 @@ "dot-prop": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=", "requires": { "is-obj": "^1.0.0" } @@ -4937,7 +4937,7 @@ }, "jsonfile": { "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, "requires": { @@ -7485,7 +7485,7 @@ }, "kind-of": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", "dev": true }, @@ -9120,7 +9120,7 @@ }, "jasmine-core": { "version": "2.99.1", - "resolved": "http://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", "dev": true }, @@ -11194,7 +11194,7 @@ "dependencies": { "commander": { "version": "1.0.4", - "resolved": "http://registry.npmjs.org/commander/-/commander-1.0.4.tgz", + "resolved": "https://registry.npmjs.org/commander/-/commander-1.0.4.tgz", "integrity": "sha1-Xt6xruI8T7VBprcNaSq+8ZZpotM=", "dev": true, "requires": { @@ -13041,7 +13041,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -13053,7 +13053,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, @@ -13500,7 +13500,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -14321,7 +14321,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -15885,7 +15885,7 @@ "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=", "dev": true, "requires": { "nopt": "~1.0.10" diff --git a/print/common/css/email.css b/print/common/css/email.css index 6b15fbcba..a2b129057 100644 --- a/print/common/css/email.css +++ b/print/common/css/email.css @@ -1,3 +1,7 @@ +/** + * Email only stylesheet + * +*/ body { background-color: #EEE } diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 5914c3587..26b9bf8e0 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -1,3 +1,7 @@ +/** + * CSS layout elements + * +*/ .container { font-family: "Roboto", "Helvetica", "Arial", sans-serif; font-size: 16px diff --git a/print/common/css/misc.css b/print/common/css/misc.css index 16a37b6c3..093d5a974 100644 --- a/print/common/css/misc.css +++ b/print/common/css/misc.css @@ -1,3 +1,7 @@ +/** + * CSS misc classes + * +*/ .uppercase { text-transform: uppercase } diff --git a/print/common/css/report.css b/print/common/css/report.css index 24b20c330..e1105957b 100644 --- a/print/common/css/report.css +++ b/print/common/css/report.css @@ -1,3 +1,7 @@ +/** + * Report only stylesheet + * +*/ body { zoom: 0.55 } diff --git a/print/config/routes.json b/print/config/routes.json deleted file mode 100644 index 58d46193c..000000000 --- a/print/config/routes.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - {"type": "email", "name": "client-welcome"}, - {"type": "email", "name": "printer-setup"}, - {"type": "email", "name": "payment-update"}, - {"type": "email", "name": "letter-debtor-st"}, - {"type": "email", "name": "letter-debtor-nd"}, - {"type": "email", "name": "claim-pickup-order"}, - {"type": "email", "name": "sepa-core"}, - {"type": "email", "name": "client-lcr"}, - {"type": "email", "name": "driver-route"}, - {"type": "email", "name": "delivery-note"}, - {"type": "report", "name": "rpt-delivery-note"}, - {"type": "report", "name": "rpt-claim-pickup-order"}, - {"type": "report", "name": "rpt-letter-debtor"}, - {"type": "report", "name": "rpt-sepa-core"}, - {"type": "report", "name": "rpt-receipt"}, - {"type": "report", "name": "rpt-zone"}, - {"type": "report", "name": "rpt-route"}, - {"type": "report", "name": "rpt-lcr"}, - {"type": "report", "name": "rpt-item-label"}, - {"type": "static", "name": "email-header"}, - {"type": "static", "name": "email-footer"}, - {"type": "static", "name": "report-header"}, - {"type": "static", "name": "report-footer"} -] \ No newline at end of file diff --git a/print/core/component.js b/print/core/component.js new file mode 100644 index 000000000..26490c9e3 --- /dev/null +++ b/print/core/component.js @@ -0,0 +1,103 @@ +const Vue = require('vue'); +const VueI18n = require('vue-i18n'); +const renderer = require('vue-server-renderer').createRenderer(); +Vue.use(VueI18n); + +const fs = require('fs'); +const yaml = require('js-yaml'); +const juice = require('juice'); +const path = require('path'); + +const config = require('./config'); + +class Component { + constructor(name) { + this.name = name; + } + + get path() { + return `./components/${this.name}`; + } + + get template() { + const templatePath = `${this.path}/${this.name}.html`; + const fullPath = path.resolve(__dirname, templatePath); + + return fs.readFileSync(fullPath, 'utf8'); + } + + get locale() { + const mergedLocale = {messages: {}}; + const localePath = path.resolve(__dirname, `${this.path}/locale`); + + if (!fs.existsSync(localePath)) + return mergedLocale; + + const localeDir = fs.readdirSync(localePath); + localeDir.forEach(locale => { + const fullPath = path.join(localePath, '/', locale); + const yamlLocale = fs.readFileSync(fullPath, 'utf8'); + const jsonLocale = yaml.safeLoad(yamlLocale); + const localeName = locale.replace('.yml', ''); + + mergedLocale.messages[localeName] = jsonLocale; + }); + + return mergedLocale; + } + + get stylesheet() { + let mergedStyles = ''; + const stylePath = path.resolve(__dirname, `${this.path}/assets/css`); + + if (!fs.existsSync(stylePath)) + return mergedStyles; + + const styleDir = fs.readdirSync(stylePath); + styleDir.forEach(fileName => { + const fullPath = path.join(stylePath, '/', fileName); + const contents = fs.readFileSync(fullPath, 'utf8'); + + mergedStyles += contents; + }); + + return mergedStyles; + } + + get attachments() { + const attachmentsPath = `${this.path}/attachments.json`; + const fullPath = path.resolve(__dirname, attachmentsPath); + + if (!fs.existsSync(fullPath)) + return []; + + return require(fullPath); + } + + build() { + const component = require(`${this.path}/${this.name}`); + + component.i18n = this.locale; + component.attachments = this.attachments; + component.template = juice.inlineContent(this.template, this.stylesheet, { + inlinePseudoElements: true + }); + + return component; + } + + async render() { + const component = this.build(); + const i18n = new VueI18n(config.i18n); + const app = new Vue({ + i18n: i18n, + render: h => h(component, { + props: this.args + }) + }); + + return renderer.renderToString(app); + } +} + +module.exports = Component; diff --git a/print/templates/email/email-footer/assets/css/style.css b/print/core/components/email-footer/assets/css/style.css similarity index 100% rename from print/templates/email/email-footer/assets/css/style.css rename to print/core/components/email-footer/assets/css/style.css diff --git a/print/templates/email/email-footer/assets/images/action.png b/print/core/components/email-footer/assets/images/action.png similarity index 100% rename from print/templates/email/email-footer/assets/images/action.png rename to print/core/components/email-footer/assets/images/action.png diff --git a/print/templates/email/email-footer/assets/images/facebook.png b/print/core/components/email-footer/assets/images/facebook.png similarity index 100% rename from print/templates/email/email-footer/assets/images/facebook.png rename to print/core/components/email-footer/assets/images/facebook.png diff --git a/print/templates/email/email-footer/assets/images/info.png b/print/core/components/email-footer/assets/images/info.png similarity index 100% rename from print/templates/email/email-footer/assets/images/info.png rename to print/core/components/email-footer/assets/images/info.png diff --git a/print/templates/email/email-footer/assets/images/instagram.png b/print/core/components/email-footer/assets/images/instagram.png similarity index 100% rename from print/templates/email/email-footer/assets/images/instagram.png rename to print/core/components/email-footer/assets/images/instagram.png diff --git a/print/templates/email/email-footer/assets/images/linkedin.png b/print/core/components/email-footer/assets/images/linkedin.png similarity index 100% rename from print/templates/email/email-footer/assets/images/linkedin.png rename to print/core/components/email-footer/assets/images/linkedin.png diff --git a/print/templates/email/email-footer/assets/images/pinterest.png b/print/core/components/email-footer/assets/images/pinterest.png similarity index 100% rename from print/templates/email/email-footer/assets/images/pinterest.png rename to print/core/components/email-footer/assets/images/pinterest.png diff --git a/print/templates/email/email-footer/assets/images/twitter.png b/print/core/components/email-footer/assets/images/twitter.png similarity index 100% rename from print/templates/email/email-footer/assets/images/twitter.png rename to print/core/components/email-footer/assets/images/twitter.png diff --git a/print/templates/email/email-footer/assets/images/youtube.png b/print/core/components/email-footer/assets/images/youtube.png similarity index 100% rename from print/templates/email/email-footer/assets/images/youtube.png rename to print/core/components/email-footer/assets/images/youtube.png diff --git a/print/core/components/email-footer/attachments.json b/print/core/components/email-footer/attachments.json new file mode 100644 index 000000000..ca9329065 --- /dev/null +++ b/print/core/components/email-footer/attachments.json @@ -0,0 +1,27 @@ +[ + { + "filename": "facebook.png", + "path": "/assets/images/facebook.png", + "cid": "facebook.png" + }, { + "filename": "twitter.png", + "path": "/assets/images/twitter.png", + "cid": "twitter.png" + }, { + "filename": "youtube.png", + "path": "/assets/images/youtube.png", + "cid": "youtube.png" + }, { + "filename": "pinterest.png", + "path": "/assets/images/pinterest.png", + "cid": "pinterest.png" + }, { + "filename": "instagram.png", + "path": "/assets/images/instagram.png", + "cid": "instagram.png" + }, { + "filename": "linkedin.png", + "path": "/assets/images/linkedin.png", + "cid": "linkedin.png" + } +] \ No newline at end of file diff --git a/print/templates/email/email-footer/index.html b/print/core/components/email-footer/email-footer.html similarity index 67% rename from print/templates/email/email-footer/index.html rename to print/core/components/email-footer/email-footer.html index dd7853591..ae013691f 100644 --- a/print/templates/email/email-footer/index.html +++ b/print/core/components/email-footer/email-footer.html @@ -4,13 +4,13 @@
{{ $t('buttons.webAcccess')}} - +
{{ $t('buttons.info')}} - +
--> @@ -19,22 +19,22 @@
- Facebook + Facebook - Twitter + Twitter - Youtube + Youtube - Pinterest + Pinterest - Instagram + Instagram - Linkedin + Linkedin
diff --git a/print/core/components/email-footer/email-footer.js b/print/core/components/email-footer/email-footer.js new file mode 100755 index 000000000..527c8121a --- /dev/null +++ b/print/core/components/email-footer/email-footer.js @@ -0,0 +1,4 @@ +module.exports = { + name: 'email-footer', + props: ['isPreview', 'locale'] +}; diff --git a/print/core/components/email-footer/locale/es.yml b/print/core/components/email-footer/locale/es.yml new file mode 100644 index 000000000..592a46737 --- /dev/null +++ b/print/core/components/email-footer/locale/es.yml @@ -0,0 +1,19 @@ +buttons: + webAcccess: Visita nuestra Web + info: Ayúdanos a mejorar +privacy: + fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es + disclaimer: '- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado + exclusivamente por la persona destinataria del mismo. Si has recibido este mensaje + por error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier + documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la + confidencialidad ni a ningún privilegio por causa de transmisión errónea o mal + funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, + errores u omisiones que pudieran hacerse al mensaje una vez enviado.' + law: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de + Datos de Carácter Personal, te comunicamos que los datos personales que facilites + se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en + todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, + comunicándolo por escrito al domicilio social de la entidad. La finalidad del + fichero es la gestión administrativa, contabilidad, y facturación. diff --git a/print/core/components/email-footer/locale/fr.yml b/print/core/components/email-footer/locale/fr.yml new file mode 100644 index 000000000..38262a160 --- /dev/null +++ b/print/core/components/email-footer/locale/fr.yml @@ -0,0 +1,19 @@ +buttons: + webAcccess: Visitez notre site web + info: Ayúdanos a mejorar +privacy: + fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es + disclaimer: '- AVISO - Ce message est privé et confidentiel et doit être utilisé.exclusivamente + por la persona destinataria del mismo. Si has recibido este mensajepor error, + te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier documentoadjunto + que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad + ni aningún privilegio por causa de transmisión errónea o mal funcionamiento. Igualmente + no se haceresponsable de los cambios, alteraciones, errores u omisiones que pudieran + hacerse al mensaje una vez enviado.' + law: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de + Datos de Carácter Personal,te comunicamos que los datos personales que facilites + se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L.,pudiendo en + todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, + comunicándolo porescrito al domicilio social de la entidad. La finalidad del fichero + es la gestión administrativa, contabilidad, y facturación. diff --git a/print/templates/email/email-header/assets/css/style.css b/print/core/components/email-header/assets/css/style.css similarity index 100% rename from print/templates/email/email-header/assets/css/style.css rename to print/core/components/email-header/assets/css/style.css diff --git a/print/templates/email/email-header/assets/images/email-logo.png b/print/core/components/email-header/assets/images/email-logo.png similarity index 100% rename from print/templates/email/email-header/assets/images/email-logo.png rename to print/core/components/email-header/assets/images/email-logo.png diff --git a/print/core/components/email-header/attachments.json b/print/core/components/email-header/attachments.json new file mode 100644 index 000000000..5e57ae009 --- /dev/null +++ b/print/core/components/email-header/attachments.json @@ -0,0 +1,7 @@ +[ + { + "filename": "email-logo.png", + "path": "/assets/images/email-logo.png", + "cid": "email-logo.png" + } +] \ No newline at end of file diff --git a/print/core/components/email-header/email-header.html b/print/core/components/email-header/email-header.html new file mode 100644 index 000000000..f2b5a90cf --- /dev/null +++ b/print/core/components/email-header/email-header.html @@ -0,0 +1,5 @@ +
+ + VerdNatura + +
diff --git a/print/core/components/email-header/email-header.js b/print/core/components/email-header/email-header.js new file mode 100755 index 000000000..a1c73ee60 --- /dev/null +++ b/print/core/components/email-header/email-header.js @@ -0,0 +1,4 @@ +module.exports = { + name: 'email-header', + props: ['isPreview'] +}; diff --git a/print/templates/reports/report-footer/assets/css/style.css b/print/core/components/report-footer/assets/css/style.css similarity index 100% rename from print/templates/reports/report-footer/assets/css/style.css rename to print/core/components/report-footer/assets/css/style.css diff --git a/print/core/components/report-footer/locale/es.yml b/print/core/components/report-footer/locale/es.yml new file mode 100644 index 000000000..8c54b796f --- /dev/null +++ b/print/core/components/report-footer/locale/es.yml @@ -0,0 +1,10 @@ +numPages: Página {{page}} de {{pages}} +law: + phytosanitary: 'VERDNATURA LEVANTE SL - Pasaporte Fitosanitario R.P. Generalitat + Valenciana - Nº Comerciante: ES17462130' + privacy: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección + de Datos de Carácter Personal, le comunicamos que los datos personales que facilite + se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en + todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, + comunicándolo por escrito al domicilio social de la entidad. La finalidad del + fichero es la gestión administrativa, contabilidad, y facturación. diff --git a/print/core/components/report-footer/locale/fr.yml b/print/core/components/report-footer/locale/fr.yml new file mode 100644 index 000000000..e35f9fb7f --- /dev/null +++ b/print/core/components/report-footer/locale/fr.yml @@ -0,0 +1,10 @@ +numPages: Page {{page}} de {{pages}} +law: + phytosanitary: 'VERDNATURA LEVANTE SL - Passeport Phytosanitaire R.P. Generalitat + Valenciana - Numéro d''opérateur: ES17462130' + privacy: Conformément aux dispositions de la loi organique 15/1999 sur la protection + des données personnelles, nous vous informons que les données personnelles que + vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous + pouvez à tout moment, exercer les droits d'accès, de rectification, d'annulation + et d'opposition, en communiquant par écrit au siège social de la société. Le dossier + a pour objet la gestion administrative, la comptabilité et la facturation. diff --git a/print/core/components/report-footer/locale/pt.yml b/print/core/components/report-footer/locale/pt.yml new file mode 100644 index 000000000..8494c1ed5 --- /dev/null +++ b/print/core/components/report-footer/locale/pt.yml @@ -0,0 +1,10 @@ +numPages: Página {{page}} de {{pages}} +law: + phytosanitary: 'VERDNATURA LEVANTE S.L - Passaporte Fitossanitário R.P. Generalitat + Valenciana - Nº Comerciante: ES17462130' + privacy: Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados + de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão + nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento + exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando + por escrito ao domicílio social da entidade. A finalidade do ficheiro é a gestão + administrativa, contabilidade e facturação. diff --git a/print/templates/reports/report-footer/index.html b/print/core/components/report-footer/report-footer.html similarity index 100% rename from print/templates/reports/report-footer/index.html rename to print/core/components/report-footer/report-footer.html diff --git a/print/templates/reports/report-footer/index.js b/print/core/components/report-footer/report-footer.js similarity index 100% rename from print/templates/reports/report-footer/index.js rename to print/core/components/report-footer/report-footer.js diff --git a/print/templates/reports/report-header/assets/css/style.css b/print/core/components/report-header/assets/css/style.css similarity index 100% rename from print/templates/reports/report-header/assets/css/style.css rename to print/core/components/report-header/assets/css/style.css diff --git a/print/templates/reports/report-header/assets/images/report-logo.png b/print/core/components/report-header/assets/images/report-logo.png similarity index 100% rename from print/templates/reports/report-header/assets/images/report-logo.png rename to print/core/components/report-header/assets/images/report-logo.png diff --git a/print/templates/reports/report-header/assets/images/report-logo.svg b/print/core/components/report-header/assets/images/report-logo.svg similarity index 100% rename from print/templates/reports/report-header/assets/images/report-logo.svg rename to print/core/components/report-header/assets/images/report-logo.svg diff --git a/print/core/components/report-header/locale/es.yml b/print/core/components/report-header/locale/es.yml new file mode 100644 index 000000000..51552c24c --- /dev/null +++ b/print/core/components/report-header/locale/es.yml @@ -0,0 +1,5 @@ +company: + fiscalAddress: VERDNATURA LEVANTE S.L., B97367486 Avda. Espioca, 100, 46460 Silla + - www.verdnatura.es - clientes@verdnatura.es + registry: 'CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, + Folio 160, Sección 8, Hoja V 102076' diff --git a/print/core/components/report-header/locale/pt.yml b/print/core/components/report-header/locale/pt.yml new file mode 100644 index 000000000..51552c24c --- /dev/null +++ b/print/core/components/report-header/locale/pt.yml @@ -0,0 +1,5 @@ +company: + fiscalAddress: VERDNATURA LEVANTE S.L., B97367486 Avda. Espioca, 100, 46460 Silla + - www.verdnatura.es - clientes@verdnatura.es + registry: 'CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, + Folio 160, Sección 8, Hoja V 102076' diff --git a/print/templates/reports/report-header/index.html b/print/core/components/report-header/report-header.html similarity index 100% rename from print/templates/reports/report-header/index.html rename to print/core/components/report-header/report-header.html diff --git a/print/templates/reports/report-header/index.js b/print/core/components/report-header/report-header.js similarity index 100% rename from print/templates/reports/report-header/index.js rename to print/core/components/report-header/report-header.js diff --git a/print/lib/config.js b/print/core/config.js similarity index 100% rename from print/lib/config.js rename to print/core/config.js diff --git a/print/lib/cssReader.js b/print/core/cssReader.js similarity index 100% rename from print/lib/cssReader.js rename to print/core/cssReader.js diff --git a/print/lib/database.js b/print/core/database.js similarity index 100% rename from print/lib/database.js rename to print/core/database.js diff --git a/print/core/directives/index.js b/print/core/directives/index.js new file mode 100644 index 000000000..b93a6ca1e --- /dev/null +++ b/print/core/directives/index.js @@ -0,0 +1 @@ +// Import global directives diff --git a/print/lib/emailEngine.js b/print/core/email.js similarity index 62% rename from print/lib/emailEngine.js rename to print/core/email.js index 2ccff4f87..f85e42035 100644 --- a/print/lib/emailEngine.js +++ b/print/core/email.js @@ -1,26 +1,92 @@ -const Vue = require('vue'); -const VueI18n = require('vue-i18n'); -const renderer = require('vue-server-renderer').createRenderer(); -const fs = require('fs-extra'); -const juice = require('juice'); +const path = require('path'); const smtp = require('./smtp'); -const fallbackLocale = 'es'; +const Component = require('./component'); +const Report = require('./report'); if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; -Vue.use(VueI18n); +class Email extends Component { + constructor(name, args) { + super(name); -module.exports = { + this.args = args; + } + + get path() { + return `../templates/email/${this.name}`; + } + + + get subject() { + return null; + } + + async send() { + const instance = this.build(); + const rendered = await this.render(); + const attachments = []; + const getAttachments = async(componentPath, files) => { + for (file of files) { + const fileCopy = Object.assign({}, file); + if (fileCopy.cid) { + const templatePath = `${componentPath}/${file.path}`; + const fullFilePath = path.resolve(__dirname, templatePath); + + fileCopy.path = path.resolve(__dirname, fullFilePath); + } else { + const reportName = fileCopy.filename.replace('.pdf', ''); + const report = new Report(reportName, this.args); + fileCopy.content = await report.toPdfStream(); + } + + attachments.push(fileCopy); + } + }; + + if (instance.components) { + const components = instance.components; + for (let componentName in components) { + const component = components[componentName]; + const componentPath = `../components/${componentName}`; + await getAttachments(componentPath, component.attachments); + } + } + + + if (this.attachments) + await getAttachments(this.path, this.attachments); + /* + this.attachments.forEach(file => { + const fileCopy = Object.assign({}, file); + if (fileCopy.path) { + const templatePath = `${this.path}/${file.path}`; + const fullFilePath = path.resolve(__dirname, templatePath); + + fileCopy.path = path.resolve(__dirname, fullFilePath); + } + + attachments.push(fileCopy); + }); */ + + const options = { + to: this.args.recipient, + subject: 'Test', + html: rendered, + attachments: attachments + }; + + return smtp.send(options); + } +} + +module.exports = Email; + + +/* module.exports = { path: `${appPath}/report`, - /** - * Renders a report component - * - * @param {String} name - Report name - * @param {Object} ctx - Request context - */ async render(name, ctx) { const component = require(`${this.path}/${name}`); const result = await this.preFetch(component, ctx); @@ -39,12 +105,6 @@ module.exports = { }); }, - /** - * Prefetch all component data from asyncData method - * - * @param {Object} orgComponent - Component object - * @param {Object} ctx - Request context - */ async preFetch(orgComponent, ctx) { let component = Object.create(orgComponent); let mergedData = {attachments: []}; @@ -150,3 +210,4 @@ module.exports = { return smtp.send(options); }, }; + */ diff --git a/print/lib/exceptions/userException.js b/print/core/exceptions/userException.js similarity index 100% rename from print/lib/exceptions/userException.js rename to print/core/exceptions/userException.js diff --git a/print/core/filters/currency.js b/print/core/filters/currency.js new file mode 100644 index 000000000..b455673ac --- /dev/null +++ b/print/core/filters/currency.js @@ -0,0 +1,7 @@ +const Vue = require('vue'); +const currency = { + methods: { + }, +}; + +Vue.mixin(currency); diff --git a/print/core/filters/index.js b/print/core/filters/index.js new file mode 100644 index 000000000..caf95d54a --- /dev/null +++ b/print/core/filters/index.js @@ -0,0 +1 @@ +// Import global filters diff --git a/print/lib/filters/index.js b/print/core/filters/translate.js similarity index 100% rename from print/lib/filters/index.js rename to print/core/filters/translate.js diff --git a/print/core/mixins/image-src.js b/print/core/mixins/image-src.js new file mode 100644 index 000000000..730604455 --- /dev/null +++ b/print/core/mixins/image-src.js @@ -0,0 +1,15 @@ +const Vue = require('vue'); +const imageSrc = { + methods: { + getSrc(image) { + let src = `cid:${image}`; + + if (this.isPreview === 'true') + src = `/api/assets/${this.$options.name}/images/${image}`; + + return src; + } + }, +}; + +Vue.mixin(imageSrc); diff --git a/print/core/mixins/index.js b/print/core/mixins/index.js new file mode 100644 index 000000000..3baffcec4 --- /dev/null +++ b/print/core/mixins/index.js @@ -0,0 +1,2 @@ +// Import global mixins +require('./image-src'); diff --git a/print/lib/report.js b/print/core/report.js similarity index 74% rename from print/lib/report.js rename to print/core/report.js index 6cfaee4b4..4b00b25b7 100644 --- a/print/lib/report.js +++ b/print/core/report.js @@ -1,66 +1,20 @@ -const Vue = require('vue'); -const VueI18n = require('vue-i18n'); -const renderer = require('vue-server-renderer').createRenderer(); - const fs = require('fs'); const pdf = require('html-pdf'); -const juice = require('juice'); -const path = require('path'); - const config = require('./config'); -const reportsPath = '../templates/reports'; +const Component = require('./component'); if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; -Vue.use(VueI18n); - -class Report { +class Report extends Component { constructor(name, args) { - this.name = name; + super(name); + this.args = args; } get path() { - return `${reportsPath}/${this.name}`; - } - - get template() { - const templatePath = `${this.path}/${this.name}.html`; - const fullPath = path.resolve(__dirname, templatePath); - - return fs.readFileSync(fullPath, 'utf8'); - } - - get locale() { - - } - - get style() { - - } - - async render() { - const localePath = `${this.path}/locale`; - const stylePath = `${this.path}/assets/css/index`; - - const stylesheet = require(stylePath); - const component = require(this.path); - - component.i18n = require(localePath); - component.template = juice.inlineContent(this.template, stylesheet, { - inlinePseudoElements: true - }); - - const i18n = new VueI18n(config.i18n); - const app = new Vue({ - i18n: i18n, - render: h => h(component, { - props: this.args - }) - }); - - return renderer.renderToString(app); + return `../templates/reports/${this.name}`; } async toPdfStream() { diff --git a/print/lib/router.js b/print/core/router.js similarity index 71% rename from print/lib/router.js rename to print/core/router.js index eff4b5c9e..f800ace0c 100644 --- a/print/lib/router.js +++ b/print/core/router.js @@ -1,13 +1,25 @@ -const Report = require('./report'); -const emailEngine = require('./emailEngine'); const express = require('express'); const path = require('path'); -const vue = require('vue'); - const fs = require('fs'); + +const Report = require('./report'); +const Email = require('./email'); + const templatesPath = path.resolve(__dirname, '../templates'); +const componentsPath = path.resolve(__dirname, './components'); module.exports = app => { + /** + * Serve component static files + */ + const componentsDir = fs.readdirSync(componentsPath); + componentsDir.forEach(componentName => { + const componentDir = path.join(componentsPath, '/', componentName); + const assetsDir = `${componentDir}/assets`; + + app.use(`/api/assets/${componentName}`, express.static(assetsDir)); + }); + /** * Serve static files */ @@ -20,7 +32,7 @@ module.exports = app => { const templateDir = path.join(templatesPath, '/', directory, '/', templateName); const assetsDir = `${templateDir}/assets`; - app.use(`/api/assets`, express.static(assetsDir)); + app.use(`/api/assets/${templateName}`, express.static(assetsDir)); }); }); @@ -28,19 +40,34 @@ module.exports = app => { const args = Object.assign({}, req.body, req.query); const report = new Report(req.params.name, args); const stream = await report.toPdfStream(); - res.setHeader('Content-type', 'application/pdf'); stream.pipe(res); }); - /* app.get(`/api/email/${name}`, (request, response) => { - emailEngine.render(name, request).then(rendered => { - response.send(rendered.html); - }).catch(e => { - next(e); + app.get(`/api/email/:name`, async(req, res) => { + const args = req.query; + const requiredArgs = ['userId']; + + const hasRequiredArgs = requiredArgs.every(arg => { + return args[arg]; }); + + if (!hasRequiredArgs) + res.json({message: 'userId'}); + + const email = new Email(req.params.name, args); + if (args.isPreview === 'true') { + const rendered = await email.render(); + + res.send(rendered); + } else { + await email.send(); + res.status(200).json({message: 'Sent'}); + } }); + /* + app.post(`/api/email/${name}`, (request, response, next) => { emailEngine.toEmail(name, request).then(() => { response.status(200).json({status: 200}); diff --git a/print/lib/smtp.js b/print/core/smtp.js similarity index 86% rename from print/lib/smtp.js rename to print/core/smtp.js index 65fb58289..6f8bb20f9 100644 --- a/print/lib/smtp.js +++ b/print/core/smtp.js @@ -1,5 +1,5 @@ const nodemailer = require('nodemailer'); -const config = require('./config.js'); +const config = require('./config'); module.exports = { init() { @@ -11,7 +11,7 @@ module.exports = { options.from = `${config.app.senderName} <${config.app.senderMail}>`; if (process.env.NODE_ENV !== 'production') { - if (!config.smtp.user) + if (!config.smtp.auth.user) return Promise.resolve(true); options.to = config.app.senderMail; diff --git a/print/lib/mixins/text.js b/print/lib/mixins/text.js deleted file mode 100755 index be67a8746..000000000 --- a/print/lib/mixins/text.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - methods: { - uFirst: (text) => { - return text; - }, - }, -}; diff --git a/print/package-lock.json b/print/package-lock.json index 2be86cc84..5e8073291 100644 --- a/print/package-lock.json +++ b/print/package-lock.json @@ -25,6 +25,14 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -309,6 +317,11 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -519,6 +532,15 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -997,6 +1019,11 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, "sqlstring": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", diff --git a/print/package.json b/print/package.json index 0332817c2..898e75da0 100755 --- a/print/package.json +++ b/print/package.json @@ -15,6 +15,7 @@ "dependencies": { "fs-extra": "^7.0.1", "html-pdf": "^2.2.0", + "js-yaml": "^3.13.1", "juice": "^5.0.1", "mysql2": "^1.6.5", "nodemailer": "^4.7.0", diff --git a/print/server.js b/print/server.js index 31830009d..112873b9b 100644 --- a/print/server.js +++ b/print/server.js @@ -4,11 +4,16 @@ module.exports = app => { process.env.OPENSSL_CONF = '/etc/ssl/'; // Init database instance - require('./lib/database').init(); + require('./core/database').init(); // Init SMTP Instance - require('./lib/smtp').init(); + require('./core/smtp').init(); - require('./lib/router')(app); + require('./core/router')(app); + + require('./core/mixins'); + require('./core/filters'); + require('./core/directives'); + // require('./core/components/email-header/email-header'); }; diff --git a/print/templates/email/claim-pickup-order/assets/css/email.css b/print/templates/email/claim-pickup-order/assets/css/email.css new file mode 100644 index 000000000..a2b129057 --- /dev/null +++ b/print/templates/email/claim-pickup-order/assets/css/email.css @@ -0,0 +1,44 @@ +/** + * Email only stylesheet + * +*/ +body { + background-color: #EEE +} + +.container { + max-width: 600px; + min-width: 320px; + margin: 0 auto; + color: #555 +} + +.main { + background-color: #FFF; + padding: 20px +} + +.main a { + color: #8dba25 +} + +.main h1 { + color: #999 +} + +.main h3 { + font-size: 16px +} + +.title { + background-color: #95d831; + text-transform: uppercase; + text-align: center; + padding: 35px 0 +} + +.title h1 { + font-size: 32px; + color: #333; + margin: 0 +} diff --git a/print/templates/email/claim-pickup-order/assets/css/index.js b/print/templates/email/claim-pickup-order/assets/css/index.js deleted file mode 100644 index 321c632dc..000000000 --- a/print/templates/email/claim-pickup-order/assets/css/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/email.css`, - `${appPath}/common/css/misc.css`]) - .mergeStyles(); diff --git a/print/templates/email/claim-pickup-order/assets/css/layout.css b/print/templates/email/claim-pickup-order/assets/css/layout.css new file mode 100644 index 000000000..26b9bf8e0 --- /dev/null +++ b/print/templates/email/claim-pickup-order/assets/css/layout.css @@ -0,0 +1,233 @@ +/** + * CSS layout elements + * +*/ +.container { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 16px +} + +.columns { + overflow: hidden +} + +.columns .size100 { + width: 100%; + float: left +} + +.columns .size75 { + width: 75%; + float: left +} + +.columns .size50 { + width: 50%; + float: left +} + +.columns .size33 { + width: 33.33%; + float: left +} + +.columns .size25 { + width: 25%; + float: left +} + +.clearfix { + overflow: hidden; + display: block; + clear: both +} + +.panel { + position: relative; + margin-bottom: 15px; + padding-top: 10px; + break-inside: avoid; + break-before: always; + break-after: always; +} + +.panel .header { + background-color: #FFF; + padding: 2.5px 10px; + position: absolute; + font-weight: bold; + top: 0px; + left: 17.5px; +} + +.panel .body { + border: 1px solid #CCC; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 +} + +.panel.dark .header { + border: 1px solid #808080; + background-color: #FFF; +} + +.panel.dark .body { + border: 1px solid #808080; + background-color: #c0c0c0 +} + +.field { + border-bottom: 1px solid #CCC; + border-left: 1px solid #CCC; + border-top: 1px solid #CCC; + float: left +} + +.field span { + border-right: 1px solid #CCC; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: table-cell; + vertical-align: middle; + text-align: center; + font-weight: bold +} + +.field.square span { + height: 35.4px; + width: 35.4px +} + +.emptyField { + border-bottom: 1px dotted grey; + min-height: 1em; + display: block +} + +.field.rectangle span { + height: 2em; + width: 8em +} + +.pull-left { + float: left !important +} + +.pull-right { + float: right !important +} + +.vertical-text { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + right: -108px; + width: 200px; + top: 50% +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +.row-oriented, .column-oriented { + text-align: left; + width: 100% +} + +.column-oriented { + margin-bottom: 15px +} + +.column-oriented td, +.column-oriented th { + padding: 5px 10px +} + +.column-oriented thead { + background-color: #e5e5e5 +} + +.column-oriented thead tr { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + background-color: #e5e5e5 +} + +.column-oriented tfoot { + border-top: 2px solid #808080; +} + +.column-oriented tfoot tr:first-child td { + padding-top: 20px !important; +} + +.column-oriented .description { + border-bottom: 1px solid #DDD; + font-size: 0.8em +} + +.panel .row-oriented td, .panel .row-oriented th { + padding: 10px 0 +} + +.row-oriented > tbody > tr > td { + width: 30% +} + +.row-oriented > tbody > tr > th { + padding-left: 30px; + width: 70% +} + +.row-oriented .description { + padding: 0 !important; + font-size: 0.6em; + color: #888 +} + +.line { + border-bottom: 1px solid #DDD; + border-right: 1px solid #DDD; + border-left: 1px solid #DDD; + position: relative; + margin-left: -1px; + margin-right: 1px; + margin-top: 10px; + color: #999; + padding: 5px 0 +} + +.line .vertical-aligned { + position: absolute; + text-align: center; + width: 100%; + +} + +.line span { + background-color: #FFF; + padding: 5px +} + +.signature { + width: 100% +} + +.signature section { + height: 150px +} + +.signature p { + margin-right: 50%; + margin-top: 140px +} diff --git a/print/templates/email/claim-pickup-order/assets/css/misc.css b/print/templates/email/claim-pickup-order/assets/css/misc.css new file mode 100644 index 000000000..093d5a974 --- /dev/null +++ b/print/templates/email/claim-pickup-order/assets/css/misc.css @@ -0,0 +1,47 @@ +/** + * CSS misc classes + * +*/ +.uppercase { + text-transform: uppercase +} + +.justified { + text-align: justify +} + +.centered { + text-align: center +} + +.align-right { + text-align: right +} + +.align-left { + text-align: left +} + +.number { + text-align: right +} + +.font.gray { + color: #555 +} + +.font.light-gray { + color: #888 +} + +.font.small { + font-size: 0.65em +} + +.font.bold { + font-weight: bold +} + +.non-page-break { + page-break-inside: avoid; +} \ No newline at end of file diff --git a/print/templates/email/claim-pickup-order/attachments.json b/print/templates/email/claim-pickup-order/attachments.json new file mode 100644 index 000000000..1c77a5539 --- /dev/null +++ b/print/templates/email/claim-pickup-order/attachments.json @@ -0,0 +1,3 @@ +[{ + "filename": "claim-pickup-order.pdf" +}] \ No newline at end of file diff --git a/print/templates/email/claim-pickup-order/index.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html similarity index 71% rename from print/templates/email/claim-pickup-order/index.html rename to print/templates/email/claim-pickup-order/claim-pickup-order.html index fa2b0c530..3cd63bd56 100644 --- a/print/templates/email/claim-pickup-order/index.html +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html @@ -6,7 +6,7 @@
- +
@@ -15,6 +15,8 @@ + {{$t('testing')}} +

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

{{$t('description.instructions')}}

@@ -27,9 +29,14 @@

{{$t('sections.howToBuy.stock')}}

{{$t('sections.howToBuy.delivery')}}

--> +
+
+ Ver PDF +
+
- +
diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js new file mode 100755 index 000000000..452331b34 --- /dev/null +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -0,0 +1,39 @@ +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const attachments = require('./attachments.json'); + +module.exports = { + name: 'claim-pickup-order', + /* async serverPrefetch() { + this.client = await this.fetchClient(this.clientId); + },*/ + created() { + if (this.locale) + this.$i18n.locale = this.locale; + }, + data() { + return { + attachments + }; + }, + methods: { + fetchClient(claimId) { + return db.findOne(` + SELECT + c.id, + u.lang locale, + c.email recipient + FROM claim cl + JOIN client c ON c.id = cl.clientFk + JOIN account.user u ON u.id = c.id + WHERE cl.id = ?`, [claimId]); + }, + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: ['claimId', 'isPreview'] +}; diff --git a/print/templates/email/claim-pickup-order/index.js b/print/templates/email/claim-pickup-order/index.js deleted file mode 100755 index 38cb65e78..000000000 --- a/print/templates/email/claim-pickup-order/index.js +++ /dev/null @@ -1,53 +0,0 @@ -const UserException = require(`${appPath}/lib/exceptions/userException`); -const reportEngine = require(`${appPath}/lib/reportEngine`); -const database = require(`${appPath}/lib/database`); -const emailHeader = require('../email-header'); -const emailFooter = require('../email-footer'); - - -module.exports = { - name: 'claim-pickup-order', - async asyncData(ctx, params) { - const promises = []; - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.claimFk) - throw new UserException('No claim id specified'); - - promises.push(reportEngine.toPdf('rpt-claim-pickup-order', ctx)); - promises.push(this.methods.fetchClient(params.claimFk)); - - return Promise.all(promises).then(result => { - const stream = result[0]; - const [[client]] = result[1]; - - Object.assign(data, client); - Object.assign(data, {attachments: [{filename: 'claim-pickup-order.pdf', content: stream}]}); - - return data; - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - methods: { - fetchClient(claimFk) { - return database.pool.query(` - SELECT - c.id, - u.lang locale, - c.email recipient - FROM claim cl - JOIN client c ON c.id = cl.clientFk - JOIN account.user u ON u.id = c.id - WHERE cl.id = ?`, [claimFk]); - }, - }, - components: { - emailHeader, - emailFooter, - }, -}; diff --git a/print/templates/email/claim-pickup-order/locale.js b/print/templates/email/claim-pickup-order/locale.js deleted file mode 100644 index 343a9f9ab..000000000 --- a/print/templates/email/claim-pickup-order/locale.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Orden de recogida', - title: 'Orden de recogida', - description: { - dear: 'Estimado cliente', - instructions: 'Aqui tienes tu orden de recogida.' - }, - sections: { - howToBuy: { - title: 'Cómo hacer un pedido', - description: `Para realizar un pedido en nuestra web, - debes configurarlo indicando:`, - requeriments: [ - 'Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si lo prefieres recoger en alguno de nuestros almacenes.', - 'La fecha en la que quieres recibir el pedido (se preparará el día anterior).', - 'La dirección de entrega o el almacén donde quieres recoger el pedido.'], - stock: 'En nuestra web y aplicaciones puedes visualizar el stock disponible de flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que dicho stock puede variar en función de la fecha seleccionada al configurar el pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada.', - delivery: 'El reparto se realiza de lunes a sábado según la zona en la que te encuentres. Por regla general, los pedidos que se entregan por agencia, deben estar confirmados y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), aunque esto puede variar si el pedido se envía a través de nuestro reparto y según la zona.', - } - } - }, - }, -}; diff --git a/print/templates/email/claim-pickup-order/locale/es.yml b/print/templates/email/claim-pickup-order/locale/es.yml new file mode 100644 index 000000000..1d49b2b2b --- /dev/null +++ b/print/templates/email/claim-pickup-order/locale/es.yml @@ -0,0 +1,23 @@ +subject: Orden de recogida +title: Orden de recogida +description: + dear: Estimado cliente + instructions: Aqui tienes tu orden de recogida. +sections: + howToBuy: + title: Cómo hacer un pedido + description: 'Para realizar un pedido en nuestra web, debes configurarlo indicando:' + requeriments: + - Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si + lo prefieres recoger en alguno de nuestros almacenes. + - La fecha en la que quieres recibir el pedido (se preparará el día anterior). + - La dirección de entrega o el almacén donde quieres recoger el pedido. + stock: En nuestra web y aplicaciones puedes visualizar el stock disponible de + flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que + dicho stock puede variar en función de la fecha seleccionada al configurar el + pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada. + delivery: El reparto se realiza de lunes a sábado según la zona en la que te encuentres. + Por regla general, los pedidos que se entregan por agencia, deben estar confirmados + y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), + aunque esto puede variar si el pedido se envía a través de nuestro reparto y + según la zona. diff --git a/print/templates/email/client-welcome/assets/css/email.css b/print/templates/email/client-welcome/assets/css/email.css new file mode 120000 index 000000000..78b0e007a --- /dev/null +++ b/print/templates/email/client-welcome/assets/css/email.css @@ -0,0 +1 @@ +../../../../../common/css/email.css \ No newline at end of file diff --git a/print/templates/email/client-welcome/assets/css/index.js b/print/templates/email/client-welcome/assets/css/index.js deleted file mode 100644 index 321c632dc..000000000 --- a/print/templates/email/client-welcome/assets/css/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/email.css`, - `${appPath}/common/css/misc.css`]) - .mergeStyles(); diff --git a/print/templates/email/client-welcome/assets/css/layout.css b/print/templates/email/client-welcome/assets/css/layout.css new file mode 100644 index 000000000..26b9bf8e0 --- /dev/null +++ b/print/templates/email/client-welcome/assets/css/layout.css @@ -0,0 +1,233 @@ +/** + * CSS layout elements + * +*/ +.container { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 16px +} + +.columns { + overflow: hidden +} + +.columns .size100 { + width: 100%; + float: left +} + +.columns .size75 { + width: 75%; + float: left +} + +.columns .size50 { + width: 50%; + float: left +} + +.columns .size33 { + width: 33.33%; + float: left +} + +.columns .size25 { + width: 25%; + float: left +} + +.clearfix { + overflow: hidden; + display: block; + clear: both +} + +.panel { + position: relative; + margin-bottom: 15px; + padding-top: 10px; + break-inside: avoid; + break-before: always; + break-after: always; +} + +.panel .header { + background-color: #FFF; + padding: 2.5px 10px; + position: absolute; + font-weight: bold; + top: 0px; + left: 17.5px; +} + +.panel .body { + border: 1px solid #CCC; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 +} + +.panel.dark .header { + border: 1px solid #808080; + background-color: #FFF; +} + +.panel.dark .body { + border: 1px solid #808080; + background-color: #c0c0c0 +} + +.field { + border-bottom: 1px solid #CCC; + border-left: 1px solid #CCC; + border-top: 1px solid #CCC; + float: left +} + +.field span { + border-right: 1px solid #CCC; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: table-cell; + vertical-align: middle; + text-align: center; + font-weight: bold +} + +.field.square span { + height: 35.4px; + width: 35.4px +} + +.emptyField { + border-bottom: 1px dotted grey; + min-height: 1em; + display: block +} + +.field.rectangle span { + height: 2em; + width: 8em +} + +.pull-left { + float: left !important +} + +.pull-right { + float: right !important +} + +.vertical-text { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + right: -108px; + width: 200px; + top: 50% +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +.row-oriented, .column-oriented { + text-align: left; + width: 100% +} + +.column-oriented { + margin-bottom: 15px +} + +.column-oriented td, +.column-oriented th { + padding: 5px 10px +} + +.column-oriented thead { + background-color: #e5e5e5 +} + +.column-oriented thead tr { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + background-color: #e5e5e5 +} + +.column-oriented tfoot { + border-top: 2px solid #808080; +} + +.column-oriented tfoot tr:first-child td { + padding-top: 20px !important; +} + +.column-oriented .description { + border-bottom: 1px solid #DDD; + font-size: 0.8em +} + +.panel .row-oriented td, .panel .row-oriented th { + padding: 10px 0 +} + +.row-oriented > tbody > tr > td { + width: 30% +} + +.row-oriented > tbody > tr > th { + padding-left: 30px; + width: 70% +} + +.row-oriented .description { + padding: 0 !important; + font-size: 0.6em; + color: #888 +} + +.line { + border-bottom: 1px solid #DDD; + border-right: 1px solid #DDD; + border-left: 1px solid #DDD; + position: relative; + margin-left: -1px; + margin-right: 1px; + margin-top: 10px; + color: #999; + padding: 5px 0 +} + +.line .vertical-aligned { + position: absolute; + text-align: center; + width: 100%; + +} + +.line span { + background-color: #FFF; + padding: 5px +} + +.signature { + width: 100% +} + +.signature section { + height: 150px +} + +.signature p { + margin-right: 50%; + margin-top: 140px +} diff --git a/print/templates/email/client-welcome/assets/css/misc.css b/print/templates/email/client-welcome/assets/css/misc.css new file mode 100644 index 000000000..093d5a974 --- /dev/null +++ b/print/templates/email/client-welcome/assets/css/misc.css @@ -0,0 +1,47 @@ +/** + * CSS misc classes + * +*/ +.uppercase { + text-transform: uppercase +} + +.justified { + text-align: justify +} + +.centered { + text-align: center +} + +.align-right { + text-align: right +} + +.align-left { + text-align: left +} + +.number { + text-align: right +} + +.font.gray { + color: #555 +} + +.font.light-gray { + color: #888 +} + +.font.small { + font-size: 0.65em +} + +.font.bold { + font-weight: bold +} + +.non-page-break { + page-break-inside: avoid; +} \ No newline at end of file diff --git a/print/templates/email/client-welcome/index.html b/print/templates/email/client-welcome/client-welcome.html similarity index 71% rename from print/templates/email/client-welcome/index.html rename to print/templates/email/client-welcome/client-welcome.html index d6643e978..1608ee13e 100644 --- a/print/templates/email/client-welcome/index.html +++ b/print/templates/email/client-welcome/client-welcome.html @@ -6,7 +6,7 @@
- +
@@ -19,8 +19,8 @@

-

{{$t('clientId')}}: {{ id }}
-
{{$t('user')}}: {{userName}}
+
{{$t('clientId')}}: {{client.id}}
+
{{$t('user')}}: {{client.userName}}
{{$t('password')}}: ******** ({{$t('passwordResetText')}})
@@ -52,20 +52,21 @@

-

- {{$t('salesPersonName')}}: {{salesPersonName}} +
+ {{$t('salesPersonName')}}: {{client.salesPersonName}}
-
- {{$t('salesPersonPhone')}}: {{salesPersonPhone}} +
+ {{$t('salesPersonPhone')}}: {{client.salesPersonPhone}}
-
+
{{$t('salesPersonEmail')}}: - {{salesPersonEmail}} + {{client.salesPersonEmail}}

+ {{isPreview}} - +
diff --git a/print/templates/email/client-welcome/index.js b/print/templates/email/client-welcome/client-welcome.js similarity index 67% rename from print/templates/email/client-welcome/index.js rename to print/templates/email/client-welcome/client-welcome.js index b2278b4ee..022b90865 100755 --- a/print/templates/email/client-welcome/index.js +++ b/print/templates/email/client-welcome/client-welcome.js @@ -1,9 +1,15 @@ -const database = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); +const db = require(`${appPath}/lib/database`); +const Component = require(`${appPath}/lib/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + module.exports = { name: 'client-welcome', - async asyncData(ctx, params) { + async serverPrefetch() { + this.client = await this.fetchClient(this.clientId); + }, + /* async asyncData(ctx, params) { const data = { isPreview: ctx.method === 'GET', }; @@ -17,14 +23,14 @@ module.exports = { throw new UserException('No client data found'); return Object.assign(data, result[0]); }); - }, + }, */ created() { if (this.locale) this.$i18n.locale = this.locale; }, methods: { - fetchClient(clientFk) { - return database.pool.query(` + fetchClient(clientId) { + return db.findOne(` SELECT c.id, u.lang locale, @@ -37,11 +43,12 @@ module.exports = { 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 = ?`, [clientFk]); + WHERE c.id = ?`, [clientId]); }, }, components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() }, + props: ['clientId', 'isPreview'] }; diff --git a/print/templates/email/client-welcome/locale.js b/print/templates/email/client-welcome/locale.js deleted file mode 100644 index bf18a9d91..000000000 --- a/print/templates/email/client-welcome/locale.js +++ /dev/null @@ -1,55 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Bienvenido a Verdnatura', - title: '¡Te damos la bienvenida!', - dearClient: 'Estimado cliente', - clientData: `Tus datos para poder comprar en la web de Verdnatura - (https://www.verdnatura.es) - o en nuestras aplicaciones para iOS y - Android - (Ver tutorial de uso), son`, - clientId: 'Identificador de cliente', - user: 'Usuario', - password: 'Contraseña', - passwordResetText: 'Haz clic en "¿Has olvidado tu contraseña?"', - sections: { - howToBuy: { - title: 'Cómo hacer un pedido', - description: `Para realizar un pedido en nuestra web, - debes configurarlo indicando:`, - requeriments: [ - 'Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si lo prefieres recoger en alguno de nuestros almacenes.', - 'La fecha en la que quieres recibir el pedido (se preparará el día anterior).', - 'La dirección de entrega o el almacén donde quieres recoger el pedido.'], - stock: 'En nuestra web y aplicaciones puedes visualizar el stock disponible de flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que dicho stock puede variar en función de la fecha seleccionada al configurar el pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada.', - delivery: 'El reparto se realiza de lunes a sábado según la zona en la que te encuentres. Por regla general, los pedidos que se entregan por agencia, deben estar confirmados y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), aunque esto puede variar si el pedido se envía a través de nuestro reparto y según la zona.', - }, - howToPay: { - title: 'Cómo pagar', - description: 'Las formas de pago admitidas en Verdnatura son:', - options: [ - 'Con tarjeta a través de nuestra plataforma web (al confirmar el pedido).', - 'Mediante giro bancario mensual, modalidad que hay que solicitar y tramitar.', - ], - }, - toConsider: { - title: 'Cosas a tener en cuenta', - description: `Verdnatura vende EXCLUSIVAMENTE a profesionales, por lo que debes - remitirnos el Modelo 036 ó 037, para comprobar que está - dado/a de alta en el epígrafe correspondiente al comercio de flores.`, - }, - claimsPolicy: { - title: 'POLÍTICA DE RECLAMACIONES', - description: `Verdnatura aceptará las reclamaciones que se realicen dentro - de los dos días naturales siguientes a la recepción del pedido (incluyendo el mismo día de la recepción). - Pasado este plazo no se aceptará ninguna reclamación.`, - }, - }, - help: 'Cualquier duda que te surja, no dudes en consultarla, ¡estamos para atenderte!', - salesPersonName: 'Soy tu comercial y mi nombre es', - salesPersonPhone: 'Teléfono y whatsapp', - salesPersonEmail: 'Dirección de e-mail', - }, - }, -}; diff --git a/print/templates/email/client-welcome/locale/es.yml b/print/templates/email/client-welcome/locale/es.yml new file mode 100644 index 000000000..ac43a7cc6 --- /dev/null +++ b/print/templates/email/client-welcome/locale/es.yml @@ -0,0 +1,55 @@ +subject: Bienvenido a Verdnatura +title: "¡Te damos la bienvenida!" +dearClient: Estimado cliente +clientData: 'Tus datos para poder comprar en la web de Verdnatura (https://www.verdnatura.es) + o en nuestras aplicaciones para iOS y Android (Ver tutorial de uso), son' +clientId: Identificador de cliente +user: Usuario +password: Contraseña +passwordResetText: Haz clic en '¿Has olvidado tu contraseña?' +sections: + howToBuy: + title: Cómo hacer un pedido + description: 'Para realizar un pedido en nuestra web, debes configurarlo indicando:' + requeriments: + - Si quieres recibir el pedido (por agencia o por nuestro propio reparto) o si + lo prefieres recoger en alguno de nuestros almacenes. + - La fecha en la que quieres recibir el pedido (se preparará el día anterior). + - La dirección de entrega o el almacén donde quieres recoger el pedido. + stock: En nuestra web y aplicaciones puedes visualizar el stock disponible de + flor cortada, verdes, plantas, complementos y artificial. Ten en cuenta que + dicho stock puede variar en función de la fecha seleccionada al configurar el + pedido. Es importante CONFIRMAR los pedidos para que la mercancía quede reservada. + delivery: El reparto se realiza de lunes a sábado según la zona en la que te encuentres. + Por regla general, los pedidos que se entregan por agencia, deben estar confirmados + y pagados antes de las 17h del día en que se preparan (el día anterior a recibirlos), + aunque esto puede variar si el pedido se envía a través de nuestro reparto y + según la zona. + howToPay: + title: Cómo pagar + description: 'Las formas de pago admitidas en Verdnatura son:' + options: + - Con tarjeta a través de nuestra plataforma web (al confirmar + el pedido). + - Mediante giro bancario mensual, modalidad que hay que solicitar + y tramitar. + toConsider: + title: Cosas a tener en cuenta + description: Verdnatura vende EXCLUSIVAMENTE a profesionales, por lo que debes + remitirnos el Modelo 036 ó 037, para comprobar que está dado/a de alta en el + epígrafe correspondiente al comercio de flores. + claimsPolicy: + title: POLÍTICA DE RECLAMACIONES + description: Verdnatura aceptará las reclamaciones que se realicen dentro de los + dos días naturales siguientes a la recepción del pedido (incluyendo el mismo + día de la recepción). Pasado este plazo no se aceptará ninguna reclamación. +help: Cualquier duda que te surja, no dudes en consultarla, ¡estamos para + atenderte! +salesPersonName: Soy tu comercial y mi nombre es +salesPersonPhone: Teléfono y whatsapp +salesPersonEmail: Dirección de e-mail diff --git a/print/templates/email/delivery-note/assets/css/email.css b/print/templates/email/delivery-note/assets/css/email.css new file mode 100644 index 000000000..a2b129057 --- /dev/null +++ b/print/templates/email/delivery-note/assets/css/email.css @@ -0,0 +1,44 @@ +/** + * Email only stylesheet + * +*/ +body { + background-color: #EEE +} + +.container { + max-width: 600px; + min-width: 320px; + margin: 0 auto; + color: #555 +} + +.main { + background-color: #FFF; + padding: 20px +} + +.main a { + color: #8dba25 +} + +.main h1 { + color: #999 +} + +.main h3 { + font-size: 16px +} + +.title { + background-color: #95d831; + text-transform: uppercase; + text-align: center; + padding: 35px 0 +} + +.title h1 { + font-size: 32px; + color: #333; + margin: 0 +} diff --git a/print/templates/email/delivery-note/assets/css/index.js b/print/templates/email/delivery-note/assets/css/index.js deleted file mode 100644 index 321c632dc..000000000 --- a/print/templates/email/delivery-note/assets/css/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/email.css`, - `${appPath}/common/css/misc.css`]) - .mergeStyles(); diff --git a/print/templates/email/delivery-note/assets/css/layout.css b/print/templates/email/delivery-note/assets/css/layout.css new file mode 100644 index 000000000..26b9bf8e0 --- /dev/null +++ b/print/templates/email/delivery-note/assets/css/layout.css @@ -0,0 +1,233 @@ +/** + * CSS layout elements + * +*/ +.container { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 16px +} + +.columns { + overflow: hidden +} + +.columns .size100 { + width: 100%; + float: left +} + +.columns .size75 { + width: 75%; + float: left +} + +.columns .size50 { + width: 50%; + float: left +} + +.columns .size33 { + width: 33.33%; + float: left +} + +.columns .size25 { + width: 25%; + float: left +} + +.clearfix { + overflow: hidden; + display: block; + clear: both +} + +.panel { + position: relative; + margin-bottom: 15px; + padding-top: 10px; + break-inside: avoid; + break-before: always; + break-after: always; +} + +.panel .header { + background-color: #FFF; + padding: 2.5px 10px; + position: absolute; + font-weight: bold; + top: 0px; + left: 17.5px; +} + +.panel .body { + border: 1px solid #CCC; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 +} + +.panel.dark .header { + border: 1px solid #808080; + background-color: #FFF; +} + +.panel.dark .body { + border: 1px solid #808080; + background-color: #c0c0c0 +} + +.field { + border-bottom: 1px solid #CCC; + border-left: 1px solid #CCC; + border-top: 1px solid #CCC; + float: left +} + +.field span { + border-right: 1px solid #CCC; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: table-cell; + vertical-align: middle; + text-align: center; + font-weight: bold +} + +.field.square span { + height: 35.4px; + width: 35.4px +} + +.emptyField { + border-bottom: 1px dotted grey; + min-height: 1em; + display: block +} + +.field.rectangle span { + height: 2em; + width: 8em +} + +.pull-left { + float: left !important +} + +.pull-right { + float: right !important +} + +.vertical-text { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + right: -108px; + width: 200px; + top: 50% +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +.row-oriented, .column-oriented { + text-align: left; + width: 100% +} + +.column-oriented { + margin-bottom: 15px +} + +.column-oriented td, +.column-oriented th { + padding: 5px 10px +} + +.column-oriented thead { + background-color: #e5e5e5 +} + +.column-oriented thead tr { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + background-color: #e5e5e5 +} + +.column-oriented tfoot { + border-top: 2px solid #808080; +} + +.column-oriented tfoot tr:first-child td { + padding-top: 20px !important; +} + +.column-oriented .description { + border-bottom: 1px solid #DDD; + font-size: 0.8em +} + +.panel .row-oriented td, .panel .row-oriented th { + padding: 10px 0 +} + +.row-oriented > tbody > tr > td { + width: 30% +} + +.row-oriented > tbody > tr > th { + padding-left: 30px; + width: 70% +} + +.row-oriented .description { + padding: 0 !important; + font-size: 0.6em; + color: #888 +} + +.line { + border-bottom: 1px solid #DDD; + border-right: 1px solid #DDD; + border-left: 1px solid #DDD; + position: relative; + margin-left: -1px; + margin-right: 1px; + margin-top: 10px; + color: #999; + padding: 5px 0 +} + +.line .vertical-aligned { + position: absolute; + text-align: center; + width: 100%; + +} + +.line span { + background-color: #FFF; + padding: 5px +} + +.signature { + width: 100% +} + +.signature section { + height: 150px +} + +.signature p { + margin-right: 50%; + margin-top: 140px +} diff --git a/print/templates/email/delivery-note/assets/css/misc.css b/print/templates/email/delivery-note/assets/css/misc.css new file mode 100644 index 000000000..093d5a974 --- /dev/null +++ b/print/templates/email/delivery-note/assets/css/misc.css @@ -0,0 +1,47 @@ +/** + * CSS misc classes + * +*/ +.uppercase { + text-transform: uppercase +} + +.justified { + text-align: justify +} + +.centered { + text-align: center +} + +.align-right { + text-align: right +} + +.align-left { + text-align: left +} + +.number { + text-align: right +} + +.font.gray { + color: #555 +} + +.font.light-gray { + color: #888 +} + +.font.small { + font-size: 0.65em +} + +.font.bold { + font-weight: bold +} + +.non-page-break { + page-break-inside: avoid; +} \ No newline at end of file diff --git a/print/templates/email/delivery-note/attachments.json b/print/templates/email/delivery-note/attachments.json new file mode 100644 index 000000000..d1d96d94a --- /dev/null +++ b/print/templates/email/delivery-note/attachments.json @@ -0,0 +1,4 @@ +[{ + "filename": "delivery-note.pdf", + "href": "http://localhost:5000/pi" +}] \ No newline at end of file diff --git a/print/templates/email/delivery-note/index.html b/print/templates/email/delivery-note/delivery-note.html similarity index 80% rename from print/templates/email/delivery-note/index.html rename to print/templates/email/delivery-note/delivery-note.html index b85f8fab0..683a02271 100644 --- a/print/templates/email/delivery-note/index.html +++ b/print/templates/email/delivery-note/delivery-note.html @@ -6,7 +6,7 @@
- +
@@ -20,7 +20,7 @@

- +
diff --git a/print/templates/email/delivery-note/index.js b/print/templates/email/delivery-note/delivery-note.js similarity index 69% rename from print/templates/email/delivery-note/index.js rename to print/templates/email/delivery-note/delivery-note.js index 550e58bbb..aa1430657 100755 --- a/print/templates/email/delivery-note/index.js +++ b/print/templates/email/delivery-note/delivery-note.js @@ -1,6 +1,7 @@ -const database = require(`${appPath}/lib/database`); -const reportEngine = require(`${appPath}/lib/reportEngine.js`); -const UserException = require(`${appPath}/lib/exceptions/userException`); +const db = require(`${appPath}/lib/database`); +const Component = require(`${appPath}/lib/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); module.exports = { name: 'delivery-note', @@ -27,12 +28,11 @@ module.exports = { }); }, created() { - if (this.locale) - this.$i18n.locale = this.locale; + this.locale = 'es'; }, methods: { - fetchTicket(ticketFk) { - return database.pool.query(` + fetchTicket(ticketId) { + return db.findOne(` SELECT t.id, u.lang locale, @@ -40,11 +40,12 @@ module.exports = { FROM ticket t JOIN client c ON c.id = t.clientFk JOIN account.user u ON u.id = c.id - WHERE t.id = ?`, [ticketFk]); + WHERE t.id = ?`, [ticketId]); }, }, components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() }, + props: ['ticketId', 'isPreview'] }; diff --git a/print/templates/email/delivery-note/locale.js b/print/templates/email/delivery-note/locale.js deleted file mode 100644 index 0ddde5fc7..000000000 --- a/print/templates/email/delivery-note/locale.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Aquí tienes tu albarán', - title: '¡Este es tu albarán!', - dearClient: 'Estimado cliente', - clientData: `A continuación adjuntamos tu albarán.`, - help: 'Cualquier duda que te surja, no dudes en consultarla, ¡estamos para atenderte!' - }, - }, -}; diff --git a/print/templates/email/delivery-note/locale/es.yml b/print/templates/email/delivery-note/locale/es.yml new file mode 100644 index 000000000..cdc63e8eb --- /dev/null +++ b/print/templates/email/delivery-note/locale/es.yml @@ -0,0 +1,6 @@ +subject: Aquí tienes tu albarán +title: "¡Este es tu albarán!" +dearClient: Estimado cliente +clientData: A continuación adjuntamos tu albarán. +help: Cualquier duda que te surja, no dudes en consultarla, ¡estamos para + atenderte! \ No newline at end of file diff --git a/print/templates/email/email-footer/assets/css/index.js b/print/templates/email/email-footer/assets/css/index.js deleted file mode 100644 index c321a3fe7..000000000 --- a/print/templates/email/email-footer/assets/css/index.js +++ /dev/null @@ -1,4 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([`${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/email/email-footer/index.js b/print/templates/email/email-footer/index.js deleted file mode 100755 index 22321dd7d..000000000 --- a/print/templates/email/email-footer/index.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - name: 'email-footer', - asyncData(ctx) { - return { - isPreview: ctx.method === 'GET', - }; - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - - const embeded = []; - this.files.map(file => { - const src = this.isPreview ? `/api/${file}` : `cid:${file}`; - embeded[file] = src; - }); - this.embeded = embeded; - }, - data() { - return { - files: [ - /* '/assets/images/action.png', - '/assets/images/info.png', */ - '/assets/images/facebook.png', - '/assets/images/twitter.png', - '/assets/images/youtube.png', - '/assets/images/pinterest.png', - '/assets/images/instagram.png', - '/assets/images/linkedin.png', - ], - }; - }, - props: ['locale'] -}; diff --git a/print/templates/email/email-footer/locale.js b/print/templates/email/email-footer/locale.js deleted file mode 100644 index 7e8aa401d..000000000 --- a/print/templates/email/email-footer/locale.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - messages: { - es: { - buttons: { - webAcccess: 'Visita nuestra Web', - info: 'Ayúdanos a mejorar', - }, - privacy: { - fiscalAddress: 'VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla · www.verdnatura.es · clientes@verdnatura.es', - disclaimer: `- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado - exclusivamente por la persona destinataria del mismo. Si has recibido este mensaje - por error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier documento - adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad ni a - ningún privilegio por causa de transmisión errónea o mal funcionamiento. Igualmente no se hace - responsable de los cambios, alteraciones, errores u omisiones que pudieran hacerse al mensaje una vez enviado.`, - law: `En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, - te comunicamos que los datos personales que facilites se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., - pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por - escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación.`, - }, - }, - /* fr: { - buttons: { - webAcccess: 'Visitez notre site web', - info: 'Ayúdanos a mejorar', - }, - privacy: { - fiscalAddress: 'VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla · www.verdnatura.es · clientes@verdnatura.es', - disclaimer: `- AVISO - Ce message est privé et confidentiel et doit être utilisé. - exclusivamente por la persona destinataria del mismo. Si has recibido este mensaje - por error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier documento - adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad ni a - ningún privilegio por causa de transmisión errónea o mal funcionamiento. Igualmente no se hace - responsable de los cambios, alteraciones, errores u omisiones que pudieran hacerse al mensaje una vez enviado.`, - law: `En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, - te comunicamos que los datos personales que facilites se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., - pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por - escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación.`, - }, - }, */ - }, -}; diff --git a/print/templates/email/email-header/assets/css/index.js b/print/templates/email/email-header/assets/css/index.js deleted file mode 100644 index c321a3fe7..000000000 --- a/print/templates/email/email-header/assets/css/index.js +++ /dev/null @@ -1,4 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([`${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/email/email-header/index.html b/print/templates/email/email-header/index.html deleted file mode 100644 index a8f5f2d74..000000000 --- a/print/templates/email/email-header/index.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - VerdNatura - -
diff --git a/print/templates/email/email-header/index.js b/print/templates/email/email-header/index.js deleted file mode 100755 index e92d2fa64..000000000 --- a/print/templates/email/email-header/index.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - name: 'email-header', - asyncData(ctx) { - return { - isPreview: ctx.method === 'GET', - }; - }, - created() { - const embeded = []; - this.files.map(file => { - const src = this.isPreview ? `/api/${file}` : `cid:${file}`; - embeded[file] = src; - }); - this.embeded = embeded; - }, - - data() { - return { - files: ['/assets/images/email-logo.png'], - }; - }, -}; diff --git a/print/templates/email/email-header/locale.js b/print/templates/email/email-header/locale.js deleted file mode 100644 index 7200e6048..000000000 --- a/print/templates/email/email-header/locale.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - messages: { - es: {}, - }, -}; diff --git a/print/templates/email/printer-setup/assets/css/email.css b/print/templates/email/printer-setup/assets/css/email.css new file mode 100644 index 000000000..a2b129057 --- /dev/null +++ b/print/templates/email/printer-setup/assets/css/email.css @@ -0,0 +1,44 @@ +/** + * Email only stylesheet + * +*/ +body { + background-color: #EEE +} + +.container { + max-width: 600px; + min-width: 320px; + margin: 0 auto; + color: #555 +} + +.main { + background-color: #FFF; + padding: 20px +} + +.main a { + color: #8dba25 +} + +.main h1 { + color: #999 +} + +.main h3 { + font-size: 16px +} + +.title { + background-color: #95d831; + text-transform: uppercase; + text-align: center; + padding: 35px 0 +} + +.title h1 { + font-size: 32px; + color: #333; + margin: 0 +} diff --git a/print/templates/email/printer-setup/assets/css/index.js b/print/templates/email/printer-setup/assets/css/index.js deleted file mode 100644 index 321c632dc..000000000 --- a/print/templates/email/printer-setup/assets/css/index.js +++ /dev/null @@ -1,7 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/email.css`, - `${appPath}/common/css/misc.css`]) - .mergeStyles(); diff --git a/print/templates/email/printer-setup/assets/css/layout.css b/print/templates/email/printer-setup/assets/css/layout.css new file mode 100644 index 000000000..26b9bf8e0 --- /dev/null +++ b/print/templates/email/printer-setup/assets/css/layout.css @@ -0,0 +1,233 @@ +/** + * CSS layout elements + * +*/ +.container { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 16px +} + +.columns { + overflow: hidden +} + +.columns .size100 { + width: 100%; + float: left +} + +.columns .size75 { + width: 75%; + float: left +} + +.columns .size50 { + width: 50%; + float: left +} + +.columns .size33 { + width: 33.33%; + float: left +} + +.columns .size25 { + width: 25%; + float: left +} + +.clearfix { + overflow: hidden; + display: block; + clear: both +} + +.panel { + position: relative; + margin-bottom: 15px; + padding-top: 10px; + break-inside: avoid; + break-before: always; + break-after: always; +} + +.panel .header { + background-color: #FFF; + padding: 2.5px 10px; + position: absolute; + font-weight: bold; + top: 0px; + left: 17.5px; +} + +.panel .body { + border: 1px solid #CCC; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 +} + +.panel.dark .header { + border: 1px solid #808080; + background-color: #FFF; +} + +.panel.dark .body { + border: 1px solid #808080; + background-color: #c0c0c0 +} + +.field { + border-bottom: 1px solid #CCC; + border-left: 1px solid #CCC; + border-top: 1px solid #CCC; + float: left +} + +.field span { + border-right: 1px solid #CCC; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: table-cell; + vertical-align: middle; + text-align: center; + font-weight: bold +} + +.field.square span { + height: 35.4px; + width: 35.4px +} + +.emptyField { + border-bottom: 1px dotted grey; + min-height: 1em; + display: block +} + +.field.rectangle span { + height: 2em; + width: 8em +} + +.pull-left { + float: left !important +} + +.pull-right { + float: right !important +} + +.vertical-text { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + right: -108px; + width: 200px; + top: 50% +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +.row-oriented, .column-oriented { + text-align: left; + width: 100% +} + +.column-oriented { + margin-bottom: 15px +} + +.column-oriented td, +.column-oriented th { + padding: 5px 10px +} + +.column-oriented thead { + background-color: #e5e5e5 +} + +.column-oriented thead tr { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + background-color: #e5e5e5 +} + +.column-oriented tfoot { + border-top: 2px solid #808080; +} + +.column-oriented tfoot tr:first-child td { + padding-top: 20px !important; +} + +.column-oriented .description { + border-bottom: 1px solid #DDD; + font-size: 0.8em +} + +.panel .row-oriented td, .panel .row-oriented th { + padding: 10px 0 +} + +.row-oriented > tbody > tr > td { + width: 30% +} + +.row-oriented > tbody > tr > th { + padding-left: 30px; + width: 70% +} + +.row-oriented .description { + padding: 0 !important; + font-size: 0.6em; + color: #888 +} + +.line { + border-bottom: 1px solid #DDD; + border-right: 1px solid #DDD; + border-left: 1px solid #DDD; + position: relative; + margin-left: -1px; + margin-right: 1px; + margin-top: 10px; + color: #999; + padding: 5px 0 +} + +.line .vertical-aligned { + position: absolute; + text-align: center; + width: 100%; + +} + +.line span { + background-color: #FFF; + padding: 5px +} + +.signature { + width: 100% +} + +.signature section { + height: 150px +} + +.signature p { + margin-right: 50%; + margin-top: 140px +} diff --git a/print/templates/email/printer-setup/assets/css/misc.css b/print/templates/email/printer-setup/assets/css/misc.css new file mode 100644 index 000000000..093d5a974 --- /dev/null +++ b/print/templates/email/printer-setup/assets/css/misc.css @@ -0,0 +1,47 @@ +/** + * CSS misc classes + * +*/ +.uppercase { + text-transform: uppercase +} + +.justified { + text-align: justify +} + +.centered { + text-align: center +} + +.align-right { + text-align: right +} + +.align-left { + text-align: left +} + +.number { + text-align: right +} + +.font.gray { + color: #555 +} + +.font.light-gray { + color: #888 +} + +.font.small { + font-size: 0.65em +} + +.font.bold { + font-weight: bold +} + +.non-page-break { + page-break-inside: avoid; +} \ No newline at end of file diff --git a/print/templates/email/printer-setup/attachments.json b/print/templates/email/printer-setup/attachments.json new file mode 100644 index 000000000..cdc147f79 --- /dev/null +++ b/print/templates/email/printer-setup/attachments.json @@ -0,0 +1,10 @@ +[{ + "filename": "model.ezp", + "path": "/assets/files/model.ezp", + "cid": "model.ezp" +}, +{ + "filename": "port.png", + "path": "/assets/files/port.png", + "cid": "port.png" +}] \ No newline at end of file diff --git a/print/templates/email/printer-setup/index.js b/print/templates/email/printer-setup/index.js deleted file mode 100755 index 1353d996c..000000000 --- a/print/templates/email/printer-setup/index.js +++ /dev/null @@ -1,55 +0,0 @@ -const database = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); - -module.exports = { - name: 'printer-setup', - async asyncData(ctx, params) { - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.clientFk) - throw new UserException('No client id specified'); - - return this.methods.fetchClient(params.clientFk) - .then(([result]) => { - if (!result) - throw new UserException('No client data found'); - return Object.assign(data, result[0]); - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - data() { - return { - files: [ - '/assets/files/model.ezp', - '/assets/files/port.png' - ], - }; - }, - methods: { - fetchClient(clientFk) { - return database.pool.query(` - SELECT - c.id, - u.lang locale, - u.name AS userName, - c.email recipient, - 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 = ?`, [clientFk]); - }, - }, - components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), - }, -}; diff --git a/print/templates/email/printer-setup/locale.js b/print/templates/email/printer-setup/locale.js deleted file mode 100644 index dc95c931a..000000000 --- a/print/templates/email/printer-setup/locale.js +++ /dev/null @@ -1,59 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Instalación y configuración de impresora', - title: '¡Gracias por tu confianza!', - description: { - dear: 'Estimado cliente', - instructions: 'Sigue las instrucciones especificadas en este correo para llevar a cabo la instalación de la impresora.', - followGuide: `Puedes utilizar como guía, el vídeo del montaje del ribon y la cinta - https://www.youtube.com/watch?v=qhb0kgQF3o8. - También necesitarás el QLabel, el programa para imprimir las cintas.`, - downloadFrom: `Puedes descargarlo desde este enlace - https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01`, - }, - sections: { - QLabel: { - title: 'Utilización de QLabel', - description: 'Para utilizar el programa de impresión de cintas sigue estos pasos', - steps: [ - 'Abre el programa QLabel', - 'Haz clic en el icono de la barra superior con forma de "carpeta"', - 'Selecciona el archivo llamado "model.ezp" adjunto en este correo, y haz clic en abrir', - 'Ve a "File" -> "Save as" y guárdalo en el escritorio con otro nombre', - 'Cierra el Qlabel y abre el archivo que acabamos de guardar', - 'Haz clic encima del texto con el botón secundario del ratón', - 'Elige la primera opción "setup"', - 'Cambia el texto para imprimir', - 'Haz clic en el botón "Ok"', - 'Desplázate con el ratón para ver la medida máxima que ocupa el texto', - 'Haz clic encima del texto con el botón secundario del ratón', - 'Elige la segunda opción "Setup printer"', - 'Haz clic en la primera pestaña "Label Setup"', - 'Modifica la propiedad "Paper Height" con la medida máxima consultada anteriormente', - `Comprueba el puerto de la impresora, botón de de la derecha - "SETUP PRINTER" y en la parte derecha, igual como la imagen - que adjuntamos, seleccionar la que ponga "USB00x: GODEX"`, - 'Haz clic en el botón "Ok"', - 'Haz clic sobre el icono de la impresora', - 'Haz clic en "Print"', - ], - }, - help: { - title: '¿Necesitas ayuda?', - description: `Si necesitas ayuda, descárgate nuestro programa de soporte para poder conectarnos - remotamente a tu equipo y hacerte la instalación. Proporciónanos un horario de contacto para atenderte, y contactaremos contigo.`, - remoteSupport: `Puedes descargarte el programa desde este enlace - http://soporte.verdnatura.es.`, - }, - }, - help: 'Cualquier duda que te surja, no dudes en consultarla, ¡estamos para atenderte!', - salesPersonName: 'Soy tu comercial y mi nombre es', - salesPersonPhone: 'Teléfono y whatsapp', - salesPersonEmail: 'Dirección de e-mail', - }, - }, -}; - - diff --git a/print/templates/email/printer-setup/locale/es.yml b/print/templates/email/printer-setup/locale/es.yml new file mode 100644 index 000000000..39568bd1b --- /dev/null +++ b/print/templates/email/printer-setup/locale/es.yml @@ -0,0 +1,50 @@ +subject: Instalación y configuración de impresora +title: "¡Gracias por tu confianza!" +description: + dear: Estimado cliente + instructions: Sigue las instrucciones especificadas en este correo para llevar a + cabo la instalación de la impresora. + followGuide: Puedes utilizar como guía, el vídeo del montaje del ribon y la cinta + https://www.youtube.com/watch?v=qhb0kgQF3o8. También + necesitarás el QLabel, el programa para imprimir las cintas. + downloadFrom: Puedes descargarlo desde este enlace https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01 +sections: + QLabel: + title: Utilización de QLabel + description: Para utilizar el programa de impresión de cintas sigue estos pasos + steps: + - Abre el programa QLabel + - Haz clic en el icono de la barra superior con forma de 'carpeta' + - Selecciona el archivo llamado 'model.ezp' adjunto en este correo, y haz clic + en abrir + - Ve a 'File' -> 'Save as' y guárdalo en el escritorio con otro nombre + - Cierra el Qlabel y abre el archivo que acabamos de guardar + - Haz clic encima del texto con el botón secundario del ratón + - Elige la primera opción 'setup' + - Cambia el texto para imprimir + - Haz clic en el botón 'Ok' + - Desplázate con el ratón para ver la medida máxima que ocupa el texto + - Haz clic encima del texto con el botón secundario del ratón + - Elige la segunda opción 'Setup printer' + - Haz clic en la primera pestaña 'Label Setup' + - Modifica la propiedad 'Paper Height' con la medida máxima consultada anteriormente + - 'Comprueba el puerto de la impresora, botón de de la derecha ''SETUP PRINTER'' + y en la parte derecha, igual como la imagen que adjuntamos, seleccionar la que + ponga ''USB00x: GODEX''' + - Haz clic en el botón 'Ok' + - Haz clic sobre el icono de la impresora + - Haz clic en 'Print' + help: + title: "¿Necesitas ayuda?" + description: Si necesitas ayuda, descárgate nuestro programa de soporte para poder + conectarnos remotamente a tu equipo y hacerte la instalación. Proporciónanos + un horario de contacto para atenderte, y contactaremos contigo. + remoteSupport: Puedes descargarte el programa desde este enlace http://soporte.verdnatura.es. +help: Cualquier duda que te surja, no dudes en consultarla, ¡estamos para + atenderte! +salesPersonName: Soy tu comercial y mi nombre es +salesPersonPhone: Teléfono y whatsapp +salesPersonEmail: Dirección de e-mail \ No newline at end of file diff --git a/print/templates/email/printer-setup/options.json b/print/templates/email/printer-setup/options.json new file mode 100644 index 000000000..e69de29bb diff --git a/print/templates/email/printer-setup/index.html b/print/templates/email/printer-setup/printer-setup.html similarity index 70% rename from print/templates/email/printer-setup/index.html rename to print/templates/email/printer-setup/printer-setup.html index 0b62f5919..44f5e344a 100644 --- a/print/templates/email/printer-setup/index.html +++ b/print/templates/email/printer-setup/printer-setup.html @@ -6,7 +6,7 @@
- +
@@ -35,20 +35,20 @@

-

- {{$t('salesPersonName')}}: {{salesPersonName}} +
+ {{$t('salesPersonName')}}: {{client.salesPersonName}}
-
- {{$t('salesPersonPhone')}}: {{salesPersonPhone}} +
+ {{$t('salesPersonPhone')}}: {{client.salesPersonPhone}}
-
+
{{$t('salesPersonEmail')}}: - {{salesPersonEmail}} + {{client.salesPersonEmail}}

- +
diff --git a/print/templates/email/printer-setup/printer-setup.js b/print/templates/email/printer-setup/printer-setup.js new file mode 100755 index 000000000..6fa412301 --- /dev/null +++ b/print/templates/email/printer-setup/printer-setup.js @@ -0,0 +1,38 @@ +const db = require(`${appPath}/lib/database`); +const Component = require(`${appPath}/lib/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'printer-setup', + async serverPrefetch() { + this.client = await this.fetchClient(this.clientId); + }, + created() { + /* if (this.locale) + this.$i18n.locale = this.locale; */ + }, + methods: { + fetchClient(clientId) { + return db.findOne(` + SELECT + c.id, + u.lang locale, + u.name AS userName, + c.email recipient, + 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', 'isPreview'] +}; diff --git a/print/templates/reports/claim-pickup-order/assets/css/layout.css b/print/templates/reports/claim-pickup-order/assets/css/layout.css new file mode 100644 index 000000000..26b9bf8e0 --- /dev/null +++ b/print/templates/reports/claim-pickup-order/assets/css/layout.css @@ -0,0 +1,233 @@ +/** + * CSS layout elements + * +*/ +.container { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 16px +} + +.columns { + overflow: hidden +} + +.columns .size100 { + width: 100%; + float: left +} + +.columns .size75 { + width: 75%; + float: left +} + +.columns .size50 { + width: 50%; + float: left +} + +.columns .size33 { + width: 33.33%; + float: left +} + +.columns .size25 { + width: 25%; + float: left +} + +.clearfix { + overflow: hidden; + display: block; + clear: both +} + +.panel { + position: relative; + margin-bottom: 15px; + padding-top: 10px; + break-inside: avoid; + break-before: always; + break-after: always; +} + +.panel .header { + background-color: #FFF; + padding: 2.5px 10px; + position: absolute; + font-weight: bold; + top: 0px; + left: 17.5px; +} + +.panel .body { + border: 1px solid #CCC; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 +} + +.panel.dark .header { + border: 1px solid #808080; + background-color: #FFF; +} + +.panel.dark .body { + border: 1px solid #808080; + background-color: #c0c0c0 +} + +.field { + border-bottom: 1px solid #CCC; + border-left: 1px solid #CCC; + border-top: 1px solid #CCC; + float: left +} + +.field span { + border-right: 1px solid #CCC; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: table-cell; + vertical-align: middle; + text-align: center; + font-weight: bold +} + +.field.square span { + height: 35.4px; + width: 35.4px +} + +.emptyField { + border-bottom: 1px dotted grey; + min-height: 1em; + display: block +} + +.field.rectangle span { + height: 2em; + width: 8em +} + +.pull-left { + float: left !important +} + +.pull-right { + float: right !important +} + +.vertical-text { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + right: -108px; + width: 200px; + top: 50% +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +.row-oriented, .column-oriented { + text-align: left; + width: 100% +} + +.column-oriented { + margin-bottom: 15px +} + +.column-oriented td, +.column-oriented th { + padding: 5px 10px +} + +.column-oriented thead { + background-color: #e5e5e5 +} + +.column-oriented thead tr { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + background-color: #e5e5e5 +} + +.column-oriented tfoot { + border-top: 2px solid #808080; +} + +.column-oriented tfoot tr:first-child td { + padding-top: 20px !important; +} + +.column-oriented .description { + border-bottom: 1px solid #DDD; + font-size: 0.8em +} + +.panel .row-oriented td, .panel .row-oriented th { + padding: 10px 0 +} + +.row-oriented > tbody > tr > td { + width: 30% +} + +.row-oriented > tbody > tr > th { + padding-left: 30px; + width: 70% +} + +.row-oriented .description { + padding: 0 !important; + font-size: 0.6em; + color: #888 +} + +.line { + border-bottom: 1px solid #DDD; + border-right: 1px solid #DDD; + border-left: 1px solid #DDD; + position: relative; + margin-left: -1px; + margin-right: 1px; + margin-top: 10px; + color: #999; + padding: 5px 0 +} + +.line .vertical-aligned { + position: absolute; + text-align: center; + width: 100%; + +} + +.line span { + background-color: #FFF; + padding: 5px +} + +.signature { + width: 100% +} + +.signature section { + height: 150px +} + +.signature p { + margin-right: 50%; + margin-top: 140px +} diff --git a/print/templates/reports/claim-pickup-order/assets/css/misc.css b/print/templates/reports/claim-pickup-order/assets/css/misc.css new file mode 100644 index 000000000..093d5a974 --- /dev/null +++ b/print/templates/reports/claim-pickup-order/assets/css/misc.css @@ -0,0 +1,47 @@ +/** + * CSS misc classes + * +*/ +.uppercase { + text-transform: uppercase +} + +.justified { + text-align: justify +} + +.centered { + text-align: center +} + +.align-right { + text-align: right +} + +.align-left { + text-align: left +} + +.number { + text-align: right +} + +.font.gray { + color: #555 +} + +.font.light-gray { + color: #888 +} + +.font.small { + font-size: 0.65em +} + +.font.bold { + font-weight: bold +} + +.non-page-break { + page-break-inside: avoid; +} \ No newline at end of file diff --git a/print/templates/reports/claim-pickup-order/assets/css/report.css b/print/templates/reports/claim-pickup-order/assets/css/report.css new file mode 100644 index 000000000..e1105957b --- /dev/null +++ b/print/templates/reports/claim-pickup-order/assets/css/report.css @@ -0,0 +1,14 @@ +/** + * Report only stylesheet + * +*/ +body { + zoom: 0.55 +} + +.title { + margin-bottom: 20px; + font-weight: 100; + margin-top: 0; + font-size: 2em +} \ No newline at end of file diff --git a/print/templates/reports/rpt-claim-pickup-order/assets/css/style.css b/print/templates/reports/claim-pickup-order/assets/css/style.css similarity index 100% rename from print/templates/reports/rpt-claim-pickup-order/assets/css/style.css rename to print/templates/reports/claim-pickup-order/assets/css/style.css diff --git a/print/templates/reports/rpt-claim-pickup-order/index.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html similarity index 96% rename from print/templates/reports/rpt-claim-pickup-order/index.html rename to print/templates/reports/claim-pickup-order/claim-pickup-order.html index b5c571a5c..6f96718b2 100644 --- a/print/templates/reports/rpt-claim-pickup-order/index.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -3,7 +3,7 @@
- +
@@ -77,6 +77,7 @@
diff --git a/print/templates/reports/rpt-claim-pickup-order/index.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js similarity index 58% rename from print/templates/reports/rpt-claim-pickup-order/index.js rename to print/templates/reports/claim-pickup-order/claim-pickup-order.js index 2124be828..5ad7ad642 100755 --- a/print/templates/reports/rpt-claim-pickup-order/index.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -1,30 +1,14 @@ const strftime = require('strftime'); -const database = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); module.exports = { name: 'rpt-claim-pickup-order', - async asyncData(ctx, params) { - const promises = []; - const data = {}; - - if (!params.claimFk) - throw new UserException('No claim id specified'); - - promises.push(this.methods.fetchClaim(params.claimFk)); - promises.push(this.methods.fetchSales(params.claimFk)); - - return Promise.all(promises).then(result => { - const [[claim]] = result[0]; - const [sales] = result[1]; - - if (!claim) - throw new UserException('No claim data found'); - - Object.assign(data, claim, {sales}); - - return data; - }); + async serverPrefetch() { + this.claim = await this.fetchClaim(this.claimId); + this.sales = await this.fetchSales(this.claimId); }, created() { if (this.locale) @@ -34,8 +18,8 @@ module.exports = { dated: () => { return strftime('%d-%m-%Y', new Date()); }, - fetchClaim(claimFk) { - return database.pool.query( + fetchClaim(claimId) { + return db.findOne( `SELECT u.lang locale, c.id clientId, @@ -57,11 +41,10 @@ module.exports = { JOIN ticket t ON t.id = cl.ticketFk JOIN address a ON a.id = t.addressFk LEFT JOIN province p ON p.id = c.provinceFk - WHERE cl.id = ?`, [claimFk]); + WHERE cl.id = ?`, [claimId]); }, - - fetchSales(claimFk) { - return database.pool.query( + fetchSales(claimId) { + return db.pool.query( `SELECT s.id, s.quantity, @@ -69,11 +52,12 @@ module.exports = { cb.quantity claimQuantity FROM claimBeginning cb JOIN sale s ON s.id = cb.saleFk - WHERE cb.claimFk = ?`, [claimFk]); + WHERE cb.claimFk = ?`, [claimId]); }, }, components: { - 'report-header': require('../report-header'), - 'report-footer': require('../report-footer'), + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() }, + props: ['claimId', 'isPreview'] }; diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml new file mode 100644 index 000000000..534fd2da8 --- /dev/null +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -0,0 +1,15 @@ +title: Ord. recogida +claimId: Reclamación +clientId: Cliente +date: Fecha +clientData: Dirección de recogida +quantity: Cantidad +claims: Reclama +reference: Referencia +concept: Concepto +clientSignature: Firma del cliente +claim: Reclamación {0} +sections: + agency: + description: 'Para agilizar tu recogida, por favor, pónte en contacto con la oficina + de integrados.
Tlf: 96 166 77 88 - Ana Gómez (Ext. 2133) (agomezf@integra2.es)' diff --git a/print/templates/reports/receipt/assets/css/index.js b/print/templates/reports/delivery-note/assets/css/index.js similarity index 100% rename from print/templates/reports/receipt/assets/css/index.js rename to print/templates/reports/delivery-note/assets/css/index.js diff --git a/print/templates/reports/rpt-delivery-note/assets/css/style.css b/print/templates/reports/delivery-note/assets/css/style.css similarity index 100% rename from print/templates/reports/rpt-delivery-note/assets/css/style.css rename to print/templates/reports/delivery-note/assets/css/style.css diff --git a/print/templates/reports/rpt-delivery-note/index.html b/print/templates/reports/delivery-note/delivery-note.html similarity index 100% rename from print/templates/reports/rpt-delivery-note/index.html rename to print/templates/reports/delivery-note/delivery-note.html diff --git a/print/templates/reports/rpt-delivery-note/index.js b/print/templates/reports/delivery-note/delivery-note.js similarity index 98% rename from print/templates/reports/rpt-delivery-note/index.js rename to print/templates/reports/delivery-note/delivery-note.js index be6bb83c5..ad7400854 100755 --- a/print/templates/reports/rpt-delivery-note/index.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -226,7 +226,8 @@ module.exports = { }, }, components: { - 'report-header': require('../report-header'), - 'report-footer': require('../report-footer'), + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() }, + props: ['clientId', 'isPreview'] }; diff --git a/print/templates/reports/delivery-note/locale/es.yml b/print/templates/reports/delivery-note/locale/es.yml new file mode 100644 index 000000000..4dc7d4ff9 --- /dev/null +++ b/print/templates/reports/delivery-note/locale/es.yml @@ -0,0 +1,26 @@ +title: Albarán +ticketId: Albarán +clientId: Cliente +deliveryAddress: Dirección de entrega +fiscalData: Datos fiscales +saleLines: Líneas de pedido +date: Fecha +reference: Ref. +quantity: Cant. +concept: Concepto +price: PVP/u +discount: Dto. +vat: IVA +amount: Importe +type: Tipo +taxBase: Base imp. +tax: Tasa +fee: Cuota +total: Total +subtotal: Subtotal +taxBreakdown: Desglose impositivo +packagings: Cubos y embalajes +services: Servicios +vatType: Tipo de IVA +digitalSignature: Firma digital +ticket: Albarán {0} \ No newline at end of file diff --git a/print/templates/reports/receipt/assets/css/layout.css b/print/templates/reports/receipt/assets/css/layout.css new file mode 120000 index 000000000..174dbc1b9 --- /dev/null +++ b/print/templates/reports/receipt/assets/css/layout.css @@ -0,0 +1 @@ +../../../../../common/css/layout.css \ No newline at end of file diff --git a/print/templates/reports/receipt/assets/css/misc.css b/print/templates/reports/receipt/assets/css/misc.css new file mode 120000 index 000000000..e23d53e0f --- /dev/null +++ b/print/templates/reports/receipt/assets/css/misc.css @@ -0,0 +1 @@ +../../../../../common/css/misc.css \ No newline at end of file diff --git a/print/templates/reports/receipt/assets/css/report.css b/print/templates/reports/receipt/assets/css/report.css new file mode 120000 index 000000000..4d46936a9 --- /dev/null +++ b/print/templates/reports/receipt/assets/css/report.css @@ -0,0 +1 @@ +../../../../../common/css/report.css \ No newline at end of file diff --git a/print/templates/reports/receipt/locale.js b/print/templates/reports/receipt/locale.js deleted file mode 100644 index b8d524274..000000000 --- a/print/templates/reports/receipt/locale.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - messages: { - es: { - title: 'Recibo', - date: 'Fecha', - payed: 'En {0}, a {1} de {2} de {3}', - client: 'Cliente {0}', - months: [ - 'Enero', - 'Febrero', - 'Marzo', - 'Abril', - 'Mayo', - 'Junio', - 'Julio', - 'Agosto', - 'Septiembre', - 'Octubre', - 'Noviembre', - 'Diciembre' - ] - }, - }, -}; diff --git a/print/templates/reports/receipt/locale/en.yml b/print/templates/reports/receipt/locale/en.yml new file mode 100644 index 000000000..e69de29bb diff --git a/print/templates/reports/receipt/locale/es.yml b/print/templates/reports/receipt/locale/es.yml new file mode 100644 index 000000000..67b9a948f --- /dev/null +++ b/print/templates/reports/receipt/locale/es.yml @@ -0,0 +1,17 @@ +title: 'Recibo' +date: 'Fecha' +payed: 'En {0}, a {1} de {2} de {3}' +client: 'Cliente {0}' +months: + - 'Enero' + - 'Febrero' + - 'Marzo' + - 'Abril' + - 'Mayo' + - 'Junio' + - 'Julio' + - 'Agosto' + - 'Septiembre' + - 'Octubre' + - 'Noviembre' + - 'Diciembre' \ No newline at end of file diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index f70c7ad00..99058dd9c 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -17,7 +17,12 @@

-

+

{{$t('payed', [ + 'Silla', + receipt.payed.getDate(), + $t('months')[receipt.payed.getMonth()], + receipt.payed.getFullYear()]) + }}

diff --git a/print/templates/reports/receipt/index.js b/print/templates/reports/receipt/receipt.js similarity index 82% rename from print/templates/reports/receipt/index.js rename to print/templates/reports/receipt/receipt.js index 93fdad6d5..09f5d5b5d 100755 --- a/print/templates/reports/receipt/index.js +++ b/print/templates/reports/receipt/receipt.js @@ -1,6 +1,8 @@ const strftime = require('strftime'); const db = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); +const Component = require(`${appPath}/lib/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); module.exports = { name: 'receipt', @@ -46,11 +48,14 @@ module.exports = { FROM receipt r JOIN client c ON c.id = r.clientFk WHERE r.id = ?`, [receiptId]); - } - /* dated: () => { + }, + dated: () => { return strftime('%d-%m-%Y', new Date()); - }, */ + }, + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() }, - template: '
{{client}}
', props: ['userId', 'receiptId'] }; diff --git a/print/templates/reports/report-footer/assets/css/index.js b/print/templates/reports/report-footer/assets/css/index.js deleted file mode 100644 index c44219258..000000000 --- a/print/templates/reports/report-footer/assets/css/index.js +++ /dev/null @@ -1,6 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${__dirname}/style.css`, - `${appPath}/common/css/misc.css`]) - .mergeStyles(); diff --git a/print/templates/reports/report-footer/locale.js b/print/templates/reports/report-footer/locale.js deleted file mode 100644 index bf564c731..000000000 --- a/print/templates/reports/report-footer/locale.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - messages: { - es: { - numPages: 'Página {{page}} de {{pages}}', - law: { - phytosanitary: 'VERDNATURA LEVANTE SL - Pasaporte Fitosanitario R.P. Generalitat Valenciana - Nº Comerciante: ES17462130', - privacy: `En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, - le comunicamos que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., - pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo - por escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación.`, - } - }, - fr: { - numPages: 'Page {{page}} de {{pages}}', - law: { - phytosanitary: `VERDNATURA LEVANTE SL - Passeport Phytosanitaire R.P. Generalitat Valenciana - Numéro d'opérateur: ES17462130`, - privacy: `Conformément aux dispositions de la loi organique 15/1999 sur la protection des données personnelles, nous vous informons que les données personnelles que vous fournissez seront incluses dans des dossiers. - VERDNATURA LEVANTE S.L., vous pouvez à tout moment, exercer les droits d'accès, de rectification, d'annulation et d'opposition, en communiquant par écrit au siège social de la société. Le dossier a pour objet la gestion administrative, la comptabilité et la facturation.`, - } - }, - pt: { - numPages: 'Página {{page}} de {{pages}}', - law: { - phytosanitary: 'VERDNATURA LEVANTE S.L - Passaporte Fitossanitário R.P. Generalitat Valenciana - Nº Comerciante: ES17462130', - privacy: `Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados de Carácter Pessoal, comunicamos que os - dados pessoais que facilite se incluirão nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento - exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando por escrito ao domicílio social da entidade. - A finalidade do ficheiro é a gestão administrativa, contabilidade e facturação.`, - } - }, - }, -}; diff --git a/print/templates/reports/report-header/assets/css/index.js b/print/templates/reports/report-header/assets/css/index.js deleted file mode 100644 index c321a3fe7..000000000 --- a/print/templates/reports/report-header/assets/css/index.js +++ /dev/null @@ -1,4 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([`${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/reports/report-header/locale.js b/print/templates/reports/report-header/locale.js deleted file mode 100644 index 7b3b9f38e..000000000 --- a/print/templates/reports/report-header/locale.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - messages: { - es: { - company: { - fiscalAddress: 'VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla · www.verdnatura.es · clientes@verdnatura.es', - registry: `CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, Folio 160, sección 8, Hoja V 102076`, - } - }, - pt: { - company: { - fiscalAddress: 'VERDNATURA LEVANTE S.L., B97367486 Avda. Espioca, 100, 46460 Silla - www.verdnatura.es - clientes@verdnatura.es', - registry: `CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, Folio 160, Sección 8, Hoja V 102076`, - } - }, - }, -}; diff --git a/print/templates/reports/rpt-claim-pickup-order/assets/css/index.js b/print/templates/reports/rpt-claim-pickup-order/assets/css/index.js deleted file mode 100644 index 515dea750..000000000 --- a/print/templates/reports/rpt-claim-pickup-order/assets/css/index.js +++ /dev/null @@ -1,8 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/report.css`, - `${appPath}/common/css/misc.css`, - `${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/reports/rpt-claim-pickup-order/locale.js b/print/templates/reports/rpt-claim-pickup-order/locale.js deleted file mode 100644 index e15bd28c1..000000000 --- a/print/templates/reports/rpt-claim-pickup-order/locale.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - messages: { - es: { - title: 'Ord. recogida', - claimId: 'Reclamación', - clientId: 'Cliente', - date: 'Fecha', - clientData: 'Dirección de recogida', - quantity: 'Cantidad', - claims: 'Reclama', - reference: 'Referencia', - concept: 'Concepto', - clientSignature: 'Firma del cliente', - claim: 'Reclamación {0}', - sections: { - agency: { - description: `Para agilizar tu recogida, por favor, pónte en contacto con la oficina de integrados.
- Tlf: 96 166 77 88 - Ana Gómez (Ext. 2133) (agomezf@integra2.es) ` - } - } - }, - }, -}; diff --git a/print/templates/reports/rpt-delivery-note/assets/css/index.js b/print/templates/reports/rpt-delivery-note/assets/css/index.js deleted file mode 100644 index 515dea750..000000000 --- a/print/templates/reports/rpt-delivery-note/assets/css/index.js +++ /dev/null @@ -1,8 +0,0 @@ -const CssReader = require(`${appPath}/lib/cssReader`); - -module.exports = new CssReader([ - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/report.css`, - `${appPath}/common/css/misc.css`, - `${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/reports/rpt-delivery-note/locale.js b/print/templates/reports/rpt-delivery-note/locale.js deleted file mode 100644 index c637d9977..000000000 --- a/print/templates/reports/rpt-delivery-note/locale.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - messages: { - es: { - title: 'Albarán', - ticketId: 'Albarán', - clientId: 'Cliente', - deliveryAddress: 'Dirección de entrega', - fiscalData: 'Datos fiscales', - saleLines: 'Líneas de pedido', - date: 'Fecha', - reference: 'Ref.', - quantity: 'Cant.', - concept: 'Concepto', - price: 'PVP/u', - discount: 'Dto.', - vat: 'IVA', - amount: 'Importe', - type: 'Tipo', - taxBase: 'Base imp.', - tax: 'Tasa', - fee: 'Cuota', - total: 'Total', - subtotal: 'Subtotal', - taxBreakdown: 'Desglose impositivo', - packagings: 'Cubos y embalajes', - services: 'Servicios', - vatType: 'Tipo de IVA', - digitalSignature: 'Firma digital', - ticket: 'Albarán {0}' - }, - }, -}; diff --git a/print/templates/reports/rpt-sepa-core/locale/fr.yml b/print/templates/reports/rpt-sepa-core/locale/fr.yml new file mode 100644 index 000000000..333472def --- /dev/null +++ b/print/templates/reports/rpt-sepa-core/locale/fr.yml @@ -0,0 +1,38 @@ +{ + title: 'Autorisation pour débit', + description: `Mediante la firma de esta orden de domiciliación, el deudor autoriza (A) al acreedor a enviar instrucciones + a la entidad del deudor para adeudar su cuenta y (B) a la entidad para efectuar los adeudos en su cuenta siguiendo las + instrucciones del acreedor.Como parte de sus derechos, el deudor está legitimado al reembolso por su entidad en los + términos y condiciones del contrato suscrito con la misma. La solicitud de reembolso deberá efectuarse dentro de las + ocho semanas que adeudo en cuenta. Puede obtener información adicional sobre sus derechos en su entidad financiera.`, + documentCopy: `Debe llevar a su entidad Bancaria una copia + del documento firmado para que lo registre y evitar la devolución.`, + mandatoryFields: `TODOS LOS CAMPOS HAN DE SER CUMPLIMENTADOS OBLIGATORIAMENTE.`, + sendOrder: `UNA VEZ FIRMADA ESTA ORDEN DE DOMICILIACIÓN DEBE SER ENVIADA AL ACREEDOR PARA SU CUSTODIA Y ES RECOMENDABLE FACILITAR UNA COPIA A SU ENTIDAD BANCARIA.`, + supplier: { + toCompleteBySupplier: 'A cumplimentar por el acreedor', + orderReference: 'Referencia de la orden de domiciliación', + identifier: 'Identificador del acreedor', + name: 'Nombre del acreedor', + street: 'Dirección', + location: 'CP - Población - Provincia', + country: 'País' + }, + client: { + toCompleteByClient: 'A cumplimentar por el deudor', + name: 'Nombre del deudor/es', + street: 'Dirección del deudor', + location: 'CP - Población - Provincia', + country: 'País del deudor', + swift: 'Swift BIC', + accountNumber: 'Número de cuenta - IBAN', + accountHolder: '(Titular/es de la cuenta de cargo)', + accountNumberFormat: 'En Francia el IBAN consta de 27 posiciones comenzando siempre por FR', + paymentType: 'Tipo de pago', + recurrent: 'Recurrente', + unique: 'Único', + signLocation: 'Fecha - Localidad', + sign: 'Firma del deudor y sello', + }, + order: 'Orden de domiciliación', +} \ No newline at end of file From a2ea532fc18225b6ad2ff9a469eb9cad72f03b8a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 31 Oct 2019 12:43:04 +0100 Subject: [PATCH 04/18] refactor --- loopback/server/boot/print.js | 2 +- print/boot.js | 57 ++ print/config/print.json | 1 + print/core/component.js | 25 +- .../email-footer/assets/css/import.js | 8 + .../components/email-footer/email-footer.html | 12 +- .../components/email-footer/locale/fr.yml | 4 +- .../email-header/assets/css/import.js | 8 + .../components/email-header/email-header.html | 2 +- .../components/email-header/email-header.js | 2 +- .../report-footer/assets/css/import.js} | 4 +- .../report-footer/report-footer.html | 4 +- .../components/report-footer/report-footer.js | 4 - .../report-header/assets/css/import.js} | 4 +- .../report-header/report-header.html | 2 +- .../components/report-header/report-header.js | 17 +- print/core/database.js | 7 +- print/core/directives/index.js | 1 + print/core/directives/pin.js | 12 + print/core/email.js | 174 +----- print/core/exceptions/userException.js | 12 - print/core/filters/currency.js | 12 +- print/core/filters/date.js | 6 + print/core/filters/index.js | 3 + print/core/filters/percentage.js | 11 + print/core/filters/translate.js | 0 print/core/mixins/image-src.js | 11 +- print/core/mixins/index.js | 2 + print/core/mixins/prop-validator.js | 26 + print/core/mixins/user-locale.js | 24 + print/core/report.js | 104 +--- print/core/router.js | 93 +-- print/core/{cssReader.js => stylesheet.js} | 4 +- print/package-lock.json | 556 +++++++++++++----- print/package.json | 11 +- print/server.js | 19 - .../claim-pickup-order/assets/css/email.css | 44 -- .../claim-pickup-order/assets/css/import.js | 7 + .../claim-pickup-order/assets/css/layout.css | 233 -------- .../claim-pickup-order/assets/css/misc.css | 47 -- .../email/claim-pickup-order/attachments.json | 4 +- .../claim-pickup-order.html | 13 +- .../claim-pickup-order/claim-pickup-order.js | 4 +- .../email/client-welcome/assets/css/email.css | 1 - .../email/client-welcome/assets/css/import.js | 7 + .../client-welcome/assets/css/layout.css | 233 -------- .../email/client-welcome/assets/css/misc.css | 47 -- .../email/client-welcome/client-welcome.html | 7 +- .../email/client-welcome/client-welcome.js | 32 +- .../email/delivery-note/assets/css/email.css | 44 -- .../email/delivery-note/assets/css/import.js | 7 + .../email/delivery-note/assets/css/layout.css | 233 -------- .../email/delivery-note/assets/css/misc.css | 47 -- .../email/delivery-note/attachments.json | 5 +- .../email/delivery-note/delivery-note.html | 6 + .../email/delivery-note/delivery-note.js | 35 +- .../assets/css/import.js} | 4 +- .../claim-pickup-order/assets/css/layout.css | 233 -------- .../claim-pickup-order/assets/css/misc.css | 47 -- .../claim-pickup-order/assets/css/report.css | 14 - .../claim-pickup-order.html | 31 +- .../claim-pickup-order/claim-pickup-order.js | 40 +- .../delivery-note/assets/css/import.js | 8 + .../reports/delivery-note/delivery-note.html | 42 +- .../reports/delivery-note/delivery-note.js | 128 ++-- .../reports/item-label/assets/css/import.js | 8 + .../assets/css/style.css | 0 .../index.html => item-label/item-label.html} | 4 +- .../reports/item-label/item-label.js | 87 +++ .../options.json | 0 .../reports/receipt/assets/css/import.js | 8 + .../reports/receipt/assets/css/layout.css | 1 - .../reports/receipt/assets/css/misc.css | 1 - .../reports/receipt/assets/css/report.css | 1 - print/templates/reports/receipt/receipt.html | 16 +- print/templates/reports/receipt/receipt.js | 33 +- .../templates/reports/rpt-item-label/index.js | 83 --- .../reports/rpt-item-label/locale.js | 24 - .../templates/reports/rpt-sepa-core/locale.js | 81 --- .../reports/sepa-core/assets/css/import.js | 8 + .../assets/css/style.css | 0 .../templates/reports/sepa-core/locale/es.yml | 38 ++ .../locale/fr.yml | 0 .../templates/reports/sepa-core/locale/pt.yml | 39 ++ .../index.html => sepa-core/sepa-core.html} | 0 .../index.js => sepa-core/sepa-core.js} | 39 +- 86 files changed, 1091 insertions(+), 2227 deletions(-) create mode 100644 print/boot.js create mode 100644 print/core/components/email-footer/assets/css/import.js create mode 100644 print/core/components/email-header/assets/css/import.js rename print/{templates/reports/rpt-item-label/assets/css/index.js => core/components/report-footer/assets/css/import.js} (64%) rename print/{templates/reports/rpt-sepa-core/assets/css/index.js => core/components/report-header/assets/css/import.js} (64%) create mode 100644 print/core/directives/pin.js delete mode 100644 print/core/exceptions/userException.js create mode 100644 print/core/filters/date.js create mode 100644 print/core/filters/percentage.js delete mode 100644 print/core/filters/translate.js create mode 100644 print/core/mixins/prop-validator.js create mode 100644 print/core/mixins/user-locale.js rename print/core/{cssReader.js => stylesheet.js} (85%) delete mode 100644 print/server.js delete mode 100644 print/templates/email/claim-pickup-order/assets/css/email.css create mode 100644 print/templates/email/claim-pickup-order/assets/css/import.js delete mode 100644 print/templates/email/claim-pickup-order/assets/css/layout.css delete mode 100644 print/templates/email/claim-pickup-order/assets/css/misc.css delete mode 120000 print/templates/email/client-welcome/assets/css/email.css create mode 100644 print/templates/email/client-welcome/assets/css/import.js delete mode 100644 print/templates/email/client-welcome/assets/css/layout.css delete mode 100644 print/templates/email/client-welcome/assets/css/misc.css delete mode 100644 print/templates/email/delivery-note/assets/css/email.css create mode 100644 print/templates/email/delivery-note/assets/css/import.js delete mode 100644 print/templates/email/delivery-note/assets/css/layout.css delete mode 100644 print/templates/email/delivery-note/assets/css/misc.css rename print/templates/reports/{delivery-note/assets/css/index.js => claim-pickup-order/assets/css/import.js} (64%) delete mode 100644 print/templates/reports/claim-pickup-order/assets/css/layout.css delete mode 100644 print/templates/reports/claim-pickup-order/assets/css/misc.css delete mode 100644 print/templates/reports/claim-pickup-order/assets/css/report.css create mode 100644 print/templates/reports/delivery-note/assets/css/import.js create mode 100644 print/templates/reports/item-label/assets/css/import.js rename print/templates/reports/{rpt-item-label => item-label}/assets/css/style.css (100%) rename print/templates/reports/{rpt-item-label/index.html => item-label/item-label.html} (95%) create mode 100755 print/templates/reports/item-label/item-label.js rename print/templates/reports/{rpt-item-label => item-label}/options.json (100%) create mode 100644 print/templates/reports/receipt/assets/css/import.js delete mode 120000 print/templates/reports/receipt/assets/css/layout.css delete mode 120000 print/templates/reports/receipt/assets/css/misc.css delete mode 120000 print/templates/reports/receipt/assets/css/report.css delete mode 100755 print/templates/reports/rpt-item-label/index.js delete mode 100644 print/templates/reports/rpt-item-label/locale.js delete mode 100644 print/templates/reports/rpt-sepa-core/locale.js create mode 100644 print/templates/reports/sepa-core/assets/css/import.js rename print/templates/reports/{rpt-sepa-core => sepa-core}/assets/css/style.css (100%) create mode 100644 print/templates/reports/sepa-core/locale/es.yml rename print/templates/reports/{rpt-sepa-core => sepa-core}/locale/fr.yml (100%) create mode 100644 print/templates/reports/sepa-core/locale/pt.yml rename print/templates/reports/{rpt-sepa-core/index.html => sepa-core/sepa-core.html} (100%) rename print/templates/reports/{rpt-sepa-core/index.js => sepa-core/sepa-core.js} (68%) diff --git a/loopback/server/boot/print.js b/loopback/server/boot/print.js index 4a4996d2c..0f6af4d56 100644 --- a/loopback/server/boot/print.js +++ b/loopback/server/boot/print.js @@ -1,3 +1,3 @@ module.exports = function(app) { - require('../../../print/server.js')(app); + require('../../../print/boot.js')(app); }; diff --git a/print/boot.js b/print/boot.js new file mode 100644 index 000000000..7f9761478 --- /dev/null +++ b/print/boot.js @@ -0,0 +1,57 @@ +const express = require('express'); +const path = require('path'); +const fs = require('fs'); + +const templatesPath = path.resolve(__dirname, './templates'); +const componentsPath = path.resolve(__dirname, './core/components'); + +module.exports = app => { + global.appPath = __dirname; + + process.env.OPENSSL_CONF = '/etc/ssl/'; + + // Extended locale intl polyfill + const IntlPolyfill = require('intl'); + Intl.NumberFormat = IntlPolyfill.NumberFormat; + Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat; + + // Init database instance + require('./core/database').init(); + // Init SMTP Instance + require('./core/smtp').init(); + // + require('./core/mixins'); + require('./core/filters'); + require('./core/directives'); + // Init router + require('./core/router')(app); + + /** + * Serve component static files + */ + const componentsDir = fs.readdirSync(componentsPath); + componentsDir.forEach(componentName => { + const componentDir = path.join(componentsPath, '/', componentName); + const assetsDir = `${componentDir}/assets`; + + app.use(`/api/assets/${componentName}`, express.static(assetsDir)); + }); + + /** + * Serve static files + */ + const templatesDir = fs.readdirSync(templatesPath); + templatesDir.forEach(directory => { + const templateTypeDir = path.join(templatesPath, '/', directory); + const templates = fs.readdirSync(templateTypeDir); + + templates.forEach(templateName => { + const templateDir = path.join(templatesPath, '/', directory, '/', templateName); + const assetsDir = `${templateDir}/assets`; + + app.use(`/api/assets/${templateName}`, express.static(assetsDir)); + }); + }); +}; + + diff --git a/print/config/print.json b/print/config/print.json index 6a8d8b112..a075feed7 100755 --- a/print/config/print.json +++ b/print/config/print.json @@ -1,5 +1,6 @@ { "app": { + "host": "http://localhost:5000", "port": 3000, "senderMail": "nocontestar@verdnatura.es", "senderName": "Verdnatura" diff --git a/print/core/component.js b/print/core/component.js index 26490c9e3..836b8c9d9 100644 --- a/print/core/component.js +++ b/print/core/component.js @@ -7,7 +7,6 @@ const fs = require('fs'); const yaml = require('js-yaml'); const juice = require('juice'); const path = require('path'); - const config = require('./config'); class Component { @@ -27,6 +26,13 @@ class Component { } get locale() { + if (!this._locale) + this.getLocale(); + + return this._locale; + } + + getLocale() { const mergedLocale = {messages: {}}; const localePath = path.resolve(__dirname, `${this.path}/locale`); @@ -43,7 +49,7 @@ class Component { mergedLocale.messages[localeName] = jsonLocale; }); - return mergedLocale; + this._locale = mergedLocale; } get stylesheet() { @@ -53,15 +59,7 @@ class Component { if (!fs.existsSync(stylePath)) return mergedStyles; - const styleDir = fs.readdirSync(stylePath); - styleDir.forEach(fileName => { - const fullPath = path.join(stylePath, '/', fileName); - const contents = fs.readFileSync(fullPath, 'utf8'); - - mergedStyles += contents; - }); - - return mergedStyles; + return require(`${stylePath}/import`); } get attachments() { @@ -75,8 +73,11 @@ class Component { } build() { - const component = require(`${this.path}/${this.name}`); + const fullPath = path.resolve(__dirname, this.path); + if (!fs.existsSync(fullPath)) + throw new Error(`Sample "${this.name}" not found`); + const component = require(`${this.path}/${this.name}`); component.i18n = this.locale; component.attachments = this.attachments; component.template = juice.inlineContent(this.template, this.stylesheet, { diff --git a/print/core/components/email-footer/assets/css/import.js b/print/core/components/email-footer/assets/css/import.js new file mode 100644 index 000000000..cb7a45205 --- /dev/null +++ b/print/core/components/email-footer/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/core/components/email-footer/email-footer.html b/print/core/components/email-footer/email-footer.html index ae013691f..61f97257a 100644 --- a/print/core/components/email-footer/email-footer.html +++ b/print/core/components/email-footer/email-footer.html @@ -19,22 +19,22 @@
- Facebook + Facebook - Twitter + Twitter - Youtube + Youtube - Pinterest + Pinterest - Instagram + Instagram - Linkedin + Linkedin
diff --git a/print/core/components/email-footer/locale/fr.yml b/print/core/components/email-footer/locale/fr.yml index 38262a160..c62ca57a0 100644 --- a/print/core/components/email-footer/locale/fr.yml +++ b/print/core/components/email-footer/locale/fr.yml @@ -4,7 +4,7 @@ buttons: privacy: fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla · www.verdnatura.es · clientes@verdnatura.es - disclaimer: '- AVISO - Ce message est privé et confidentiel et doit être utilisé.exclusivamente + disclaimer: '- AVIS - Ce message est privé et confidentiel et doit être utilisé.exclusivamente por la persona destinataria del mismo. Si has recibido este mensajepor error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier documentoadjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad @@ -12,7 +12,7 @@ privacy: no se haceresponsable de los cambios, alteraciones, errores u omisiones que pudieran hacerse al mensaje una vez enviado.' law: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de - Datos de Carácter Personal,te comunicamos que los datos personales que facilites + Datos de Carácter Personal, te comunicamos que los datos personales que facilites se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L.,pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo porescrito al domicilio social de la entidad. La finalidad del fichero diff --git a/print/core/components/email-header/assets/css/import.js b/print/core/components/email-header/assets/css/import.js new file mode 100644 index 000000000..cb7a45205 --- /dev/null +++ b/print/core/components/email-header/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/core/components/email-header/email-header.html b/print/core/components/email-header/email-header.html index f2b5a90cf..9b55d7139 100644 --- a/print/core/components/email-header/email-header.html +++ b/print/core/components/email-header/email-header.html @@ -1,5 +1,5 @@
- VerdNatura + VerdNatura
diff --git a/print/core/components/email-header/email-header.js b/print/core/components/email-header/email-header.js index a1c73ee60..257770cad 100755 --- a/print/core/components/email-header/email-header.js +++ b/print/core/components/email-header/email-header.js @@ -1,4 +1,4 @@ module.exports = { name: 'email-header', - props: ['isPreview'] + props: ['locale'] }; diff --git a/print/templates/reports/rpt-item-label/assets/css/index.js b/print/core/components/report-footer/assets/css/import.js similarity index 64% rename from print/templates/reports/rpt-item-label/assets/css/index.js rename to print/core/components/report-footer/assets/css/import.js index 515dea750..a2a9334cb 100644 --- a/print/templates/reports/rpt-item-label/assets/css/index.js +++ b/print/core/components/report-footer/assets/css/import.js @@ -1,6 +1,6 @@ -const CssReader = require(`${appPath}/lib/cssReader`); +const Stylesheet = require(`${appPath}/core/stylesheet`); -module.exports = new CssReader([ +module.exports = new Stylesheet([ `${appPath}/common/css/layout.css`, `${appPath}/common/css/report.css`, `${appPath}/common/css/misc.css`, diff --git a/print/core/components/report-footer/report-footer.html b/print/core/components/report-footer/report-footer.html index 11b314af0..af433676f 100644 --- a/print/core/components/report-footer/report-footer.html +++ b/print/core/components/report-footer/report-footer.html @@ -1,7 +1,7 @@