mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 12:18:54 +02:00
Use shorter format for barcodes, to generate shorter (better readable) barcodes.
This commit is contained in:
parent
f9f2774f36
commit
3dd0ef26b3
4 changed files with 22 additions and 9 deletions
|
@ -48,7 +48,18 @@ class BarcodeNormalizer
|
|||
return [$matches[1], (int) $matches[2]];
|
||||
}
|
||||
|
||||
//New Code39 barcodes use L-000001 format
|
||||
//New Code39 barcode use L0001 format
|
||||
if (preg_match('#^([A-Z])(\d{4,})$#', $input, $matches)) {
|
||||
$prefix = $matches[1];
|
||||
$id = (int) $matches[2];
|
||||
|
||||
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
||||
throw new \InvalidArgumentException('Unknown prefix ' . $prefix);
|
||||
}
|
||||
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
||||
}
|
||||
|
||||
//During development the L-000001 format was used
|
||||
if (preg_match('#^(\w)-(\d{6,})$#', $input, $matches)) {
|
||||
$prefix = $matches[1];
|
||||
$id = (int) $matches[2];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue