mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added different barcodes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user