text changes to registration mail content
[namibia] / module / Stock / src / Stock / Entity / TuhpiLog.php
1 <?php
2 namespace Stock\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * @ORM\Entity
10  * @ORM\HasLifecycleCallbacks
11  * @ORM\Table(name="tuhpi_log")
12  */
13 class TuhpiLog
14 {
15
16         /**
17          * Can archive records.
18          */
19         const ARCHIVE = true;
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          * @ORM\Id
31          * @ORM\Column(type="integer");
32          * @ORM\GeneratedValue(strategy="AUTO")
33          */
34         protected $id;
35
36         /**
37          * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
38          * @ORM\JoinColumn(nullable=false, name="company_id")
39          **/
40         protected $company;
41
42         /**
43          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
44          * @ORM\JoinColumn(nullable=false, name="created_by_profile_id")
45          **/
46         protected $createdBy;
47
48         /**
49          * @ORM\ManyToOne(targetEntity="Stock")
50          * @ORM\JoinColumn(nullable=false, name="stock_id", referencedColumnName="id")
51          **/
52         protected $stock;
53
54         /**
55          * @ORM\ManyToOne(targetEntity="Tuhpi")
56          * @ORM\JoinColumn(nullable=true, name="tuhpi_id", referencedColumnName="id")
57          **/
58         protected $tuhpi;
59
60         /**
61          * @ORM\Column(type="string", length=250)
62          */
63         protected $status;
64
65         /**
66          * @ORM\Column(type="datetime");
67          */
68         protected $created;
69
70         /**
71          * @ORM\Column(type="boolean");
72          */
73         protected $archived = false;
74
75
76         /**
77          * Magic getter to expose protected properties.
78          *
79          * @param string $property
80          * @return mixed
81          */
82         public function __get($property)
83         {
84                 return $this->$property;
85         }
86
87         /**
88          * Magic setter to save protected properties.
89          *
90          * @param string $property
91          * @param mixed $value
92          */
93         public function __set($property, $value)
94         {
95                 $this->$property = $value;
96         }
97
98         /**
99          * @ORM\PrePersist
100          */
101         public function setCreateTime()
102         {
103                 $this->created = new \DateTime("now");
104                 if (\Utility\Registry::isAuthenticated())
105                 {
106                         $this->company   = \Utility\Registry::resolveCompanyContext($this->company);
107                         $this->createdBy = \Utility\Registry::resolveProfileContext($this->createdBy);
108                 }
109         }
110
111         /**
112          * @ORM\PreUpdate
113          */
114         public function setUpdateTime()
115         {
116                 $this->updated = new \DateTime("now");
117         }
118
119         /**
120          * Convert the object to an array.
121          * @param array $expand
122          * @param array $intersect
123          * @return array
124          */
125         public function toArray(
126                         array $expand = array(), array $intersect = array(),
127                         $showIdentifiers = false, $expandAll = 0
128                         )
129         {
130                 $includeAll = empty($intersect);
131                 $data = array();
132                 ($includeAll || isset($intersect['id']))
133                         && $data['id'] = $this->id;
134                 ($includeAll || isset($intersect['company']))
135                         && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
136                                                                         && !is_null($this->company)
137                                 ? (!$showIdentifiers || in_array('company', $expand) ? $this->company->toArray(
138                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
139                                                 ) : $this->company->id)
140                                 : null;
141                 ($includeAll || isset($intersect['createdBy']))
142                         && $data['createdBy'] = (in_array('createdBy', $expand) || $expandAll || $showIdentifiers)
143                                                                         && !is_null($this->createdBy)
144                                 ? (!$showIdentifiers || in_array('createdBy', $expand) ? $this->createdBy->toArray(
145                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
146                                                 ) : $this->createdBy->id)
147                                 : null;
148                 ($includeAll || isset($intersect['stock']))
149                         && $data['stock'] = (in_array('stock', $expand) || $expandAll || $showIdentifiers)
150                                                                         && !is_null($this->stock)
151                                 ? (!$showIdentifiers || in_array('stock', $expand) ? $this->stock->toArray(
152                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
153                                                 ) : $this->stock->id)
154                                 : null;
155                 ($includeAll || isset($intersect['tuhpi']))
156                         && $data['tuhpi'] = (in_array('tuhpi', $expand) || $expandAll || $showIdentifiers)
157                                                                         && !is_null($this->tuhpi)
158                                 ? (!$showIdentifiers || in_array('tuhpi', $expand) ? $this->tuhpi->toArray(
159                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
160                                                 ) : $this->tuhpi->id)
161                                 : null;
162                 ($includeAll || isset($intersect['status']))
163                         && $data['status'] = $this->status;
164                 ($includeAll || isset($intersect['created']))
165                         && $data['created'] = !is_null($this->created)
166                                 ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
167                                 : null;
168                 return $data;
169         }
170
171         /**
172          * Populate from an array.
173          * @param array $data
174          */
175         public function fromArray($data = array())
176         {
177                 isset($data['id'])
178                         && $this->id = $data['id'];
179                 isset($data['company'])
180                         && $this->company = $data['company'];
181                 isset($data['createdBy'])
182                         && $this->createdBy = $data['createdBy'];
183                 isset($data['stock'])
184                         && $this->stock  = $data['stock'];
185                 isset($data['tuhpi'])
186                         && $this->tuhpi  = $data['tuhpi'];
187                 isset($data['status'])
188                         && $this->status  = $data['status'];
189         }
190
191 }