Added support for Code128 barcode.

This commit is contained in:
Jan Böhmer 2020-05-07 23:27:40 +02:00
parent c58b36e9c5
commit f64910374f
5 changed files with 14 additions and 5 deletions

View file

@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
*/ */
class LabelOptions 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 SUPPORTED_ELEMENTS = ['part', 'part_lot'];
public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment']; public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];

View file

@ -75,6 +75,7 @@ class LabelOptionsType extends AbstractType
'choices' => [ 'choices' => [
'label_options.barcode_type.none' => 'none', 'label_options.barcode_type.none' => 'none',
'label_options.barcode_type.qr' => 'qr', 'label_options.barcode_type.qr' => 'qr',
'label_options.barcode_type.code128' => 'code128',
'label_options.barcode_type.code39' => 'code39', 'label_options.barcode_type.code39' => 'code39',
'label_options.barcode_type.code93' => 'code93', 'label_options.barcode_type.code93' => 'code93',
'label_options.barcode_type.datamatrix' => 'datamatrix', 'label_options.barcode_type.datamatrix' => 'datamatrix',
@ -83,7 +84,7 @@ class LabelOptionsType extends AbstractType
if (in_array($choice, ['qr', 'datamatrix'])) { if (in_array($choice, ['qr', 'datamatrix'])) {
return 'label_options.barcode_type.2D'; 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'; return 'label_options.barcode_type.1D';
} }

View file

@ -50,14 +50,15 @@ class BarcodeGenerator
case 'code93': case 'code93':
$type = 'C93'; $type = 'C93';
break; break;
case 'code128':
$type = 'C128A';
break;
case 'none': case 'none':
return null; return null;
default: default:
throw new \InvalidArgumentException('Unknown label type!'); throw new \InvalidArgumentException('Unknown label type!');
} }
$bobj = $barcode->getBarcodeObj($type, $this->getContent($options, $target)); $bobj = $barcode->getBarcodeObj($type, $this->getContent($options, $target));
return $bobj->getSvgCode(); return $bobj->getSvgCode();
@ -71,6 +72,7 @@ class BarcodeGenerator
return $this->barcodeContentGenerator->getURLContent($target); return $this->barcodeContentGenerator->getURLContent($target);
case 'code39': case 'code39':
case 'code93': case 'code93':
case 'code128':
return $this->barcodeContentGenerator->get1DBarcodeContent($target); return $this->barcodeContentGenerator->get1DBarcodeContent($target);
case 'none': case 'none':
return null; return null;

View file

@ -18,7 +18,7 @@
{% include "LabelSystem/labels/label_page_none.html.twig" %} {% include "LabelSystem/labels/label_page_none.html.twig" %}
{% elseif options.barcodeType in ['qr', 'datamatrix'] %} {% elseif options.barcodeType in ['qr', 'datamatrix'] %}
{% include "LabelSystem/labels/label_page_qr.html.twig" %} {% include "LabelSystem/labels/label_page_qr.html.twig" %}
{% elseif options.barcodeType in ['code39', 'code93'] %} {% elseif options.barcodeType in ['code39', 'code93', 'code128'] %}
{% include "LabelSystem/labels/label_page_1d.html.twig" %} {% include "LabelSystem/labels/label_page_1d.html.twig" %}
{% endif %} {% endif %}
</div> </div>

View file

@ -8430,5 +8430,11 @@ Element 3</target>
<target>Update</target> <target>Update</target>
</segment> </segment>
</unit> </unit>
<unit id="uIJQMqh" name="label_options.barcode_type.code128">
<segment>
<source>label_options.barcode_type.code128</source>
<target>Code 128 (recommended)</target>
</segment>
</unit>
</file> </file>
</xliff> </xliff>