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