2019-08-12 15:47:57 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2019-11-09 00:47:20 +01:00
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
2019-08-12 15:47:57 +02:00
|
|
|
*
|
2019-11-01 13:40:30 +01:00
|
|
|
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
2019-08-12 15:47:57 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* part-db version 0.1
|
|
|
|
* Copyright (C) 2005 Christoph Lechner
|
|
|
|
* http://www.cl-projects.de/.
|
|
|
|
*
|
|
|
|
* part-db version 0.2+
|
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
|
|
|
* http://code.google.com/p/part-db/
|
|
|
|
*
|
|
|
|
* Part-DB Version 0.4+
|
|
|
|
* Copyright (C) 2016 - 2019 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 General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Entity\Parts;
|
|
|
|
|
2019-09-24 13:39:49 +02:00
|
|
|
use App\Entity\Attachments\StorelocationAttachment;
|
2019-09-04 19:37:35 +02:00
|
|
|
use App\Entity\Base\PartsContainingDBElement;
|
2019-09-24 13:39:49 +02:00
|
|
|
use Doctrine\Common\Collections\Collection;
|
2019-08-12 15:47:57 +02:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
/**
|
2019-11-10 14:00:56 +01:00
|
|
|
* Class Store location.
|
2019-08-12 15:47:57 +02:00
|
|
|
*
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
|
|
|
* @ORM\Table("`storelocations`")
|
|
|
|
*/
|
2019-09-04 19:37:35 +02:00
|
|
|
class Storelocation extends PartsContainingDBElement
|
2019-08-12 15:47:57 +02:00
|
|
|
{
|
2019-09-24 13:39:49 +02:00
|
|
|
/**
|
|
|
|
* @var Collection|StorelocationAttachment[]
|
2019-09-24 18:28:35 +02:00
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
2019-09-24 13:39:49 +02:00
|
|
|
*/
|
|
|
|
protected $attachments;
|
|
|
|
|
2019-08-12 15:47:57 +02:00
|
|
|
/**
|
|
|
|
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
|
|
|
|
*/
|
|
|
|
protected $children;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children")
|
|
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
|
|
|
*/
|
|
|
|
protected $parent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
* @ORM\Column(type="boolean")
|
|
|
|
*/
|
2019-08-14 18:45:28 +02:00
|
|
|
protected $is_full = false;
|
2019-08-12 15:47:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
* @ORM\Column(type="boolean")
|
|
|
|
*/
|
2019-08-14 18:45:28 +02:00
|
|
|
protected $only_single_part = false;
|
2019-08-12 15:47:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
* @ORM\Column(type="boolean")
|
|
|
|
*/
|
2019-08-14 18:45:28 +02:00
|
|
|
protected $limit_to_existing_parts = false;
|
2019-08-12 15:47:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
|
|
|
|
* @ORM\ManyToOne(targetEntity="MeasurementUnit")
|
|
|
|
* @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id")
|
|
|
|
*/
|
|
|
|
protected $storage_type;
|
|
|
|
|
2019-09-04 19:37:35 +02:00
|
|
|
/**
|
2020-01-01 17:13:04 +01:00
|
|
|
* @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")}
|
|
|
|
* )
|
2019-09-04 19:37:35 +02:00
|
|
|
*/
|
|
|
|
protected $parts;
|
|
|
|
|
2019-08-12 15:47:57 +02:00
|
|
|
/********************************************************************************
|
|
|
|
*
|
|
|
|
* Getters
|
|
|
|
*
|
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "is full" attribute.
|
|
|
|
*
|
|
|
|
* When this attribute is set, it is not possible to add additional parts or increase the instock of existing parts.
|
|
|
|
*
|
2019-11-10 14:00:56 +01:00
|
|
|
* @return bool * true if the store location is full
|
|
|
|
* * false if the store location isn't full
|
2019-08-12 15:47:57 +02:00
|
|
|
*/
|
|
|
|
public function isFull(): bool
|
|
|
|
{
|
|
|
|
return (bool) $this->is_full;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When this property is set, only one part (but many instock) is allowed to be stored in this store location.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isOnlySinglePart(): bool
|
|
|
|
{
|
|
|
|
return $this->only_single_part;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Storelocation
|
|
|
|
*/
|
2019-11-09 00:47:20 +01:00
|
|
|
public function setOnlySinglePart(bool $only_single_part): self
|
2019-08-12 15:47:57 +02:00
|
|
|
{
|
|
|
|
$this->only_single_part = $only_single_part;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-08-12 15:47:57 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When this property is set, it is only possible to increase the instock of parts, that are already stored here.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isLimitToExistingParts(): bool
|
|
|
|
{
|
|
|
|
return $this->limit_to_existing_parts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Storelocation
|
|
|
|
*/
|
2019-11-09 00:47:20 +01:00
|
|
|
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
|
2019-08-12 15:47:57 +02:00
|
|
|
{
|
|
|
|
$this->limit_to_existing_parts = $limit_to_existing_parts;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-08-12 15:47:57 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return MeasurementUnit|null
|
|
|
|
*/
|
|
|
|
public function getStorageType(): ?MeasurementUnit
|
|
|
|
{
|
|
|
|
return $this->storage_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Storelocation
|
|
|
|
*/
|
2019-11-09 00:47:20 +01:00
|
|
|
public function setStorageType(?MeasurementUnit $storage_type): self
|
2019-08-12 15:47:57 +02:00
|
|
|
{
|
|
|
|
$this->storage_type = $storage_type;
|
2019-11-09 00:47:20 +01:00
|
|
|
|
2019-08-12 15:47:57 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
*
|
|
|
|
* Setters
|
|
|
|
*
|
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
/**
|
2019-11-10 14:00:56 +01:00
|
|
|
* Change the "is full" attribute of this store location.
|
2019-08-12 15:47:57 +02:00
|
|
|
*
|
|
|
|
* "is_full" = true means that there is no more space in this storelocation.
|
|
|
|
* This attribute is only for information, it has no effect.
|
|
|
|
*
|
|
|
|
* @param bool $new_is_full * true means that the storelocation is full
|
|
|
|
* * false means that the storelocation isn't full
|
2019-11-09 00:47:20 +01:00
|
|
|
*
|
2019-08-12 15:47:57 +02:00
|
|
|
* @return Storelocation
|
|
|
|
*/
|
2019-11-09 00:47:20 +01:00
|
|
|
public function setIsFull(bool $new_is_full): self
|
2019-08-12 15:47:57 +02:00
|
|
|
{
|
|
|
|
$this->is_full = $new_is_full;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the ID as an string, defined by the element class.
|
|
|
|
* This should have a form like P000014, for a part with ID 14.
|
|
|
|
*
|
|
|
|
* @return string The ID as a string;
|
|
|
|
*/
|
|
|
|
public function getIDString(): string
|
|
|
|
{
|
|
|
|
return 'L'.sprintf('%06d', $this->getID());
|
|
|
|
}
|
|
|
|
}
|