text changes to registration mail content
[namibia] / module / Adherence / src / Adherence / Entity / Adherence.php
1 <?php
2 namespace Adherence\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * @ORM\Entity
10  * @ORM\HasLifecycleCallbacks
11  * @ORM\Table(name="adherence")
12  */
13 class Adherence
14 {
15
16         /**
17          * Can archive records.
18          */
19         const ARCHIVE = false;
20         /**
21          * Pull Synchronization Strategy for this table.
22          */
23         const PULL_SYNCH_STRATEGY = false;
24         /**
25          * Push Synchronization Strategy for this table.
26          */
27         const PUSH_SYNCH_STRATEGY = false;
28
29
30         /**
31          * @ORM\Id
32          * @ORM\Column(type="integer");
33          * @ORM\GeneratedValue(strategy="AUTO")
34          */
35         protected $id;
36
37         /**
38          * @ORM\Column(type="string", length=64, name="hash")
39          */
40         protected $hash;
41
42         /**
43          * @ORM\Column(type="string", length=20, name="source")
44          */
45         protected $source;
46
47         /**
48          * @ORM\Column(type="string", length=20, name="type")
49          */
50         protected $type;
51
52         /**
53          * @ORM\Column(type="string", length=64, name="file")
54          */
55         protected $file;
56
57         /**
58          * @ORM\Column(type="string", length=20, name="dealer_code")
59          */
60         protected $dealerCode;
61
62         /**
63          * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
64          * @ORM\JoinColumn(nullable=true, name="company_id")
65          **/
66         protected $company;
67
68         /**
69          * @ORM\Column(type="datetime", nullable=true, name="date_sold");
70          */
71         protected $dateSold;
72
73         /**
74          * @ORM\Column(type="string", length=20, nullable=true, name="stock_no")
75          */
76         protected $stockNumber;
77
78         /**
79          * @ORM\Column(type="string", length=15, nullable=true, name="registration_number")
80          */
81         protected $registrationNumber;
82
83         /**
84          * @ORM\Column(type="string", length=40, nullable=true, name="vin_number")
85          */
86         protected $vinNumber;
87
88         /**
89          * @ORM\Column(type="string", length=40, nullable=true, name="engine_number")
90          */
91         protected $engineNumber;
92
93         /**
94          * @ORM\Column(type="string", length=50, nullable=true, name="vehicle_make")
95          */
96         protected $make;
97
98         /**
99          * @ORM\Column(type="string", length=150, name="sold_to")
100          */
101         protected $soldTo;
102
103         /**
104          * @ORM\Column(type="decimal", scale=4, precision=13, nullable=false, name="amount", options={"unsigned"=false});
105          */
106         protected $amount = 0.0;
107
108         /**
109          * @ORM\OneToMany(targetEntity="\Adherence\Entity\AdherenceStock", mappedBy="adherence", cascade={"all"}, fetch="EXTRA_LAZY")
110          **/
111         protected $stock;
112
113         /**
114          * @ORM\Column(type="datetime");
115          */
116         protected $created;
117
118         /**
119          * @ORM\Column(type="datetime", nullable=true);
120          */
121         protected $updated;
122
123
124
125         /**
126          * Initialize collections.
127          */
128         public function __construct()
129         {
130                 $this->stock = new \Doctrine\Common\Collections\ArrayCollection();
131         }
132
133         /**
134          * Magic getter to expose protected properties.
135          * @param string $property
136          * @return mixed
137          */
138         public function __get($property)
139         {
140                 return $this->$property;
141         }
142
143         /**
144          * Magic setter to save protected properties.
145          * @param string $property
146          * @param mixed $value
147          */
148         public function __set($property, $value)
149         {
150                 $this->$property = $value;
151         }
152
153
154         /**
155          * @ORM\PrePersist
156          */
157         public function setCreateTime()
158         {
159                 $this->created = new \DateTime("now");
160         }
161
162         /**
163          * @ORM\PreUpdate
164          */
165         public function setUpdateTime()
166         {
167                 $this->updated = new \DateTime("now");
168         }
169
170         public function fromArray($data)
171         {
172                 isset($data['hash'])
173                         && $this->hash = $data['hash'];
174                 isset($data['source'])
175                         && $this->source = $data['source'];
176                 isset($data['type'])
177                         && $this->type = $data['type'];
178                 isset($data['file'])
179                         && $this->file = $data['file'];
180                 isset($data['dealerCode'])
181                         && $this->dealerCode = $data['dealerCode'];
182                 isset($data['company'])
183                         && $this->company = $data['company'];
184                 isset($data['dateSold'])
185                         && $this->dateSold = $data['dateSold'];
186                 isset($data['stockNumber'])
187                         && $this->stockNumber = $data['stockNumber'];
188                 isset($data['registrationNumber'])
189                         && $this->registrationNumber = $data['registrationNumber'];
190                 isset($data['vinNumber'])
191                         && $this->vinNumber = $data['vinNumber'];
192                 isset($data['engineNumber'])
193                         && $this->engineNumber = $data['engineNumber'];
194                 isset($data['make'])
195                         && $this->make = $data['make'];
196                 isset($data['soldTo'])
197                         && $this->soldTo = $data['soldTo'];
198                 isset($data['amount'])
199                         && $this->amount = $data['amount'];
200         }
201
202         public function toArray()
203         {
204                 return array(
205                                 'id'                                    => $this->id,
206                                 'hash'                                  => $this->hash,
207                                 'source'                                => $this->source,
208                                 'type'                                  => $this->type,
209                                 'file'                                  => $this->file,
210                                 'dealerCode'                    => $this->dealerCode,
211                                 'company'                               => !is_null($this->company)
212                                         ? $this->company->toArray()
213                                         : null,
214                                 'dateSold'                              => !is_null($this->dateSold)
215                                         ? $this->dateSold->format(\Utility\Registry::getConfigParam('DateFormat'))
216                                         : null,
217                                 'stockNumber'                   => $this->stockNumber,
218                                 'registrationNumber'    => $this->registrationNumber,
219                                 'vinNumber'                     => $this->vinNumber,
220                                 'engineNumber'                  => $this->engineNumber,
221                                 'make'                                  => $this->make,
222                                 'soldTo'                                => $this->soldTo,
223                                 'amount'                                => $this->amount
224                 );
225         }
226 }