2 namespace Adherence\Entity;
4 use Doctrine\ORM\Mapping as ORM;
10 * @ORM\HasLifecycleCallbacks
11 * @ORM\Table(name="adherence")
17 * Can archive records.
19 const ARCHIVE = false;
21 * Pull Synchronization Strategy for this table.
23 const PULL_SYNCH_STRATEGY = false;
25 * Push Synchronization Strategy for this table.
27 const PUSH_SYNCH_STRATEGY = false;
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 * @ORM\Column(type="string", length=64, name="hash")
43 * @ORM\Column(type="string", length=20, name="source")
48 * @ORM\Column(type="string", length=20, name="type")
53 * @ORM\Column(type="string", length=64, name="file")
58 * @ORM\Column(type="string", length=20, name="dealer_code")
60 protected $dealerCode;
63 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
64 * @ORM\JoinColumn(nullable=true, name="company_id")
69 * @ORM\Column(type="datetime", nullable=true, name="date_sold");
74 * @ORM\Column(type="string", length=20, nullable=true, name="stock_no")
76 protected $stockNumber;
79 * @ORM\Column(type="string", length=15, nullable=true, name="registration_number")
81 protected $registrationNumber;
84 * @ORM\Column(type="string", length=40, nullable=true, name="vin_number")
89 * @ORM\Column(type="string", length=40, nullable=true, name="engine_number")
91 protected $engineNumber;
94 * @ORM\Column(type="string", length=50, nullable=true, name="vehicle_make")
99 * @ORM\Column(type="string", length=150, name="sold_to")
104 * @ORM\Column(type="decimal", scale=4, precision=13, nullable=false, name="amount", options={"unsigned"=false});
106 protected $amount = 0.0;
109 * @ORM\OneToMany(targetEntity="\Adherence\Entity\AdherenceStock", mappedBy="adherence", cascade={"all"}, fetch="EXTRA_LAZY")
114 * @ORM\Column(type="datetime");
119 * @ORM\Column(type="datetime", nullable=true);
126 * Initialize collections.
128 public function __construct()
130 $this->stock = new \Doctrine\Common\Collections\ArrayCollection();
134 * Magic getter to expose protected properties.
135 * @param string $property
138 public function __get($property)
140 return $this->$property;
144 * Magic setter to save protected properties.
145 * @param string $property
146 * @param mixed $value
148 public function __set($property, $value)
150 $this->$property = $value;
157 public function setCreateTime()
159 $this->created = new \DateTime("now");
165 public function setUpdateTime()
167 $this->updated = new \DateTime("now");
170 public function fromArray($data)
173 && $this->hash = $data['hash'];
174 isset($data['source'])
175 && $this->source = $data['source'];
177 && $this->type = $data['type'];
179 && $this->file = $data['file'];
180 isset($data['dealerCode'])
181 && $this->dealerCode = $data['dealerCode'];
182 isset($data['company'])
183 && $this->company = $data['company'];
184 isset($data['dateSold'])
185 && $this->dateSold = $data['dateSold'];
186 isset($data['stockNumber'])
187 && $this->stockNumber = $data['stockNumber'];
188 isset($data['registrationNumber'])
189 && $this->registrationNumber = $data['registrationNumber'];
190 isset($data['vinNumber'])
191 && $this->vinNumber = $data['vinNumber'];
192 isset($data['engineNumber'])
193 && $this->engineNumber = $data['engineNumber'];
195 && $this->make = $data['make'];
196 isset($data['soldTo'])
197 && $this->soldTo = $data['soldTo'];
198 isset($data['amount'])
199 && $this->amount = $data['amount'];
202 public function toArray()
206 'hash' => $this->hash,
207 'source' => $this->source,
208 'type' => $this->type,
209 'file' => $this->file,
210 'dealerCode' => $this->dealerCode,
211 'company' => !is_null($this->company)
212 ? $this->company->toArray()
214 'dateSold' => !is_null($this->dateSold)
215 ? $this->dateSold->format(\Utility\Registry::getConfigParam('DateFormat'))
217 'stockNumber' => $this->stockNumber,
218 'registrationNumber' => $this->registrationNumber,
219 'vinNumber' => $this->vinNumber,
220 'engineNumber' => $this->engineNumber,
221 'make' => $this->make,
222 'soldTo' => $this->soldTo,
223 'amount' => $this->amount