コード例 #1
0
 public function detailsAction()
 {
     $container = new Container('output_inventory');
     $viewModel = new ViewModel();
     if (!$container->id) {
         return $this->redirect()->toRoute('process/output_inventory');
     }
     $outputInventoryId = $container->id;
     $user = $container->user;
     $outputInventory = $this->getOutputInventoryTable()->get($outputInventoryId, $user);
     $form = new DetailsOutputInventoryForm();
     $detailsOutputInventory = new DetailsOutputInventory();
     $form->setInputFilter($detailsOutputInventory->getInputFilter());
     $request = $this->getRequest();
     $data = $request->getPost()->toArray();
     $form->setData($data);
     if ($request->isPost()) {
         if ($form->isValid()) {
             $data['output_inventory'] = $outputInventoryId;
             $data['serial'] = $data['product'];
             $data['cost'] = str_replace('.', '', $data['cost']);
             $productsReceiveInventory = $this->getProductsReceiveInventoryTable()->getBySerial($data['serial']);
             $detailsReceiveInventory = $productsReceiveInventory->getDetailsReceiveInventory();
             $number = $productsReceiveInventory->getNumber();
             $product = $productsReceiveInventory->getProduct();
             $data['product'] = $product;
             $this->getProductsReceiveInventoryTable()->update($detailsReceiveInventory, $number);
             $detailsOutputInventory->exchangeArray($data);
             $this->getDetailsOutputInventoryTable()->save($detailsOutputInventory);
             return $this->redirect()->toRoute('process/output_inventory/add/details');
         }
     }
     $detailsOutputInventory = $this->getDetailsOutputInventoryTable()->get($container->id);
     $viewModel->setVariable('form', $form);
     $viewModel->setVariable('outputInventory', $outputInventory);
     $viewModel->setVariable('config', $this->config);
     $viewModel->setVariable('detailsOutputInventory', $detailsOutputInventory);
     $viewModel->setTemplate("process/output-inventory/details");
     return $viewModel;
 }
コード例 #2
0
 public function save(DetailsOutputInventory $detailsOutputInventory)
 {
     $data = array('output_inventory' => $detailsOutputInventory->getOutputInventory(), 'product' => $detailsOutputInventory->getProduct(), 'cost' => $detailsOutputInventory->getCost(), 'iva' => $detailsOutputInventory->getIva(), 'serial' => $detailsOutputInventory->getSerial(), 'register_date' => date("Y-m-d H:i:s", time()), 'update_date' => date("Y-m-d H:i:s", time()));
     $id = (int) $detailsOutputInventory->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
         $id = $this->tableGateway->getLastInsertValue();
         if ($id) {
             return $id;
         } else {
             return false;
         }
     } else {
         if ($this->get($id)) {
             $this->tableGateway->update($data, array('id' => $id));
             return $id;
         } else {
             return false;
         }
     }
 }