mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Added basic admin page for Label profiles.
This commit is contained in:
parent
b23dec0262
commit
a8a92b9c5d
20 changed files with 1688 additions and 857 deletions
|
@ -43,7 +43,7 @@ use LogicException;
|
|||
* "Footprint" = "FootprintAttachment", "Manufacturer" = "ManufacturerAttachment",
|
||||
* "Currency" = "CurrencyAttachment", "Group" = "GroupAttachment",
|
||||
* "MeasurementUnit" = "MeasurementUnitAttachment", "Storelocation" = "StorelocationAttachment",
|
||||
* "Supplier" = "SupplierAttachment", "User" = "UserAttachment"
|
||||
* "Supplier" = "SupplierAttachment", "User" = "UserAttachment", "LabelProfile" = "LabelAttachment",
|
||||
* })
|
||||
* @ORM\EntityListeners({"App\EntityListeners\AttachmentDeleteListener"})
|
||||
*/
|
||||
|
|
44
src/Entity/Attachments/LabelAttachment.php
Normal file
44
src/Entity/Attachments/LabelAttachment.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* 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\Attachments;
|
||||
|
||||
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
/**
|
||||
* A attachment attached to a user element.
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @UniqueEntity({"name", "attachment_type", "element"})
|
||||
*/
|
||||
class LabelAttachment extends Attachment
|
||||
{
|
||||
public const ALLOWED_ELEMENT_CLASS = LabelProfile::class;
|
||||
|
||||
/**
|
||||
* @var LabelProfile the element this attachment is associated with
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\LabelSystem\LabelProfile", inversedBy="attachments")
|
||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
262
src/Entity/LabelSystem/LabelOptions.php
Normal file
262
src/Entity/LabelSystem/LabelOptions.php
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39'];
|
||||
public const SUPPORTED_ELEMENTS = ['part'];
|
||||
public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment'];
|
||||
public const POSITIONS = ['left', 'right', 'top', 'bottom'];
|
||||
public const FONTS = ['default'];
|
||||
|
||||
/**
|
||||
* @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 The position where the barcode should be put
|
||||
* @Assert\Choice(choices=LabelOptions::POSITIONS)
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $barcode_position = 'left';
|
||||
|
||||
/**
|
||||
* @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::POSITIONS)
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $picture_position = 'left';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @Assert\Choice(choices=LabelOptions::SUPPORTED_ELEMENTS)
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $supported_element = 'part';
|
||||
|
||||
/**
|
||||
* @var string The font that should be used in the Barcode
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $font = 'default';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $lines = '';
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $width
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setWidth(float $width): LabelOptions
|
||||
{
|
||||
$this->width = $width;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $height
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setHeight(float $height): LabelOptions
|
||||
{
|
||||
$this->height = $height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBarcodeType(): string
|
||||
{
|
||||
return $this->barcode_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $barcode_type
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setBarcodeType(string $barcode_type): LabelOptions
|
||||
{
|
||||
$this->barcode_type = $barcode_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBarcodePosition(): string
|
||||
{
|
||||
return $this->barcode_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $barcode_position
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setBarcodePosition(string $barcode_position): LabelOptions
|
||||
{
|
||||
$this->barcode_position = $barcode_position;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPictureType(): string
|
||||
{
|
||||
return $this->picture_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $picture_type
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setPictureType(string $picture_type): LabelOptions
|
||||
{
|
||||
$this->picture_type = $picture_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPicturePosition(): string
|
||||
{
|
||||
return $this->picture_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $picture_position
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setPicturePosition(string $picture_position): LabelOptions
|
||||
{
|
||||
$this->picture_position = $picture_position;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSupportedElement(): string
|
||||
{
|
||||
return $this->supported_element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $supported_element
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setSupportedElement(string $supported_element): LabelOptions
|
||||
{
|
||||
$this->supported_element = $supported_element;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFont(): string
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $font
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setFont(string $font): LabelOptions
|
||||
{
|
||||
$this->font = $font;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLines(): string
|
||||
{
|
||||
return $this->lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lines
|
||||
* @return LabelOptions
|
||||
*/
|
||||
public function setLines(string $lines): LabelOptions
|
||||
{
|
||||
$this->lines = $lines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
92
src/Entity/LabelSystem/LabelProfile.php
Normal file
92
src/Entity/LabelSystem/LabelProfile.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* 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 App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\LabelAttachment;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\NamedDBElementRepository")
|
||||
* @ORM\Table(name="label_profiles")
|
||||
* @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"})
|
||||
* @UniqueEntity({"name", "options.supported_element"})
|
||||
* @package App\Entity\LabelSystem
|
||||
*/
|
||||
class LabelProfile extends AttachmentContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @var Collection<int, LabelAttachment>
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\LabelAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"name" = "ASC"})
|
||||
*/
|
||||
protected $attachments;
|
||||
|
||||
/**
|
||||
* @var LabelOptions
|
||||
* @ORM\Embedded(class="LabelOptions")
|
||||
* @Assert\Valid()
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var string The comment info for this element
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $comment = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->options = new LabelOptions();
|
||||
}
|
||||
|
||||
public function getOptions(): LabelOptions
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comment of the element.
|
||||
* @return string the comment
|
||||
*/
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function setComment(string $new_comment): string
|
||||
{
|
||||
$this->comment = $new_comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIDString(): string
|
||||
{
|
||||
return 'LP'.sprintf('%09d', $this->getID());
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ use App\Entity\Attachments\AttachmentType;
|
|||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Devices\Device;
|
||||
use App\Entity\Devices\DevicePart;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use App\Entity\Parameters\AbstractParameter;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
|
@ -117,6 +118,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
protected const TARGET_TYPE_PRICEDETAIL = 16;
|
||||
protected const TARGET_TYPE_MEASUREMENTUNIT = 17;
|
||||
protected const TARGET_TYPE_PARAMETER = 18;
|
||||
protected const TARGET_TYPE_LABEL_PROFILE = 19;
|
||||
|
||||
/** @var array This const is used to convert the numeric level to a PSR-3 compatible log level */
|
||||
protected const LEVEL_ID_TO_STRING = [
|
||||
|
@ -149,6 +151,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
self::TARGET_TYPE_PRICEDETAIL => Pricedetail::class,
|
||||
self::TARGET_TYPE_MEASUREMENTUNIT => MeasurementUnit::class,
|
||||
self::TARGET_TYPE_PARAMETER => AbstractParameter::class,
|
||||
self::TARGET_TYPE_LABEL_PROFILE => LabelProfile::class,
|
||||
];
|
||||
|
||||
/** @var User The user which has caused this log entry
|
||||
|
@ -163,7 +166,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
protected $timestamp;
|
||||
|
||||
/** @var int The priority level of the associated level. 0 is highest, 7 lowest
|
||||
* @ORM\Column(type="integer", name="level", columnDefinition="TINYINT")
|
||||
* @ORM\Column(type="integer", name="level", columnDefinition="TINYINT(4) NOT NULL")
|
||||
*/
|
||||
protected $level;
|
||||
|
||||
|
|
|
@ -85,11 +85,11 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
protected $storage_type;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="part_lots",
|
||||
* joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")}
|
||||
* )
|
||||
* //@ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* //@ORM\JoinTable(name="part_lots",
|
||||
* // joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")},
|
||||
* // inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")}
|
||||
* //)
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
|
|
|
@ -101,11 +101,11 @@ class Supplier extends AbstractCompany
|
|||
protected $shipping_costs;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="orderdetails",
|
||||
* joinColumns={@ORM\JoinColumn(name="id_supplier", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="part_id", referencedColumnName="id")}
|
||||
* )
|
||||
* //@ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* //@ORM\JoinTable(name="orderdetails",
|
||||
* // joinColumns={@ORM\JoinColumn(name="id_supplier", referencedColumnName="id")},
|
||||
* // inverseJoinColumns={@ORM\JoinColumn(name="part_id", referencedColumnName="id")}
|
||||
* //)
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue