Beispiel #1
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\NpdSheetItem
  */
 protected function makeBean($resultset)
 {
     return NpdSheetItemFactory::createFromArray($resultset);
 }
Beispiel #2
0
 public function newProductAction()
 {
     //     			echo '<pre>';
     //     			print_r(print_r($this->getRequest()->getParams()).'dgdfg');
     //     			die;
     $params = $this->getRequest()->getParams();
     $idNpd = $params['idNpd'];
     $idAuthorizedSupplier = $params['authorizeSupplier'];
     $colors = $params["colors"];
     $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpd, $this->i18n->_("Npd with id {$idNpd} does not esxist"));
     $supplierBudget = SupplierBudgetQuery::create()->findByPKOrThrow($idAuthorizedSupplier, $this->i18n->_("supplier with id {$idAuthorizedSupplier} does not esxist"));
     $npdSheetSupplier = NpdSheetSupplierQuery::create()->findByPKOrThrow($supplierBudget->getIdNpdSupplier(), $this->i18n->_("NPD supplier with id {$idAuthorizedSupplier} does not esxist"));
     try {
         $this->getNpdSheetCatalog()->beginTransaction();
         NpdSheetFactory::populate($npdSheet, $params);
         $npdSheet->setStatus(NpdSheet::$Status['Pending Product']);
         if ($this->getRequest()->getParam('id_subfamily') == '') {
             $npdSheet->setIdSubfamily(null);
         }
         $this->getNpdSheetCatalog()->update($npdSheet);
         supplierBudgetFactory::populate($supplierBudget, $params);
         $this->getSupplierBudgetCatalog()->update($supplierBudget);
         NpdSheetSupplierFactory::populate($npdSheetSupplier, $params);
         $this->getNPDSupplierCatalog()->update($npdSheetSupplier);
         $this->getCatalog("NpdSheetCatalog")->unlinkAllColor($npdSheet->getIdNpdSheet());
         if ($colors) {
             foreach ($colors as $color) {
                 if ($color) {
                     $this->getCatalog("NpdSheetCatalog")->linkToColor($npdSheet->getIdNpdSheet(), $color['idColor']);
                 }
                 if ($color['idNpdSheetItem']) {
                     $npdSheetItem = NpdSheetItemQuery::create()->findByPK($color['idNpdSheetItem']);
                     $fields = array(NpdSheetItem::ID_NPD_SHEET => $npdSheet->getIdNpdSheet(), NpdSheetItem::ID_COLOR => $color['idColor'], NpdSheetItem::VIM => $color['vim'], NpdSheetItem::NAME => $color['itemName']);
                     //die(print_r($npdSheetItem));
                     NpdSheetItemFactory::populate($npdSheetItem, $fields);
                     $this->getCatalog("NpdSheetItemCatalog")->update($npdSheetItem);
                 } else {
                     $npdsheetItem = new NpdSheetItem();
                     $npdsheetItem->setIdColor($color['idColor']);
                     $npdsheetItem->setIdNpdSheet($npdSheet->getIdNpdSheet());
                     $npdsheetItem->setVim($color['vim']);
                     $npdsheetItem->setName($color['itemName']);
                     $this->getCatalog("NpdSheetItemCatalog")->create($npdsheetItem);
                 }
             }
         }
         $this->getNpdSheetCatalog()->commit();
         $this->setFlash('ok', $this->i18n->_("Information was successfully saved, pending product code"));
     } catch (Exception $e) {
         $this->getNpdSheetCatalog()->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     $this->_redirect('npd-sheet/list');
 }