mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 21:04:34 +02:00
Added entities and properties for some future features.
This commit is contained in:
parent
bcdba8b3e0
commit
7826e3d2ad
49 changed files with 1477 additions and 362 deletions
286
src/Entity/Parts/Category.php
Normal file
286
src/Entity/Parts/Category.php
Normal file
|
@ -0,0 +1,286 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Part-DB Version 0.4+ "nextgen"
|
||||
* 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;
|
||||
|
||||
use App\Entity\Base\PartsContainingDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class AttachmentType.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table(name="`categories`")
|
||||
*/
|
||||
class Category extends PartsContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="category")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $partname_hint = "";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $partname_regex = "";
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $disable_footprints = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $disable_manufacturers = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $disable_autodatasheets = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $disable_properties = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $default_description = "";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $default_comment = "";
|
||||
|
||||
/**
|
||||
* 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 'C'.sprintf('%09d', $this->getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPartnameHint(): string
|
||||
{
|
||||
return $this->partname_hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $partname_hint
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameHint(string $partname_hint): Category
|
||||
{
|
||||
$this->partname_hint = $partname_hint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPartnameRegex(): string
|
||||
{
|
||||
return $this->partname_regex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $partname_regex
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameRegex(string $partname_regex): Category
|
||||
{
|
||||
$this->partname_regex = $partname_regex;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableFootprints(): bool
|
||||
{
|
||||
return $this->disable_footprints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_footprints
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableFootprints(bool $disable_footprints): Category
|
||||
{
|
||||
$this->disable_footprints = $disable_footprints;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableManufacturers(): bool
|
||||
{
|
||||
return $this->disable_manufacturers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_manufacturers
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableManufacturers(bool $disable_manufacturers): Category
|
||||
{
|
||||
$this->disable_manufacturers = $disable_manufacturers;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableAutodatasheets(): bool
|
||||
{
|
||||
return $this->disable_autodatasheets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_autodatasheets
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableAutodatasheets(bool $disable_autodatasheets): Category
|
||||
{
|
||||
$this->disable_autodatasheets = $disable_autodatasheets;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableProperties(): bool
|
||||
{
|
||||
return $this->disable_properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_properties
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableProperties(bool $disable_properties): Category
|
||||
{
|
||||
$this->disable_properties = $disable_properties;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDescription(): string
|
||||
{
|
||||
return $this->default_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $default_description
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultDescription(string $default_description): Category
|
||||
{
|
||||
$this->default_description = $default_description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultComment(): string
|
||||
{
|
||||
return $this->default_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $default_comment
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultComment(string $default_comment): Category
|
||||
{
|
||||
$this->default_comment = $default_comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
244
src/Entity/Parts/Footprint.php
Normal file
244
src/Entity/Parts/Footprint.php
Normal file
|
@ -0,0 +1,244 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
use App\Entity\Base\PartsContainingDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Footprint.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table("`footprints`")
|
||||
*/
|
||||
class Footprint extends PartsContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=65536)
|
||||
*/
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=65536)
|
||||
*/
|
||||
protected $filename_3d;
|
||||
|
||||
/**
|
||||
* 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 'F'.sprintf('%06d', $this->getID());
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* Getters
|
||||
****************************************/
|
||||
|
||||
/**
|
||||
* Get the filename of the picture (absolute path from filesystem root).
|
||||
*
|
||||
* @return string the saved filename in the DB
|
||||
* * an empty string if there is no picture
|
||||
*/
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename of the 3d model (absolute path from filesystem root).
|
||||
*
|
||||
* @param bool $absolute If set to true, then the absolute filename (from system root) is returned.
|
||||
* If set to false, then the path relative to Part-DB folder is returned.
|
||||
*
|
||||
* @return string * the absolute path to the model (from filesystem root), as a UNIX path (with slashes)
|
||||
* * an empty string if there is no model
|
||||
*/
|
||||
public function get3dFilename(bool $absolute = true): string
|
||||
{
|
||||
if (true === $absolute) {
|
||||
//TODO
|
||||
throw new \Exception('Not Implemented yet...');
|
||||
//return str_replace('%BASE%', BASE, $this->db_data['filename_3d']);
|
||||
}
|
||||
|
||||
return $this->filename_3d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the filename of this footprint is valid (picture exists).
|
||||
*
|
||||
* This method is used to get all footprints with broken filename
|
||||
* (Footprint::get_broken_filename_footprints()).
|
||||
*
|
||||
* An empty filename is a valid filename.
|
||||
*
|
||||
* @return bool * true if file exists or filename is empty
|
||||
* * false if there is no file with this filename
|
||||
*/
|
||||
public function isFilenameValid(): bool
|
||||
{
|
||||
if (empty($this->getFilename())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return file_exists($this->getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the filename of this 3d footprint is valid (model exists and have ).
|
||||
*
|
||||
* This method is used to get all footprints with broken 3d filename
|
||||
* (Footprint::get_broken_3d_filename_footprints()).
|
||||
*
|
||||
* An empty filename is a valid filename.
|
||||
*
|
||||
* @return bool * true if file exists or filename is empty
|
||||
* * false if there is no file with this filename
|
||||
*/
|
||||
public function is3dFilenameValid(): bool
|
||||
{
|
||||
if (empty($this->get3dFilename())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check if file is X3D-Model (these has .x3d extension)
|
||||
if (false === strpos($this->get3dFilename(), '.x3d')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return file_exists($this->get3dFilename());
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Setters
|
||||
****************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Change the filename of this footprint.
|
||||
*
|
||||
* The filename won't be checked if it is valid.
|
||||
* It's not really a Problem if there is no such file...
|
||||
* (For this purpose we have the method Footprint::get_broken_filename_footprints())
|
||||
*
|
||||
* @param string $new_filename * the new filename (absolute path from filesystem root, as a UNIX path [only slashes!] !! )
|
||||
* * see also lib.functions.php::to_unix_path()
|
||||
*
|
||||
* It's really important that you pass the whole (UNIX) path from filesystem root!
|
||||
* If the file is located in the base directory of Part-DB, the base path
|
||||
* will be automatically replaced with a placeholder before write it in the database.
|
||||
* This way, the filenames are still correct if the installation directory
|
||||
* of Part-DB is moved.
|
||||
*
|
||||
* The path-replacing will be done in Footprint::check_values_validity(), not here.
|
||||
*
|
||||
* @return Footprint
|
||||
*
|
||||
* @throws \Exception if there was an error
|
||||
*/
|
||||
public function setFilename(string $new_filename): self
|
||||
{
|
||||
$this->filename = $new_filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the 3d model filename of this footprint.
|
||||
*
|
||||
* @throws \Exception if there was an error
|
||||
*/
|
||||
public function set3dFilename(string $new_filename): self
|
||||
{
|
||||
$this->filename = $new_filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
101
src/Entity/Parts/Manufacturer.php
Normal file
101
src/Entity/Parts/Manufacturer.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
use App\Entity\Base\Company;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Manufacturer.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table("`manufacturers`")
|
||||
*/
|
||||
class Manufacturer extends Company
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* 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 'M'.sprintf('%06d', $this->getID());
|
||||
}
|
||||
}
|
140
src/Entity/Parts/MeasurementUnit.php
Normal file
140
src/Entity/Parts/MeasurementUnit.php
Normal file
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
/**
|
||||
* This unit represents the unit in which the amount of parts in stock are measured.
|
||||
* This could be something like N, gramms, meters, etc...
|
||||
*
|
||||
* @package App\Entity
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table(name="`measurement_units`")
|
||||
* @UniqueEntity("unit")
|
||||
*/
|
||||
class MeasurementUnit extends StructuralDBElement
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for gramms)
|
||||
* or m (for meters).
|
||||
* @ORM\Column(type="string", name="unit", unique=true)
|
||||
*/
|
||||
protected $unit;
|
||||
|
||||
/**
|
||||
* @var bool Determines if the amount value associated with this unit should be treated as integer.
|
||||
* Set to false, to measure continuous sizes likes masses or lengthes.
|
||||
* @ORM\Column(type="boolean", name="is_integer")
|
||||
*/
|
||||
protected $isInteger;
|
||||
|
||||
/**
|
||||
* @var bool Determines if the unit can be used with SI Prefixes (kilo, giga, milli, etc.).
|
||||
* Useful for sizes like meters.
|
||||
* @ORM\Column(type="boolean", name="use_si_prefix")
|
||||
*/
|
||||
protected $usesSIPrefixes;
|
||||
|
||||
/**
|
||||
* 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 'MU' . $this->getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUnit(): string
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $unit
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setUnit(string $unit): MeasurementUnit
|
||||
{
|
||||
$this->unit = $unit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isInteger(): bool
|
||||
{
|
||||
return $this->isInteger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isInteger
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setIsInteger(bool $isInteger): MeasurementUnit
|
||||
{
|
||||
$this->isInteger = $isInteger;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isUsesSIPrefixes(): bool
|
||||
{
|
||||
return $this->usesSIPrefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $usesSIPrefixes
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setUsesSIPrefixes(bool $usesSIPrefixes): MeasurementUnit
|
||||
{
|
||||
$this->usesSIPrefixes = $usesSIPrefixes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
1191
src/Entity/Parts/Part.php
Normal file
1191
src/Entity/Parts/Part.php
Normal file
File diff suppressed because it is too large
Load diff
118
src/Entity/Parts/PartLot.php
Normal file
118
src/Entity/Parts/PartLot.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* This entity describes a lot where parts can be stored.
|
||||
* It is the connection between a part and its store locations.
|
||||
* @package App\Entity\Parts
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="part_lots")
|
||||
*/
|
||||
class PartLot extends NamedDBElement
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string A short description about this lot, shown in table
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @var string A comment stored with this lot.
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
/**
|
||||
* @var \DateTime Set a time until when the lot must be used.
|
||||
* Set to null, if the lot can be used indefinitley.
|
||||
* @ORM\Column(type="datetimetz", name="expiration_date", nullable=true)
|
||||
*/
|
||||
protected $expiration_date;
|
||||
|
||||
/**
|
||||
* @var Storelocation The storelocation of this lot
|
||||
* @ORM\ManyToOne(targetEntity="Storelocation")
|
||||
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id")
|
||||
*/
|
||||
protected $storage_location;
|
||||
|
||||
/**
|
||||
* @var Part The part that is stored in this lot
|
||||
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
|
||||
* @ORM\JoinColumn(name="id_part", referencedColumnName="id")
|
||||
*/
|
||||
protected $part;
|
||||
|
||||
/**
|
||||
* @var bool If this is set to true, the instock amount is marked as not known
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $instock_unknown;
|
||||
|
||||
/**
|
||||
* @var int For integer sizes the instock is saved here.
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
* @Assert\Positive()
|
||||
*/
|
||||
protected $instock;
|
||||
|
||||
/**
|
||||
* @var float For continuos sizes (length, volume, etc.) the instock is saved here.
|
||||
* @ORM\Column(type="float", nullable=true)
|
||||
*/
|
||||
protected $amount;
|
||||
|
||||
/**
|
||||
* @var boolean Determines if this lot was manually marked for refilling.
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $needs_refill;
|
||||
|
||||
/**
|
||||
* 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 'PL' . $this->getID();
|
||||
}
|
||||
}
|
228
src/Entity/Parts/Storelocation.php
Normal file
228
src/Entity/Parts/Storelocation.php
Normal file
|
@ -0,0 +1,228 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
use App\Entity\Base\PartsContainingDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Storelocation.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table("`storelocations`")
|
||||
*/
|
||||
class Storelocation extends PartsContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="storelocation")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $is_full;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $only_single_part;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $limit_to_existing_parts;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @return bool * true if the storelocation is full
|
||||
* * false if the storelocation isn't full
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $only_single_part
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setOnlySinglePart(bool $only_single_part): Storelocation
|
||||
{
|
||||
$this->only_single_part = $only_single_part;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $limit_to_existing_parts
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setLimitToExistingParts(bool $limit_to_existing_parts): Storelocation
|
||||
{
|
||||
$this->limit_to_existing_parts = $limit_to_existing_parts;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeasurementUnit|null
|
||||
*/
|
||||
public function getStorageType(): ?MeasurementUnit
|
||||
{
|
||||
return $this->storage_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MeasurementUnit|null $storage_type
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setStorageType(?MeasurementUnit $storage_type): Storelocation
|
||||
{
|
||||
$this->storage_type = $storage_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Change the "is full" attribute of this storelocation.
|
||||
*
|
||||
* "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
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setIsFull(bool $new_is_full): Storelocation
|
||||
{
|
||||
$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());
|
||||
}
|
||||
}
|
155
src/Entity/Parts/Supplier.php
Normal file
155
src/Entity/Parts/Supplier.php
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
use App\Entity\Base\Company;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Class Supplier.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table("`suppliers`")
|
||||
*/
|
||||
class Supplier extends Company
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Supplier", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="supplier")
|
||||
*/
|
||||
protected $orderdetails;
|
||||
|
||||
/**
|
||||
* @var Currency|null The currency that should be used by default for order informations with this supplier.
|
||||
* Set to null, to use global base currency.
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency")
|
||||
* @ORM\JoinColumn(name="default_currency_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $default_currency;
|
||||
|
||||
/**
|
||||
* @var float|null The shipping costs that have to be paid, when ordering via this supplier.
|
||||
* @ORM\Column(name="shipping_costs", nullable=true, type="decimal")
|
||||
* @Assert\PositiveOrZero()
|
||||
*/
|
||||
protected $shipping_costs;
|
||||
|
||||
/**
|
||||
* @return ?Currency
|
||||
*/
|
||||
public function getDefaultCurrency()
|
||||
{
|
||||
return $this->default_currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?Currency $default_currency
|
||||
* @return Supplier
|
||||
*/
|
||||
public function setDefaultCurrency(?Currency $default_currency) : Supplier
|
||||
{
|
||||
$this->default_currency = $default_currency;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?float
|
||||
*/
|
||||
public function getShippingCosts() : ?float
|
||||
{
|
||||
return $this->shipping_costs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?float $shipping_costs
|
||||
* @return Supplier
|
||||
*/
|
||||
public function setShippingCosts(?float $shipping_costs) : Supplier
|
||||
{
|
||||
$this->shipping_costs = $shipping_costs;
|
||||
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());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue