From 9fc901d565b995a4c387cef50bdb71c1ab7e0919 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 8 Jan 2025 14:30:21 +0100 Subject: [PATCH 1/2] feat: refs #7280 refs 7280 First commit --- .../route/scanExpeditionPalletLabel.js | 36 ++++++++ modules/route/back/models/route.js | 1 + .../assets/css/import.js | 12 +++ .../assets/css/style.css | 92 +++++++++++++++++++ .../locale/es.yml | 1 + .../scan-expedition-pallet-label/options.json | 11 +++ .../scan-expedition-pallet-label.html | 7 ++ .../scan-expedition-pallet-label.js | 40 ++++++++ .../scan-expedition-pallet-label/sql/data.sql | 38 ++++++++ 9 files changed, 238 insertions(+) create mode 100644 modules/route/back/methods/route/scanExpeditionPalletLabel.js create mode 100644 print/templates/reports/scan-expedition-pallet-label/assets/css/import.js create mode 100644 print/templates/reports/scan-expedition-pallet-label/assets/css/style.css create mode 100644 print/templates/reports/scan-expedition-pallet-label/locale/es.yml create mode 100644 print/templates/reports/scan-expedition-pallet-label/options.json create mode 100644 print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html create mode 100755 print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js create mode 100644 print/templates/reports/scan-expedition-pallet-label/sql/data.sql diff --git a/modules/route/back/methods/route/scanExpeditionPalletLabel.js b/modules/route/back/methods/route/scanExpeditionPalletLabel.js new file mode 100644 index 000000000..035a66ef0 --- /dev/null +++ b/modules/route/back/methods/route/scanExpeditionPalletLabel.js @@ -0,0 +1,36 @@ +module.exports = Self => { + Self.remoteMethodCtx('scanExpeditionPalletLabel', { + description: 'Returns the scan expedition pallet label', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The pallet 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/scan-expedition-pallet-label', + verb: 'GET' + } + }); + + Self.expeditionPalletLabel = (ctx, id) => Self.printReport(ctx, id, 'scan-expedition-pallet-label'); +}; diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index f73ff3e51..1e2af3552 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -17,4 +17,5 @@ module.exports = Self => { require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); require('../methods/route/optimizePriority')(Self); + require('../methods/route/scanExpeditionPalletLabel')(Self); }; diff --git a/print/templates/reports/scan-expedition-pallet-label/assets/css/import.js b/print/templates/reports/scan-expedition-pallet-label/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-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/scan-expedition-pallet-label/assets/css/style.css b/print/templates/reports/scan-expedition-pallet-label/assets/css/style.css new file mode 100644 index 000000000..36db0fdef --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/assets/css/style.css @@ -0,0 +1,92 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; + margin-left: -3px; +} +.leftTable { + width: 47%; + font-size: 12px; + float: left; + text-align: center; +} +.leftTable img { + margin-top: 3px; + width: 110px; +} +.rightTable { + width: 53%; + font-size: 14px; + float: right; +} +.rightTable td { + border: 3px solid white; +} +.center { + text-align: center; +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black-bg { + background-color: black; + color: white; +} +.sm-txt { + font-size: 18px; +} +.md-txt { + font-size: 20px; +} +.xl-txt { + font-size: 36px; +} +.cell { + border: 2px solid black; + box-sizing: content-box; + width: 100%; + height: 30px; + display: flex; + justify-content: center; + align-items: center; +} +.padding { + padding: 7px; +} +.md-height { + height: 68px; + max-height: 68px; +} +.xs-width { + width: 60px; + max-width: 60px; +} +.sm-width { + width: 130px; + max-width: 130px; +} +.md-width { + width: 190px; + max-width: 190px; +} +.lg-width { + width: 240px; + max-width: 240px; +} +.overflow-multiline { + max-height: inherit; + display: -webkit-box; + overflow: hidden; + word-wrap: break-word; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.overflow-line { + width: inherit; + max-width: inherit; + overflow: hidden; + white-space: nowrap; +} \ No newline at end of file diff --git a/print/templates/reports/scan-expedition-pallet-label/locale/es.yml b/print/templates/reports/scan-expedition-pallet-label/locale/es.yml new file mode 100644 index 000000000..eb0e58f54 --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta de un pallet escaneado \ No newline at end of file diff --git a/print/templates/reports/scan-expedition-pallet-label/options.json b/print/templates/reports/scan-expedition-pallet-label/options.json new file mode 100644 index 000000000..c6ffaddea --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10.4cm", + "height": "4.9cm", + "margin": { + "top": "0.17cm", + "right": "0.3cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html new file mode 100644 index 000000000..939ab7081 --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html @@ -0,0 +1,7 @@ + + + + +
+ + \ No newline at end of file diff --git a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js new file mode 100755 index 000000000..aeb09ad4a --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js @@ -0,0 +1,40 @@ +const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); + +module.exports = { + name: 'scan-expedition-pallet-label', + async serverPrefetch() { + this.date = Date.vnNew(); + this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]); + if (!this.buys.length) throw new UserError(`Empty data source`); + this.qr = await this.getQr(this.buys[0].buyFk); + this.date = moment(this.date).format('WW/DD'); + }, + methods: { + formatNumber(number) { + return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The item id' + }, + warehouseId: { + type: Number + }, + packing: { + type: Number + }, + copies: { + type: Number + }, + userId: { + type: Number + }, + typeId: { + type: String + } + } +}; diff --git a/print/templates/reports/scan-expedition-pallet-label/sql/data.sql b/print/templates/reports/scan-expedition-pallet-label/sql/data.sql new file mode 100644 index 000000000..739f8449f --- /dev/null +++ b/print/templates/reports/scan-expedition-pallet-label/sql/data.sql @@ -0,0 +1,38 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ? +) +SELECT ROW_NUMBER() OVER() labelNum, + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName, + i.isLaid, + c.code company + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.company c ON c.id = e.companyFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file -- 2.40.1 From fe6d1da274b0b9f0e3f5f7816898982eadd75af5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 9 Jan 2025 14:19:07 +0100 Subject: [PATCH 2/2] feat: refs #7280 Second commit --- .../scan-expedition-pallet-label.html | 20 ++++++++++++++++++- .../scan-expedition-pallet-label.js | 17 +--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html index 939ab7081..3c089c31d 100644 --- a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html +++ b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.html @@ -2,6 +2,24 @@ + + + + + + + + + + + + + + + + + +
- \ No newline at end of file + diff --git a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js index aeb09ad4a..ea626d909 100755 --- a/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js +++ b/print/templates/reports/scan-expedition-pallet-label/scan-expedition-pallet-label.js @@ -19,22 +19,7 @@ module.exports = { id: { type: Number, required: true, - description: 'The item id' - }, - warehouseId: { - type: Number - }, - packing: { - type: Number - }, - copies: { - type: Number - }, - userId: { - type: Number - }, - typeId: { - type: String + description: 'The expedition pallet id' } } }; -- 2.40.1