|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* part-db version 0.1 |
|
6
|
|
|
* Copyright (C) 2005 Christoph Lechner |
|
7
|
|
|
* http://www.cl-projects.de/ |
|
8
|
|
|
* |
|
9
|
|
|
* part-db version 0.2+ |
|
10
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
|
11
|
|
|
* http://code.google.com/p/part-db/ |
|
12
|
|
|
* |
|
13
|
|
|
* Part-DB Version 0.4+ |
|
14
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
|
15
|
|
|
* https://github.com/jbtronics |
|
16
|
|
|
* |
|
17
|
|
|
* This program is free software; you can redistribute it and/or |
|
18
|
|
|
* modify it under the terms of the GNU General Public License |
|
19
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
20
|
|
|
* of the License, or (at your option) any later version. |
|
21
|
|
|
* |
|
22
|
|
|
* This program is distributed in the hope that it will be useful, |
|
23
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25
|
|
|
* GNU General Public License for more details. |
|
26
|
|
|
* |
|
27
|
|
|
* You should have received a copy of the GNU General Public License |
|
28
|
|
|
* along with this program; if not, write to the Free Software |
|
29
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|
30
|
|
|
* |
|
31
|
|
|
*/ |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
namespace App\Entity; |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
38
|
|
|
//use Webmozart\Assert\Assert; |
|
39
|
|
|
|
|
40
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class Part |
|
44
|
|
|
* @package App\Entity |
|
45
|
|
|
* |
|
46
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\PartRepository") |
|
47
|
|
|
* @ORM\Table("parts") |
|
48
|
|
|
*/ |
|
49
|
|
|
class Part extends AttachmentContainingDBElement |
|
50
|
|
|
{ |
|
51
|
|
|
const INSTOCK_UNKNOWN = -2; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var Category |
|
55
|
|
|
* @ORM\ManyToOne(targetEntity="Category", inversedBy="parts") |
|
56
|
|
|
* @ORM\JoinColumn(name="id_category", referencedColumnName="id") |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $category; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var Footprint|null |
|
62
|
|
|
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="parts") |
|
63
|
|
|
* @ORM\JoinColumn(name="id_footprint", referencedColumnName="id") |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $footprint; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @var Storelocation|null |
|
69
|
|
|
* @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="parts") |
|
70
|
|
|
* @ORM\JoinColumn(name="id_storelocation", referencedColumnName="id") |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $storelocation; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var Manufacturer|null |
|
76
|
|
|
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="parts") |
|
77
|
|
|
* @ORM\JoinColumn(name="id_manufacturer", referencedColumnName="id") |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $manufacturer; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @var Attachment |
|
83
|
|
|
* @ORM\ManyToOne(targetEntity="Attachment") |
|
84
|
|
|
* @ORM\JoinColumn(name="id_master_picture_attachement", referencedColumnName="id") |
|
85
|
|
|
*/ |
|
86
|
|
|
protected $master_picture_attachment; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @var |
|
90
|
|
|
* @ORM\OneToMany(targetEntity="Orderdetail", mappedBy="part") |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $orderdetails; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @var Orderdetail |
|
96
|
|
|
* @ORM\OneToOne(targetEntity="Orderdetail") |
|
97
|
|
|
* @ORM\JoinColumn(name="order_orderdetails_id", referencedColumnName="id") |
|
98
|
|
|
*/ |
|
99
|
|
|
protected $order_orderdetail; |
|
100
|
|
|
|
|
101
|
|
|
//TODO |
|
102
|
|
|
protected $devices; |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
/********************** |
|
106
|
|
|
* Propertys |
|
107
|
|
|
***********************/ |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @var string |
|
111
|
|
|
* @ORM\Column(type="string") |
|
112
|
|
|
*/ |
|
113
|
|
|
protected $description = ""; |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @var int |
|
117
|
|
|
* @ORM\Column(type="integer") |
|
118
|
|
|
* @Assert\GreaterThanOrEqual(0) |
|
119
|
|
|
*/ |
|
120
|
|
|
protected $instock = 0; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @var int |
|
124
|
|
|
* @ORM\Column(type="integer") |
|
125
|
|
|
* @Assert\GreaterThanOrEqual(0) |
|
126
|
|
|
*/ |
|
127
|
|
|
protected $mininstock = 0; |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @var string |
|
131
|
|
|
* @ORM\Column(type="string") |
|
132
|
|
|
*/ |
|
133
|
|
|
protected $comment = ""; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @var bool |
|
137
|
|
|
* @ORM\Column(type="boolean") |
|
138
|
|
|
*/ |
|
139
|
|
|
protected $visible = true; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @var bool |
|
143
|
|
|
* @ORM\Column(type="boolean") |
|
144
|
|
|
*/ |
|
145
|
|
|
protected $favorite = false; |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @var int |
|
149
|
|
|
* @ORM\Column(type="integer") |
|
150
|
|
|
*/ |
|
151
|
|
|
protected $order_quantity = 0; |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @var bool |
|
155
|
|
|
* @ORM\Column(type="boolean") |
|
156
|
|
|
*/ |
|
157
|
|
|
protected $manual_order = false; |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* @var string |
|
161
|
|
|
* @ORM\Column(type="string") |
|
162
|
|
|
*/ |
|
163
|
|
|
protected $manufacturer_product_url = ""; |
|
164
|
|
|
|
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Returns the ID as an string, defined by the element class. |
|
168
|
|
|
* This should have a form like P000014, for a part with ID 14. |
|
169
|
|
|
* @return string The ID as a string; |
|
170
|
|
|
*/ |
|
171
|
|
|
public function getIDString(): string |
|
172
|
|
|
{ |
|
173
|
|
|
return 'P' . sprintf('%06d', $this->getID()); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
|
|
177
|
|
|
/********************************************************************************* |
|
178
|
|
|
* Getters |
|
179
|
|
|
********************************************************************************/ |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Get the description string like it is saved in the database. |
|
183
|
|
|
* This can contain BBCode, it is not parsed yet. |
|
184
|
|
|
* |
|
185
|
|
|
* @return string the description |
|
186
|
|
|
*/ |
|
187
|
|
|
public function getDescription() : string |
|
188
|
|
|
{ |
|
189
|
|
|
return htmlspecialchars($this->description); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Get the count of parts which are in stock. |
|
194
|
|
|
* When the instock is unkown, then Part::INSTOCK_UNKNOWN is returned. |
|
195
|
|
|
* |
|
196
|
|
|
* @return int count of parts which are in stock |
|
197
|
|
|
*/ |
|
198
|
|
|
public function getInstock() : int |
|
199
|
|
|
{ |
|
200
|
|
|
return $this->instock; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Check if the value of the Instock is unknown. |
|
205
|
|
|
* @return bool True, if the value of the instock is unknown. |
|
206
|
|
|
*/ |
|
207
|
|
|
public function isInstockUnknown() : bool |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->instock <= static::INSTOCK_UNKNOWN; |
|
210
|
|
|
}/** @noinspection ReturnTypeCanBeDeclaredInspection */ |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* Get the count of parts which must be in stock at least |
|
214
|
|
|
* |
|
215
|
|
|
* @return integer count of parts which must be in stock at least |
|
216
|
|
|
*/ |
|
217
|
|
|
public function getMinInstock() : int |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->mininstock; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* Get the comment associated with this part. |
|
224
|
|
|
* |
|
225
|
|
|
* @return string The raw/unparsed comment |
|
226
|
|
|
*/ |
|
227
|
|
|
public function getComment() : string |
|
228
|
|
|
{ |
|
229
|
|
|
|
|
230
|
|
|
return htmlspecialchars($this->comment); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* Get if this part is obsolete |
|
235
|
|
|
* |
|
236
|
|
|
* A Part is marked as "obsolete" if all their orderdetails are marked as "obsolete". |
|
237
|
|
|
* If a part has no orderdetails, the part isn't marked as obsolete. |
|
238
|
|
|
* |
|
239
|
|
|
* @return boolean true, if this part is obsolete. false, if this part isn't obsolete |
|
240
|
|
|
*/ |
|
241
|
|
|
public function isObsolete() : bool |
|
242
|
|
|
{ |
|
243
|
|
|
$all_orderdetails = $this->getOrderdetails(); |
|
244
|
|
|
|
|
245
|
|
|
if (count($all_orderdetails) == 0) { |
|
246
|
|
|
return false; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
foreach ($all_orderdetails as $orderdetails) { |
|
250
|
|
|
if (! $orderdetails->getObsolete()) { |
|
251
|
|
|
return false; |
|
252
|
|
|
} |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
return true; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* Get if this part is visible |
|
260
|
|
|
* |
|
261
|
|
|
* @return boolean true if this part is visible |
|
262
|
|
|
* false if this part isn't visible |
|
263
|
|
|
*/ |
|
264
|
|
|
public function isVisible() : bool |
|
265
|
|
|
{ |
|
266
|
|
|
return $this->visible; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/** |
|
270
|
|
|
* Get if this part is a favorite. |
|
271
|
|
|
* |
|
272
|
|
|
* @return bool * true if this part is a favorite |
|
273
|
|
|
* * false if this part is not a favorite. |
|
274
|
|
|
*/ |
|
275
|
|
|
public function isFavorite() : bool |
|
276
|
|
|
{ |
|
277
|
|
|
return $this->favorite; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* Get the selected order orderdetails of this part |
|
282
|
|
|
* |
|
283
|
|
|
* @return Orderdetail the selected order orderdetails |
|
284
|
|
|
* @return NULL if there is no order supplier selected |
|
285
|
|
|
* @throws Exception |
|
286
|
|
|
*/ |
|
287
|
|
|
public function getOrderOrderdetails() : ?Orderdetail |
|
288
|
|
|
{ |
|
289
|
|
|
//TODO |
|
290
|
|
|
/* |
|
291
|
|
|
if ($this->order_orderdetails->getObsolete()) { |
|
292
|
|
|
$this->setOrderOrderdetailsID(null); |
|
293
|
|
|
$this->order_orderdetails = null; |
|
294
|
|
|
}*/ |
|
295
|
|
|
|
|
296
|
|
|
return $this->order_orderdetail; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
/** |
|
300
|
|
|
* Get the order quantity of this part |
|
301
|
|
|
* |
|
302
|
|
|
* @return integer the order quantity |
|
303
|
|
|
*/ |
|
304
|
|
|
public function getOrderQuantity() : int |
|
305
|
|
|
{ |
|
306
|
|
|
return $this->order_quantity; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* Get the minimum quantity which should be ordered |
|
311
|
|
|
* |
|
312
|
|
|
* @param boolean $with_devices * if true, all parts from devices which are marked as "to order" will be included in the calculation |
|
313
|
|
|
* * if false, only max(mininstock - instock, 0) will be returned |
|
314
|
|
|
* |
|
315
|
|
|
* @return integer the minimum order quantity |
|
316
|
|
|
* @throws Exception |
|
317
|
|
|
*/ |
|
318
|
|
|
public function getMinOrderQuantity(bool $with_devices = true) : int |
|
|
|
|
|
|
319
|
|
|
{ |
|
320
|
|
|
//TODO |
|
321
|
|
|
throw new \Exception("Not implemented yet..."); |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
if ($with_devices) { |
|
325
|
|
|
$count_must_order = 0; // for devices with "order_only_missing_parts == false" |
|
326
|
|
|
$count_should_order = 0; // for devices with "order_only_missing_parts == true" |
|
327
|
|
|
$deviceparts = DevicePart::getOrderDeviceParts($this->database, $this->current_user, $this->log, $this->getID()); |
|
328
|
|
|
foreach ($deviceparts as $devicepart) { |
|
329
|
|
|
/** @var $devicepart DevicePart */ |
|
330
|
|
|
/** @var $device Device */ /** |
|
331
|
|
|
$device = $devicepart->getDevice(); |
|
332
|
|
|
if ($device->getOrderOnlyMissingParts()) { |
|
333
|
|
|
$count_should_order += $device->getOrderQuantity() * $devicepart->getMountQuantity(); |
|
334
|
|
|
} else { |
|
335
|
|
|
$count_must_order += $device->getOrderQuantity() * $devicepart->getMountQuantity(); |
|
336
|
|
|
} |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
return $count_must_order + max(0, $this->getMinInstock() - $this->getInstock() + $count_should_order); |
|
340
|
|
|
} else { |
|
341
|
|
|
return max(0, $this->getMinInstock() - $this->getInstock()); |
|
342
|
|
|
} **/ |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* Check if this part is marked for manual ordering |
|
347
|
|
|
* |
|
348
|
|
|
* @return boolean the "manual_order" attribute |
|
349
|
|
|
*/ |
|
350
|
|
|
public function isMarkedForManualOrder() : bool |
|
351
|
|
|
{ |
|
352
|
|
|
return $this->manual_order; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* Check if the part is automatically marked for Ordering, because the instock value is smaller than the min instock value. |
|
357
|
|
|
* This is called automatic ordering |
|
358
|
|
|
* @return bool True, if the part should be ordered. |
|
359
|
|
|
*/ |
|
360
|
|
|
public function isAutoOrdered() : bool |
|
361
|
|
|
{ |
|
362
|
|
|
//Parts with negative instock never gets ordered. |
|
363
|
|
|
if ($this->getInstock() < 0) { |
|
364
|
|
|
return false; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
return $this->getInstock() < $this->getMinInstock(); |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* Get the link to the website of the article on the manufacturers website |
|
372
|
|
|
* When no this part has no explicit url set, then it is tried to generate one from the Manufacturer of this part |
|
373
|
|
|
* automatically. |
|
374
|
|
|
* |
|
375
|
|
|
* @param |
|
376
|
|
|
* |
|
377
|
|
|
* @return string the link to the article |
|
378
|
|
|
*/ |
|
379
|
|
|
public function getManufacturerProductUrl() : string |
|
380
|
|
|
{ |
|
381
|
|
|
if ($this->manufacturer_product_url != '') { |
|
382
|
|
|
return $this->manufacturer_product_url; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
if ($this->getManufacturer() !== null) { |
|
386
|
|
|
return $this->getManufacturer()->getAutoProductUrl($this->name); |
|
387
|
|
|
} else { |
|
388
|
|
|
return ''; |
|
389
|
|
|
} // no url is available |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
/** |
|
393
|
|
|
* Similar to getManufacturerProductUrl, but here only the database value is returned. |
|
394
|
|
|
* @return string The manufacturer url saved in DB for this part. |
|
395
|
|
|
*/ |
|
396
|
|
|
public function getOwnProductURL() : string |
|
397
|
|
|
{ |
|
398
|
|
|
return $this->manufacturer_product_url; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* Get the category of this part |
|
403
|
|
|
* |
|
404
|
|
|
* There is always a category, for each part! |
|
405
|
|
|
* |
|
406
|
|
|
* @return Category the category of this part |
|
407
|
|
|
*/ |
|
408
|
|
|
public function getCategory() : Category |
|
409
|
|
|
{ |
|
410
|
|
|
return $this->category; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* Get the footprint of this part (if there is one) |
|
415
|
|
|
* |
|
416
|
|
|
* @return Footprint the footprint of this part (if there is one) |
|
417
|
|
|
* @return NULL if this part has no footprint |
|
418
|
|
|
*/ |
|
419
|
|
|
public function getFootprint() : ?Footprint |
|
420
|
|
|
{ |
|
421
|
|
|
return $this->footprint; |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
/** |
|
425
|
|
|
* Get the storelocation of this part (if there is one) |
|
426
|
|
|
* |
|
427
|
|
|
* @return Storelocation the storelocation of this part (if there is one) |
|
428
|
|
|
* @return NULL if this part has no storelocation |
|
429
|
|
|
*/ |
|
430
|
|
|
public function getStorelocation() : ?Storelocation |
|
431
|
|
|
{ |
|
432
|
|
|
return $this->storelocation; |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* Get the manufacturer of this part (if there is one) |
|
437
|
|
|
* |
|
438
|
|
|
* @return Manufacturer the manufacturer of this part (if there is one) |
|
439
|
|
|
* @return NULL if this part has no manufacturer |
|
440
|
|
|
*/ |
|
441
|
|
|
public function getManufacturer() : ?Manufacturer |
|
442
|
|
|
{ |
|
443
|
|
|
return $this->manufacturer; |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
/** |
|
447
|
|
|
* Get the master picture "Attachement"-object of this part (if there is one) |
|
448
|
|
|
* |
|
449
|
|
|
* @return Attachment the master picture Attachement of this part (if there is one) |
|
450
|
|
|
* @return NULL if this part has no master picture |
|
451
|
|
|
*/ |
|
452
|
|
|
public function getMasterPictureAttachement() : ?Attachment |
|
453
|
|
|
{ |
|
454
|
|
|
return $this->master_picture_attachment; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* Get all orderdetails of this part |
|
459
|
|
|
* |
|
460
|
|
|
* @param boolean $hide_obsolete If true, obsolete orderdetails will NOT be returned |
|
461
|
|
|
* |
|
462
|
|
|
* @return Orderdetails[] * all orderdetails as a one-dimensional array of Orderdetails objects |
|
463
|
|
|
* (empty array if there are no ones) |
|
464
|
|
|
* * the array is sorted by the suppliers names / minimum order quantity |
|
465
|
|
|
* |
|
466
|
|
|
* @throws Exception if there was an error |
|
467
|
|
|
*/ |
|
468
|
|
|
public function getOrderdetails(bool $hide_obsolete = false) |
|
469
|
|
|
{ |
|
470
|
|
|
if ($hide_obsolete) { |
|
471
|
|
|
$orderdetails = $this->orderdetails; |
|
472
|
|
|
foreach ($orderdetails as $key => $details) { |
|
473
|
|
|
if ($details->getObsolete()) { |
|
474
|
|
|
unset($orderdetails[$key]); |
|
475
|
|
|
} |
|
476
|
|
|
} |
|
477
|
|
|
return $orderdetails; |
|
478
|
|
|
} else { |
|
479
|
|
|
return $this->orderdetails; |
|
480
|
|
|
} |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
/** |
|
484
|
|
|
* Get all devices which uses this part |
|
485
|
|
|
* |
|
486
|
|
|
* @return Device[] * all devices which uses this part as a one-dimensional array of Device objects |
|
487
|
|
|
* (empty array if there are no ones) |
|
488
|
|
|
* * the array is sorted by the devices names |
|
489
|
|
|
* |
|
490
|
|
|
* @throws Exception if there was an error |
|
491
|
|
|
*/ |
|
492
|
|
|
public function getDevices() : array |
|
493
|
|
|
{ |
|
494
|
|
|
return $this->devices; |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
/** |
|
498
|
|
|
* Get all suppliers of this part |
|
499
|
|
|
* |
|
500
|
|
|
* This method simply gets the suppliers of the orderdetails and prepare them.\n |
|
501
|
|
|
* You can get the suppliers as an array or as a string with individual delimeter. |
|
502
|
|
|
* |
|
503
|
|
|
* @param boolean $object_array * if true, this method returns an array of Supplier objects |
|
504
|
|
|
* * if false, this method returns an array of strings |
|
505
|
|
|
* @param string|NULL $delimeter * if this is a string and "$object_array == false", |
|
506
|
|
|
* this method returns a string with all |
|
507
|
|
|
* supplier names, delimeted by "$delimeter" |
|
508
|
|
|
* @param boolean $full_paths * if true and "$object_array = false", the returned |
|
509
|
|
|
* suppliernames are full paths (path + name) |
|
510
|
|
|
* * if true and "$object_array = false", the returned |
|
511
|
|
|
* suppliernames are only the names (without path) |
|
512
|
|
|
* @param boolean $hide_obsolete If true, suppliers from obsolete orderdetails will NOT be returned |
|
513
|
|
|
* |
|
514
|
|
|
* @return array all suppliers as a one-dimensional array of Supplier objects |
|
515
|
|
|
* (if "$object_array == true") |
|
516
|
|
|
* @return array all supplier-names as a one-dimensional array of strings |
|
517
|
|
|
* ("if $object_array == false" and "$delimeter == NULL") |
|
518
|
|
|
* @return string a sting of all supplier names, delimeted by $delimeter |
|
519
|
|
|
* ("if $object_array == false" and $delimeter is a string) |
|
520
|
|
|
* |
|
521
|
|
|
* @throws Exception if there was an error |
|
522
|
|
|
*/ |
|
523
|
|
|
public function getSuppliers(bool $object_array = true, $delimeter = null, bool $full_paths = false, bool $hide_obsolete = false) |
|
524
|
|
|
{ |
|
525
|
|
|
$suppliers = array(); |
|
526
|
|
|
$orderdetails = $this->getOrderdetails($hide_obsolete); |
|
527
|
|
|
|
|
528
|
|
|
foreach ($orderdetails as $details) { |
|
529
|
|
|
$suppliers[] = $details->getSupplier(); |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
|
|
if ($object_array) { |
|
533
|
|
|
return $suppliers; |
|
534
|
|
|
} else { |
|
535
|
|
|
$supplier_names = array(); |
|
536
|
|
|
foreach ($suppliers as $supplier) { |
|
537
|
|
|
/** @var Supplier $supplier */ |
|
538
|
|
|
if ($full_paths) { |
|
539
|
|
|
$supplier_names[] = $supplier->getFullPath(); |
|
540
|
|
|
} else { |
|
541
|
|
|
$supplier_names[] = $supplier->getName(); |
|
542
|
|
|
} |
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
if (\is_string($delimeter)) { |
|
546
|
|
|
return implode($delimeter, $supplier_names); |
|
|
|
|
|
|
547
|
|
|
} else { |
|
548
|
|
|
return $supplier_names; |
|
549
|
|
|
} |
|
550
|
|
|
} |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* Get all supplier-part-Nrs |
|
555
|
|
|
* |
|
556
|
|
|
* This method simply gets the suppliers-part-Nrs of the orderdetails and prepare them.\n |
|
557
|
|
|
* You can get the numbers as an array or as a string with individual delimeter. |
|
558
|
|
|
* |
|
559
|
|
|
* @param string|NULL $delimeter * if this is a string, this method returns a delimeted string |
|
560
|
|
|
* * otherwise, this method returns an array of strings |
|
561
|
|
|
* @param boolean $hide_obsolete If true, supplierpartnrs from obsolete orderdetails will NOT be returned |
|
562
|
|
|
* |
|
563
|
|
|
* @return array all supplierpartnrs as an array of strings (if "$delimeter == NULL") |
|
564
|
|
|
* @return string all supplierpartnrs as a string, delimeted ba $delimeter (if $delimeter is a string) |
|
565
|
|
|
* |
|
566
|
|
|
* @throws Exception if there was an error |
|
567
|
|
|
*/ |
|
568
|
|
|
public function getSupplierPartNrs($delimeter = null, bool $hide_obsolete = false) |
|
569
|
|
|
{ |
|
570
|
|
|
$supplierpartnrs = array(); |
|
571
|
|
|
|
|
572
|
|
|
foreach ($this->getOrderdetails($hide_obsolete) as $details) { |
|
573
|
|
|
$supplierpartnrs[] = $details->getSupplierPartNr(); |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
if (\is_string($delimeter)) { |
|
577
|
|
|
return implode($delimeter, $supplierpartnrs); |
|
|
|
|
|
|
578
|
|
|
} else { |
|
579
|
|
|
return $supplierpartnrs; |
|
580
|
|
|
} |
|
581
|
|
|
} |
|
582
|
|
|
|
|
583
|
|
|
/** |
|
584
|
|
|
* Get all prices of this part |
|
585
|
|
|
* |
|
586
|
|
|
* This method simply gets the prices of the orderdetails and prepare them.\n |
|
587
|
|
|
* In the returned array/string there is a price for every supplier. |
|
588
|
|
|
* |
|
589
|
|
|
* @param boolean $float_array * if true, the returned array is an array of floats |
|
590
|
|
|
* * if false, the returned array is an array of strings |
|
591
|
|
|
* @param string|NULL $delimeter if this is a string, this method returns a delimeted string |
|
592
|
|
|
* instead of an array. |
|
593
|
|
|
* @param integer $quantity this is the quantity to choose the correct priceinformation |
|
594
|
|
|
* @param integer|NULL $multiplier * This is the multiplier which will be applied to every single price |
|
595
|
|
|
* * If you pass NULL, the number from $quantity will be used |
|
596
|
|
|
* @param boolean $hide_obsolete If true, prices from obsolete orderdetails will NOT be returned |
|
597
|
|
|
* |
|
598
|
|
|
* @return array all prices as an array of floats (if "$delimeter == NULL" & "$float_array == true") |
|
599
|
|
|
* @return array all prices as an array of strings (if "$delimeter == NULL" & "$float_array == false") |
|
600
|
|
|
* @return string all prices as a string, delimeted by $delimeter (if $delimeter is a string) |
|
601
|
|
|
* |
|
602
|
|
|
* If there are orderdetails without prices, for these orderdetails there |
|
603
|
|
|
* will be a "NULL" in the returned float array (or a "-" in the string array)!! |
|
604
|
|
|
* (This is needed for the HTML output, if there are all orderdetails and prices listed.) |
|
605
|
|
|
* |
|
606
|
|
|
* @throws Exception if there was an error |
|
607
|
|
|
*/ |
|
608
|
|
|
public function getPrices(bool $float_array = false, $delimeter = null, int $quantity = 1, $multiplier = null, bool $hide_obsolete = false) |
|
609
|
|
|
{ |
|
610
|
|
|
$prices = array(); |
|
611
|
|
|
|
|
612
|
|
|
foreach ($this->getOrderdetails($hide_obsolete) as $details) { |
|
613
|
|
|
$prices[] = $details->getPrice(! $float_array, $quantity, $multiplier); |
|
614
|
|
|
} |
|
615
|
|
|
|
|
616
|
|
|
if (\is_string($delimeter)) { |
|
617
|
|
|
return implode($delimeter, $prices); |
|
|
|
|
|
|
618
|
|
|
} else { |
|
619
|
|
|
return $prices; |
|
620
|
|
|
} |
|
621
|
|
|
} |
|
622
|
|
|
|
|
623
|
|
|
/** |
|
624
|
|
|
* Get the average price of all orderdetails |
|
625
|
|
|
* |
|
626
|
|
|
* With the $multiplier you're able to multiply the price before it will be returned. |
|
627
|
|
|
* This is useful if you want to have the price as a string with currency, but multiplied with a factor. |
|
628
|
|
|
* |
|
629
|
|
|
* @param boolean $as_money_string * if true, the retruned value will be a string incl. currency, |
|
630
|
|
|
* ready to print it out. See float_to_money_string(). |
|
631
|
|
|
* * if false, the returned value is a float |
|
632
|
|
|
* @param integer $quantity this is the quantity to choose the correct priceinformations |
|
633
|
|
|
* @param integer|NULL $multiplier * This is the multiplier which will be applied to every single price |
|
634
|
|
|
* * If you pass NULL, the number from $quantity will be used |
|
635
|
|
|
* |
|
636
|
|
|
* @return float price (if "$as_money_string == false") |
|
637
|
|
|
* @return NULL if there are no prices for this part and "$as_money_string == false" |
|
638
|
|
|
* @return string price with currency (if "$as_money_string == true") |
|
639
|
|
|
* |
|
640
|
|
|
* @throws Exception if there was an error |
|
641
|
|
|
*/ |
|
642
|
|
|
public function getAveragePrice(bool $as_money_string = false, int $quantity = 1, $multiplier = null) |
|
643
|
|
|
{ |
|
644
|
|
|
$prices = $this->getPrices(true, null, $quantity, $multiplier, true); |
|
645
|
|
|
$average_price = null; |
|
646
|
|
|
|
|
647
|
|
|
$count = 0; |
|
648
|
|
|
foreach ($prices as $price) { |
|
649
|
|
|
if ($price !== null) { |
|
650
|
|
|
$average_price += $price; |
|
651
|
|
|
$count++; |
|
652
|
|
|
} |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
if ($count > 0) { |
|
656
|
|
|
$average_price /= $count; |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
if ($as_money_string) { |
|
660
|
|
|
return floatToMoneyString($average_price); |
|
|
|
|
|
|
661
|
|
|
} else { |
|
662
|
|
|
return $average_price; |
|
663
|
|
|
} |
|
664
|
|
|
} |
|
665
|
|
|
|
|
666
|
|
|
/** |
|
667
|
|
|
* Get the filename of the master picture (absolute path from filesystem root) |
|
668
|
|
|
* |
|
669
|
|
|
* @param boolean $use_footprint_filename * if true, and this part has no picture, this method |
|
670
|
|
|
* will return the filename of its footprint (if available) |
|
671
|
|
|
* * if false, and this part has no picture, |
|
672
|
|
|
* this method will return NULL |
|
673
|
|
|
* |
|
674
|
|
|
* @return string the whole path + filename from filesystem root as a UNIX path (with slashes) |
|
675
|
|
|
* @return NULL if there is no picture |
|
676
|
|
|
* |
|
677
|
|
|
* @throws \Exception if there was an error |
|
678
|
|
|
*/ |
|
679
|
|
|
public function getMasterPictureFilename(bool $use_footprint_filename = false) : ?string |
|
680
|
|
|
{ |
|
681
|
|
|
$master_picture = $this->getMasterPictureAttachement(); // returns an Attachement-object |
|
682
|
|
|
|
|
683
|
|
|
if ($master_picture !== null) { |
|
684
|
|
|
return $master_picture->getFilename(); |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
if ($use_footprint_filename) { |
|
688
|
|
|
$footprint = $this->getFootprint(); |
|
689
|
|
|
if ($footprint !== null) { |
|
690
|
|
|
return $footprint->getFilename(); |
|
691
|
|
|
} |
|
692
|
|
|
} |
|
693
|
|
|
|
|
694
|
|
|
return null; |
|
695
|
|
|
} |
|
696
|
|
|
|
|
697
|
|
|
/** |
|
698
|
|
|
* Parses the selected fields and extract Properties of the part. |
|
699
|
|
|
* @param bool $use_description Use the description field for parsing |
|
700
|
|
|
* @param bool $use_comment Use the comment field for parsing |
|
701
|
|
|
* @param bool $use_name Use the name field for parsing |
|
702
|
|
|
* @param bool $force_output Properties are parsed even if properties are disabled. |
|
703
|
|
|
* @return array A array of PartProperty objects. |
|
704
|
|
|
* @return array If Properties are disabled or nothing was detected, then an empty array is returned. |
|
705
|
|
|
* @throws Exception |
|
706
|
|
|
*/ |
|
707
|
|
|
public function getProperties(bool $use_description = true, bool $use_comment = true, bool $use_name = true, bool $force_output = false) : array |
|
|
|
|
|
|
708
|
|
|
{ |
|
709
|
|
|
//TODO |
|
710
|
|
|
throw new \Exception("Not implemented yet!"); |
|
711
|
|
|
/* |
|
712
|
|
|
global $config; |
|
713
|
|
|
|
|
714
|
|
|
if ($config['properties']['active'] || $force_output) { |
|
715
|
|
|
if ($this->getCategory()->getDisableProperties(true)) { |
|
716
|
|
|
return array(); |
|
717
|
|
|
} |
|
718
|
|
|
|
|
719
|
|
|
$name = array(); |
|
720
|
|
|
$desc = array(); |
|
721
|
|
|
$comm = array(); |
|
722
|
|
|
|
|
723
|
|
|
if ($use_name === true) { |
|
724
|
|
|
$name = $this->getCategory()->getPartnameRegexObj()->getProperties($this->getName()); |
|
725
|
|
|
} |
|
726
|
|
|
if ($use_description === true) { |
|
727
|
|
|
$desc = PartProperty::parseDescription($this->getDescription()); |
|
728
|
|
|
} |
|
729
|
|
|
if ($use_comment === true) { |
|
730
|
|
|
$comm = PartProperty::parseDescription($this->getComment(false)); |
|
731
|
|
|
} |
|
732
|
|
|
|
|
733
|
|
|
return array_merge($name, $desc, $comm); |
|
734
|
|
|
} else { |
|
735
|
|
|
return array(); |
|
736
|
|
|
}*/ |
|
737
|
|
|
} |
|
738
|
|
|
|
|
739
|
|
|
/** |
|
740
|
|
|
* Returns a loop (array) of the array representations of the properties of this part. |
|
741
|
|
|
* @param bool $use_description Use the description field for parsing |
|
742
|
|
|
* @param bool $use_comment Use the comment field for parsing |
|
743
|
|
|
* @return array A array of arrays with the name and value of the properties. |
|
744
|
|
|
*/ |
|
745
|
|
|
public function getPropertiesLoop(bool $use_description = true, bool $use_comment = true, bool $use_name = true) : array |
|
|
|
|
|
|
746
|
|
|
{ |
|
747
|
|
|
//TODO |
|
748
|
|
|
throw new \Exception("Not implemented yet!"); |
|
749
|
|
|
$arr = array(); |
|
|
|
|
|
|
750
|
|
|
foreach ($this->getProperties($use_description, $use_comment, $use_name) as $property) { |
|
751
|
|
|
/* @var PartProperty $property */ |
|
752
|
|
|
$arr[] = $property->getArray(true); |
|
753
|
|
|
} |
|
754
|
|
|
return $arr; |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
/* |
|
758
|
|
|
public function hasValidName() : bool |
|
759
|
|
|
{ |
|
760
|
|
|
return self::isValidName($this->getName(), $this->getCategory()); |
|
761
|
|
|
} */ |
|
762
|
|
|
|
|
763
|
|
|
|
|
764
|
|
|
public function getAttachmentTypes() : array |
|
765
|
|
|
{ |
|
766
|
|
|
return parent::getAttachmentTypes(); |
|
767
|
|
|
} |
|
768
|
|
|
|
|
769
|
|
|
public function getAttachments($type_id = null, bool $only_table_attachements = false) : array |
|
770
|
|
|
{ |
|
771
|
|
|
return parent::getAttachments($type_id, $only_table_attachements); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/******************************************************************************** |
|
775
|
|
|
* |
|
776
|
|
|
* Setters |
|
777
|
|
|
* |
|
778
|
|
|
*********************************************************************************/ |
|
779
|
|
|
|
|
780
|
|
|
/** |
|
781
|
|
|
* Set the description |
|
782
|
|
|
* |
|
783
|
|
|
* @param string $new_description the new description |
|
784
|
|
|
* |
|
785
|
|
|
* @return self |
|
786
|
|
|
*/ |
|
787
|
|
|
public function setDescription(?string $new_description) : self |
|
788
|
|
|
{ |
|
789
|
|
|
$this->description = $new_description; |
|
790
|
|
|
return $this; |
|
791
|
|
|
} |
|
792
|
|
|
|
|
793
|
|
|
/** |
|
794
|
|
|
* Set the count of parts which are in stock |
|
795
|
|
|
* |
|
796
|
|
|
* @param integer $new_instock the new count of parts which are in stock |
|
797
|
|
|
* |
|
798
|
|
|
* @return self |
|
799
|
|
|
*/ |
|
800
|
|
|
public function setInstock(int $new_instock, $comment = null) : self |
|
|
|
|
|
|
801
|
|
|
{ |
|
802
|
|
|
//Assert::natural($new_instock, 'New instock must be positive. Got: %s'); |
|
803
|
|
|
|
|
804
|
|
|
$old_instock = (int) $this->getInstock(); |
|
|
|
|
|
|
805
|
|
|
$this->instock = $new_instock; |
|
806
|
|
|
//TODO |
|
807
|
|
|
/* |
|
808
|
|
|
InstockChangedEntry::add( |
|
809
|
|
|
$this->database, |
|
810
|
|
|
$this->current_user, |
|
811
|
|
|
$this->log, |
|
812
|
|
|
$this, |
|
813
|
|
|
$old_instock, |
|
814
|
|
|
$new_instock, |
|
815
|
|
|
$comment |
|
816
|
|
|
);*/ |
|
817
|
|
|
|
|
818
|
|
|
return $this; |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
|
|
/** |
|
822
|
|
|
* Sets the unknown status of this part. |
|
823
|
|
|
* When the instock is currently unknown and you pass false, then the instock is set to zero. |
|
824
|
|
|
* If the instock is not unknown and you pass false, nothing is changed. |
|
825
|
|
|
* |
|
826
|
|
|
* @param bool $new_unknown Set this to true if the instock should be marked as unknown. |
|
827
|
|
|
* @return Part |
|
828
|
|
|
*/ |
|
829
|
|
|
public function setInstockUnknown(bool $new_unknown) : self |
|
830
|
|
|
{ |
|
831
|
|
|
if($new_unknown == true) { |
|
|
|
|
|
|
832
|
|
|
$this->instock = self::INSTOCK_UNKNOWN; |
|
|
|
|
|
|
833
|
|
|
} else { |
|
834
|
|
|
//Change only if instock is currently unknown. |
|
835
|
|
|
if ($this->isInstockUnknown()) { |
|
836
|
|
|
$this->setInstock(0); |
|
837
|
|
|
} |
|
838
|
|
|
} |
|
839
|
|
|
|
|
840
|
|
|
} |
|
841
|
|
|
|
|
842
|
|
|
/** |
|
843
|
|
|
* Withdrawal the given number of parts. |
|
844
|
|
|
* @param $count int The number of parts which should be withdrawan. |
|
845
|
|
|
* @param $comment string A comment that should be associated with the withdrawal. |
|
846
|
|
|
* |
|
847
|
|
|
* @return self |
|
848
|
|
|
*/ |
|
849
|
|
|
public function withdrawalParts(int $count, $comment = null) : self |
|
|
|
|
|
|
850
|
|
|
{ |
|
851
|
|
|
//Assert::greaterThan($count,0, 'Count of withdrawn parts must be greater 0! Got %s!'); |
|
852
|
|
|
//Assert::greaterThan($count, $this->instock, 'You can not withdraw more parts, than there are existing!'); |
|
853
|
|
|
|
|
854
|
|
|
$old_instock = $this->getInstock(); |
|
855
|
|
|
$new_instock = $old_instock - $count; |
|
856
|
|
|
|
|
857
|
|
|
//TODO |
|
858
|
|
|
/* |
|
859
|
|
|
InstockChangedEntry::add( |
|
860
|
|
|
$this->database, |
|
861
|
|
|
$this->current_user, |
|
862
|
|
|
$this->log, |
|
863
|
|
|
$this, |
|
864
|
|
|
$old_instock, |
|
865
|
|
|
$new_instock, |
|
866
|
|
|
$comment |
|
867
|
|
|
);*/ |
|
868
|
|
|
|
|
869
|
|
|
$this->instock = $new_instock; |
|
870
|
|
|
|
|
871
|
|
|
return $this; |
|
872
|
|
|
} |
|
873
|
|
|
|
|
874
|
|
|
/** |
|
875
|
|
|
* Add the given number of parts. |
|
876
|
|
|
* @param $count int The number of parts which should be withdrawan. |
|
877
|
|
|
* @param $comment string A comment that should be associated with the withdrawal. |
|
878
|
|
|
* |
|
879
|
|
|
* @return self |
|
880
|
|
|
*/ |
|
881
|
|
|
public function addParts(int $count, string $comment = null) : self |
|
|
|
|
|
|
882
|
|
|
{ |
|
883
|
|
|
//Assert::greaterThan($count, 0, 'Count of added parts must be greater zero! Got %s.'); |
|
884
|
|
|
|
|
885
|
|
|
//TODO |
|
886
|
|
|
|
|
887
|
|
|
$old_instock = $this->getInstock(); |
|
888
|
|
|
$new_instock = $old_instock + $count; |
|
889
|
|
|
|
|
890
|
|
|
//TODO |
|
891
|
|
|
/* |
|
892
|
|
|
InstockChangedEntry::add( |
|
893
|
|
|
$this->database, |
|
894
|
|
|
$this->current_user, |
|
895
|
|
|
$this->log, |
|
896
|
|
|
$this, |
|
897
|
|
|
$old_instock, |
|
898
|
|
|
$new_instock, |
|
899
|
|
|
$comment |
|
900
|
|
|
);*/ |
|
901
|
|
|
|
|
902
|
|
|
$this->instock = $new_instock; |
|
903
|
|
|
|
|
904
|
|
|
return $this; |
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
|
|
/** |
|
908
|
|
|
* Set the count of parts which should be in stock at least |
|
909
|
|
|
* |
|
910
|
|
|
* @param integer $new_mininstock the new count of parts which should be in stock at least |
|
911
|
|
|
* @return self |
|
912
|
|
|
*/ |
|
913
|
|
|
public function setMinInstock(int $new_mininstock) : self |
|
914
|
|
|
{ |
|
915
|
|
|
//Assert::natural($new_mininstock, 'The new minimum instock value must be positive! Got %s.'); |
|
916
|
|
|
|
|
917
|
|
|
$this->mininstock = $new_mininstock; |
|
918
|
|
|
return $this; |
|
919
|
|
|
} |
|
920
|
|
|
|
|
921
|
|
|
/** |
|
922
|
|
|
* Set the comment |
|
923
|
|
|
* |
|
924
|
|
|
* @param string $new_comment the new comment |
|
925
|
|
|
* |
|
926
|
|
|
* @return self |
|
927
|
|
|
*/ |
|
928
|
|
|
public function setComment(string $new_comment) : self |
|
929
|
|
|
{ |
|
930
|
|
|
$this->comment = $new_comment; |
|
931
|
|
|
|
|
932
|
|
|
return $this; |
|
933
|
|
|
} |
|
934
|
|
|
|
|
935
|
|
|
/** |
|
936
|
|
|
* Set the "manual_order" attribute |
|
937
|
|
|
* |
|
938
|
|
|
* @param boolean $new_manual_order the new "manual_order" attribute |
|
939
|
|
|
* @param integer $new_order_quantity the new order quantity |
|
940
|
|
|
* @param integer|NULL $new_order_orderdetails_id * the ID of the new order orderdetails |
|
941
|
|
|
* * or Zero for "no order orderdetails" |
|
942
|
|
|
* * or NULL for automatic order orderdetails |
|
943
|
|
|
* (if the part has exactly one orderdetails, |
|
944
|
|
|
* set this orderdetails as order orderdetails. |
|
945
|
|
|
* Otherwise, set "no order orderdetails") |
|
946
|
|
|
* |
|
947
|
|
|
* @return self |
|
948
|
|
|
*/ |
|
949
|
|
|
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, $new_order_orderdetails_id = null) : self |
|
|
|
|
|
|
950
|
|
|
{ |
|
951
|
|
|
//Assert::greaterThan($new_order_quantity, 0, 'The new order quantity must be greater zero. Got %s!'); |
|
952
|
|
|
|
|
953
|
|
|
|
|
954
|
|
|
$this->manual_order = $new_manual_order; |
|
955
|
|
|
|
|
956
|
|
|
//TODO; |
|
957
|
|
|
/* $this->order_orderdetail = $new_order_orderdetails_id; */ |
|
958
|
|
|
$this->order_quantity = $new_order_quantity; |
|
959
|
|
|
|
|
960
|
|
|
return $this; |
|
961
|
|
|
} |
|
962
|
|
|
|
|
963
|
|
|
/** |
|
964
|
|
|
* Set the ID of the order orderdetails |
|
965
|
|
|
* |
|
966
|
|
|
* @param integer|NULL $new_order_orderdetails_id * the new order orderdetails ID |
|
967
|
|
|
* * Or, to remove the orderdetails, pass a NULL |
|
968
|
|
|
* |
|
969
|
|
|
* @return self |
|
970
|
|
|
*/ |
|
971
|
|
|
public function setOrderOrderdetailsID($new_order_orderdetails_id) : self |
|
|
|
|
|
|
972
|
|
|
{ |
|
973
|
|
|
//TODO |
|
974
|
|
|
throw new \Exception("Not implemented yet..."); |
|
975
|
|
|
|
|
976
|
|
|
return $this; |
|
|
|
|
|
|
977
|
|
|
} |
|
978
|
|
|
|
|
979
|
|
|
/** |
|
980
|
|
|
* Set the order quantity |
|
981
|
|
|
* |
|
982
|
|
|
* @param integer $new_order_quantity the new order quantity |
|
983
|
|
|
* |
|
984
|
|
|
* @return self |
|
985
|
|
|
*/ |
|
986
|
|
|
public function setOrderQuantity(int $new_order_quantity) : self |
|
987
|
|
|
{ |
|
988
|
|
|
//Assert::greaterThan($new_order_quantity,0, 'The new order quantity must be greater zero. Got %s!'); |
|
989
|
|
|
|
|
990
|
|
|
$this->order_quantity = $new_order_quantity; |
|
991
|
|
|
|
|
992
|
|
|
return $this; |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
/** |
|
996
|
|
|
* Set the ID of the category |
|
997
|
|
|
* |
|
998
|
|
|
* Every part must have a valid category (in contrast to the |
|
999
|
|
|
* attributes "footprint", "storelocation", ...)! |
|
1000
|
|
|
* |
|
1001
|
|
|
* @param integer $new_category_id the ID of the category |
|
1002
|
|
|
* |
|
1003
|
|
|
* @return self |
|
1004
|
|
|
*/ |
|
1005
|
|
|
public function setCategory(Category $category) : self |
|
1006
|
|
|
{ |
|
1007
|
|
|
//TODO |
|
1008
|
|
|
$this->category = $category; |
|
1009
|
|
|
|
|
1010
|
|
|
return $this; |
|
1011
|
|
|
} |
|
1012
|
|
|
|
|
1013
|
|
|
/** |
|
1014
|
|
|
* Set the footprint ID |
|
1015
|
|
|
* |
|
1016
|
|
|
* @param integer|NULL $new_footprint_id * the ID of the footprint |
|
1017
|
|
|
* * NULL means "no footprint" |
|
1018
|
|
|
* |
|
1019
|
|
|
* @throws Exception if the new footprint ID is not valid |
|
1020
|
|
|
* @throws Exception if there was an error |
|
1021
|
|
|
*/ |
|
1022
|
|
|
public function setFootprintID($new_footprint_id) : self |
|
|
|
|
|
|
1023
|
|
|
{ |
|
1024
|
|
|
//TODO |
|
1025
|
|
|
throw new \Exception("Not implemented yet!"); |
|
1026
|
|
|
|
|
1027
|
|
|
return $this; |
|
|
|
|
|
|
1028
|
|
|
} |
|
1029
|
|
|
|
|
1030
|
|
|
/** |
|
1031
|
|
|
* Set the storelocation ID |
|
1032
|
|
|
* |
|
1033
|
|
|
* @param integer|NULL $new_storelocation_id * the ID of the storelocation |
|
1034
|
|
|
* * NULL means "no storelocation" |
|
1035
|
|
|
* |
|
1036
|
|
|
* @throws Exception if the new storelocation ID is not valid |
|
1037
|
|
|
* @throws Exception if there was an error |
|
1038
|
|
|
*/ |
|
1039
|
|
|
public function setStorelocationID($new_storelocation_id) : self |
|
|
|
|
|
|
1040
|
|
|
{ |
|
1041
|
|
|
//TODO |
|
1042
|
|
|
throw new \Exception("Not implemented yet!"); |
|
1043
|
|
|
|
|
1044
|
|
|
return $this; |
|
|
|
|
|
|
1045
|
|
|
} |
|
1046
|
|
|
|
|
1047
|
|
|
/** |
|
1048
|
|
|
* Set the manufacturer ID |
|
1049
|
|
|
* |
|
1050
|
|
|
* @param integer|NULL $new_manufacturer_id * the ID of the manufacturer |
|
1051
|
|
|
* * NULL means "no manufacturer" |
|
1052
|
|
|
* |
|
1053
|
|
|
* @throws Exception if the new manufacturer ID is not valid |
|
1054
|
|
|
* @throws Exception if there was an error |
|
1055
|
|
|
*/ |
|
1056
|
|
|
public function setManufacturerID($new_manufacturer_id) : self |
|
|
|
|
|
|
1057
|
|
|
{ |
|
1058
|
|
|
//TODO |
|
1059
|
|
|
throw new \Exception("Not implemented yet!"); |
|
1060
|
|
|
|
|
1061
|
|
|
return $this; |
|
|
|
|
|
|
1062
|
|
|
} |
|
1063
|
|
|
|
|
1064
|
|
|
/** |
|
1065
|
|
|
* Set the favorite status for this part. |
|
1066
|
|
|
* @param $new_favorite_status bool The new favorite status, that should be applied on this part. |
|
1067
|
|
|
* Set this to true, when the part should be a favorite. |
|
1068
|
|
|
* |
|
1069
|
|
|
* @return self |
|
1070
|
|
|
*/ |
|
1071
|
|
|
public function setFavorite(bool $new_favorite_status) : self |
|
1072
|
|
|
{ |
|
1073
|
|
|
$this->favorite = $new_favorite_status; |
|
1074
|
|
|
|
|
1075
|
|
|
return $this; |
|
1076
|
|
|
} |
|
1077
|
|
|
|
|
1078
|
|
|
/** |
|
1079
|
|
|
* Sets the URL to the manufacturer site about this Part. Set to "" if this part should use the automatically URL based on its manufacturer. |
|
1080
|
|
|
* @param string $new_url The new url |
|
1081
|
|
|
* @return self |
|
1082
|
|
|
*/ |
|
1083
|
|
|
public function setManufacturerProductURL(string $new_url) : self |
|
1084
|
|
|
{ |
|
1085
|
|
|
$this->manufacturer_product_url = $new_url; |
|
1086
|
|
|
|
|
1087
|
|
|
return $this; |
|
1088
|
|
|
} |
|
1089
|
|
|
|
|
1090
|
|
|
/** |
|
1091
|
|
|
* Set the ID of the master picture Attachement |
|
1092
|
|
|
* |
|
1093
|
|
|
* @param integer|NULL $new_master_picture_attachement_id * the ID of the Attachement object of the master picture |
|
1094
|
|
|
* * NULL means "no master picture" |
|
1095
|
|
|
* |
|
1096
|
|
|
* @throws Exception if the new ID is not valid |
|
1097
|
|
|
* @throws Exception if there was an error |
|
1098
|
|
|
* |
|
1099
|
|
|
* @return self |
|
1100
|
|
|
*/ |
|
1101
|
|
|
public function setMasterPictureAttachementID($new_master_picture_attachement_id) : self |
|
|
|
|
|
|
1102
|
|
|
{ |
|
1103
|
|
|
//TODO |
|
1104
|
|
|
throw new \Exception("Not implemented yet!"); |
|
1105
|
|
|
|
|
1106
|
|
|
return $this; |
|
|
|
|
|
|
1107
|
|
|
} |
|
1108
|
|
|
|
|
1109
|
|
|
|
|
1110
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.