Added Code93 and Datamatrix as valid barcode types.

This commit is contained in:
Jan Böhmer 2020-04-24 23:58:19 +02:00
parent 6bd3ad6138
commit 3beba96e39
6 changed files with 120 additions and 9 deletions

View file

@ -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'];

View file

@ -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, [

View file

@ -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;

View file

@ -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,

View file

@ -15,9 +15,9 @@
<div style="page-break-inside: avoid; page-break-before: avoid; {% if not loop.last %}page-break-after: always;{% endif %}">
{% 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 %}
</div>

View file

@ -8280,5 +8280,95 @@ Element 3</target>
<target>Width</target>
</segment>
</unit>
<unit id="MxYhcsN" name="label_options.barcode_type.qr">
<segment>
<source>label_options.barcode_type.qr</source>
<target>QR Code (recommended)</target>
</segment>
</unit>
<unit id="kPFpWmf" name="label_options.barcode_type.datamatrix">
<segment>
<source>label_options.barcode_type.datamatrix</source>
<target>Datamatrix</target>
</segment>
</unit>
<unit id="8jpgdV8" name="label_options.barcode_type.2D">
<segment>
<source>label_options.barcode_type.2D</source>
<target>2D</target>
</segment>
</unit>
<unit id="O7.UnHb" name="label_options.barcode_type.1D">
<segment>
<source>label_options.barcode_type.1D</source>
<target>1D</target>
</segment>
</unit>
<unit id="56JwbDf" name="label_options.barcode_type.code39">
<segment>
<source>label_options.barcode_type.code39</source>
<target>Code 39 (recommended)</target>
</segment>
</unit>
<unit id="Z8_BSQ1" name="label_profile.lines.label">
<segment>
<source>label_profile.lines.label</source>
<target>Content</target>
</segment>
</unit>
<unit id="FmESg.O" name="label_options.barcode_type.none">
<segment>
<source>label_options.barcode_type.none</source>
<target>None</target>
</segment>
</unit>
<unit id="lz068u3" name="label_options.barcode_type.code93">
<segment>
<source>label_options.barcode_type.code93</source>
<target>Code 93</target>
</segment>
</unit>
<unit id="bqeaYn7" name="label_generator.title">
<segment>
<source>label_generator.title</source>
<target>Label generator</target>
</segment>
</unit>
<unit id="GN.UJxb" name="label_generator.target_id.label">
<segment>
<source>label_generator.target_id.label</source>
<target>Target ID</target>
</segment>
</unit>
<unit id="nez5RLt" name="label_generator.target_id.range_hint">
<segment>
<source>label_generator.target_id.range_hint</source>
<target>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.</target>
</segment>
</unit>
<unit id="7ZEGFJ3" name="label_options.supported_elements.label">
<segment>
<source>label_options.supported_elements.label</source>
<target>Target type</target>
</segment>
</unit>
<unit id="t.j1KtN" name="label_options.height.placeholder">
<segment>
<source>label_options.height.placeholder</source>
<target>Height</target>
</segment>
</unit>
<unit id="eSLhawk" name="label_options.barcode_type.label">
<segment>
<source>label_options.barcode_type.label</source>
<target>Barcode</target>
</segment>
</unit>
<unit id="UFelt6r" name="label_generator.download">
<segment>
<source>label_generator.download</source>
<target>Download</target>
</segment>
</unit>
</file>
</xliff>