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 @@
{% if options.barcodeType == 'none' %} {% include "LabelSystem/labels/label_page_none.html.twig" %} - {% elseif options.barcodeType == 'qr' %} + {% elseif options.barcodeType in ['qr', 'datamatrix'] %} {% include "LabelSystem/labels/label_page_qr.html.twig" %} - {% elseif options.barcodeType == 'code39' %} + {% elseif options.barcodeType in ['code39', 'code93'] %} {% include "LabelSystem/labels/label_page_1d.html.twig" %} {% endif %}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 6757eda3..86c76622 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -8280,5 +8280,95 @@ Element 3 Width + + + label_options.barcode_type.qr + QR Code (recommended) + + + + + label_options.barcode_type.datamatrix + Datamatrix + + + + + label_options.barcode_type.2D + 2D + + + + + label_options.barcode_type.1D + 1D + + + + + label_options.barcode_type.code39 + Code 39 (recommended) + + + + + label_profile.lines.label + Content + + + + + label_options.barcode_type.none + None + + + + + label_options.barcode_type.code93 + Code 93 + + + + + label_generator.title + Label generator + + + + + label_generator.target_id.label + Target ID + + + + + label_generator.target_id.range_hint + You can specify multiple IDs (e.g. 1,2,3) and/or a range (1-3) here to generate labels for multiple elements at once. + + + + + label_options.supported_elements.label + Target type + + + + + label_options.height.placeholder + Height + + + + + label_options.barcode_type.label + Barcode + + + + + label_generator.download + Download + +