diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html index cea44f88b..e0caafb43 100644 --- a/modules/client/front/sample/create/index.html +++ b/modules/client/front/sample/create/index.html @@ -8,9 +8,13 @@
- + + + + - { - if (res.data) { - let dialog = this.$scope.showPreview.element; - let body = dialog.querySelector('tpl-body'); - let scroll = dialog.querySelector('div:first-child'); + let dialog = this.$scope.showPreview.element; + let body = dialog.querySelector('tpl-body'); + let scroll = dialog.querySelector('div:first-child'); - body.innerHTML = res.data; - this.$scope.showPreview.show(); + body.innerHTML = res.data; + this.$scope.showPreview.show(); - scroll.scrollTop = 0; - } + scroll.scrollTop = 0; }); } @@ -62,24 +78,34 @@ class Controller { sendSample() { let sampleType = this.$scope.sampleType.selection; - let params = {clientFk: this.$stateParams.id}; + let params = { + clientId: this.$stateParams.id, + recipient: this.clientSample.recipient + }; + + if (!sampleType) + return this.vnApp.showError(this.$translate.instant('Choose a sample')); + + if (sampleType.hasCompany && !this.clientSample.companyFk) + return this.vnApp.showError(this.$translate.instant('Choose a company')); if (sampleType.hasCompany) - params.companyFk = this.clientSample.companyFk; + params.companyId = this.clientSample.companyFk; - - let query = `/api/email/${sampleType.code}?${this.jsonToQuery(params)}`; - this.$http.post(query).then(res => { - if (res) { - this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); - this.$state.go('client.card.sample.index'); - } + const serializedParams = this.$httpParamSerializer(params); + const query = `/api/email/${sampleType.code}?${serializedParams}`; + this.$http.get(query).then(res => { + this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); + this.$state.go('client.card.sample.index'); }); } } -Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; +Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate', '$httpParamSerializer']; ngModule.component('vnClientSampleCreate', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + client: '<' + } }); diff --git a/print/templates/email/delivery-note/delivery-note.html b/print/templates/email/delivery-note/delivery-note.html index 28c3881cb..e9cd62496 100644 --- a/print/templates/email/delivery-note/delivery-note.html +++ b/print/templates/email/delivery-note/delivery-note.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -26,7 +29,10 @@
- + + diff --git a/print/templates/email/delivery-note/delivery-note.js b/print/templates/email/delivery-note/delivery-note.js index efb46cf56..64839b8e0 100755 --- a/print/templates/email/delivery-note/delivery-note.js +++ b/print/templates/email/delivery-note/delivery-note.js @@ -1,29 +1,16 @@ const Component = require(`${appPath}/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); -const db = require(`${appPath}/core/database`); module.exports = { name: 'delivery-note', - methods: { - fetchTicket(ticketId) { - return db.findOne(` - SELECT - t.id, - u.lang locale, - c.email recipient - FROM ticket t - JOIN client c ON c.id = t.clientFk - JOIN account.user u ON u.id = c.id - WHERE t.id = ?`, [ticketId]); - }, - }, components: { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, props: { ticketId: { + type: String, required: true } } diff --git a/print/templates/email/driver-route/assets/css/index.js b/print/templates/email/driver-route/assets/css/import.js similarity index 60% rename from print/templates/email/driver-route/assets/css/index.js rename to print/templates/email/driver-route/assets/css/import.js index 321c632dc..e88633a52 100644 --- a/print/templates/email/driver-route/assets/css/index.js +++ b/print/templates/email/driver-route/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/email.css`, `${appPath}/common/css/misc.css`]) diff --git a/print/templates/email/driver-route/index.html b/print/templates/email/driver-route/driver-route.html similarity index 66% rename from print/templates/email/driver-route/index.html rename to print/templates/email/driver-route/driver-route.html index 45dbd3e1f..1288a78c4 100644 --- a/print/templates/email/driver-route/index.html +++ b/print/templates/email/driver-route/driver-route.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -17,7 +20,10 @@

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

- + +
diff --git a/print/templates/email/driver-route/driver-route.js b/print/templates/email/driver-route/driver-route.js new file mode 100755 index 000000000..de1dd9c39 --- /dev/null +++ b/print/templates/email/driver-route/driver-route.js @@ -0,0 +1,17 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'driver-route', + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: { + routeId: { + type: String, + required: true + } + } +}; diff --git a/print/templates/email/driver-route/index.js b/print/templates/email/driver-route/index.js deleted file mode 100755 index 2a142856f..000000000 --- a/print/templates/email/driver-route/index.js +++ /dev/null @@ -1,54 +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: 'driver-route', - async asyncData(ctx, params) { - const promises = []; - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.routeFk) - throw new UserException('No route id specified'); - - promises.push(reportEngine.toPdf('rpt-route', ctx)); - promises.push(this.methods.fetchRoute(params.routeFk)); - - return Promise.all(promises).then(result => { - const stream = result[0]; - const [[route]] = result[1]; - - Object.assign(data, route); - Object.assign(data, {attachments: [{filename: 'driver-route.pdf', content: stream}]}); - - return data; - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - methods: { - fetchRoute(routeFk) { - return database.pool.query(` - SELECT - u.id, - u.lang AS locale, - mu.email AS recipient - FROM route r - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN account.user u ON u.id = w.userFk - LEFT JOIN account.emailUser mu ON mu.userFk = u.id - WHERE r.id = ?`, [routeFk]); - }, - }, - components: { - emailHeader, - emailFooter, - }, -}; diff --git a/print/templates/email/driver-route/locale.js b/print/templates/email/driver-route/locale.js deleted file mode 100644 index 9255f8f97..000000000 --- a/print/templates/email/driver-route/locale.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Hoja de ruta', - title: 'Hoja de ruta', - description: { - instructions: 'Adjuntamos tu hoja de ruta.' - }, - }, - }, -}; diff --git a/print/templates/email/driver-route/locale/es.yml b/print/templates/email/driver-route/locale/es.yml new file mode 100644 index 000000000..f5ed12e5d --- /dev/null +++ b/print/templates/email/driver-route/locale/es.yml @@ -0,0 +1,4 @@ +subject: Hoja de ruta +title: Hoja de ruta +description: + instructions: Adjuntamos tu hoja de ruta. \ No newline at end of file diff --git a/print/templates/email/letter-debtor-nd/assets/css/index.js b/print/templates/email/letter-debtor-nd/assets/css/import.js similarity index 60% rename from print/templates/email/letter-debtor-nd/assets/css/index.js rename to print/templates/email/letter-debtor-nd/assets/css/import.js index 321c632dc..e88633a52 100644 --- a/print/templates/email/letter-debtor-nd/assets/css/index.js +++ b/print/templates/email/letter-debtor-nd/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/email.css`, `${appPath}/common/css/misc.css`]) diff --git a/print/templates/email/letter-debtor-nd/attachments.json b/print/templates/email/letter-debtor-nd/attachments.json new file mode 100644 index 000000000..e56f31de6 --- /dev/null +++ b/print/templates/email/letter-debtor-nd/attachments.json @@ -0,0 +1 @@ +[{"filename": "letter-debtor.pdf"}] \ No newline at end of file diff --git a/print/templates/email/letter-debtor-nd/index.js b/print/templates/email/letter-debtor-nd/index.js deleted file mode 100755 index b68e9cc93..000000000 --- a/print/templates/email/letter-debtor-nd/index.js +++ /dev/null @@ -1,58 +0,0 @@ -const database = require(`${appPath}/lib/database`); -const reportEngine = require(`${appPath}/lib/reportEngine.js`); -const UserException = require(`${appPath}/lib/exceptions/userException`); - -module.exports = { - name: 'letter-debtor-nd', - async asyncData(ctx, params) { - const promises = []; - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.clientFk) - throw new UserException('No client id specified'); - - if (!params.companyFk) - throw new UserException('No company id specified'); - - promises.push(reportEngine.toPdf('rpt-letter-debtor', ctx)); - promises.push(this.methods.fetchClient(params.clientFk, params.companyFk)); - - return Promise.all(promises).then(result => { - const stream = result[0]; - const [[client]] = result[1]; - - Object.assign(data, client); - Object.assign(data, {attachments: [{filename: 'rpt-letter-debtor.pdf', content: stream}]}); - - return data; - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - methods: { - fetchClient(clientFk, companyFk) { - return database.pool.query(` - SELECT - u.lang locale, - c.email recipient, - c.dueDay, - c.iban, - sa.iban, - be.name AS bankName - FROM client c - JOIN company AS cny - JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk - JOIN bankEntity be ON be.id = sa.bankEntityFk - JOIN account.user u ON u.id = c.id - WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]); - }, - }, - components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), - }, -}; diff --git a/print/templates/email/letter-debtor-nd/index.html b/print/templates/email/letter-debtor-nd/letter-debtor-nd.html similarity index 74% rename from print/templates/email/letter-debtor-nd/index.html rename to print/templates/email/letter-debtor-nd/letter-debtor-nd.html index 01247ced4..995af59b9 100644 --- a/print/templates/email/letter-debtor-nd/index.html +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -42,16 +45,23 @@

-
{{bankName}}
-
{{iban}}
+
{{debtor.bankName}}
+
{{debtor.iban}}
{{$t('transferAccount') }}

+ +
+ Ver PDF +
- + +
diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js new file mode 100755 index 000000000..38130ff6f --- /dev/null +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js @@ -0,0 +1,41 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const db = require(`${appPath}/core/database`); + +module.exports = { + name: 'letter-debtor-nd', + async serverPrefetch() { + this.debtor = await this.fetchDebtor(this.clientId, this.companyId); + + if (!this.debtor) + throw new Error('Something went wrong'); + }, + methods: { + fetchDebtor(clientId, companyId) { + return db.findOne(` + SELECT + c.dueDay, + c.iban, + sa.iban, + be.name AS bankName + FROM client c + JOIN company AS cny + JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk + JOIN bankEntity be ON be.id = sa.bankEntityFk + WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]); + } + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: { + clientId: { + required: true + }, + companyId: { + required: true + } + } +}; diff --git a/print/templates/email/letter-debtor-nd/locale.js b/print/templates/email/letter-debtor-nd/locale.js deleted file mode 100644 index f15437a72..000000000 --- a/print/templates/email/letter-debtor-nd/locale.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Reiteración de aviso por saldo deudor', - title: 'Aviso reiterado', - sections: { - introduction: { - title: 'Estimado cliente', - description: `Nos dirigimos a ti nuevamente para informarte que sigue - pendiente tu deuda con nuestra empresa, tal y como puedes comprobar en el extracto adjunto.`, - terms: `Dado que los plazos de pago acordados están ampliamente superados, no procede mayor dilación en la liquidación del importe adeudado.`, - }, - payMethod: { - description: 'Para ello dispones de las siguientes formas de pago', - options: [ - 'Pago online desde nuestra web.', - 'Ingreso o transferencia al número de cuenta que detallamos al pie de esta carta, indicando el número de cliente.', - ], - }, - legalAction: { - description: `En caso de no ser atendido este apremio de pago, nos veremos obligados - a iniciar las acciones legales que procedan, entre las que están`, - options: [ - 'Inclusión en ficheros negativos sobre solvencia patrimonial y crédito.', - 'Reclamación judicial.', - 'Cesión de deuda a una empresa de gestión de cobro.', - ], - }, - }, - contactPhone: 'Para consultas, puedes ponerte en contacto con nosotros en el 96 324 21 00.', - conclusion: 'En espera de tus noticias.
Gracias por tu atención.', - transferAccount: 'Datos para transferencia bancaria', - }, - }, -}; diff --git a/print/templates/email/letter-debtor-nd/locale/es.yml b/print/templates/email/letter-debtor-nd/locale/es.yml new file mode 100644 index 000000000..506c55dd6 --- /dev/null +++ b/print/templates/email/letter-debtor-nd/locale/es.yml @@ -0,0 +1,26 @@ +subject: Reiteración de aviso por saldo deudor +title: Aviso reiterado +sections: + introduction: + title: Estimado cliente + description: Nos dirigimos a ti nuevamente para informarte que sigue pendiente + tu deuda con nuestra empresa, tal y como puedes comprobar en el extracto adjunto. + terms: Dado que los plazos de pago acordados están ampliamente superados, no procede + mayor dilación en la liquidación del importe adeudado. + payMethod: + description: Para ello dispones de las siguientes formas de pago + options: + - Pago online desde nuestra web. + - Ingreso o transferencia al número de cuenta que detallamos al pie de esta carta, + indicando el número de cliente. + legalAction: + description: En caso de no ser atendido este apremio de pago, nos veremos obligados + a iniciar las acciones legales que procedan, entre las que están + options: + - Inclusión en ficheros negativos sobre solvencia patrimonial y crédito. + - Reclamación judicial. + - Cesión de deuda a una empresa de gestión de cobro. +contactPhone: Para consultas, puedes ponerte en contacto con nosotros en el 96 + 324 21 00. +conclusion: En espera de tus noticias.
Gracias por tu atención. +transferAccount: Datos para transferencia bancaria \ No newline at end of file diff --git a/print/templates/email/letter-debtor-st/assets/css/index.js b/print/templates/email/letter-debtor-st/assets/css/import.js similarity index 60% rename from print/templates/email/letter-debtor-st/assets/css/index.js rename to print/templates/email/letter-debtor-st/assets/css/import.js index 321c632dc..e88633a52 100644 --- a/print/templates/email/letter-debtor-st/assets/css/index.js +++ b/print/templates/email/letter-debtor-st/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/email.css`, `${appPath}/common/css/misc.css`]) diff --git a/print/templates/email/letter-debtor-st/attachments.json b/print/templates/email/letter-debtor-st/attachments.json new file mode 100644 index 000000000..e56f31de6 --- /dev/null +++ b/print/templates/email/letter-debtor-st/attachments.json @@ -0,0 +1 @@ +[{"filename": "letter-debtor.pdf"}] \ No newline at end of file diff --git a/print/templates/email/letter-debtor-st/index.js b/print/templates/email/letter-debtor-st/index.js deleted file mode 100755 index 8d6ca0362..000000000 --- a/print/templates/email/letter-debtor-st/index.js +++ /dev/null @@ -1,59 +0,0 @@ -const database = require(`${appPath}/lib/database`); -const reportEngine = require(`${appPath}/lib/reportEngine.js`); -const UserException = require(`${appPath}/lib/exceptions/userException`); - - -module.exports = { - name: 'letter-debtor-st', - async asyncData(ctx, params) { - const promises = []; - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.clientFk) - throw new UserException('No client id specified'); - - if (!params.companyFk) - throw new UserException('No company id specified'); - - promises.push(reportEngine.toPdf('rpt-letter-debtor', ctx)); - promises.push(this.methods.fetchClient(params.clientFk, params.companyFk)); - - return Promise.all(promises).then(result => { - const stream = result[0]; - const [[client]] = result[1]; - - Object.assign(data, client); - Object.assign(data, {attachments: [{filename: 'rpt-letter-debtor.pdf', content: stream}]}); - - return data; - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - methods: { - fetchClient(clientFk, companyFk) { - return database.pool.query(` - SELECT - u.lang locale, - c.email recipient, - c.dueDay, - c.iban, - sa.iban, - be.name AS bankName - FROM client c - JOIN company AS cny - JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk - JOIN bankEntity be ON be.id = sa.bankEntityFk - JOIN account.user u ON u.id = c.id - WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]); - } - }, - components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), - }, -}; diff --git a/print/templates/email/letter-debtor-st/index.html b/print/templates/email/letter-debtor-st/letter-debtor-st.html similarity index 71% rename from print/templates/email/letter-debtor-st/index.html rename to print/templates/email/letter-debtor-st/letter-debtor-st.html index 4f5ea17ac..1c50c177d 100644 --- a/print/templates/email/letter-debtor-st/index.html +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -25,8 +28,8 @@

-
{{bankName}}
-
{{iban}}
+
{{debtor.bankName}}
+
{{debtor.iban}}
{{$t('transferAccount') }}
@@ -34,7 +37,10 @@

- + +
diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js new file mode 100755 index 000000000..3109baedf --- /dev/null +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -0,0 +1,41 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const db = require(`${appPath}/core/database`); + +module.exports = { + name: 'letter-debtor-st', + async serverPrefetch() { + this.debtor = await this.fetchDebtor(this.clientId, this.companyId); + + if (!this.debtor) + throw new Error('Something went wrong'); + }, + methods: { + fetchDebtor(clientId, companyId) { + return db.findOne(` + SELECT + c.dueDay, + c.iban, + sa.iban, + be.name AS bankName + FROM client c + JOIN company AS cny + JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk + JOIN bankEntity be ON be.id = sa.bankEntityFk + WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]); + } + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: { + clientId: { + required: true + }, + companyId: { + required: true + } + } +}; diff --git a/print/templates/email/letter-debtor-st/locale.js b/print/templates/email/letter-debtor-st/locale.js deleted file mode 100644 index afee35288..000000000 --- a/print/templates/email/letter-debtor-st/locale.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Aviso inicial por saldo deudor', - title: 'Aviso inicial', - sections: { - introduction: { - title: 'Estimado cliente', - description: `Por el presente escrito te comunicamos que, según nuestros - datos contables, tu cuenta tiene un saldo pendiente de liquidar.`, - }, - }, - checkExtract: `Te solicitamos compruebes que el extracto adjunto corresponde con los datos de que dispones. - Nuestro departamento de administración te aclarará gustosamente cualquier duda que puedas tener, - e igualmente te facilitará cualquier documento que solicites.`, - checkValidData: `Si al comprobar los datos aportados resultaran correctos, - te rogamos procedas a regularizar tu situación.`, - payMethod: `Si no deseas desplazarte personalmente hasta nuestras oficinas, - puedes realizar el pago mediante transferencia bancaria a la cuenta que figura al pie del comunicado, - indicando tu número de cliente, o bien puedes realizar el pago online desde nuestra página web.`, - conclusion: 'De antemano te agradecemos tu amable colaboración.', - transferAccount: 'Datos para transferencia bancaria', - }, - }, -}; - - diff --git a/print/templates/email/letter-debtor-st/locale/es.yml b/print/templates/email/letter-debtor-st/locale/es.yml new file mode 100644 index 000000000..167301417 --- /dev/null +++ b/print/templates/email/letter-debtor-st/locale/es.yml @@ -0,0 +1,19 @@ +subject: Aviso inicial por saldo deudor +title: Aviso inicial +sections: + introduction: + title: Estimado cliente + description: Por el presente escrito te comunicamos que, según nuestros datos + contables, tu cuenta tiene un saldo pendiente de liquidar. +checkExtract: Te solicitamos compruebes que el extracto adjunto corresponde con los + datos de que dispones. Nuestro departamento de administración te aclarará gustosamente + cualquier duda que puedas tener, e igualmente te facilitará cualquier documento + que solicites. +checkValidData: Si al comprobar los datos aportados resultaran correctos, te rogamos + procedas a regularizar tu situación. +payMethod: Si no deseas desplazarte personalmente hasta nuestras oficinas, puedes + realizar el pago mediante transferencia bancaria a la cuenta que figura al pie del + comunicado, indicando tu número de cliente, o bien puedes realizar el pago online + desde nuestra página web. +conclusion: De antemano te agradecemos tu amable colaboración. +transferAccount: Datos para transferencia bancaria diff --git a/print/templates/email/payment-update/assets/css/index.js b/print/templates/email/payment-update/assets/css/import.js similarity index 60% rename from print/templates/email/payment-update/assets/css/index.js rename to print/templates/email/payment-update/assets/css/import.js index 321c632dc..e88633a52 100644 --- a/print/templates/email/payment-update/assets/css/index.js +++ b/print/templates/email/payment-update/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/email.css`, `${appPath}/common/css/misc.css`]) diff --git a/print/templates/email/payment-update/index.js b/print/templates/email/payment-update/index.js deleted file mode 100755 index 23218ec89..000000000 --- a/print/templates/email/payment-update/index.js +++ /dev/null @@ -1,52 +0,0 @@ -const database = require(`${appPath}/lib/database`); -const emailHeader = require('../email-header'); -const emailFooter = require('../email-footer'); -const UserException = require(`${appPath}/lib/exceptions/userException`); - -module.exports = { - name: 'payment-update', - 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; - }, - methods: { - fetchClient(clientFk) { - return database.pool.query(` - SELECT - u.lang locale, - c.email recipient, - c.dueDay, - c.iban, - pm.id payMethodFk, - pm.name payMethodName - FROM client c - JOIN payMethod pm ON pm.id = c.payMethodFk - JOIN account.user u ON u.id = c.id - WHERE c.id = ?`, [clientFk]); - }, - }, - computed: { - accountAddress: function() { - return this.iban.slice(-4); - }, - }, - components: { - 'email-header': emailHeader, - 'email-footer': emailFooter, - }, -}; diff --git a/print/templates/email/payment-update/locale.js b/print/templates/email/payment-update/locale.js deleted file mode 100644 index 891af2062..000000000 --- a/print/templates/email/payment-update/locale.js +++ /dev/null @@ -1,49 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Cambios en las condiciones de pago', - title: 'Cambios en las condiciones', - sections: { - introduction: { - title: 'Estimado cliente', - description: `Te informamos que han cambiado las condiciones de pago de tu cuenta. -
A continuación te indicamos las nuevas condiciones`, - }, - pay: { - method: 'Método de pago', - day: 'Día de pago', - dueDay: '{0} de cada mes', - cardImplicates: `Tu modo de pago actual implica que deberás abonar el - importe de los pedidos realizados en el mismo día para que se puedan enviar.`, - accountImplicates: `Tu modo de pago actual implica que se te pasará un cargo a la - cuenta terminada en "{0}" por el importe pendiente, al vencimiento establecido en las condiciones.`, - }, - }, - notifyAnError: `En el caso de detectar algún error en los datos indicados - o para cualquier aclaración, debes dirigirte a tu comercial.`, - }, - fr: { - subject: 'Changement des C.G.V', - title: 'Changement des C.G.V', - sections: { - introduction: { - title: 'Chèr client', - description: `Nous vous informons que les conditions de paiement ont changé. -
Voici les nouvelles conditions`, - }, - pay: { - method: 'Méthode de paiement', - day: 'Date paiement', - dueDay: '{0} de chaque mois', - cardImplicates: `Avec votre mode de règlement vous devrez - payer le montant des commandes avant son départ.`, - accountImplicates: `Avec ce mode de règlement nous vous passerons un prélèvement automatique dans votre compte bancaire - se termine dans "{0}" our le montant dû, au date à terme établi en nos conditions.`, - }, - }, - notifyAnError: `Pour tout renseignement contactez votre commercial.`, - }, - }, -}; - - diff --git a/print/templates/email/payment-update/locale/es.yml b/print/templates/email/payment-update/locale/es.yml new file mode 100644 index 000000000..464b52591 --- /dev/null +++ b/print/templates/email/payment-update/locale/es.yml @@ -0,0 +1,18 @@ +subject: Cambios en las condiciones de pago +title: Cambios en las condiciones +sections: + introduction: + title: Estimado cliente + description: Te informamos que han cambiado las condiciones de pago de tu cuenta. +
A continuación te indicamos las nuevas condiciones + pay: + method: Método de pago + day: Día de pago + dueDay: "{0} de cada mes" + cardImplicates: Tu modo de pago actual implica que deberás abonar el importe de + los pedidos realizados en el mismo día para que se puedan enviar. + accountImplicates: Tu modo de pago actual implica que se te pasará un cargo a + la cuenta terminada en '{0}' por el importe pendiente, al vencimiento + establecido en las condiciones. +notifyAnError: En el caso de detectar algún error en los datos indicados o para cualquier + aclaración, debes dirigirte a tu comercial. diff --git a/print/templates/email/payment-update/locale/fr.yml b/print/templates/email/payment-update/locale/fr.yml new file mode 100644 index 000000000..20fa7a5f4 --- /dev/null +++ b/print/templates/email/payment-update/locale/fr.yml @@ -0,0 +1,17 @@ +subject: Changement des C.G.V +title: Changement des C.G.V +sections: + introduction: + title: Chèr client + description: Nous vous informons que les conditions de paiement ont changé.
Voici + les nouvelles conditions + pay: + method: Méthode de paiement + day: Date paiement + dueDay: "{0} de chaque mois" + cardImplicates: Avec votre mode de règlement vous devrez payer le montant des + commandes avant son départ. + accountImplicates: Avec ce mode de règlement nous vous passerons un prélèvement + automatique dans votre compte bancaire se termine dans '{0}' + our le montant dû, au date à terme établi en nos conditions. +notifyAnError: Pour tout renseignement contactez votre commercial. diff --git a/print/templates/email/payment-update/index.html b/print/templates/email/payment-update/payment-update.html similarity index 60% rename from print/templates/email/payment-update/index.html rename to print/templates/email/payment-update/payment-update.html index fdc893662..54af66e8d 100644 --- a/print/templates/email/payment-update/index.html +++ b/print/templates/email/payment-update/payment-update.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -21,23 +24,26 @@

{{ $t('sections.pay.method') }}: - {{ payMethodName }} + {{client.payMethodName}}
-
+
{{ $t('sections.pay.day') }}: - {{ $t('sections.pay.dueDay', [dueDay]) }} + {{ $t('sections.pay.dueDay', [client.dueDay]) }}

-

-

+

+

{{ $t('sections.pay.cardImplicates') }}

{{ $t('notifyAnError') }}

- + +
diff --git a/print/templates/email/payment-update/payment-update.js b/print/templates/email/payment-update/payment-update.js new file mode 100755 index 000000000..944953151 --- /dev/null +++ b/print/templates/email/payment-update/payment-update.js @@ -0,0 +1,43 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const db = require(`${appPath}/core/database`); + +module.exports = { + name: 'payment-update', + async serverPrefetch() { + this.client = await this.fetchClient(this.clientId); + + if (!this.client) + throw new Error('Something went wrong'); + }, + computed: { + accountAddress: function() { + return this.iban.slice(-4); + }, + }, + methods: { + // Redmine #1854 Replace payMethodId by code + fetchClient(id) { + return db.findOne( + `SELECT + c.dueDay, + c.iban, + pm.id payMethodId, + pm.name payMethodName + FROM client c + JOIN payMethod pm ON pm.id = c.payMethodFk + JOIN account.user u ON u.id = c.id + WHERE c.id = :clientId`, {clientId: id}); + } + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: { + clientId: { + required: true + } + } +}; diff --git a/print/templates/email/printer-setup/assets/css/email.css b/print/templates/email/printer-setup/assets/css/email.css deleted file mode 100644 index a2b129057..000000000 --- a/print/templates/email/printer-setup/assets/css/email.css +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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/import.js b/print/templates/email/printer-setup/assets/css/import.js new file mode 100644 index 000000000..e88633a52 --- /dev/null +++ b/print/templates/email/printer-setup/assets/css/import.js @@ -0,0 +1,7 @@ +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`]) + .mergeStyles(); diff --git a/print/templates/email/printer-setup/assets/css/layout.css b/print/templates/email/printer-setup/assets/css/layout.css deleted file mode 100644 index 26b9bf8e0..000000000 --- a/print/templates/email/printer-setup/assets/css/layout.css +++ /dev/null @@ -1,233 +0,0 @@ -/** - * 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 deleted file mode 100644 index 093d5a974..000000000 --- a/print/templates/email/printer-setup/assets/css/misc.css +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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/options.json b/print/templates/email/printer-setup/options.json deleted file mode 100644 index e69de29bb..000000000 diff --git a/print/templates/email/printer-setup/printer-setup.html b/print/templates/email/printer-setup/printer-setup.html index 44f5e344a..642a6ab27 100644 --- a/print/templates/email/printer-setup/printer-setup.html +++ b/print/templates/email/printer-setup/printer-setup.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -48,7 +51,10 @@

- + +
diff --git a/print/templates/email/printer-setup/printer-setup.js b/print/templates/email/printer-setup/printer-setup.js index 6fa412301..78def7aea 100755 --- a/print/templates/email/printer-setup/printer-setup.js +++ b/print/templates/email/printer-setup/printer-setup.js @@ -1,5 +1,5 @@ -const db = require(`${appPath}/lib/database`); -const Component = require(`${appPath}/lib/component`); +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); @@ -8,10 +8,6 @@ module.exports = { async serverPrefetch() { this.client = await this.fetchClient(this.clientId); }, - created() { - /* if (this.locale) - this.$i18n.locale = this.locale; */ - }, methods: { fetchClient(clientId) { return db.findOne(` @@ -34,5 +30,9 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, - props: ['clientId', 'isPreview'] + props: { + clientId: { + required: true + } + } }; diff --git a/print/templates/email/sepa-core/assets/css/import.js b/print/templates/email/sepa-core/assets/css/import.js new file mode 100644 index 000000000..e88633a52 --- /dev/null +++ b/print/templates/email/sepa-core/assets/css/import.js @@ -0,0 +1,7 @@ +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`]) + .mergeStyles(); diff --git a/print/templates/email/sepa-core/assets/css/index.js b/print/templates/email/sepa-core/assets/css/index.js deleted file mode 100644 index 321c632dc..000000000 --- a/print/templates/email/sepa-core/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/sepa-core/attachments.json b/print/templates/email/sepa-core/attachments.json new file mode 100644 index 000000000..808fb3a85 --- /dev/null +++ b/print/templates/email/sepa-core/attachments.json @@ -0,0 +1,3 @@ +[{ + "filename": "sepa-core.pdf" +}] \ No newline at end of file diff --git a/print/templates/email/sepa-core/index.js b/print/templates/email/sepa-core/index.js deleted file mode 100755 index 00fe18c3f..000000000 --- a/print/templates/email/sepa-core/index.js +++ /dev/null @@ -1,49 +0,0 @@ -const database = require(`${appPath}/lib/database`); -const reportEngine = require(`${appPath}/lib/reportEngine.js`); -const UserException = require(`${appPath}/lib/exceptions/userException`); - -module.exports = { - name: 'sepa-core', - async asyncData(ctx, params) { - const promises = []; - const data = { - isPreview: ctx.method === 'GET', - }; - - if (!params.clientFk) - throw new UserException('No client id specified'); - - promises.push(reportEngine.toPdf('rpt-sepa-core', ctx)); - promises.push(this.methods.fetchClient(params.clientFk)); - - return Promise.all(promises).then(result => { - const stream = result[0]; - const [[client]] = result[1]; - - Object.assign(data, client); - Object.assign(data, {attachments: [{filename: 'rpt-sepa-core.pdf', content: stream}]}); - - return data; - }); - }, - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - - methods: { - fetchClient(clientFk) { - return database.pool.query(` - SELECT - u.lang locale, - c.email recipient - FROM client c - JOIN account.user u ON u.id = c.id - WHERE c.id = ?`, [clientFk]); - }, - }, - components: { - 'email-header': require('../email-header'), - 'email-footer': require('../email-footer'), - }, -}; diff --git a/print/templates/email/sepa-core/locale.js b/print/templates/email/sepa-core/locale.js deleted file mode 100644 index 1c5f926a1..000000000 --- a/print/templates/email/sepa-core/locale.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - messages: { - es: { - subject: 'Solicitud de domiciliación bancaria', - title: 'Domiciliación SEPA CORE', - description: { - dear: 'Estimado cliente', - instructions: `Para poder tramitar tu solicitud de cambio de tu forma de pago a giro bancario, - te adjuntamos los documentos correspondientes a la ley de pago, que tienes que cumplimentar y enviarnos.`, - conclusion: 'Gracias por tu atención.' - }, - }, - pt: { - subject: 'Autorização de débito directo SEPA CORE', - title: 'Débito directo SEPA CORE', - description: { - dear: 'Prezado Cliente', - instructions: `Para poder tramitar vossa solicitação de forma de pagamento a Débito Automático, anexamos os - documentos correspondentes à Lei de Pagamentos, que deves preencher e reenviar-nos.`, - conclusion: 'Obrigado pela atenção.' - }, - } - }, -}; diff --git a/print/templates/email/sepa-core/locale/es.yml b/print/templates/email/sepa-core/locale/es.yml new file mode 100644 index 000000000..33315ee2f --- /dev/null +++ b/print/templates/email/sepa-core/locale/es.yml @@ -0,0 +1,8 @@ +subject: Solicitud de domiciliación bancaria +title: Domiciliación SEPA CORE +description: + dear: Estimado cliente + instructions: Para poder tramitar tu solicitud de cambio de tu forma de pago a giro + bancario, te adjuntamos los documentos correspondientes a la ley de pago, que + tienes que cumplimentar y enviarnos. + conclusion: Gracias por tu atención. diff --git a/print/templates/email/sepa-core/locale/pt.yml b/print/templates/email/sepa-core/locale/pt.yml new file mode 100644 index 000000000..9999dbc6a --- /dev/null +++ b/print/templates/email/sepa-core/locale/pt.yml @@ -0,0 +1,8 @@ +subject: Autorização de débito directo SEPA CORE +title: Débito directo SEPA CORE +description: + dear: Prezado Cliente + instructions: Para poder tramitar vossa solicitação de forma de pagamento a Débito + Automático, anexamos os documentos correspondentes à Lei de Pagamentos, que deves + preencher e reenviar-nos. + conclusion: Obrigado pela atenção. diff --git a/print/templates/email/sepa-core/index.html b/print/templates/email/sepa-core/sepa-core.html similarity index 69% rename from print/templates/email/sepa-core/index.html rename to print/templates/email/sepa-core/sepa-core.html index c41c18593..74fafbeb8 100644 --- a/print/templates/email/sepa-core/index.html +++ b/print/templates/email/sepa-core/sepa-core.html @@ -1,12 +1,15 @@ - + {{ $t('subject') }}
- + +
@@ -20,7 +23,10 @@

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

- + +
diff --git a/print/templates/email/sepa-core/sepa-core.js b/print/templates/email/sepa-core/sepa-core.js new file mode 100755 index 000000000..b1f38accd --- /dev/null +++ b/print/templates/email/sepa-core/sepa-core.js @@ -0,0 +1,11 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'sepa-core', + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + } +}; diff --git a/print/templates/reports/rpt-route/assets/css/index.js b/print/templates/reports/route/assets/css/import.js similarity index 64% rename from print/templates/reports/rpt-route/assets/css/index.js rename to print/templates/reports/route/assets/css/import.js index 515dea750..a2a9334cb 100644 --- a/print/templates/reports/rpt-route/assets/css/index.js +++ b/print/templates/reports/route/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/templates/reports/rpt-route/assets/css/style.css b/print/templates/reports/route/assets/css/style.css similarity index 100% rename from print/templates/reports/rpt-route/assets/css/style.css rename to print/templates/reports/route/assets/css/style.css diff --git a/print/templates/reports/route/locale/es.yml b/print/templates/reports/route/locale/es.yml new file mode 100644 index 000000000..25c830e5c --- /dev/null +++ b/print/templates/reports/route/locale/es.yml @@ -0,0 +1,24 @@ +title: Hoja de ruta +information: Información +date: Fecha +time: Hora +volume: Cubicaje +driver: Conductor +vehicle: Vehículo +agency: Agencia +order: Orden +client: Cliente +address: Consignatario +packages: Bultos +street: Dirección +postcode: Código Postal +city: Ciudad +mobile: Móvil +phone: Teléfono +warehouse: Almacén +salesPerson: Comercial +import: Importe +stowaway: Encajado dentro del ticket +route: Ruta +routeId: Ruta {0} +ticket: Tiquet \ No newline at end of file diff --git a/print/templates/reports/rpt-route/index.html b/print/templates/reports/route/route.html similarity index 86% rename from print/templates/reports/rpt-route/index.html rename to print/templates/reports/route/route.html index e3b814c50..a0b7093d1 100644 --- a/print/templates/reports/rpt-route/index.html +++ b/print/templates/reports/route/route.html @@ -1,40 +1,43 @@ - +
- + +
-

{{$t('Title')}}

+

{{$t('title')}}

-
{{$t('Information')}}
+
{{$t('information')}}
- + - + - - - + + + - - + + - + - + @@ -81,11 +84,11 @@
{{$t('Route')}}{{$t('route')}} {{route.id}}{{$t('Driver')}}{{$t('driver')}} {{route.userNickName}}
{{$t('Date')}}{{date(route.created)}}{{$t('Vehicle')}}{{$t('date')}}{{route.created | date('%d-%m-%Y')}}{{$t('vehicle')}} {{route.vehicleTradeMark}} {{route.vehicleModel}}
{{$t('Time')}}{{time(route.time)}}{{$t('time')}}{{route.time | date('%H:%M')}} {{route.plateNumber}}
{{$t('Volume')}}{{$t('volume')}} {{route.m3}}{{$t('Agency')}}{{$t('agency')}} {{route.agencyName}}
- - - - - + + + + + @@ -108,31 +111,31 @@
{{$t('Order')}}{{$t('Ticket')}}{{$t('Client')}}{{$t('Address')}}{{$t('Packages')}}{{$t('order')}}{{$t('ticket')}}{{$t('client')}}{{$t('address')}}{{$t('packages')}}
- + - + - + - + - + - + - + - + @@ -147,8 +150,9 @@ + v-bind:left-text="$t('routeId', [route.id])" + v-bind:is-preview="isPreview" + v-bind:locale="locale"> diff --git a/print/templates/reports/rpt-route/index.js b/print/templates/reports/route/route.js similarity index 62% rename from print/templates/reports/rpt-route/index.js rename to print/templates/reports/route/route.js index 989a27254..858fd8407 100755 --- a/print/templates/reports/rpt-route/index.js +++ b/print/templates/reports/route/route.js @@ -1,49 +1,47 @@ -const strftime = require('strftime'); -const database = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); +const db = require(`${appPath}/core/database`); module.exports = { - name: 'rpt-route', - async asyncData(ctx, params) { - Object.assign(this, this.methods); + name: 'route', + async serverPrefetch() { + this.route = await this.fetchRoute(this.routeId); + this.tickets = await this.fetchTickets(this.routeId); - const [[route]] = await this.fetchRoute(params.routeFk); - const [tickets] = await this.fetchTickets(params.routeFk); + if (!this.route) + throw new Error('Something went wrong'); + }, + computed: { + dated: function() { + const filters = this.$options.filters; - if (!route) - throw new UserException('No route data found'); - - if (!tickets) - throw new UserException('No ticket data found'); - - return {route, tickets}; + return filters.date(new Date(), '%d-%m-%Y'); + } }, methods: { - fetchRoute(routeFk) { - return database.pool.query( + fetchRoute(id) { + return db.findOne( `SELECT r.id, r.m3, r.created, r.time, u.nickName userNickName, - u.lang AS locale, v.tradeMark vehicleTradeMark, v.model vehicleModel, v.numberPlate plateNumber, am.name agencyName FROM route r - LEFT JOIN ticket t ON t.routeFk = r.id - LEFT JOIN sale s ON s.ticketFk = t.id - LEFT JOIN cache.last_buy lb ON lb.item_id = s.itemFk LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN worker w ON w.id = r.workerFk LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk - WHERE r.id = ?`, [routeFk]); + WHERE r.id = :routeId`, {routeId: id}); }, - fetchTickets(routeFk) { - return database.pool.query( + // Redmine #1855 Replace function Averiguar_ComercialCliente_Id() + fetchTickets(routeId) { + return db.find( `SELECT t.nickname addressName, t.packages, @@ -76,19 +74,17 @@ module.exports = { LEFT JOIN agencyMode am ON am.id = t.agencyModeFk LEFT JOIN stowaway s ON s.id = t.id WHERE r.id = ? - ORDER BY t.priority, t.id`, [routeFk]); - }, - date(date) { - if (date) - return strftime('%d-%m-%Y', date); - }, - time: time => { - if (time) - return strftime('%H:%M', time); - }, + ORDER BY t.priority, t.id`, [routeId]); + } }, components: { - 'report-header': require('../report-header'), - 'report-footer': require('../report-footer'), + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() }, + props: { + routeId: { + type: String, + required: true + } + } }; diff --git a/print/templates/reports/rpt-route/locale.js b/print/templates/reports/rpt-route/locale.js deleted file mode 100644 index ef835b20f..000000000 --- a/print/templates/reports/rpt-route/locale.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = { - messages: { - es: { - Title: 'Hoja de ruta', - Information: 'Información', - Route: 'Ruta', - Date: 'Fecha', - Time: 'Hora', - Volume: 'Cubicaje', - Driver: 'Conductor', - Vehicle: 'Vehículo', - Agency: 'Agencia', - Order: 'Orden', - Client: 'Cliente', - Address: 'Consignatario', - Packages: 'Bultos', - Street: 'Dirección', - Postcode: 'Código Postal', - City: 'Ciudad', - Mobile: 'Móvil', - Phone: 'Teléfono', - Warehouse: 'Almacén', - salesPerson: 'Comercial', - Import: 'Importe', - stowaway: 'Encajado dentro del ticket', - route: 'Ruta {0}' - } - }, -}; diff --git a/print/templates/reports/rpt-zone/assets/css/index.js b/print/templates/reports/rpt-zone/assets/css/index.js deleted file mode 100644 index 06417fcee..000000000 --- a/print/templates/reports/rpt-zone/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/report.css`, - `${__dirname}/style.css`]) - .mergeStyles(); diff --git a/print/templates/reports/rpt-zone/index.js b/print/templates/reports/rpt-zone/index.js deleted file mode 100755 index c6b0a245c..000000000 --- a/print/templates/reports/rpt-zone/index.js +++ /dev/null @@ -1,36 +0,0 @@ -const strftime = require('strftime'); -const database = require(`${appPath}/lib/database`); -const UserException = require(`${appPath}/lib/exceptions/userException`); - -module.exports = { - name: 'rpt-zone', - async asyncData(ctx, params) { - if (!params.routeFk) - throw new UserException('No route id specified'); - - let [[zone]] = await this.methods.fetchRoute(params.routeFk); - - if (!zone) - throw new UserException('Route not ready'); - - return {zone}; - }, - methods: { - fetchRoute(routeFk) { - return database.pool.query( - `SELECT - r.id, - r.time, - am.name agencyName, - v.numberPlate plateNumber - FROM route r - JOIN agencyMode am ON am.id = r.agencyModeFk - JOIN vehicle v ON v.id = r.vehicleFk - WHERE r.id = ?`, [routeFk]); - }, - zoneTime: zoneTime => { - if (zoneTime) - return strftime('%H:%M', zoneTime); - }, - }, -}; diff --git a/print/templates/reports/rpt-zone/locale.js b/print/templates/reports/rpt-zone/locale.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/print/templates/reports/sample-report/assets/css/style.css b/print/templates/reports/sample-report/assets/css/style.css deleted file mode 100644 index e621f3e23..000000000 --- a/print/templates/reports/sample-report/assets/css/style.css +++ /dev/null @@ -1,3 +0,0 @@ -table.column-oriented { - margin-top: 50px !important -} \ No newline at end of file diff --git a/print/templates/reports/sample-report/index.html b/print/templates/reports/sample-report/index.html deleted file mode 100644 index 9a60114fd..000000000 --- a/print/templates/reports/sample-report/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - -
- - - -
- -

{{$t('title')}}

-

{{$t('date')}} {{dated()}}

-
{{$t('Street')}}{{$t('street')}} {{ticket.street}}{{$t('Postcode')}}{{$t('postcode')}} {{ticket.postalCode}}
{{$t('City')}}{{$t('city')}} {{ticket.city}}{{$t('Agency')}}{{$t('agency')}} {{ticket.ticketAgency}}
{{$t('Mobile')}}{{$t('mobile')}} {{ticket.mobile}}{{$t('Phone')}}{{$t('phone')}} {{ticket.phone}}
{{$t('Warehouse')}}{{$t('warehouse')}} {{ticket.warehouseName}} {{$t('salesPerson')}} {{ticket.salesPersonName}}
{{$t('Import')}}{{$t('import')}} {{ticket.import}}
- - - - - - - - - - - - - - -
Id{{$t('concept')}}{{$t('quantity')}}
{{sale.id}}{{sale.concept}}{{sale.quantity}}
- -
- - - - -
- - \ No newline at end of file diff --git a/print/templates/reports/sample-report/index.js b/print/templates/reports/sample-report/index.js deleted file mode 100755 index b6894060a..000000000 --- a/print/templates/reports/sample-report/index.js +++ /dev/null @@ -1,32 +0,0 @@ -const strftime = require('strftime'); - -module.exports = { - name: 'sample-report', - created() { - if (this.locale) - this.$i18n.locale = this.locale; - }, - data() { - return { - client: { - id: 10252, - name: 'Batman', - }, - sales: [ - {id: 1, concept: 'My item 1', quantity: 25}, - {id: 2, concept: 'My item 2', quantity: 50}, - {id: 3, concept: 'My item 3', quantity: 150} - ], - locale: 'es' - }; - }, - methods: { - dated: () => { - return strftime('%d-%m-%Y', new Date()); - }, - }, - components: { - 'report-header': require('../report-header'), - 'report-footer': require('../report-footer'), - }, -}; diff --git a/print/templates/reports/sample-report/locale.js b/print/templates/reports/sample-report/locale.js deleted file mode 100644 index d231e10ff..000000000 --- a/print/templates/reports/sample-report/locale.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - messages: { - es: { - title: 'Sample report', - date: 'Fecha', - quantity: 'Cantidad', - concept: 'Concepto', - client: 'Cliente {0}', - }, - }, -}; diff --git a/print/templates/reports/sepa-core/sepa-core.html b/print/templates/reports/sepa-core/sepa-core.html index e9982a19f..0f939250a 100644 --- a/print/templates/reports/sepa-core/sepa-core.html +++ b/print/templates/reports/sepa-core/sepa-core.html @@ -7,7 +7,7 @@

{{$t('title')}}

-
+
{{$t('supplier.toCompleteBySupplier')}} @@ -17,7 +17,7 @@ {{$t('supplier.orderReference')}} - {{mandateCode}} + {{supplier.mandateCode}} {{$t('supplier.identifier')}} @@ -25,19 +25,19 @@ {{$t('supplier.name')}} - {{supplierName}} + {{supplier.name}} {{$t('supplier.street')}} - {{supplierStreet}} + {{supplier.street}} {{$t('supplier.location')}} - {{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}}) + {{supplier.postCode}}, {{supplier.city}} ({{supplier.province}}) {{$t('supplier.country')}} - {{supplierCountry}} + {{supplier.country}} @@ -49,7 +49,7 @@ {{$t('documentCopy')}}

- +

{{$t('mandatoryFields')}}

{{$t('sendOrder')}}

diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index c34601903..f2d245536 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -7,12 +7,13 @@ const rptSepaCore = { name: 'sepa-core', async serverPrefetch() { this.client = await this.fetchClient(this.clientId, this.companyId); + this.supplier = await this.fetchSupplier(this.clientId, this.companyId); if (!this.client) throw new Error('Something went wrong'); }, computed: { - dated: () => { + dated: function() { const filters = this.$options.filters; return filters.date(new Date(), '%d-%m-%Y'); @@ -22,27 +23,35 @@ const rptSepaCore = { fetchClient(clientId, companyId) { return db.findOne( `SELECT - c.id clientId, - u.lang locale, + c.id, m.code mandateCode, - c.email AS recipient, - c.socialName AS clientName, - c.street AS clientStreet, - c.postcode AS clientPostCode, - c.city AS clientCity, - p.name AS clientProvince, - ct.country AS clientCountry, - ct.code AS clientCountryCode, - ct.ibanLength AS ibanLength, - s.name AS supplierName, - s.street AS supplierStreet, - sc.country AS supplierCountry, - s.postCode AS supplierPostCode, - s.city AS supplierCity, - sp.name AS supplierProvince + c.socialName, + c.street, + c.postcode, + c.city, + p.name AS province, + ct.country, + ct.code AS countryCode, + ct.ibanLength AS ibanLength FROM client c - JOIN account.user u ON u.id = c.id JOIN country ct ON ct.id = c.countryFk + LEFT JOIN mandate m ON m.clientFk = c.id + AND m.companyFk = :companyId AND m.finished IS NULL + LEFT JOIN province p ON p.id = c.provinceFk + WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId + ORDER BY m.created DESC LIMIT 1`, {companyId, clientId}); + }, + fetchSupplier(clientId, companyId) { + return db.findOne( + `SELECT + m.code mandateCode, + s.name, + s.street, + sc.country, + s.postCode, + s.city, + sp.name province + FROM client c LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = :companyId AND m.finished IS NULL LEFT JOIN supplier s ON s.id = m.companyFk diff --git a/print/templates/reports/sample-report/assets/css/index.js b/print/templates/reports/zone/assets/css/import.js similarity index 64% rename from print/templates/reports/sample-report/assets/css/index.js rename to print/templates/reports/zone/assets/css/import.js index 515dea750..a2a9334cb 100644 --- a/print/templates/reports/sample-report/assets/css/index.js +++ b/print/templates/reports/zone/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/templates/reports/rpt-zone/assets/css/style.css b/print/templates/reports/zone/assets/css/style.css similarity index 100% rename from print/templates/reports/rpt-zone/assets/css/style.css rename to print/templates/reports/zone/assets/css/style.css diff --git a/print/templates/reports/rpt-zone/index.html b/print/templates/reports/zone/zone.html similarity index 92% rename from print/templates/reports/rpt-zone/index.html rename to print/templates/reports/zone/zone.html index 5e64da73c..b5a3e7c3e 100644 --- a/print/templates/reports/rpt-zone/index.html +++ b/print/templates/reports/zone/zone.html @@ -6,7 +6,7 @@
{{zone.agencyName}}
{{zone.id}}
-
{{zone.plateNumber}} {{zoneTime(zone.time)}}
+
{{zone.plateNumber}} {{zone.time | date('%H:%M')}}
diff --git a/print/templates/reports/zone/zone.js b/print/templates/reports/zone/zone.js new file mode 100755 index 000000000..0debd4ef4 --- /dev/null +++ b/print/templates/reports/zone/zone.js @@ -0,0 +1,31 @@ +const db = require(`${appPath}/core/database`); + +module.exports = { + name: 'zone', + async serverPrefetch() { + this.zone = await this.fetchZone(this.routeId); + + if (!this.zone) + throw new Error('Something went wrong'); + }, + methods: { + fetchZone(routeId) { + return db.findOne( + `SELECT + r.id, + r.time, + am.name agencyName, + v.numberPlate plateNumber + FROM route r + JOIN agencyMode am ON am.id = r.agencyModeFk + JOIN vehicle v ON v.id = r.vehicleFk + WHERE r.id = :routeId`, {routeId}); + } + }, + props: { + routeId: { + type: String, + required: true + } + } +};