Lettre.php 7.47 KB
Newer Older
Mat's avatar
Mat committed
1
2
3
4
<?php

namespace PotageBundle\Entity;

5
use JMS\Serializer\Annotation\MaxDepth;
Mat's avatar
Mat committed
6
use Doctrine\Common\Collections\ArrayCollection;
Mat's avatar
Mat committed
7
8
9
10
11
12
13
use Doctrine\ORM\Mapping as ORM;

/**
 * Lettre
 *
 * @ORM\Table(name="lettre")
 * @ORM\Entity(repositoryClass="PotageBundle\Repository\LettreRepository")
14
 * @ORM\HasLifecycleCallbacks()
Mat's avatar
Mat committed
15
16
17
18
19
20
21
22
23
24
25
 */
class Lettre
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
26
    
Mat's avatar
Mat committed
27
28
29
30
    /**
     * @var int
     * @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Offre", inversedBy="lettres")
     * @ORM\JoinColumn(name="id_offre", nullable=false)
31
     * @MaxDepth(2)
Mat's avatar
Mat committed
32
33
34
     */
    private $offre;
    
Mat's avatar
Mat committed
35
    /**
36
     * @var int
Mat's avatar
Mat committed
37
38
     * @ORM\ManyToMany(targetEntity="PotageBundle\Entity\Info", inversedBy="lettres")
     * @ORM\JoinTable(name="infos_lettres",
39
40
     *     joinColumns={@ORM\JoinColumn(name="id_lettre", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="id_info", referencedColumnName="id")}
Mat's avatar
Mat committed
41
42
43
44
     * )
     */
    private $infos;
    
45
46
    /**
     * @var int
47
48
     * @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Groupe", inversedBy="lettres")
     * @ORM\JoinColumn(name="id_groupe", nullable=false)
49
     * @MaxDepth(2)
50
51
52
     */
    private $groupe;
    
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    /**
     * @var string
     * @ORM\Column(name="reference", type="string", length=16, unique=true)
     */
    private $reference;
    
    /**
     * @var string
     * @ORM\Column(name="subject", type="string", length=150)
     */
    private $subject;
    
    /**
     * @var \DateTime
     * @ORM\Column(name="started_at", type="datetime")
     */
    private $startedAt;
    
    /**
     * @var \DateTime
     * @ORM\Column(name="ended_at", type="datetime")
     */
    private $endedAt;
    
    /**
     * @var string
     * @ORM\Column(name="status", type="string", columnDefinition="enum('draft', 'current', 'sent', 'closed', 'trash')")
     */
    private $status;
    
    /**
     * @var \DateTime
     * @ORM\Column(name="created_at", type="datetime")
     */
    private $createdAt;
    
    /**
     * @var \DateTime
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
     */
    private $updatedAt;
    
Mat's avatar
Mat committed
95
96
97
98
99
100
    /**
     * @var string
     * @ORM\Column(name="sorted", type="string", nullable=true)
     */
    private $sorted;
    
101
102
103
    
    /**
     * Lettre constructor.
Mat's avatar
Mat committed
104
105
     *
     * @param $reference
106
     */
Mat's avatar
Mat committed
107
    public function __construct($reference)
108
    {
Mat's avatar
Mat committed
109
        $this->infos = new ArrayCollection();
Mat's avatar
Mat committed
110
        $this->reference = $reference;
111
112
113
114
115
116
117
118
119
    }
    
    /**
     * @ORM\PrePersist()
     */
    public function prePersist()
    {
        $this->createdAt = new \DateTime();
    }
Mat's avatar
Mat committed
120

121
122
123
124
125
126
127
128
129
130
    /**
     * @ORM\PreUpdate()
     */
    public function preUpdate()
    {
        $this->updatedAt = new \DateTime();
    }
    
    
    
Mat's avatar
Mat committed
131
132
133
134
135
136
137
138
139
140
    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    /**
     * Set reference
     *
     * @param string $reference
     *
     * @return Lettre
     */
    public function setReference($reference)
    {
        $this->reference = $reference;

        return $this;
    }

    /**
     * Get reference
     *
     * @return string
     */
    public function getReference()
    {
        return $this->reference;
    }
164
165
166
167
168
169
    
    /**
     * @return string
     */
    public function getReferenceMore()
    {
170
171
172
173
        return $this->reference
            . '  [ ' . $this->getGroupe()->getNom()
            . ' ][ ' . ($this->status === 'draft' ? 'En préparation' : 'Pour relecture')
            . ' ]';
174
175
    }
    
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
    /**
     * Set subject
     *
     * @param string $subject
     *
     * @return Lettre
     */
    public function setSubject($subject)
    {
        $this->subject = $subject;

        return $this;
    }

    /**
     * Get subject
     *
     * @return string
     */
    public function getSubject()
    {
        return $this->subject;
    }

    /**
     * Set startedAt
     *
     * @param \DateTime $startedAt
     *
     * @return Lettre
     */
    public function setStartedAt($startedAt)
    {
        $this->startedAt = $startedAt;

        return $this;
    }

    /**
     * Get startedAt
     *
     * @return \DateTime
     */
    public function getStartedAt()
    {
        return $this->startedAt;
    }

    /**
     * Set endedAt
     *
     * @param \DateTime $endedAt
     *
     * @return Lettre
     */
    public function setEndedAt($endedAt)
    {
        $this->endedAt = $endedAt;

        return $this;
    }

    /**
     * Get endedAt
     *
     * @return \DateTime
     */
    public function getEndedAt()
    {
        return $this->endedAt;
    }

    /**
     * Set status
     *
     * @param string $status
     *
     * @return Lettre
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }

    /**
     * Get status
     *
     * @return string
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return Lettre
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return Lettre
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }
Mat's avatar
Mat committed
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

    /**
     * Set offre
     *
     * @param \PotageBundle\Entity\Offre $offre
     *
     * @return Lettre
     */
    public function setOffre(\PotageBundle\Entity\Offre $offre)
    {
        $this->offre = $offre;

        return $this;
    }

    /**
     * Get offre
     *
     * @return \PotageBundle\Entity\Offre
     */
    public function getOffre()
    {
        return $this->offre;
    }
Mat's avatar
Mat committed
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

    /**
     * Add info
     *
     * @param \PotageBundle\Entity\Info $info
     *
     * @return Lettre
     */
    public function addInfo(\PotageBundle\Entity\Info $info)
    {
        $this->infos[] = $info;

        return $this;
    }

    /**
     * Remove info
     *
     * @param \PotageBundle\Entity\Info $info
     */
    public function removeInfo(\PotageBundle\Entity\Info $info)
    {
        $this->infos->removeElement($info);
    }

    /**
     * Get infos
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getInfos()
    {
        return $this->infos;
    }

Mat's avatar
Mat committed
378

379
380
381
    /**
     * Set groupe
     *
Mat's avatar
Mat committed
382
     * @param \PotageBundle\Entity\Groupe $groupe
383
384
385
     *
     * @return Lettre
     */
Mat's avatar
Mat committed
386
    public function setGroupe(\PotageBundle\Entity\Groupe $groupe)
387
388
389
390
391
392
393
394
395
    {
        $this->groupe = $groupe;

        return $this;
    }

    /**
     * Get groupe
     *
Mat's avatar
Mat committed
396
     * @return \PotageBundle\Entity\Groupe
397
398
399
400
401
     */
    public function getGroupe()
    {
        return $this->groupe;
    }
Mat's avatar
Mat committed
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425

    /**
     * Set sorted
     *
     * @param string $sorted
     *
     * @return Lettre
     */
    public function setSorted($sorted)
    {
        $this->sorted = $sorted;

        return $this;
    }

    /**
     * Get sorted
     *
     * @return string
     */
    public function getSorted()
    {
        return $this->sorted;
    }
426
}