diff --git a/db/versions/10991-greenAsparagus/00-firstScript.sql b/db/versions/10991-greenAsparagus/00-firstScript.sql
new file mode 100644
index 000000000..9cfc9e19d
--- /dev/null
+++ b/db/versions/10991-greenAsparagus/00-firstScript.sql
@@ -0,0 +1,2 @@
+ALTER TABLE vn.productionConfig MODIFY COLUMN id INT(10) UNSIGNED FIRST;
+ALTER TABLE vn.productionConfig ADD scannableCodeType enum('qr','barcode') DEFAULT 'barcode' NOT NULL;
diff --git a/modules/client/front/consumption/index.html b/modules/client/front/consumption/index.html
index 17e1e8c8b..06611da5a 100644
--- a/modules/client/front/consumption/index.html
+++ b/modules/client/front/consumption/index.html
@@ -77,8 +77,7 @@
tabindex="-1">
- {{::sale.quantity | dashIfEmpty}}
-
+ {{::sale.quantity | dashIfEmpty}}
diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css
index eb300f850..3eb68a2b2 100644
--- a/print/templates/reports/collection-label/assets/css/style.css
+++ b/print/templates/reports/collection-label/assets/css/style.css
@@ -32,9 +32,12 @@ html {
#bold {
font-weight: bold;
}
-#barcode{
+.barcode{
width: 370px;
}
+.qr{
+ max-height: 137px;
+}
#shipped {
font-weight: bold;
width: 50px;
diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html
index a0bfcad0e..752a31185 100644
--- a/print/templates/reports/collection-label/collection-label.html
+++ b/print/templates/reports/collection-label/collection-label.html
@@ -8,11 +8,15 @@
{{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}}
|
- {{labelData.shipped || '---'}} |
+ {{dashIfEmpty(labelData.shipped)}} |
-
- |
- {{labelData.workerCode || '---'}} |
+
+ |
+ {{dashIfEmpty(labelData.workerCode)}} |
+
+
+ |
+ {{dashIfEmpty(labelData.workerCode)}} |
{{labelData.labelCount || 0}} |
@@ -21,11 +25,11 @@
{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}} |
- {{getAgencyDescripton(labelData)}} |
+ {{dashIfEmpty(getAgencyDescription(labelData))}} |
{{labelData.lineCount || 0}} |
- {{labelData.nickName ? labelData.nickName.toUpperCase() : '---'}} |
+ {{dashIfEmpty(labelData?.nickName.toUpperCase()) }} |
{{labelData.shippedHour || labelData.zoneHour}} |
diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js
index db2adeb34..f2f697ae6 100644
--- a/print/templates/reports/collection-label/collection-label.js
+++ b/print/templates/reports/collection-label/collection-label.js
@@ -1,6 +1,7 @@
-const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom');
const vnReport = require('../../../core/mixins/vn-report.js');
+const {toDataURL} = require('qrcode');
+const jsBarcode = require('jsbarcode');
module.exports = {
name: 'collection-label',
@@ -27,10 +28,28 @@ module.exports = {
} else
ticketIds = [this.id];
- this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
+ const labels = await this.rawSqlFromDef('labelsData', [ticketIds]);
+
+ const [{scannableCodeType}] = await this.rawSqlFromDef('barcodeType');
+ if (scannableCodeType === 'qr') {
+ for (const labelData of labels)
+ labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk);
+ }
+
+ this.labelsData = labels;
this.checkMainEntity(this.labelsData);
},
methods: {
+ async getQr(ticketFk, workerFk = null) {
+ const QRdata = JSON.stringify({
+ company: 'vnl',
+ user: workerFk,
+ created: Date.vnNew(),
+ table: 'ticket',
+ id: ticketFk
+ });
+ return toDataURL(QRdata, {margin: 0});
+ },
getBarcode(id) {
const xmlSerializer = new XMLSerializer();
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
@@ -52,18 +71,16 @@ module.exports = {
if (labelData.code == 'V')
value = value + `${labelData.wagon}-${labelData.level}`;
else
- value = value + `${labelData.color.substring(0, 4)}`;
+ value = value + `${labelData.color?.substring(0, 4)}`;
} else
value = '-'.repeat(19);
return value;
},
- getAgencyDescripton(labelData) {
+ getAgencyDescription(labelData) {
let value;
if (labelData.agencyDescription)
value = labelData.agencyDescription.toUpperCase().substring(0, 11);
- else
- value = '---';
if (labelData.routeFk) {
let routeFk = labelData.routeFk.toString();
@@ -72,5 +89,8 @@ module.exports = {
return value;
},
+ dashIfEmpty(value) {
+ return value || '---';
+ }
},
};
diff --git a/print/templates/reports/collection-label/sql/barcodeType.sql b/print/templates/reports/collection-label/sql/barcodeType.sql
new file mode 100644
index 000000000..0700c95a2
--- /dev/null
+++ b/print/templates/reports/collection-label/sql/barcodeType.sql
@@ -0,0 +1,3 @@
+SELECT scannableCodeType
+ FROM productionConfig
+ LIMIT 1
\ No newline at end of file
diff --git a/print/templates/reports/collection-label/sql/labelsData.sql b/print/templates/reports/collection-label/sql/labelsData.sql
index 61990812d..f0a9baf1f 100644
--- a/print/templates/reports/collection-label/sql/labelsData.sql
+++ b/print/templates/reports/collection-label/sql/labelsData.sql
@@ -11,6 +11,7 @@ SELECT c.itemPackingTypeFk code,
IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`)
) `size`,
w.code workerCode,
+ w.id workerFk,
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,