From 4a0b8f37cd02b23637cc9eebb255e949196633ab Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Aug 2023 13:41:44 +0200 Subject: [PATCH] refs #5995 Load blob --- modules/route/back/models/route.js | 2 +- print/templates/reports/cmr/cmr.html | 4 ++-- print/templates/reports/cmr/cmr.js | 17 +++++++++++------ print/templates/reports/cmr/sql/data.sql | 3 ++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index 96e7ed04f4..a8d44cd05f 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -29,5 +29,5 @@ module.exports = Self => { const routeMaxKm = 1000; if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) err(); - } + }; }; diff --git a/print/templates/reports/cmr/cmr.html b/print/templates/reports/cmr/cmr.html index b403cc6d86..ba0f8bfabb 100644 --- a/print/templates/reports/cmr/cmr.html +++ b/print/templates/reports/cmr/cmr.html @@ -180,7 +180,7 @@
- +
@@ -191,7 +191,7 @@
- AquĆ­ va la el stamp +
diff --git a/print/templates/reports/cmr/cmr.js b/print/templates/reports/cmr/cmr.js index ea9dc2a70e..c939e51525 100644 --- a/print/templates/reports/cmr/cmr.js +++ b/print/templates/reports/cmr/cmr.js @@ -3,6 +3,8 @@ const vnReport = require('../../../core/mixins/vn-report.js'); const md5 = require('md5'); const fs = require('fs-extra'); +const prefixBase64 = 'data:image/png;base64,'; + module.exports = { name: 'cmr', mixins: [vnReport], @@ -13,6 +15,13 @@ module.exports = { this.signature = await this.findOneFromDef('signature', [this.data.ticketFk]); } else this.merchandises = null; + + this.senderStamp = (this.data.senderStamp) + ? `${prefixBase64} ${this.data.senderStamp.toString('base64')}` + : null; + this.deliveryStamp = (this.data.deliveryStamp) + ? `${prefixBase64} ${this.data.deliveryStamp.toString('base64')}` + : null; }, props: { id: { @@ -30,11 +39,7 @@ module.exports = { const file = `${config.storage.root}/${hash}/${signatureName}.png`; if (!fs.existsSync(file)) return null; - return `data:image/png;base64, ${Buffer.from(fs.readFileSync(file), 'utf8').toString('base64')}`; + return `${prefixBase64} ${Buffer.from(fs.readFileSync(file), 'utf8').toString('base64')}`; }, - async getStamp() { - const data = this.data.stamp.toString('base64'); - return `data:image/png;base64, ${data}`; - } - }, + } }; \ No newline at end of file diff --git a/print/templates/reports/cmr/sql/data.sql b/print/templates/reports/cmr/sql/data.sql index 41ebee4bb3..d7c585f22b 100644 --- a/print/templates/reports/cmr/sql/data.sql +++ b/print/templates/reports/cmr/sql/data.sql @@ -32,7 +32,8 @@ SELECT c.id cmrFk, a2.postalCode loadPostalCode, a2.city loadCity, cou4.country loadCountry, - co.stamp + co.stamp senderStamp, + s.stamp deliveryStamp FROM cmr c LEFT JOIN supplier s ON s.id = c.supplierFk LEFT JOIN country cou ON cou.id = s.countryFk