text changes to registration mail content
[namibia] / module / PriceGuide / src / PriceGuide / Entity / Club.php
1 <?php
2 namespace PriceGuide\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A price guide club.
10  *
11  * @ORM\Entity
12  * @ORM\HasLifecycleCallbacks
13  * @ORM\Table(name="price_guide_club")
14  */
15 class Club
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="\Company\Entity\Company")
45          * @ORM\JoinColumn(nullable=false, name="company_id")
46          **/
47         protected $company;
48
49
50         /* ------------------------------------ Customer ------------------------------------ */
51         /**
52          * @ORM\Column(type="string", length=50, nullable=true, name="name")
53          */
54         protected $name;
55
56
57         /* ------------------------------------ Linkage ------------------------------------ */
58         /**
59          * @ORM\OneToMany(targetEntity="ClubStock", mappedBy="club", cascade={"all"}, fetch="EXTRA_LAZY")
60          **/
61         protected $stockItems;
62         /**
63          * @ORM\OneToMany(targetEntity="Member", mappedBy="club", cascade={"all"}, fetch="EXTRA_LAZY")
64          **/
65         protected $members;
66
67
68         /* ------------------------------------ Tracking ------------------------------------ */
69
70         /**
71          * @ORM\Column(type="string", length=25, nullable=true, name="status");
72          */
73         protected $status = 'Active';
74
75         /**
76          * @ORM\Column(type="datetime");
77          */
78         protected $created;
79
80         /**
81          * @ORM\Column(type="datetime", nullable=true);
82          */
83         protected $updated;
84
85         /**
86          * @ORM\Column(type="boolean", name="use_as_default");
87          */
88         protected $useAsDefault = false;
89
90         /**
91          * @ORM\Column(type="boolean");
92          */
93         protected $archived = false;
94
95
96
97         /**
98          * Magic getter to expose protected properties.
99          *
100          * @param string $property
101          * @return mixed
102          */
103         public function __get($property)
104         {
105                 return $this->$property;
106         }
107
108         /**
109          * Magic setter to save protected properties.
110          *
111          * @param string $property
112          * @param mixed $value
113          */
114         public function __set($property, $value)
115         {
116                 $this->$property = $value;
117         }
118
119         /**
120          * @ORM\PrePersist
121          */
122         public function setCreateTime()
123         {
124                 if (is_null($this->company))
125                 {
126                         $this->company = \Utility\Registry::resolveCompanyContext($this->company);
127                 }
128                 $this->created = new \DateTime("now");
129         }
130
131         /**
132          * @ORM\PreUpdate
133          */
134         public function setUpdateTime()
135         {
136                 $this->updated = new \DateTime("now");
137         }
138
139         /**
140          * Convert the object to an array.
141          * @param array $expand
142          * @param array $intersect
143          * @param boolean $showIdentifiers
144          * @param integer $expandAll
145          * @return array
146          */
147         public function toArray(
148                         array $expand = array(), array $intersect = array(),
149                         $showIdentifiers = false, $expandAll = 0
150                         )
151         {
152                 $intersect = array_flip($intersect);
153                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
154                 $includeAll = empty($intersect);
155                 $data = array();
156                 ($includeAll || isset($intersect['id']))
157                         && $data['id'] = $this->id;
158                 ($includeAll || isset($intersect['company']))
159                         && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
160                                                                         && !is_null($this->company)
161                                 ? (!$showIdentifiers ? $this->company->toArray(
162                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
163                                                 ) : $this->company->id)
164                                 : null;
165                 ($includeAll || isset($intersect['name']))
166                         && $data['name'] = $this->name;
167                 ($includeAll || isset($intersect['status']))
168                         && $data['status'] = $this->status;
169                 ($includeAll || isset($intersect['created']))
170                         && $data['created'] = !is_null($this->created)
171                                 ? $this->created->format($dateTimeFormat)
172                                 : null;
173                 ($includeAll || isset($intersect['updated']))
174                         && $data['updated'] = !is_null($this->updated)
175                                 ? $this->updated->format($dateTimeFormat)
176                                 : null;
177                 ($includeAll || isset($intersect['useAsDefault']))
178                         && $data['useAsDefault'] = $this->useAsDefault;
179                 return $data;
180         }
181
182         /**
183          * Populate from an array.
184          * @param array $data
185          */
186         public function fromArray($data = array())
187         {
188                 isset($data['id'])
189                         && $this->id = $data['id'];
190                 isset($data['company'])
191                         && $this->company = $data['company'];
192                 isset($data['name'])
193                         && $this->name = $data['name'];
194                 isset($data['status'])
195                         && $this->status = $data['status'];
196                 isset($data['useAsDefault'])
197                         && $this->useAsDefault = $data['useAsDefault'];
198         }
199
200
201
202 }
203