|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics) |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
|
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
declare(strict_types=1); |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* part-db version 0.1 |
|
25
|
|
|
* Copyright (C) 2005 Christoph Lechner |
|
26
|
|
|
* http://www.cl-projects.de/. |
|
27
|
|
|
* |
|
28
|
|
|
* part-db version 0.2+ |
|
29
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
|
30
|
|
|
* http://code.google.com/p/part-db/ |
|
31
|
|
|
* |
|
32
|
|
|
* Part-DB Version 0.4+ |
|
33
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
|
34
|
|
|
* https://github.com/jbtronics |
|
35
|
|
|
* |
|
36
|
|
|
* This program is free software; you can redistribute it and/or |
|
37
|
|
|
* modify it under the terms of the GNU General Public License |
|
38
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
39
|
|
|
* of the License, or (at your option) any later version. |
|
40
|
|
|
* |
|
41
|
|
|
* This program is distributed in the hope that it will be useful, |
|
42
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
43
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
44
|
|
|
* GNU General Public License for more details. |
|
45
|
|
|
* |
|
46
|
|
|
* You should have received a copy of the GNU General Public License |
|
47
|
|
|
* along with this program; if not, write to the Free Software |
|
48
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|
49
|
|
|
*/ |
|
50
|
|
|
|
|
51
|
|
|
namespace App\Entity\Parts; |
|
52
|
|
|
|
|
53
|
|
|
use App\Entity\Attachments\StorelocationAttachment; |
|
54
|
|
|
use App\Entity\Base\AbstractPartsContainingDBElement; |
|
55
|
|
|
use App\Entity\Parameters\StorelocationParameter; |
|
56
|
|
|
use Doctrine\Common\Collections\Collection; |
|
57
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
58
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Class Store location. |
|
62
|
|
|
* |
|
63
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") |
|
64
|
|
|
* @ORM\Table("`storelocations`") |
|
65
|
|
|
*/ |
|
66
|
|
|
class Storelocation extends AbstractPartsContainingDBElement |
|
67
|
|
|
{ |
|
68
|
|
|
/** |
|
69
|
|
|
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent") |
|
70
|
|
|
* @ORM\OrderBy({"name" = "ASC"}) |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $children; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="children") |
|
76
|
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id") |
|
77
|
|
|
*/ |
|
78
|
|
|
protected $parent; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here |
|
82
|
|
|
* @ORM\ManyToOne(targetEntity="MeasurementUnit") |
|
83
|
|
|
* @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id") |
|
84
|
|
|
*/ |
|
85
|
|
|
protected $storage_type; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY") |
|
89
|
|
|
* @ORM\JoinTable(name="part_lots", |
|
90
|
|
|
* joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")}, |
|
91
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")} |
|
92
|
|
|
* ) |
|
93
|
|
|
*/ |
|
94
|
|
|
protected $parts; |
|
95
|
|
|
|
|
96
|
|
|
/** @var Collection<int, StorelocationParameter> |
|
97
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) |
|
98
|
|
|
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) |
|
99
|
|
|
* @Assert\Valid() |
|
100
|
|
|
*/ |
|
101
|
|
|
protected $parameters; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @var bool |
|
105
|
|
|
* @ORM\Column(type="boolean") |
|
106
|
|
|
*/ |
|
107
|
|
|
protected $is_full = false; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @var bool |
|
111
|
|
|
* @ORM\Column(type="boolean") |
|
112
|
|
|
*/ |
|
113
|
|
|
protected $only_single_part = false; |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @var bool |
|
117
|
|
|
* @ORM\Column(type="boolean") |
|
118
|
|
|
*/ |
|
119
|
|
|
protected $limit_to_existing_parts = false; |
|
120
|
|
|
/** |
|
121
|
|
|
* @var Collection<int, StorelocationAttachment> |
|
122
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) |
|
123
|
|
|
* @Assert\Valid() |
|
124
|
|
|
*/ |
|
125
|
|
|
protected $attachments; |
|
126
|
|
|
|
|
127
|
|
|
/******************************************************************************** |
|
128
|
|
|
* |
|
129
|
|
|
* Getters |
|
130
|
|
|
* |
|
131
|
|
|
*********************************************************************************/ |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get the "is full" attribute. |
|
135
|
|
|
* |
|
136
|
|
|
* When this attribute is set, it is not possible to add additional parts or increase the instock of existing parts. |
|
137
|
|
|
* |
|
138
|
|
|
* @return bool * true if the store location is full |
|
139
|
|
|
* * false if the store location isn't full |
|
140
|
|
|
*/ |
|
141
|
|
|
public function isFull(): bool |
|
142
|
|
|
{ |
|
143
|
|
|
return (bool) $this->is_full; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* When this property is set, only one part (but many instock) is allowed to be stored in this store location. |
|
148
|
|
|
* |
|
149
|
|
|
* @return bool |
|
150
|
|
|
*/ |
|
151
|
|
|
public function isOnlySinglePart(): bool |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->only_single_part; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @return Storelocation |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setOnlySinglePart(bool $only_single_part): self |
|
160
|
|
|
{ |
|
161
|
|
|
$this->only_single_part = $only_single_part; |
|
162
|
|
|
|
|
163
|
|
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* When this property is set, it is only possible to increase the instock of parts, that are already stored here. |
|
168
|
|
|
* |
|
169
|
|
|
* @return bool |
|
170
|
|
|
*/ |
|
171
|
|
|
public function isLimitToExistingParts(): bool |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->limit_to_existing_parts; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @return Storelocation |
|
178
|
|
|
*/ |
|
179
|
|
|
public function setLimitToExistingParts(bool $limit_to_existing_parts): self |
|
180
|
|
|
{ |
|
181
|
|
|
$this->limit_to_existing_parts = $limit_to_existing_parts; |
|
182
|
|
|
|
|
183
|
|
|
return $this; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @return MeasurementUnit|null |
|
188
|
|
|
*/ |
|
189
|
|
|
public function getStorageType(): ?MeasurementUnit |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->storage_type; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return Storelocation |
|
196
|
|
|
*/ |
|
197
|
|
|
public function setStorageType(?MeasurementUnit $storage_type): self |
|
198
|
|
|
{ |
|
199
|
|
|
$this->storage_type = $storage_type; |
|
200
|
|
|
|
|
201
|
|
|
return $this; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/******************************************************************************** |
|
205
|
|
|
* |
|
206
|
|
|
* Setters |
|
207
|
|
|
* |
|
208
|
|
|
*********************************************************************************/ |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Change the "is full" attribute of this store location. |
|
212
|
|
|
* |
|
213
|
|
|
* "is_full" = true means that there is no more space in this storelocation. |
|
214
|
|
|
* This attribute is only for information, it has no effect. |
|
215
|
|
|
* |
|
216
|
|
|
* @param bool $new_is_full * true means that the storelocation is full |
|
217
|
|
|
* * false means that the storelocation isn't full |
|
218
|
|
|
* |
|
219
|
|
|
* @return Storelocation |
|
220
|
|
|
*/ |
|
221
|
|
|
public function setIsFull(bool $new_is_full): self |
|
222
|
|
|
{ |
|
223
|
|
|
$this->is_full = $new_is_full; |
|
224
|
|
|
|
|
225
|
|
|
return $this; |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|