mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-31 23:40:20 +02:00
Added Code93 and Datamatrix as valid barcode types.
This commit is contained in:
parent
6bd3ad6138
commit
3beba96e39
6 changed files with 120 additions and 9 deletions
|
@ -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'];
|
||||
|
|
|
@ -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, [
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue