diff --git a/modules/entry/back/methods/entry/entryLabel.js b/modules/entry/back/methods/entry/entryLabel.js new file mode 100644 index 000000000..50e82b54c --- /dev/null +++ b/modules/entry/back/methods/entry/entryLabel.js @@ -0,0 +1,36 @@ +module.exports = Self => { + Self.remoteMethodCtx('entryLabel', { + description: 'Returns the entry labels', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/entry-label', + verb: 'GET' + } + }); + + Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label'); +}; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..10f63b9f0 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -9,6 +9,7 @@ module.exports = Self => { require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); + require('../methods/entry/entryLabel')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/print/templates/reports/entry-label/assets/css/import.js b/print/templates/reports/entry-label/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/entry-label/assets/css/style.css new file mode 100644 index 000000000..ccafa7078 --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/style.css @@ -0,0 +1,58 @@ +html { + height: 100%; + margin-top: -6px; +} +* { + box-sizing: border-box; + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 28px; +} +table { + border: 1px solid; + width: 100%; + font-size: inherit; +} +td { + border: 1px solid; + padding: 5px; + width: 100%; +} +#barcode { + text-align: center; +} +span { + font-size: 48px; + font-weight: bold; +} +.lbl { + color: gray; + font-weight: lighter; + font-size: 18px; + display: block; +} +.flex-container { + display: flex; + justify-content: space-between; +} +.flex-item { + flex: 1; +} +.section { + height: 50px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +#variant { + width: 314px; +} +#producer { + width: 471px; +} +.cell { + width: 157px; +} + +#leftBox { + border-right: 1px solid; +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html new file mode 100644 index 000000000..6973adbea --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Variedad: + {{buy.name}} +
+
+
+ Medida: + {{buy.size}} +
+
+
+ Categoría: + {{buy.category}} +
+
+
+ Color: + {{buy.color}} +
+
+
+ Origen: + {{buy.origin}} +
+
+
+ Packing: + {{buy.packing}} +
+
+
+ Grouping: + {{buy.grouping}} +
+
+
+ Und. venta: + {{buy.stems}} +
+
+
+ {{buy.id}} +
+
+ Productor: + {{buy.producer}} +
+
+
+
+ Control: + 06/11 +
+
+ Caja nº: + {{`${buy.labelNum} / ${maxLabelNum}`}} +
+
+
+ diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js new file mode 100755 index 000000000..62186df4c --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.js @@ -0,0 +1,36 @@ +const vnReport = require('../../../core/mixins/vn-report.js'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const jsBarcode = require('jsbarcode'); + +module.exports = { + name: 'entry-label', + mixins: [vnReport], + async serverPrefetch() { + this.buys = await this.rawSqlFromDef('entry', [this.id]); + const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + this.maxLabelNum = maxLabelNum; + }, + methods: { + getBarcode(id) { + const xmlSerializer = new XMLSerializer(); + const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); + const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + + jsBarcode(svgNode, id, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.8, + height: 115, + }); + return xmlSerializer.serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The entry id' + } + } +}; diff --git a/print/templates/reports/entry-label/locale/es.yml b/print/templates/reports/entry-label/locale/es.yml new file mode 100644 index 000000000..278946f3e --- /dev/null +++ b/print/templates/reports/entry-label/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta \ No newline at end of file diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/entry-label/options.json new file mode 100644 index 000000000..d2ed03e32 --- /dev/null +++ b/print/templates/reports/entry-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10cm", + "height": "10.3cm", + "margin": { + "top": "0.17cm", + "right": "0.2cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/entry-label/sql/entry.sql new file mode 100644 index 000000000..21511df64 --- /dev/null +++ b/print/templates/reports/entry-label/sql/entry.sql @@ -0,0 +1,17 @@ +SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, + i.name, + i.`size`, + i.category, + ink.id color, + o.code origin, + b.packing, + b.`grouping`, + i.stems, + b.id, + p.name producer + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN origin o ON o.id = i.originFk + WHERE b.entryFk = ? \ No newline at end of file