diff --git a/print/config/print.json b/print/config/print.json index cb98421fc..7ad2e1316 100755 --- a/print/config/print.json +++ b/print/config/print.json @@ -5,6 +5,13 @@ "senderMail": "nocontestar@verdnatura.es", "senderName": "Verdnatura" }, + "pdf": { + "format": "A4", + "border": "1.5cm", + "footer": { + "height": "55px" + } + }, "mysql": { "host": "localhost", "port": 3306, diff --git a/print/config/routes.json b/print/config/routes.json index e658f4cc4..58d46193c 100644 --- a/print/config/routes.json +++ b/print/config/routes.json @@ -17,6 +17,7 @@ {"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"}, diff --git a/print/lib/reportEngine.js b/print/lib/reportEngine.js index 8c771c449..0903c0f78 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/reportEngine.js @@ -2,9 +2,9 @@ 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'); +const config = require('./config'); Vue.use(VueI18n); @@ -104,13 +104,11 @@ module.exports = { async toPdf(name, ctx) { const html = await this.render(name, ctx); - const options = { - format: 'A4', - border: '1.5cm', - footer: { - height: '55px', - } - }; + let options = config.pdf; + + const optionsPath = `${this.path}/${name}/options.json`; + if (fs.existsSync(optionsPath)) + options = Object.assign(options, require(optionsPath)); return new Promise(resolve => { pdf.create(html, options).toStream((err, stream) => { diff --git a/print/package.json b/print/package.json index bb7c32a3e..0332817c2 100755 --- a/print/package.json +++ b/print/package.json @@ -18,6 +18,7 @@ "juice": "^5.0.1", "mysql2": "^1.6.5", "nodemailer": "^4.7.0", + "qrcode": "^1.4.2", "strftime": "^0.10.0", "vue": "^2.6.7", "vue-i18n": "^8.8.2", diff --git a/print/report/rpt-item-label/assets/css/index.js b/print/report/rpt-item-label/assets/css/index.js new file mode 100644 index 000000000..515dea750 --- /dev/null +++ b/print/report/rpt-item-label/assets/css/index.js @@ -0,0 +1,8 @@ +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/report/rpt-item-label/assets/css/style.css b/print/report/rpt-item-label/assets/css/style.css new file mode 100644 index 000000000..98a3ec721 --- /dev/null +++ b/print/report/rpt-item-label/assets/css/style.css @@ -0,0 +1,88 @@ +* { + box-sizing: border-box; +} +.label { + font-size: 1.2em; +} + +.barcode { + float: left; + width: 40%; +} + +.barcode h1 { + text-align: center; + font-size: 1.8em; + margin: 0 +} + +.barcode .image { + text-align: center +} + +.barcode .image img { + width: 180px +} + +.data { + float: left; + width: 60%; +} + +.data .header { + background-color: #000; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + margin-bottom: 25px; + text-align: right; + font-size: 1.2em; + padding: 0.2em; + color: #FFF +} + +.data .color, +.data .producer { + text-transform: uppercase; + text-align: right; + font-size: 1.5em; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} + +.data .producer { + text-justify: inter-character; +} + +.data .details { + border-top: 4px solid #000; + padding-top: 2px; +} + +.data .details .package { + padding-right: 5px; + float: left; + width: 50%; +} + +.package .packing, +.package .dated, +.package .labelNumber { + text-align: right +} + +.package .packing { + font-size: 1.8em; + font-weight: 400 +} + +.data .details .size { + background-color: #000; + text-align: center; + font-size: 3em; + padding: 0.2em 0; + float: left; + width: 50%; + color: #FFF +} \ No newline at end of file diff --git a/print/report/rpt-item-label/index.html b/print/report/rpt-item-label/index.html new file mode 100644 index 000000000..0b46aee14 --- /dev/null +++ b/print/report/rpt-item-label/index.html @@ -0,0 +1,28 @@ + + +
+