mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 04:08:57 +02:00
Added support for Code128 barcode.
This commit is contained in:
parent
c58b36e9c5
commit
f64910374f
5 changed files with 14 additions and 5 deletions
|
@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
*/
|
||||
class LabelOptions
|
||||
{
|
||||
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93'];
|
||||
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128'];
|
||||
public const SUPPORTED_ELEMENTS = ['part', 'part_lot'];
|
||||
public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ class LabelOptionsType extends AbstractType
|
|||
'choices' => [
|
||||
'label_options.barcode_type.none' => 'none',
|
||||
'label_options.barcode_type.qr' => 'qr',
|
||||
'label_options.barcode_type.code128' => 'code128',
|
||||
'label_options.barcode_type.code39' => 'code39',
|
||||
'label_options.barcode_type.code93' => 'code93',
|
||||
'label_options.barcode_type.datamatrix' => 'datamatrix',
|
||||
|
@ -83,7 +84,7 @@ class LabelOptionsType extends AbstractType
|
|||
if (in_array($choice, ['qr', 'datamatrix'])) {
|
||||
return 'label_options.barcode_type.2D';
|
||||
}
|
||||
if (in_array($choice, ['code39', 'code93'])) {
|
||||
if (in_array($choice, ['code39', 'code93', 'code128'])) {
|
||||
return 'label_options.barcode_type.1D';
|
||||
}
|
||||
|
||||
|
|
|
@ -50,14 +50,15 @@ class BarcodeGenerator
|
|||
case 'code93':
|
||||
$type = 'C93';
|
||||
break;
|
||||
case 'code128':
|
||||
$type = 'C128A';
|
||||
break;
|
||||
case 'none':
|
||||
return null;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown label type!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$bobj = $barcode->getBarcodeObj($type, $this->getContent($options, $target));
|
||||
|
||||
return $bobj->getSvgCode();
|
||||
|
@ -71,6 +72,7 @@ class BarcodeGenerator
|
|||
return $this->barcodeContentGenerator->getURLContent($target);
|
||||
case 'code39':
|
||||
case 'code93':
|
||||
case 'code128':
|
||||
return $this->barcodeContentGenerator->get1DBarcodeContent($target);
|
||||
case 'none':
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue