示例#1
0
 public function save(ListPrice $listPrice)
 {
     $data = array('name' => $listPrice->getName(), 'description' => $listPrice->getDescription(), 'principal' => $listPrice->getPrincipal());
     $id = (int) $listPrice->getId();
     $params = array();
     $params['table'] = $this->tableGateway->getTableName();
     $params['operation'] = 1;
     $params['data'] = json_encode($data);
     if ($id == 0) {
         $this->tableGateway->insert($data);
         $id = $this->tableGateway->getLastInsertValue();
         if ($id) {
             $params['id'] = $id;
             $this->featureSet->getEventManager()->trigger("log.save", $this, $params);
             return $id;
         } else {
             return false;
         }
     } else {
         if ($this->get($id)) {
             $params['id'] = $id;
             $params['operation'] = 2;
             $this->featureSet->getEventManager()->trigger("log.save", $this, $params);
             $this->tableGateway->update($data, array('id' => $id));
             return $id;
         } else {
             return false;
         }
     }
 }
示例#2
0
 public function addAction()
 {
     $form = new listPriceForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $listPrice = new ListPrice();
         $form->setInputFilter($listPrice->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $listPrice->exchangeArray($form->getData());
             $this->getListPriceTable()->save($listPrice);
             return $this->redirect()->toRoute('admin/list_price');
         }
     }
     return array('form' => $form, 'config' => $this->config);
 }