1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Entity Article. |
5
|
|
|
* |
6
|
|
|
* PHP Version 7 |
7
|
|
|
* |
8
|
|
|
* @author Quétier Laurent <[email protected]> |
9
|
|
|
* @copyright 2014 Dev-Int GLSR |
10
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
11
|
|
|
* |
12
|
|
|
* @version GIT: <git_id> |
13
|
|
|
* |
14
|
|
|
* @link https://github.com/Dev-Int/glsr |
15
|
|
|
*/ |
16
|
|
|
namespace App\Entity\Settings; |
17
|
|
|
|
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
20
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
21
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
22
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
23
|
|
|
|
24
|
|
|
use App\Entity\Settings\Supplier; |
25
|
|
|
use App\Entity\Settings\Diverse\Unit; |
26
|
|
|
use App\Entity\Settings\Diverse\ZoneStorage; |
27
|
|
|
use App\Entity\Settings\Diverse\FamilyLog; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Article entity. |
31
|
|
|
* |
32
|
|
|
* @category Entity |
33
|
|
|
* |
34
|
|
|
* @ORM\Table(name="gs_article") |
35
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\Settings\ArticleRepository") |
36
|
|
|
* @UniqueEntity(fields="name", message="Ce nom d'article est déjà utilisé.") |
37
|
|
|
* @ORM\HasLifecycleCallbacks() |
38
|
|
|
*/ |
39
|
|
|
class Article |
40
|
|
|
{ |
41
|
|
|
/** |
42
|
|
|
* @var int $artId Id of the article |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(name="id", type="integer") |
45
|
|
|
* @ORM\Id |
46
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
47
|
|
|
*/ |
48
|
|
|
private $artId; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string $name title of the article |
52
|
|
|
* |
53
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
54
|
|
|
* @Assert\NotBlank() |
55
|
|
|
* @Assert\Regex( |
56
|
|
|
* pattern="'^\w+[^/]'", |
57
|
|
|
* message="L'intitulé ne peut contenir que des lettres, |
58
|
|
|
* chiffres et _ ou -" |
59
|
|
|
* ) |
60
|
|
|
*/ |
61
|
|
|
private $name; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string|\App\Entity\Settings\Supplier $supplier Name of supplier |
65
|
|
|
* |
66
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Supplier") |
67
|
|
|
*/ |
68
|
|
|
private $supplier; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var string|\App\Entity\Settings\Diverse\Unit $unitStorage Storage unit |
72
|
|
|
* |
73
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit") |
74
|
|
|
*/ |
75
|
|
|
private $unitStorage; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var string|\App\Entity\Settings\Diverse\Unit $unitWorking Working unit |
79
|
|
|
* |
80
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit") |
81
|
|
|
*/ |
82
|
|
|
private $unitWorking; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var double $packaging Conditioning (quantity) |
86
|
|
|
* |
87
|
|
|
* @ORM\Column(name="packaging", type="decimal", precision=7, scale=3) |
88
|
|
|
* @Assert\Type(type="numeric", |
89
|
|
|
* message="La valeur {{ value }} n'est pas un type {{ type }} valide.") |
90
|
|
|
*/ |
91
|
|
|
private $packaging; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var double $price price of the article |
95
|
|
|
* |
96
|
|
|
* @ORM\Column(name="price", type="decimal", precision=7, scale=3) |
97
|
|
|
* @Assert\Type(type="numeric", |
98
|
|
|
* message="La valeur {{ value }} n'est pas un type {{ type }} valide.") |
99
|
|
|
*/ |
100
|
|
|
private $price; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var string|\App\Entity\Settings\Diverse\Tva $tva VAT rate |
104
|
|
|
* |
105
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Tva") |
106
|
|
|
*/ |
107
|
|
|
private $tva; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var double $quantity Quantity in stock |
111
|
|
|
* |
112
|
|
|
* @ORM\Column(name="quantity", type="decimal", precision=7, scale=3, nullable=true, options={"default":0}) |
113
|
|
|
* @Assert\Type(type="numeric", |
114
|
|
|
* message="La valeur {{ value }} n'est pas un type {{ type }} valide.") |
115
|
|
|
*/ |
116
|
|
|
private $quantity; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @var double $minstock Minimum stock |
120
|
|
|
* |
121
|
|
|
* @ORM\Column(name="minstock", type="decimal", precision=7, scale=3) |
122
|
|
|
* @Assert\Type(type="numeric", |
123
|
|
|
* message="La valeur {{ value }} n'est pas un type {{ type }} valide.") |
124
|
|
|
*/ |
125
|
|
|
private $minstock; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection $zoneStorages Storage area(s) |
129
|
|
|
* |
130
|
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\Settings\Diverse\ZoneStorage") |
131
|
|
|
* @ORM\JoinTable(name="gs_article_zonestorage") |
132
|
|
|
* @Assert\NotBlank() |
133
|
|
|
*/ |
134
|
|
|
private $zoneStorages; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @var string|\App\Entity\Settings\Diverse\FamilyLog $familyLog Logistic family |
138
|
|
|
* |
139
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\FamilyLog") |
140
|
|
|
* @Assert\NotBlank() |
141
|
|
|
*/ |
142
|
|
|
private $familyLog; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @var bool On/Off |
146
|
|
|
* |
147
|
|
|
* @ORM\Column(name="active", type="boolean") |
148
|
|
|
*/ |
149
|
|
|
private $active; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @var string $slug |
153
|
|
|
* @Gedmo\Slug(fields={"name"}, updatable=false) |
154
|
|
|
* @ORM\Column(length=128, unique=true) |
155
|
|
|
*/ |
156
|
|
|
private $slug; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Constructor. |
160
|
|
|
*/ |
161
|
|
|
public function __construct() |
162
|
|
|
{ |
163
|
|
|
$this->zoneStorages = new ArrayCollection(); |
164
|
|
|
$this->active = true; |
165
|
|
|
$this->quantity = 0.000; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Get id. |
170
|
|
|
* |
171
|
|
|
* @return int |
172
|
|
|
*/ |
173
|
|
|
public function getId() |
174
|
|
|
{ |
175
|
|
|
return $this->artId; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Set name. |
180
|
|
|
* |
181
|
|
|
* @param string $name Name of article |
182
|
|
|
* |
183
|
|
|
* @return Article |
184
|
|
|
*/ |
185
|
|
|
public function setName($name) |
186
|
|
|
{ |
187
|
|
|
$this->name = $name; |
188
|
|
|
|
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Get name. |
194
|
|
|
* |
195
|
|
|
* @return string |
196
|
|
|
*/ |
197
|
|
|
public function getName() |
198
|
|
|
{ |
199
|
|
|
return $this->name; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Set packaging. |
204
|
|
|
* |
205
|
|
|
* @param double $packaging Conditioning (quantity) |
206
|
|
|
* |
207
|
|
|
* @return Article |
208
|
|
|
*/ |
209
|
|
|
public function setPackaging($packaging) |
210
|
|
|
{ |
211
|
|
|
$this->packaging = $packaging; |
212
|
|
|
|
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* Get packaging. |
218
|
|
|
* |
219
|
|
|
* @return double |
220
|
|
|
*/ |
221
|
|
|
public function getPackaging() |
222
|
|
|
{ |
223
|
|
|
return $this->packaging; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Set price. |
228
|
|
|
* |
229
|
|
|
* @param double $price price of the article |
230
|
|
|
* |
231
|
|
|
* @return Article |
232
|
|
|
*/ |
233
|
|
|
public function setPrice($price) |
234
|
|
|
{ |
235
|
|
|
$this->price = $price; |
236
|
|
|
|
237
|
|
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Get price. |
242
|
|
|
* |
243
|
|
|
* @return double |
244
|
|
|
*/ |
245
|
|
|
public function getPrice() |
246
|
|
|
{ |
247
|
|
|
return $this->price; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Set quantity. |
252
|
|
|
* |
253
|
|
|
* @param double $quantity quantity in stock |
254
|
|
|
* |
255
|
|
|
* @return Article |
256
|
|
|
*/ |
257
|
|
|
public function setQuantity($quantity) |
258
|
|
|
{ |
259
|
|
|
$this->quantity = $quantity; |
260
|
|
|
|
261
|
|
|
return $this; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Get quantity. |
266
|
|
|
* |
267
|
|
|
* @return double |
268
|
|
|
*/ |
269
|
|
|
public function getQuantity() |
270
|
|
|
{ |
271
|
|
|
return $this->quantity; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Set minstock. |
276
|
|
|
* |
277
|
|
|
* @param double $minstock minimum stock |
278
|
|
|
* |
279
|
|
|
* @return Article |
280
|
|
|
*/ |
281
|
|
|
public function setMinstock($minstock) |
282
|
|
|
{ |
283
|
|
|
$this->minstock = $minstock; |
284
|
|
|
|
285
|
|
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Get minstock. |
290
|
|
|
* |
291
|
|
|
* @return double |
292
|
|
|
*/ |
293
|
|
|
public function getMinstock() |
294
|
|
|
{ |
295
|
|
|
return $this->minstock; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Set supplier. |
300
|
|
|
* |
301
|
|
|
* @param null|\App\Entity\Settings\Supplier $supplier Supplier of the article |
302
|
|
|
* |
303
|
|
|
* @return Article |
304
|
|
|
*/ |
305
|
|
|
public function setSupplier(Supplier $supplier = null) |
306
|
|
|
{ |
307
|
|
|
$this->supplier = $supplier; |
308
|
|
|
|
309
|
|
|
return $this; |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* Get supplier. |
314
|
|
|
* |
315
|
|
|
* @return string|\App\Entity\Settings\Supplier |
316
|
|
|
*/ |
317
|
|
|
public function getSupplier() |
318
|
|
|
{ |
319
|
|
|
return $this->supplier; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Set unitStorage. |
324
|
|
|
* |
325
|
|
|
* @param null|\App\Entity\Settings\Diverse\Unit $unitStorage Storage unit |
326
|
|
|
* |
327
|
|
|
* @return Article |
328
|
|
|
*/ |
329
|
|
|
public function setUnitStorage(Unit $unitStorage = null) |
330
|
|
|
{ |
331
|
|
|
$this->unitStorage = $unitStorage; |
332
|
|
|
|
333
|
|
|
return $this; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Get unitStorage. |
338
|
|
|
* |
339
|
|
|
* @return string|\App\Entity\Settings\Diverse\Unit |
340
|
|
|
*/ |
341
|
|
|
public function getUnitStorage() |
342
|
|
|
{ |
343
|
|
|
return $this->unitStorage; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Add zoneStorage. |
348
|
|
|
* |
349
|
|
|
* @param \App\Entity\Settings\Diverse\ZoneStorage $zoneStorages Storage area(s) |
350
|
|
|
* |
351
|
|
|
* @return Article |
352
|
|
|
*/ |
353
|
|
|
public function addZoneStorage(ZoneStorage $zoneStorages) |
354
|
|
|
{ |
355
|
|
|
$this->zoneStorages[] = $zoneStorages; |
356
|
|
|
|
357
|
|
|
return $this; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Remove zoneStorage. |
362
|
|
|
* |
363
|
|
|
* @param \App\Entity\Settings\Diverse\ZoneStorage $zoneStorages Storage area to delete |
364
|
|
|
* |
365
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection|null |
366
|
|
|
*/ |
367
|
|
|
public function removeZoneStorage(ZoneStorage $zoneStorages) |
368
|
|
|
{ |
369
|
|
|
$this->zoneStorages->removeElement($zoneStorages); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Get zoneStorage. |
374
|
|
|
* |
375
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
376
|
|
|
*/ |
377
|
|
|
public function getZoneStorages() |
378
|
|
|
{ |
379
|
|
|
return $this->zoneStorages; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Set unitWorking |
384
|
|
|
* |
385
|
|
|
* @param \App\Entity\Settings\Diverse\Unit $unitWorking |
386
|
|
|
* @return Article |
387
|
|
|
*/ |
388
|
|
|
public function setUnitWorking(Unit $unitWorking = null) |
389
|
|
|
{ |
390
|
|
|
$this->unitWorking = $unitWorking; |
391
|
|
|
|
392
|
|
|
return $this; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Get unitWorking |
397
|
|
|
* |
398
|
|
|
* @return \App\Entity\Settings\Diverse\UnitWorking |
399
|
|
|
*/ |
400
|
|
|
public function getUnitWorking() |
401
|
|
|
{ |
402
|
|
|
return $this->unitWorking; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Set familyLog. |
407
|
|
|
* |
408
|
|
|
* @param null|\App\Entity\Settings\Diverse\FamilyLog $familyLog Logistics Family |
409
|
|
|
* |
410
|
|
|
* @return Article |
411
|
|
|
*/ |
412
|
|
|
public function setFamilyLog(FamilyLog $familyLog = null) |
413
|
|
|
{ |
414
|
|
|
$this->familyLog = $familyLog; |
415
|
|
|
|
416
|
|
|
return $this; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Get familyLog. |
421
|
|
|
* |
422
|
|
|
* @return \App\Entity\Settings\Diverse\FamilyLog |
423
|
|
|
*/ |
424
|
|
|
public function getFamilyLog() |
425
|
|
|
{ |
426
|
|
|
return $this->familyLog; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Set tva |
431
|
|
|
* |
432
|
|
|
* @param \App\Entity\Settings\Diverse\Tva $tva |
433
|
|
|
* @return Article |
434
|
|
|
*/ |
435
|
|
|
public function setTva(\App\Entity\Settings\Diverse\Tva $tva = null) |
436
|
|
|
{ |
437
|
|
|
$this->tva = $tva; |
438
|
|
|
|
439
|
|
|
return $this; |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Get tva |
444
|
|
|
* |
445
|
|
|
* @return \App\Entity\Settings\Diverse\Tva |
446
|
|
|
*/ |
447
|
|
|
public function getTva() |
448
|
|
|
{ |
449
|
|
|
return $this->tva; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Set active. |
454
|
|
|
* |
455
|
|
|
* @param bool $active On/Off |
456
|
|
|
* |
457
|
|
|
* @return Article |
458
|
|
|
*/ |
459
|
|
|
public function setActive($active) |
460
|
|
|
{ |
461
|
|
|
$this->active = $active; |
462
|
|
|
|
463
|
|
|
return $this; |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
/** |
467
|
|
|
* Is active |
468
|
|
|
* |
469
|
|
|
* @return boolean |
470
|
|
|
*/ |
471
|
|
|
public function isActive() |
472
|
|
|
{ |
473
|
|
|
return $this->active; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Get slug |
478
|
|
|
* |
479
|
|
|
* @return string |
480
|
|
|
*/ |
481
|
|
|
public function getSlug() |
482
|
|
|
{ |
483
|
|
|
return $this->slug; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* This method allows to do "echo $article". |
488
|
|
|
* <p> So, to "show" $uniarticlet, |
489
|
|
|
* PHP will actually show the return of this method. <br /> |
490
|
|
|
* Here, the abbreviation, so "echo $article" |
491
|
|
|
* is equivalent to "echo $article->getName()" </ p>. |
492
|
|
|
* |
493
|
|
|
* @return string name |
494
|
|
|
*/ |
495
|
|
|
public function __toString() |
496
|
|
|
{ |
497
|
|
|
return $this->name; |
498
|
|
|
} |
499
|
|
|
} |
500
|
|
|
|