From 23726b6e60d038e094b8dbe005e04a1a44129dec Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 4 Oct 2022 10:55:13 +0200 Subject: [PATCH] first commit --- .../collection-label/assets/css/style.css | 46 +++++++++++++ .../collection-label/collection-label.html | 40 +++++++++++ .../collection-label/collection-label.js | 68 +++++++++++++++++++ .../reports/collection-label/locale/es.yml | 1 + .../reports/collection-label/options.json | 11 +++ .../collection-label/sql/collection copy.sql | 35 ++++++++++ .../collection-label/sql/collection.sql | 35 ++++++++++ .../sql/collectionOrTicket.sql | 3 + 8 files changed, 239 insertions(+) create mode 100644 print/templates/reports/collection-label/assets/css/style.css create mode 100644 print/templates/reports/collection-label/collection-label.html create mode 100644 print/templates/reports/collection-label/collection-label.js create mode 100644 print/templates/reports/collection-label/locale/es.yml create mode 100644 print/templates/reports/collection-label/options.json create mode 100644 print/templates/reports/collection-label/sql/collection copy.sql create mode 100644 print/templates/reports/collection-label/sql/collection.sql create mode 100644 print/templates/reports/collection-label/sql/collectionOrTicket.sql diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css new file mode 100644 index 000000000..0eb410f0e --- /dev/null +++ b/print/templates/reports/collection-label/assets/css/style.css @@ -0,0 +1,46 @@ +@page { + size: auto; + margin: 0mm; +} +html { + font-family: "Roboto"; +} +* { + box-sizing: border-box; + text-align: center; + font-size: 32px; +} +.grid { + border: 1px solid gray; + width: 580px; + max-width: 580px; + padding-right: 12px; +} +.vertical { + writing-mode: vertical-rl; +} +.outline { + border: 1px solid black; + width: 120px; + font-size: 30px; +} +#nickname { + font-size: 28px; +} +#agencyDescripton { + font-size: 36px; + font-weight: bold; +} +#bold { + font-weight: bold; +} +#right{ + text-align: right; + width: 230px; +} +#left{ + text-align: left; +} +.center { + padding-left: 55px; +} \ No newline at end of file diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html new file mode 100644 index 000000000..370674f16 --- /dev/null +++ b/print/templates/reports/collection-label/collection-label.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{levelV}}/{{clientFk}}{{shipped}}
{{barcode}}{{workerCode}}
{{labelCount}}
{{packingTypeFk}}
{{agencyDescripton}}{{lineCount}}
{{nickname}}{{agencyHour}}
+ + + diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js new file mode 100644 index 000000000..189f0d553 --- /dev/null +++ b/print/templates/reports/collection-label/collection-label.js @@ -0,0 +1,68 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); +const qrcode = require('qrcode'); + +module.exports = { + name: 'collection-label', + async serverPrefetch() { + this.collectionTicket = await this.fetchItem(this.collectionTicketId); + this.tags = await this.fetchItemTags(this.collectionTicketId); + this.barcode = await this.getBarcodeBase64(this.collectionTicketId); + + if (!this.collectionTicket) + throw new Error('Something went wrong'); + }, + + computed: { + dated() { + const filters = this.$options.filters; + + return filters.date(new Date(), '%W/%d'); + }, + labelPage() { + const labelNumber = this.labelNumber ? this.labelNumber : 1; + const totalLabels = this.totalLabels ? this.totalLabels : 1; + + return `${labelNumber}/${totalLabels}`; + } + }, + methods: { + fetchItem(id, warehouseId) { + return this.findOneFromDef('item', [id, warehouseId]); + }, + fetchItemTags(itemId) { + return this.rawSqlFromDef('itemTags', [itemId]).then(rows => { + const tags = {}; + rows.forEach(row => tags[row.code] = row.value); + + return tags; + }); + }, + getBarcodeBase64(itemId) { + return qrcode.toDataURL(itemId, {margin: 0}); + }, + packing() { + const stems = this.item.stems ? this.item.stems : 1; + return `${this.item.packing}x${stems}`; + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + itemId: { + required: true + }, + warehouseId: { + required: true + }, + labelNumber: { + type: String + }, + totalLabels: { + type: String + } + } +}; diff --git a/print/templates/reports/collection-label/locale/es.yml b/print/templates/reports/collection-label/locale/es.yml new file mode 100644 index 000000000..a54d3bad8 --- /dev/null +++ b/print/templates/reports/collection-label/locale/es.yml @@ -0,0 +1 @@ +reportName: labelCollection \ No newline at end of file diff --git a/print/templates/reports/collection-label/options.json b/print/templates/reports/collection-label/options.json new file mode 100644 index 000000000..98c5788b1 --- /dev/null +++ b/print/templates/reports/collection-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10.4cm", + "height": "4.8cm", + "margin": { + "top": "0cm", + "right": "0cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/collection copy.sql b/print/templates/reports/collection-label/sql/collection copy.sql new file mode 100644 index 000000000..96a2bdf43 --- /dev/null +++ b/print/templates/reports/collection-label/sql/collection copy.sql @@ -0,0 +1,35 @@ +SELECT c.itemPackingTypeFk, + CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, + CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV, + tc.ticketFk, + LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription, + am.name, + t.clientFk, + CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , + CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size, + w.code workerCode, + tt.labelCount, + IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) agencyHour, + t.shipped, + COUNT(*) lineCount, + t.nickName + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.collection c ON c.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level` + AND cc.wagon = tc.wagon + AND cc.trainFk = c.trainFk + JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id + LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk + LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) + GROUP BY t.id + ORDER BY cc.`code`; \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/collection.sql b/print/templates/reports/collection-label/sql/collection.sql new file mode 100644 index 000000000..7abbb9dca --- /dev/null +++ b/print/templates/reports/collection-label/sql/collection.sql @@ -0,0 +1,35 @@ +SELECT c.itemPackingTypeFk, + CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, + CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV, + tc.ticketFk, + LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription, + am.name, + t.clientFk, + CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , + CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size, + w.code workerCode, + tt.labelCount, + IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) agencyHour, + t.shipped, + COUNT(*) lineCount, + t.nickName + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.collection c ON c.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level` + AND cc.wagon = tc.wagon + AND cc.trainFk = c.trainFk + JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id + LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk + LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + WHERE IF(?, tc.collectionFk = ?, tc.ticketFk = ?) + GROUP BY t.id + ORDER BY cc.`code`; \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/collectionOrTicket.sql b/print/templates/reports/collection-label/sql/collectionOrTicket.sql new file mode 100644 index 000000000..4961e3c0d --- /dev/null +++ b/print/templates/reports/collection-label/sql/collectionOrTicket.sql @@ -0,0 +1,3 @@ +SELECT IF(id, TRUE, FALSE) + FROM vn.collection + WHERE id = ?; \ No newline at end of file