Added different barcodes

This commit is contained in:
2025-10-31 10:33:20 +01:00
parent a327932ff5
commit 387a1538d4
5 changed files with 97 additions and 17 deletions

View File

@@ -85,9 +85,53 @@ function printBarcode(svgId) {
printWindow.close();
}
function idToEAN13(id) {
const padded = id.toString().padStart(12, "0"); // 12 digits
return padded;
function getBarcodeValue(BARCODE_TYPE, assetId) {
if (!assetId) return "";
const type = BARCODE_TYPE.toUpperCase();
if (type === "EAN13") {
let numeric = assetId.replace(/\D/g, "");
if (numeric.length < 12) {
numeric = numeric.padStart(12, "0");
} else if (numeric.length > 12) {
numeric = numeric.slice(0, 12);
}
return numeric;
} else if (type === "EAN8") {
let numeric = assetId.replace(/\D/g, "");
if (numeric.length < 7) {
numeric = numeric.padStart(7, "0");
} else if (numeric.length > 7) {
numeric = numeric.slice(0, 7);
}
return numeric;
} else if (type === "UPC") {
let numeric = assetId.replace(/\D/g, "");
if (numeric.length < 11) {
numeric = numeric.padStart(11, "0");
} else if (numeric.length > 11) {
numeric = numeric.slice(0, 11);
}
return numeric;
} else if (type === "ITF14") {
let numeric = assetId.replace(/\D/g, "");
if (numeric.length < 13) {
numeric = numeric.padStart(13, "0");
} else if (numeric.length > 13) {
numeric = numeric.slice(0, 13);
}
return numeric;
} else if (type === "PHARMACODE") {
let numeric = assetId.replace(/\D/g, "");
if (numeric.length < 2) {
numeric = numeric.padStart(6, "0");
} else if (numeric.length > 6) {
numeric = numeric.slice(0, 6);
}
return numeric;
}
return assetId.toString().padStart(12, "0");
}
// Table filter