2 namespace Stock\Entity;
4 use Doctrine\ORM\Mapping as ORM;
10 * @ORM\HasLifecycleCallbacks
11 * @ORM\Table(name="tuhpi_log")
17 * Can archive records.
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;
31 * @ORM\Column(type="integer");
32 * @ORM\GeneratedValue(strategy="AUTO")
37 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
38 * @ORM\JoinColumn(nullable=false, name="company_id")
43 * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
44 * @ORM\JoinColumn(nullable=false, name="created_by_profile_id")
49 * @ORM\ManyToOne(targetEntity="Stock")
50 * @ORM\JoinColumn(nullable=false, name="stock_id", referencedColumnName="id")
55 * @ORM\ManyToOne(targetEntity="Tuhpi")
56 * @ORM\JoinColumn(nullable=true, name="tuhpi_id", referencedColumnName="id")
61 * @ORM\Column(type="string", length=250)
66 * @ORM\Column(type="datetime");
71 * @ORM\Column(type="boolean");
73 protected $archived = false;
77 * Magic getter to expose protected properties.
79 * @param string $property
82 public function __get($property)
84 return $this->$property;
88 * Magic setter to save protected properties.
90 * @param string $property
93 public function __set($property, $value)
95 $this->$property = $value;
101 public function setCreateTime()
103 $this->created = new \DateTime("now");
104 if (\Utility\Registry::isAuthenticated())
106 $this->company = \Utility\Registry::resolveCompanyContext($this->company);
107 $this->createdBy = \Utility\Registry::resolveProfileContext($this->createdBy);
114 public function setUpdateTime()
116 $this->updated = new \DateTime("now");
120 * Convert the object to an array.
121 * @param array $expand
122 * @param array $intersect
125 public function toArray(
126 array $expand = array(), array $intersect = array(),
127 $showIdentifiers = false, $expandAll = 0
130 $includeAll = empty($intersect);
132 ($includeAll || isset($intersect['id']))
133 && $data['id'] = $this->id;
134 ($includeAll || isset($intersect['company']))
135 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
136 && !is_null($this->company)
137 ? (!$showIdentifiers || in_array('company', $expand) ? $this->company->toArray(
138 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
139 ) : $this->company->id)
141 ($includeAll || isset($intersect['createdBy']))
142 && $data['createdBy'] = (in_array('createdBy', $expand) || $expandAll || $showIdentifiers)
143 && !is_null($this->createdBy)
144 ? (!$showIdentifiers || in_array('createdBy', $expand) ? $this->createdBy->toArray(
145 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
146 ) : $this->createdBy->id)
148 ($includeAll || isset($intersect['stock']))
149 && $data['stock'] = (in_array('stock', $expand) || $expandAll || $showIdentifiers)
150 && !is_null($this->stock)
151 ? (!$showIdentifiers || in_array('stock', $expand) ? $this->stock->toArray(
152 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
153 ) : $this->stock->id)
155 ($includeAll || isset($intersect['tuhpi']))
156 && $data['tuhpi'] = (in_array('tuhpi', $expand) || $expandAll || $showIdentifiers)
157 && !is_null($this->tuhpi)
158 ? (!$showIdentifiers || in_array('tuhpi', $expand) ? $this->tuhpi->toArray(
159 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
160 ) : $this->tuhpi->id)
162 ($includeAll || isset($intersect['status']))
163 && $data['status'] = $this->status;
164 ($includeAll || isset($intersect['created']))
165 && $data['created'] = !is_null($this->created)
166 ? $this->created->format(\Utility\Registry::getConfigParam('DateTimeFormat'))
172 * Populate from an array.
175 public function fromArray($data = array())
178 && $this->id = $data['id'];
179 isset($data['company'])
180 && $this->company = $data['company'];
181 isset($data['createdBy'])
182 && $this->createdBy = $data['createdBy'];
183 isset($data['stock'])
184 && $this->stock = $data['stock'];
185 isset($data['tuhpi'])
186 && $this->tuhpi = $data['tuhpi'];
187 isset($data['status'])
188 && $this->status = $data['status'];