Example #1
0
 public function fixLastStatus($brandId)
 {
     $rel = new Table\BrandsStatusesRel();
     $row = $rel->fetchRow(array('brandId = ?' => $brandId), 'id DESC');
     if ($row !== null) {
         $data = array('statusId' => $row['statusId'], 'statusDate' => $row['date'], 'statusNote' => $row['note'], 'price' => $row['price']);
     } else {
         $data = array('statusId' => \null, 'statusDate' => \null, 'statusNote' => \null, 'price' => \null);
     }
     $this->getTable()->update($data, array('id = ?' => $brandId));
 }
Example #2
0
 protected function saveStatus(EntityInterface $entity)
 {
     if (!$entity->getStatusId() || !$entity->getStatusDate()) {
         return;
     }
     $rel = new Table\BrandsStatusesRel();
     $row = $rel->fetchRow(array('brandId = ?' => $entity->getId(), 'statusId = ?' => $entity->getStatusId(), 'date = ?' => $entity->getStatusDate()));
     try {
         if ($row === \null) {
             $row = $rel->createRow(array('brandId' => $entity->getId(), 'statusId' => $entity->getStatusId(), 'date' => $entity->getStatusDate()));
         }
         $row->note = $entity->getStatusNote();
         $row->save();
     } catch (\Exception $e) {
     }
 }
Example #3
0
 public function getStatusHistory()
 {
     if ($this->statusHistory === null) {
         $rel = new BrandsStatusesRel();
         $this->statusHistory = $rel->getAdapter()->fetchAll($rel->select(true)->setIntegrityCheck(false)->where('brandId = ?', $this->getId())->order('date DESC'));
     }
     return $this->statusHistory;
 }