2 namespace PriceGuide\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A price guide club member.
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="price_guide_offer")
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = false;
33 /* ------------------------------------ Identification ------------------------------------ */
36 * @ORM\Column(type="integer");
37 * @ORM\GeneratedValue(strategy="AUTO")
42 /* ------------------------------------ Ownership ------------------------------------ */
44 * @ORM\ManyToOne(targetEntity="PriceGuide")
45 * @ORM\JoinColumn(nullable=false, name="price_guide_id")
47 protected $priceGuideStock;
50 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
51 * @ORM\JoinColumn(nullable=false, name="company_id")
56 * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
57 * @ORM\JoinColumn(nullable=false, name="profile_id")
62 /* ------------------------------------ Offer ------------------------------------ */
64 * @ORM\Column(type="decimal", scale=2, precision=11, nullable=false, options={"unsigned"=true});
66 protected $amount = 0.0;
69 /* ------------------------------------ Tracking ------------------------------------ */
72 * @ORM\Column(type="string", length=25, nullable=true, name="previous_status");
74 protected $previousStatus = '';
77 * @ORM\Column(type="string", length=25, nullable=true, name="status");
79 protected $status = 'Updateable Offer';
82 * @ORM\Column(type="datetime");
87 * @ORM\Column(type="datetime", nullable=true);
92 * @ORM\Column(type="boolean");
94 protected $archived = false;
99 * Magic getter to expose protected properties.
101 * @param string $property
104 public function __get($property)
106 return $this->$property;
110 * Magic setter to save protected properties.
112 * @param string $property
113 * @param mixed $value
115 public function __set($property, $value)
117 $this->$property = $value;
123 public function setCreateTime()
125 if (is_null($this->company))
127 $this->company = \Utility\Registry::resolveCompanyContext($this->company);
129 if (is_null($this->profile))
131 $this->profile = \Utility\Registry::resolveProfileContext($this->profile);
133 $this->created = new \DateTime("now");
139 public function setUpdateTime()
141 $this->updated = new \DateTime("now");
145 * Convert the object to an array.
146 * @param array $expand
147 * @param array $intersect
148 * @param boolean $showIdentifiers
149 * @param integer $expandAll
152 public function toArray(
153 array $expand = array(), array $intersect = array(),
154 $showIdentifiers = false, $expandAll = 0
157 $intersect = array_flip($intersect);
158 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
159 $includeAll = empty($intersect);
161 ($includeAll || isset($intersect['id']))
162 && $data['id'] = $this->id;
163 ($includeAll || isset($intersect['priceGuideStock']))
164 && $data['priceGuideStock'] = (in_array('priceGuideStock', $expand) || $expandAll || $showIdentifiers)
165 && !is_null($this->priceGuideStock)
166 ? (!$showIdentifiers ? $this->priceGuideStock->toArray(
167 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
168 ) : $this->priceGuideStock->id)
170 ($includeAll || isset($intersect['company']))
171 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
172 && !is_null($this->company)
173 ? (!$showIdentifiers ? $this->company->toArray(
174 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
175 ) : $this->company->id)
177 ($includeAll || isset($intersect['profile']))
178 && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
179 && !is_null($this->profile)
180 ? (!$showIdentifiers ? $this->profile->toArray(
181 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
182 ) : $this->profile->id)
184 ($includeAll || isset($intersect['amount']))
185 && $data['amount'] = $this->amount;
186 ($includeAll || isset($intersect['status']))
187 && $data['status'] = $this->status;
188 ($includeAll || isset($intersect['created']))
189 && $data['created'] = !is_null($this->created)
190 ? $this->created->format($dateTimeFormat)
192 ($includeAll || isset($intersect['updated']))
193 && $data['updated'] = !is_null($this->updated)
194 ? $this->updated->format($dateTimeFormat)
200 * Populate from an array.
203 public function fromArray($data = array())
206 && $this->id = $data['id'];
207 isset($data['priceGuideStock'])
208 && $this->priceGuideStock = $data['priceGuideStock'];
209 isset($data['company'])
210 && $this->company = $data['company'];
211 isset($data['profile'])
212 && $this->profile = $data['profile'];
213 isset($data['amount'])
214 && $this->amount = $data['amount'];
215 isset($data['status'])
216 && $this->status = $data['status'];