initial commit
[namibia] / module / Utility / src / Utility / Entity / NotificationLog.php
1 <?php
2 namespace Utility\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * Notification logs.
10  * @ORM\Entity
11  * @ORM\HasLifecycleCallbacks
12  * @ORM\Table(name="lib_notification_log")
13  */
14 class NotificationLog
15 {
16
17         /**
18          * Can archive records.
19          */
20         const ARCHIVE = true;
21         /**
22          * Pull Synchronization Strategy for this table.
23          */
24         const PULL_SYNCH_STRATEGY = false;
25         /**
26          * Push Synchronization Strategy for this table.
27          */
28         const PUSH_SYNCH_STRATEGY = false;
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", nullable=true, length=250, name="email_to")
39          */
40         protected $emailTo;
41
42         /**
43          * @ORM\Column(type="string", nullable=true, length=250, name="email_subject")
44          */
45         protected $emailSubject;
46
47         /**
48          * @ORM\Column(type="text", name="email_body")
49          */
50         protected $emailBody;
51
52         /**
53          * @ORM\Column(type="string", nullable=true, length=20, name="sms_to")
54          */
55         protected $smsTo;
56
57         /**
58          * @ORM\Column(type="text", name="sms_body")
59          */
60         protected $smsBody;
61
62         /**
63          * @ORM\Column(type="string", nullable=true, length=32, name="api_msg_id")
64          */
65         protected $apiMsgId;
66
67         /**
68          * @ORM\Column(type="integer", nullable=true, name="sms_status")
69          */
70         protected $smsStatus;
71
72         /**
73          * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
74          * @ORM\JoinColumn(nullable=true, name="from_company_id")
75          **/
76         protected $fromCompany;
77
78         /**
79          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
80          * @ORM\JoinColumn(nullable=true, name="from_profile_id")
81          **/
82         protected $fromProfile;
83
84         /**
85          * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
86          * @ORM\JoinColumn(nullable=true, name="to_company_id")
87          **/
88         protected $toCompany;
89
90         /**
91          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
92          * @ORM\JoinColumn(nullable=true, name="to_profile_id")
93          **/
94         protected $toProfile;
95
96         /**
97          * @ORM\Column(type="datetime");
98          */
99         protected $created;
100
101         /**
102          * @ORM\Column(type="datetime", nullable=true);
103          */
104         protected $updated;
105
106         /**
107          * @ORM\Column(type="boolean");
108          */
109         protected $archived = false;
110
111
112         /**
113          * Magic getter to expose protected properties.
114          * @param string $property
115          * @return mixed
116          */
117         public function __get($property)
118         {
119                 return $this->$property;
120         }
121
122         /**
123          * Magic setter to save protected properties.
124          * @param string $property
125          * @param mixed $value
126          */
127         public function __set($property, $value)
128         {
129                 $this->$property = $value;
130         }
131
132         /**
133          * @ORM\PrePersist
134          */
135         public function setCreateTime()
136         {
137                 $this->created = new \DateTime("now");
138         }
139
140         /**
141          * @ORM\PreUpdate
142          */
143         public function setUpdateTime()
144         {
145                 $this->updated = new \DateTime("now");
146         }
147
148         /**
149          * Convert the object to an array.
150          * @param array $expand
151          * @param array $intersect
152          * @return array
153          */
154         public function toArray(array $expand = array('attachment'), array $intersect = array())
155         {
156                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
157                 $includeAll = empty($intersect);
158                 $data = array();
159                 ($includeAll || isset($intersect['id']))
160                         && $data['id'] = $this->id;
161                 ($includeAll || isset($intersect['emailTo']))
162                         && $data['emailTo'] = $this->emailTo;
163                 ($includeAll || isset($intersect['emailSubject']))
164                         && $data['emailSubject'] = $this->emailSubject;
165                 ($includeAll || isset($intersect['emailBody']))
166                         && $data['emailBody'] = $this->emailBody;
167                 ($includeAll || isset($intersect['smsTo']))
168                         && $data['smsTo'] = $this->smsTo;
169                 ($includeAll || isset($intersect['smsBody']))
170                         && $data['smsBody'] = $this->smsBody;
171                 ($includeAll || isset($intersect['apiMsgId']))
172                         && $data['apiMsgId'] = $this->apiMsgId;
173                 ($includeAll || isset($intersect['smsStatus']))
174                         && $data['smsStatus'] = $this->smsStatus;
175                 ($includeAll || isset($intersect['fromCompany']))
176                         && $data['fromCompany'] = in_array('fromCompany', $expand)
177                                                                         && !is_null($this->fromCompany)
178                                 ? $this->fromCompany->toArray($expand, $intersect)
179                                 : null;
180                 ($includeAll || isset($intersect['fromProfile']))
181                         && $data['fromProfile'] = in_array('fromProfile', $expand)
182                                                                         && !is_null($this->fromProfile)
183                                 ? $this->fromProfile->toArray($expand, $intersect)
184                                 : null;
185                 ($includeAll || isset($intersect['toCompany']))
186                         && $data['toCompany'] = in_array('toCompany', $expand)
187                                                                         && !is_null($this->toCompany)
188                                 ? $this->toCompany->toArray($expand, $intersect)
189                                 : null;
190                 ($includeAll || isset($intersect['toProfile']))
191                         && $data['toProfile'] = in_array('toProfile', $expand)
192                                                                         && !is_null($this->toProfile)
193                                 ? $this->toProfile->toArray($expand, $intersect)
194                                 : null;
195                 ($includeAll || isset($intersect['created']))
196                         && $data['created'] = !is_null($this->created)
197                                 ? $this->created->format($dateTimeFormat)
198                                 : null;
199                 ($includeAll || isset($intersect['updated']))
200                         && $data['updated'] = !is_null($this->updated)
201                                 ? $this->updated->format($dateTimeFormat)
202                                 : null;
203                 return $data;
204         }
205
206         /**
207          * Populate from an array.
208          * @param array $data
209          */
210         public function fromArray($data = array())
211         {
212                 isset($data['id'])
213                         && $this->id = $data['id'];
214                 isset($data['emailTo'])
215                         && $this->emailTo = $data['emailTo'];
216                 isset($data['emailSubject'])
217                         && $this->emailSubject = $data['emailSubject'];
218                 isset($data['emailBody'])
219                         && $this->emailBody = $data['emailBody'];
220                 isset($data['smsTo'])
221                         && $this->smsTo = $data['smsTo'];
222                 isset($data['smsBody'])
223                         && $this->smsBody = $data['smsBody'];
224                 isset($data['apiMsgId'])
225                         && $this->apiMsgId = $data['apiMsgId'];
226                 isset($data['smsStatus'])
227                         && $this->smsStatus = $data['smsStatus'];
228                 isset($data['fromCompany'])
229                         && $this->fromCompany = $data['fromCompany'];
230                 isset($data['fromProfile'])
231                         && $this->fromProfile = $data['fromProfile'];
232                 isset($data['toCompany'])
233                         && $this->toCompany = $data['toCompany'];
234                 isset($data['toProfile'])
235                         && $this->toProfile = $data['toProfile'];
236         }
237
238 }