From 9a2fe0260e3091d25a0111a5fab636abf23325b0 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 19 Jul 2021 10:16:15 +0200 Subject: [PATCH 1/3] last steps to preview credit request --- db/changes/10340-summer/01-credit_request.sql | 2 + print/common/css/layout.css | 10 + .../email/credit-request/assets/css/import.js | 8 + .../email/credit-request/attachments.json | 6 + .../email/credit-request/credit-request.html | 55 ++++++ .../email/credit-request/credit-request.js | 17 ++ .../email/credit-request/locale/es.yml | 4 + .../credit-request/assets/css/import.js | 9 + .../credit-request/assets/css/style.css | 52 +++++ .../credit-request/credit-request.html | 184 ++++++++++++++++++ .../reports/credit-request/credit-request.js | 11 ++ .../reports/credit-request/locale/es.yml | 17 ++ 12 files changed, 375 insertions(+) create mode 100644 db/changes/10340-summer/01-credit_request.sql create mode 100644 print/templates/email/credit-request/assets/css/import.js create mode 100644 print/templates/email/credit-request/attachments.json create mode 100644 print/templates/email/credit-request/credit-request.html create mode 100755 print/templates/email/credit-request/credit-request.js create mode 100644 print/templates/email/credit-request/locale/es.yml create mode 100644 print/templates/reports/credit-request/assets/css/import.js create mode 100644 print/templates/reports/credit-request/assets/css/style.css create mode 100644 print/templates/reports/credit-request/credit-request.html create mode 100755 print/templates/reports/credit-request/credit-request.js create mode 100644 print/templates/reports/credit-request/locale/es.yml diff --git a/db/changes/10340-summer/01-credit_request.sql b/db/changes/10340-summer/01-credit_request.sql new file mode 100644 index 0000000000..8216233269 --- /dev/null +++ b/db/changes/10340-summer/01-credit_request.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`sample` (`code`, `description`, `isVisible`, `hasCompany`, `hasPreview`) + VALUES ('credit-request', 'Solicitud de crédito', 1, 1, 1); \ No newline at end of file diff --git a/print/common/css/layout.css b/print/common/css/layout.css index c709191bbb..57c5db9e32 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -132,6 +132,16 @@ width: 8em } +.field.wide-rectangle { + white-space: nowrap +} + +.field.wide-rectangle span { + display: inline-block; + height: 2em; + width: 100%; +} + .pull-left { float: left !important } diff --git a/print/templates/email/credit-request/assets/css/import.js b/print/templates/email/credit-request/assets/css/import.js new file mode 100644 index 0000000000..b44d6bd371 --- /dev/null +++ b/print/templates/email/credit-request/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/credit-request/attachments.json b/print/templates/email/credit-request/attachments.json new file mode 100644 index 0000000000..12b10df4c7 --- /dev/null +++ b/print/templates/email/credit-request/attachments.json @@ -0,0 +1,6 @@ +[ + { + "filename": "credit-request.pdf", + "component": "credit-request" + } +] \ No newline at end of file diff --git a/print/templates/email/credit-request/credit-request.html b/print/templates/email/credit-request/credit-request.html new file mode 100644 index 0000000000..e63eba7f77 --- /dev/null +++ b/print/templates/email/credit-request/credit-request.html @@ -0,0 +1,55 @@ + + + + + + {{ $t('subject') }} + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

{{ $t('title') }}

+

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

+
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/email/credit-request/credit-request.js b/print/templates/email/credit-request/credit-request.js new file mode 100755 index 0000000000..69463f43ab --- /dev/null +++ b/print/templates/email/credit-request/credit-request.js @@ -0,0 +1,17 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const attachment = new Component('attachment'); +const attachments = require('./attachments.json'); + +module.exports = { + name: 'credit-request', + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build(), + 'attachment': attachment.build() + }, + data() { + return {attachments}; + }, +}; diff --git a/print/templates/email/credit-request/locale/es.yml b/print/templates/email/credit-request/locale/es.yml new file mode 100644 index 0000000000..aa6e63dcbd --- /dev/null +++ b/print/templates/email/credit-request/locale/es.yml @@ -0,0 +1,4 @@ +subject: Solicitud de crédito +title: Solicitud de crédito +description: + instructions: Adjuntamos el formulario para solicitud de crédito. \ No newline at end of file diff --git a/print/templates/reports/credit-request/assets/css/import.js b/print/templates/reports/credit-request/assets/css/import.js new file mode 100644 index 0000000000..fd8796c2bf --- /dev/null +++ b/print/templates/reports/credit-request/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/credit-request/assets/css/style.css b/print/templates/reports/credit-request/assets/css/style.css new file mode 100644 index 0000000000..90bbfd1038 --- /dev/null +++ b/print/templates/reports/credit-request/assets/css/style.css @@ -0,0 +1,52 @@ +.wide { + width: 900px !important +} + +.content { + position: absolute; + margin-top: -200px; + height: 400px; + top: 50% +} + +p { + font-size: 1.2em; + margin: 0 +} + +td > span { + width: 100%; + margin-bottom: 15px +} + +.green-background { + color: white; + background-color: #8dba25; + height: 2em; + line-height: 2em; + padding-left: 0.5em; +} + +.info-panel td, .info-panel th { + padding: 1em 1em; +} + +.info-panel { + margin-bottom: 5em; +} + +table { + width: 100%; +} + +th { + width: 30%; +} + +td { + width: 20%; +} + +.field { + float: none +} \ No newline at end of file diff --git a/print/templates/reports/credit-request/credit-request.html b/print/templates/reports/credit-request/credit-request.html new file mode 100644 index 0000000000..c377ad81ab --- /dev/null +++ b/print/templates/reports/credit-request/credit-request.html @@ -0,0 +1,184 @@ + + + + + + + + + +
+ + + + +
+
+

{{$t('fields.title')}}

+
+
+ + + + + + + + + +
{{$t('fields.date')}}: +
+ +
+
+ + +
+
+
+
+

{{$t('fields.companyInfo')}}

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{$t('fields.companyName')}}: +
+ +
+
{{$t('fields.businessType')}}: +
+ +
+
{{$t('fields.antiquity')}}: +
+ +
+
{{$t('fields.surface')}}: +
+ +
+
{{$t('fields.numberOfEmployees')}}: +
+ +
+
{{$t('fields.owner')}}: +
+ +
+
{{$t('fields.phone')}}: +
+ +
+
{{$t('fields.payer')}}: +
+ +
+
{{$t('fields.phone')}}: +
+ +
+
+
+
+
+
+ + +
+
+
+
+

{{$t('fields.economicInfo')}}

+
+
+ + + + + + + + + + + + + + + +
{{$t('fields.previousSalesVolume')}}: +
+ +
+
{{$t('fields.forecastedSalesVolume')}}: +
+ +
+
{{$t('fields.forecastedPurchases')}}: +
+ +
+
+
+
+
+
+ + +
+
+
+ + + + + + + + + +
{{$t('fields.personFilling')}}: +
+ +
+
{{$t('fields.phone')}}: +
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js new file mode 100755 index 0000000000..09a170bd65 --- /dev/null +++ b/print/templates/reports/credit-request/credit-request.js @@ -0,0 +1,11 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); + +const rptCreditRequest = { + name: 'credit-request', + components: { + 'report-header': reportHeader.build() + } +}; + +module.exports = rptCreditRequest; diff --git a/print/templates/reports/credit-request/locale/es.yml b/print/templates/reports/credit-request/locale/es.yml new file mode 100644 index 0000000000..e4e9739a57 --- /dev/null +++ b/print/templates/reports/credit-request/locale/es.yml @@ -0,0 +1,17 @@ +fields: + title: Solicitud de crédito + date: Fecha + companyName: Nombre de la empresa + businessType: Tipo de negocio + antiquity: Antigüedad + surface: Superficie (m²) + numberOfEmployees: Número de empleados + owner: Contacto propietario o Administrador + phone: Teléfono + payer: Contacto responsable de pagos + previousSalesVolume: Previsión ventas ejercicio anterior + forecastedSalesVolume: Previsión ventas para el presente año + forecastedPurchases: Previsión de compras a Verdnatura + personFilling: Persona que rellena el formulario + companyInfo: Información general sobre la empresa + economicInfo: Información económica \ No newline at end of file -- 2.40.1 From 4ed31f51727c776cb1d018e970290a7d7e0f3dcd Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 19 Jul 2021 10:42:12 +0200 Subject: [PATCH 2/3] added footerr to report --- .../reports/credit-request/credit-request.html | 7 +++++++ .../reports/credit-request/credit-request.js | 15 ++++++++++++++- .../reports/credit-request/sql/client.sql | 13 +++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 print/templates/reports/credit-request/sql/client.sql diff --git a/print/templates/reports/credit-request/credit-request.html b/print/templates/reports/credit-request/credit-request.html index c377ad81ab..6f9441c449 100644 --- a/print/templates/reports/credit-request/credit-request.html +++ b/print/templates/reports/credit-request/credit-request.html @@ -176,6 +176,13 @@ + + + diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js index 09a170bd65..d6a40b37c4 100755 --- a/print/templates/reports/credit-request/credit-request.js +++ b/print/templates/reports/credit-request/credit-request.js @@ -1,10 +1,23 @@ const Component = require(`${appPath}/core/component`); const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); const rptCreditRequest = { name: 'credit-request', + async serverPrefetch() { + this.client = await this.fetchClient(this.recipientId); + + if (!this.client) + throw new Error('Something went wrong'); + }, + methods: { + fetchClient(clientId) { + return this.findOneFromDef('client', [clientId]); + } + }, components: { - 'report-header': reportHeader.build() + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() } }; diff --git a/print/templates/reports/credit-request/sql/client.sql b/print/templates/reports/credit-request/sql/client.sql new file mode 100644 index 0000000000..d675cf168d --- /dev/null +++ b/print/templates/reports/credit-request/sql/client.sql @@ -0,0 +1,13 @@ +SELECT + c.id, + c.socialName, + c.street, + c.postcode, + c.city, + c.fi, + p.name AS province, + ct.country +FROM client c + JOIN country ct ON ct.id = c.countryFk + LEFT JOIN province p ON p.id = c.provinceFk +WHERE c.id = ? \ No newline at end of file -- 2.40.1 From 724da74204e57500b2f2d818ee7bfa9ce8247bf1 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 19 Jul 2021 10:57:08 +0200 Subject: [PATCH 3/3] removed footer unused bindings and added date --- .../reports/credit-request/credit-request.html | 3 +-- .../reports/credit-request/credit-request.js | 12 ++++-------- .../templates/reports/credit-request/sql/client.sql | 13 ------------- 3 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 print/templates/reports/credit-request/sql/client.sql diff --git a/print/templates/reports/credit-request/credit-request.html b/print/templates/reports/credit-request/credit-request.html index 6f9441c449..975115eef8 100644 --- a/print/templates/reports/credit-request/credit-request.html +++ b/print/templates/reports/credit-request/credit-request.html @@ -179,8 +179,7 @@ diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js index d6a40b37c4..d041064932 100755 --- a/print/templates/reports/credit-request/credit-request.js +++ b/print/templates/reports/credit-request/credit-request.js @@ -4,15 +4,11 @@ const reportFooter = new Component('report-footer'); const rptCreditRequest = { name: 'credit-request', - async serverPrefetch() { - this.client = await this.fetchClient(this.recipientId); + computed: { + dated: function() { + const filters = this.$options.filters; - if (!this.client) - throw new Error('Something went wrong'); - }, - methods: { - fetchClient(clientId) { - return this.findOneFromDef('client', [clientId]); + return filters.date(new Date(), '%d-%m-%Y'); } }, components: { diff --git a/print/templates/reports/credit-request/sql/client.sql b/print/templates/reports/credit-request/sql/client.sql deleted file mode 100644 index d675cf168d..0000000000 --- a/print/templates/reports/credit-request/sql/client.sql +++ /dev/null @@ -1,13 +0,0 @@ -SELECT - c.id, - c.socialName, - c.street, - c.postcode, - c.city, - c.fi, - p.name AS province, - ct.country -FROM client c - JOIN country ct ON ct.id = c.countryFk - LEFT JOIN province p ON p.id = c.provinceFk -WHERE c.id = ? \ No newline at end of file -- 2.40.1