diff --git a/src/Entity/LabelSystem/LabelOptions.php b/src/Entity/LabelSystem/LabelOptions.php index 4d9323aa..381186d7 100644 --- a/src/Entity/LabelSystem/LabelOptions.php +++ b/src/Entity/LabelSystem/LabelOptions.php @@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ class LabelOptions { - public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39']; + public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93']; public const SUPPORTED_ELEMENTS = ['part', 'part_lot']; public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment']; public const POSITIONS = ['left', 'right', 'top', 'bottom']; diff --git a/src/Form/LabelOptionsType.php b/src/Form/LabelOptionsType.php index 307d9af5..009f3e0a 100644 --- a/src/Form/LabelOptionsType.php +++ b/src/Form/LabelOptionsType.php @@ -67,7 +67,24 @@ class LabelOptionsType extends AbstractType 'label_options.barcode_type.none' => 'none', 'label_options.barcode_type.qr' => 'qr', 'label_options.barcode_type.code39' => 'code39', - ] + 'label_options.barcode_type.code93' => 'code93', + 'label_options.barcode_type.datamatrix' => 'datamatrix', + ], + 'group_by' => function ($choice, $key, $value) { + if (in_array($choice, ['qr', 'datamatrix'])) { + return 'label_options.barcode_type.2D'; + } + if (in_array($choice, ['code39', 'code93'])) { + return 'label_options.barcode_type.1D'; + } + + return null; + }, + 'attr' => [ + 'class' => 'selectpicker', + 'data-live-search' => true, + ], + ]); $builder->add('lines', CKEditorType::class, [ diff --git a/src/Services/LabelSystem/BarcodeGenerator.php b/src/Services/LabelSystem/BarcodeGenerator.php index 47c1f949..8d7d27d2 100644 --- a/src/Services/LabelSystem/BarcodeGenerator.php +++ b/src/Services/LabelSystem/BarcodeGenerator.php @@ -41,9 +41,15 @@ class BarcodeGenerator case 'qr': $type = 'QRCODE'; break; + case 'datamatrix': + $type = 'DATAMATRIX'; + break; case 'code39': $type = 'C93'; break; + case 'code93': + $type = 'C93'; + break; case 'none': return null; default: @@ -61,8 +67,10 @@ class BarcodeGenerator { switch ($options->getBarcodeType()) { case 'qr': + case 'datamatrix': return $this->barcodeContentGenerator->getURLContent($target); case 'code39': + case 'code93': return $this->barcodeContentGenerator->get1DBarcodeContent($target); case 'none': return null; diff --git a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php index 54d3f79f..d50fb36c 100644 --- a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php +++ b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php @@ -58,11 +58,7 @@ class BarcodeContentGenerator */ public function getURLContent(AbstractDBElement $target): string { - if ($target instanceof Part) { - $type = 'part'; - } else { - throw new EntityNotSupportedException(); - } + $type = $this->classToString(self::URL_MAP, $target); return $this->urlGenerator->generate('scan_qr', [ 'type' => $type, diff --git a/templates/LabelSystem/labels/base_label.html.twig b/templates/LabelSystem/labels/base_label.html.twig index 5e086d75..d56ddff1 100644 --- a/templates/LabelSystem/labels/base_label.html.twig +++ b/templates/LabelSystem/labels/base_label.html.twig @@ -15,9 +15,9 @@