2020-04-11 17:34:01 +02:00
|
|
|
<?php
|
2020-05-10 21:39:31 +02:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
/**
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Entity\LabelSystem;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Embeddable()
|
|
|
|
*/
|
|
|
|
class LabelOptions
|
|
|
|
{
|
2020-05-07 23:27:40 +02:00
|
|
|
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128'];
|
2020-05-08 13:49:44 +02:00
|
|
|
public const SUPPORTED_ELEMENTS = ['part', 'part_lot', 'storelocation'];
|
2020-04-11 17:34:01 +02:00
|
|
|
public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];
|
2020-05-02 19:47:31 +02:00
|
|
|
|
|
|
|
public const LINES_MODES = ['html', 'twig'];
|
2020-04-11 17:34:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float The page size of the label in mm
|
|
|
|
* @Assert\Positive()
|
|
|
|
* @ORM\Column(type="float")
|
|
|
|
*/
|
|
|
|
protected $width = 50.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float The page size of the label in mm
|
|
|
|
* @Assert\Positive()
|
|
|
|
* @ORM\Column(type="float")
|
|
|
|
*/
|
|
|
|
protected $height = 30.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The type of the barcode that should be used in the label (e.g. 'qr')
|
|
|
|
* @Assert\Choice(choices=LabelOptions::BARCODE_TYPES)
|
|
|
|
* @ORM\Column(type="string")
|
|
|
|
*/
|
|
|
|
protected $barcode_type = 'none';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string What image should be shown along the
|
|
|
|
* @Assert\Choice(choices=LabelOptions::PICTURE_TYPES)
|
|
|
|
* @ORM\Column(type="string")
|
|
|
|
*/
|
|
|
|
protected $picture_type = 'none';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
* @Assert\Choice(choices=LabelOptions::SUPPORTED_ELEMENTS)
|
|
|
|
* @ORM\Column(type="string")
|
|
|
|
*/
|
|
|
|
protected $supported_element = 'part';
|
|
|
|
|
|
|
|
/**
|
2020-05-02 19:47:31 +02:00
|
|
|
* @var string Any additional CSS for the label.
|
|
|
|
* @ORM\Column(type="text")
|
|
|
|
*/
|
|
|
|
protected $additional_css = '';
|
|
|
|
|
|
|
|
/** @var string The mode that will be used to interpret the lines.
|
|
|
|
* @Assert\Choice(choices=LabelOptions::LINES_MODES)
|
2020-04-11 17:34:01 +02:00
|
|
|
* @ORM\Column(type="string")
|
|
|
|
*/
|
2020-05-02 19:47:31 +02:00
|
|
|
protected $lines_mode = 'html';
|
2020-04-11 17:34:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
* @ORM\Column(type="text")
|
|
|
|
*/
|
|
|
|
protected $lines = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getWidth(): float
|
|
|
|
{
|
|
|
|
return $this->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setWidth(float $width): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->width = $width;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getHeight(): float
|
|
|
|
{
|
|
|
|
return $this->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setHeight(float $height): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->height = $height;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getBarcodeType(): string
|
|
|
|
{
|
|
|
|
return $this->barcode_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setBarcodeType(string $barcode_type): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->barcode_type = $barcode_type;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPictureType(): string
|
|
|
|
{
|
|
|
|
return $this->picture_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setPictureType(string $picture_type): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->picture_type = $picture_type;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getSupportedElement(): string
|
|
|
|
{
|
|
|
|
return $this->supported_element;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setSupportedElement(string $supported_element): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->supported_element = $supported_element;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getLines(): string
|
|
|
|
{
|
|
|
|
return $this->lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setLines(string $lines): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->lines = $lines;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:06 +02:00
|
|
|
/**
|
2020-05-10 21:39:31 +02:00
|
|
|
* Gets additional CSS (it will simply be attached.
|
|
|
|
*
|
2020-05-04 22:19:06 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getAdditionalCss(): string
|
|
|
|
{
|
|
|
|
return $this->additional_css;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setAdditionalCss(string $additional_css): self
|
2020-05-04 22:19:06 +02:00
|
|
|
{
|
|
|
|
$this->additional_css = $additional_css;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-05-04 22:19:06 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getLinesMode(): string
|
|
|
|
{
|
|
|
|
return $this->lines_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return LabelOptions
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setLinesMode(string $lines_mode): self
|
2020-05-04 22:19:06 +02:00
|
|
|
{
|
|
|
|
$this->lines_mode = $lines_mode;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-05-04 22:19:06 +02:00
|
|
|
return $this;
|
|
|
|
}
|
2020-05-10 21:39:31 +02:00
|
|
|
}
|