Example #1
0
 /**
  * 
  * 
  */
 public function createLandedCostAction()
 {
     $params = $this->getRequest()->getParams();
     $SAPConnector = new SAPConnectorClient();
     $landedCost = new LandedCost();
     $landedCostCosts = new LandedCostCostCollection();
     foreach ($params['landed_cost_costs'] as $landedCostCostParams) {
         $landedCostCost = LandedCostCostFactory::createFromArray($landedCostCostParams);
         $landedCostCosts->append($landedCostCost);
     }
     $landedCost->setDocEntry(1);
     $landedCost->setLandedCostCosts($landedCostCosts);
     $warehouseEntries = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, $params['id'])->find();
     $result = $SAPConnector->createLandedCost($warehouseEntries, $landedCost);
     try {
         if ($result->createLandedCostResult->success) {
             $this->getCatalog('FolioImportlandedCostCatalog')->beginTransaction();
             $folioImportLandedCost = new FolioImportLandedCost();
             $folioImportLandedCost->setIdFolioImport($params['id']);
             $folioImportLandedCost->setIdLandedCost($result->createLandedCostResult->id);
             $this->getCatalog('FolioImportlandedCostCatalog')->create($folioImportLandedCost);
             $folioImport = FolioImportQuery::create()->findByPK($params['id']);
             $this->newLogForCreateLandedCost($folioImport);
             $this->getCatalog('FolioImportlandedCostCatalog')->commit();
             $this->setFlash('ok', $this->i18n->_('The landed cost has been set'));
         } else {
             throw new Exception($this->i18n->_('It cannot be set a Landed Cost for Folio Import ' . $idFolioImport) . $result->createLandedCostResult->message);
         }
     } catch (Exception $e) {
         $this->setFlash('error', $e->getMessage());
     }
     $this->_redirect('folio-import/list');
 }
Example #2
0
 /**
  * 
  * @param WarehouseEntranceCollection $warehouseEntryCollection
  * @param LandedCost $landedCost
  * @return strClass
  */
 public function createLandedCost(WarehouseEntranceCollection $warehouseEntryCollection, LandedCost $landedCost)
 {
     $docEntries = array();
     while ($warehouseEntry = $warehouseEntryCollection->read()) {
         $docEntries[] = $warehouseEntry->getIdWarehouseEntrance();
     }
     $parameters['DocEntries'] = array_values($docEntries);
     $parameters['landedCostSochi'] = $landedCost->toSAPArray();
     // 		echo '<pre>';
     // 		print_r($parameters);
     // 		die;
     return $this->soapClient->createLandedCost($parameters);
 }