|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Entity\Settings; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
8
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
9
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
10
|
|
|
use App\Entity\Settings\Diverse\Unit; |
|
11
|
|
|
use App\Entity\Settings\Diverse\Tva; |
|
12
|
|
|
use App\Entity\Settings\Diverse\FamilyLog; |
|
13
|
|
|
use App\Entity\Settings\Diverse\ZoneStorage; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @ORM\Table(name="app_article") |
|
17
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\Settings\ArticleRepository") |
|
18
|
|
|
* @UniqueEntity(fields="name", message="This article name is already used.") |
|
19
|
|
|
* @ORM\HasLifecycleCallbacks() |
|
20
|
|
|
*/ |
|
21
|
|
|
class Article |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var int Id of the article |
|
25
|
|
|
* |
|
26
|
|
|
* @ORM\Column(name="id", type="integer") |
|
27
|
|
|
* @ORM\Id |
|
28
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
29
|
|
|
*/ |
|
30
|
|
|
private $id; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var string title of the article |
|
34
|
|
|
* |
|
35
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
|
36
|
|
|
* @Assert\NotBlank() |
|
37
|
|
|
* @Assert\Regex( |
|
38
|
|
|
* pattern="'^\w+[^/]'", |
|
39
|
|
|
* message="The title can only contain letters, digits and _ or -" |
|
40
|
|
|
* ) |
|
41
|
|
|
*/ |
|
42
|
|
|
private $name; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var string|Supplier Name of supplier |
|
46
|
|
|
* |
|
47
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Supplier") |
|
48
|
|
|
*/ |
|
49
|
|
|
private $supplier; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Unit Storage unit |
|
53
|
|
|
* |
|
54
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit") |
|
55
|
|
|
*/ |
|
56
|
|
|
private $unitStorage; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var Unit Working unit |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Unit") |
|
62
|
|
|
*/ |
|
63
|
|
|
private $unitWorking; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var double Packaging (quantity) |
|
67
|
|
|
* |
|
68
|
|
|
* @ORM\Column(name="packaging", type="decimal", precision=7, scale=3) |
|
69
|
|
|
* @Assert\Type(type="numeric", |
|
70
|
|
|
* message="The value {{value}} is not a valid type {{type}}.") |
|
71
|
|
|
*/ |
|
72
|
|
|
private $packaging; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var double price of the article |
|
76
|
|
|
* |
|
77
|
|
|
* @ORM\Column(name="price", type="decimal", precision=7, scale=3) |
|
78
|
|
|
* @Assert\Type(type="numeric", |
|
79
|
|
|
* message="The value {{value}} is not a valid type {{type}}.") |
|
80
|
|
|
*/ |
|
81
|
|
|
private $price; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @var string|Tva VAT rate |
|
85
|
|
|
* |
|
86
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\Tva") |
|
87
|
|
|
*/ |
|
88
|
|
|
private $tva; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @var double Quantity in stock |
|
92
|
|
|
* |
|
93
|
|
|
* @ORM\Column(name="quantity", type="decimal", precision=7, scale=3, nullable=true, options={"default":0}) |
|
94
|
|
|
* @Assert\Type(type="numeric", |
|
95
|
|
|
* message="The value {{value}} is not a valid type {{type}}.") |
|
96
|
|
|
*/ |
|
97
|
|
|
private $quantity; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @var double Minimum stock |
|
101
|
|
|
* |
|
102
|
|
|
* @ORM\Column(name="minstock", type="decimal", precision=7, scale=3) |
|
103
|
|
|
* @Assert\Type(type="numeric", |
|
104
|
|
|
* message="The value {{value}} is not a valid type {{type}}.") |
|
105
|
|
|
*/ |
|
106
|
|
|
private $minStock; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @var ArrayCollection Storage area(s) |
|
110
|
|
|
* |
|
111
|
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\Settings\Diverse\ZoneStorage") |
|
112
|
|
|
* @ORM\JoinTable(name="app_article_zonestorage") |
|
113
|
|
|
* @Assert\NotBlank() |
|
114
|
|
|
*/ |
|
115
|
|
|
private $zoneStorages; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @var string|FamilyLog Logistic family |
|
119
|
|
|
* |
|
120
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Settings\Diverse\FamilyLog") |
|
121
|
|
|
* @Assert\NotBlank() |
|
122
|
|
|
*/ |
|
123
|
|
|
private $familyLog; |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @var bool On / Off |
|
127
|
|
|
* |
|
128
|
|
|
* @ORM\Column(name="active", type="boolean") |
|
129
|
|
|
*/ |
|
130
|
|
|
private $active; |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @Gedmo\Slug(fields={"name"}, updatable=false) |
|
134
|
|
|
* @ORM\Column(length=128, unique=true) |
|
135
|
|
|
*/ |
|
136
|
|
|
private $slug; |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @var \DateTimeImmutable Created date |
|
140
|
|
|
* @ORM\Column(name="create_at", type="datetime_immutable") |
|
141
|
|
|
*/ |
|
142
|
|
|
private $createAt; |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @var \DateTimeImmutable Updated date |
|
146
|
|
|
* @ORM\Column(name="update_at", type="datetime_immutable") |
|
147
|
|
|
*/ |
|
148
|
|
|
private $updateAt; |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @var \DateTimeImmutable Deleted date |
|
152
|
|
|
* @ORM\Column(name="delete_at", type="datetime_immutable", nullable=true) |
|
153
|
|
|
*/ |
|
154
|
|
|
private $deleteAt; |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Constructor. |
|
158
|
|
|
*/ |
|
159
|
|
|
public function __construct() |
|
160
|
|
|
{ |
|
161
|
|
|
$this->zoneStorages = new ArrayCollection(); |
|
162
|
|
|
$this->active = true; |
|
163
|
|
|
$this->quantity = 0.000; |
|
164
|
|
|
$this->createAt = new \DateTimeImmutable() ; |
|
165
|
|
|
$this->updateAt = new \DateTimeImmutable() ; |
|
166
|
|
|
$this->deleteAt = new \DateTimeImmutable('3000-12-31') ; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function getId(): int |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->id; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function setName(string $name): self |
|
175
|
|
|
{ |
|
176
|
|
|
$this->name = $name; |
|
177
|
|
|
|
|
178
|
|
|
return $this; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
public function getName(): string |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->name; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
public function setPackaging(float $packaging): self |
|
187
|
|
|
{ |
|
188
|
|
|
$this->packaging = $packaging; |
|
189
|
|
|
|
|
190
|
|
|
return $this; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
public function getPackaging(): float |
|
194
|
|
|
{ |
|
195
|
|
|
return $this->packaging; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
public function setPrice(float $price): self |
|
199
|
|
|
{ |
|
200
|
|
|
$this->price = $price; |
|
201
|
|
|
|
|
202
|
|
|
return $this; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
public function getPrice(): float |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->price; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
public function setQuantity(float $quantity): self |
|
211
|
|
|
{ |
|
212
|
|
|
$this->quantity = $quantity; |
|
213
|
|
|
|
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public function getQuantity(): float |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->quantity; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
public function setMinStock(float $minStock): self |
|
223
|
|
|
{ |
|
224
|
|
|
$this->minStock = $minStock; |
|
225
|
|
|
|
|
226
|
|
|
return $this; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function getMinStock(): float |
|
230
|
|
|
{ |
|
231
|
|
|
return $this->minStock; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
public function setSupplier(Supplier $supplier = null): self |
|
235
|
|
|
{ |
|
236
|
|
|
$this->supplier = $supplier; |
|
237
|
|
|
|
|
238
|
|
|
return $this; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
public function getSupplier(): Supplier |
|
242
|
|
|
{ |
|
243
|
|
|
return $this->supplier; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
public function setUnitStorage(Unit $unitStorage = null): self |
|
247
|
|
|
{ |
|
248
|
|
|
$this->unitStorage = $unitStorage; |
|
249
|
|
|
|
|
250
|
|
|
return $this; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
public function getUnitStorage(): Unit |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->unitStorage; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
public function addZoneStorage(ZoneStorage $zoneStorages): self |
|
259
|
|
|
{ |
|
260
|
|
|
$this->zoneStorages[] = $zoneStorages; |
|
261
|
|
|
|
|
262
|
|
|
return $this; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
public function removeZoneStorage(ZoneStorage $zoneStorages): void |
|
266
|
|
|
{ |
|
267
|
|
|
$this->zoneStorages->removeElement($zoneStorages); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* @return ArrayCollection|ZoneStorage[] |
|
272
|
|
|
*/ |
|
273
|
|
|
public function getZoneStorages() |
|
274
|
|
|
{ |
|
275
|
|
|
return $this->zoneStorages; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
public function setUnitWorking(Unit $unitWorking = null): self |
|
279
|
|
|
{ |
|
280
|
|
|
$this->unitWorking = $unitWorking; |
|
281
|
|
|
|
|
282
|
|
|
return $this; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
public function getUnitWorking(): Unit |
|
286
|
|
|
{ |
|
287
|
|
|
return $this->unitWorking; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
public function setFamilyLog(FamilyLog $familyLog = null): self |
|
291
|
|
|
{ |
|
292
|
|
|
$this->familyLog = $familyLog; |
|
293
|
|
|
|
|
294
|
|
|
return $this; |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
public function getFamilyLog(): FamilyLog |
|
298
|
|
|
{ |
|
299
|
|
|
return $this->familyLog; |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
public function setTva(Tva $tva = null): self |
|
303
|
|
|
{ |
|
304
|
|
|
$this->tva = $tva; |
|
305
|
|
|
|
|
306
|
|
|
return $this; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
public function getTva(): Tva |
|
310
|
|
|
{ |
|
311
|
|
|
return $this->tva; |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
public function setActive(bool $active): self |
|
315
|
|
|
{ |
|
316
|
|
|
$this->active = $active; |
|
317
|
|
|
|
|
318
|
|
|
return $this; |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
public function isActive(): bool |
|
322
|
|
|
{ |
|
323
|
|
|
return $this->active; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
public function getSlug(): string |
|
327
|
|
|
{ |
|
328
|
|
|
return $this->slug; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
public function setSlug(string $slug): self |
|
332
|
|
|
{ |
|
333
|
|
|
$this->slug = $slug; |
|
334
|
|
|
|
|
335
|
|
|
return $this; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
public function getCreateAt(): \DateTimeImmutable |
|
339
|
|
|
{ |
|
340
|
|
|
return $this->createAt; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
public function setCreateAt(\DateTimeImmutable $createAt): self |
|
344
|
|
|
{ |
|
345
|
|
|
$this->createAt = $createAt; |
|
346
|
|
|
|
|
347
|
|
|
return $this; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
public function getUpdateAt(): \DateTimeImmutable |
|
351
|
|
|
{ |
|
352
|
|
|
return $this->updateAt; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
public function setUpdateAt(\DateTimeImmutable $updateAt): self |
|
356
|
|
|
{ |
|
357
|
|
|
$this->updateAt = $updateAt; |
|
358
|
|
|
|
|
359
|
|
|
return $this; |
|
360
|
|
|
} |
|
361
|
|
|
|
|
362
|
|
|
public function getDeleteAt(): \DateTimeImmutable |
|
363
|
|
|
{ |
|
364
|
|
|
return $this->updateAt; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
public function setDeleteAt(\DateTimeImmutable $deleteAt = null): self |
|
368
|
|
|
{ |
|
369
|
|
|
if ($deleteAt === null) { |
|
370
|
|
|
$this->deleteAt = new \DateTimeImmutable(); |
|
371
|
|
|
date_date_set($this->deleteAt, date('Y') + 4, 12, 31); |
|
372
|
|
|
} else { |
|
373
|
|
|
$this->deleteAt = $deleteAt; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
return $this; |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
public function __toString(): string |
|
380
|
|
|
{ |
|
381
|
|
|
return $this->name; |
|
382
|
|
|
} |
|
383
|
|
|
} |
|
384
|
|
|
|