public static function SapSync($idPurchaseOder)
 {
     $purchaseOrder = PurchaseOrderQuery::create()->findByPKOrThrow($idPurchaseOder, "The PurchaseOrder whit id {$idPurchaseOder} does not exist.");
     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->find();
     try {
         $sapConnectionClient = new SAPConnectorClient();
         $result = $sapConnectionClient->createPurchaseOrder($purchaseOrder, $purchaseOrderEntries);
     } catch (Exception $e) {
         $result = new stdClass();
         $result->SapOrdenResult->code = 500;
         $result->SapOrdenResult->message = $e->getMessage();
     }
     return $result;
 }
 /**
  * 
  * Product Collection and user for logs
  * @param ProductCollection $products
  * @param User $user
  * @return mixed
  */
 public function save(ProductCollection $products, User $user)
 {
     $this->setUser($user);
     $existProducts = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $products->getPrimaryKeys())->find();
     while ($products->valid()) {
         $product = $products->read();
         if ($existProducts->containsIndex($product->getIndex())) {
             $SAPProducts["Product"][] = $product->toSAPArray() + array("Movement" => 2);
             $this->newLogForUpdate($product);
         } else {
             $SAPProducts["Product"][] = $product->toSAPArray() + array("Movement" => 1);
             $this->newLogForCreate($product);
         }
     }
     $SAPConnectionClient = new SAPConnectorClient();
     $response = $SAPConnectionClient->saveProducts($SAPProducts);
     return json_decode($response->productResult->message);
 }
Exemple #3
0
 public function changeItemsPriceAction()
 {
     $products = $this->getRequest()->getParam('product');
     // 		echo '<pre>';
     // 		print_r($products );
     // 		die;
     $SAPConnector = new SAPConnectorClient();
     foreach ($products as $product) {
         $productCostLog = new ProductCostLog();
         $originalProduct = ProductQuery::create()->findByPK($product['ItemCode']);
         $productCostLog->setIdCurrencyFrom($originalProduct->getCurrency());
         $productCostLog->setIdCurrencyTo($originalProduct->getCurrency());
         $productCostLog->setPriceFrom($originalProduct->getCost());
         $productCostLog->setPriceTo($product['Price']);
         $productCostLog->setIdProduct($product['ItemCode']);
         $productCostLog->setNotes($product['notes']);
         $result = $SAPConnector->changeProductPrice($product['ItemCode'], $product['Price'], $product['freight'], $product['customsCode']);
         if ($result->changeProductPriceResult->success) {
             try {
                 $this->newLogForUpdateProductCost($productCostLog);
             } catch (Exception $e) {
                 $errors .= $this->i18n->_("The log for {$product['ItemCode']} cannot be created. ") . '<br>';
                 echo $e->getMessage();
                 die;
             }
             $oks .= "The product {$product['ItemCode']} has been updated<br>";
         } else {
             $errors .= $result->changeProductPriceResult->message . "<br>";
         }
     }
     if (!empty($oks)) {
         $this->setFlash('ok', $oks);
     }
     if (!empty($errors)) {
         $this->setFlash('error', $errors);
     }
     $parentKey = ProductQuery::create()->findByPK($product['ItemCode'])->getKeyMother();
     $this->_redirect('vim/sales-by-product/parent-key/' . $parentKey);
 }
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     $params = $this->getRequest()->getParams();
     if ($this->getRequest()->isPost()) {
         $idProformaInvoice = $this->getRequest()->getParam('id_proforma_invoice');
         $proformaInvoiceParams['date'] = $this->getRequest()->getParam('date', null);
         $proformaInvoiceParams['folio'] = $this->getRequest()->getParam('folio', null);
         $proformaInvoiceParams['id_courtyard'] = $this->getRequest()->getParam('id_courtyard', null);
         $proformaInvoiceParams['id_currency'] = $this->getRequest()->getParam('id_currency');
         $proformaInvoiceParams['comments'] = $this->getRequest()->getParam('comments', null);
         $proformaInvoiceEntriesParams['warehouseStore'] = $this->getRequest()->getParam('warehouse_store', '');
         $proformaInvoiceEntriesParams['entries'] = $this->getRequest()->getParam('entries', array());
         $proformaInvoicePaymentTermIds = ProformaInvoiceProgrammedPaymentQuery::create()->addColumn(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM)->whereAdd(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE, $idProformaInvoice)->fetchCol();
         $proformaInvoiceNotErasableEvents = ProformaInvoicePaymentTermQuery::create()->addColumn(ProformaInvoicePaymentTerm::ID_EVENT)->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_PAYMENT, $proformaInvoicePaymentTermIds, ProformaInvoicePaymentTermQuery::IN)->distinct()->fetchCol();
         $erasableEvents = EventQuery::create()->addColumn(Event::ID_EVENT)->whereAdd(Event::ID_EVENT, $proformaInvoiceNotErasableEvents, EventQuery::NOT_IN)->distinct()->fetchCol();
         $proformaInvoicePaymentTermsParams["events"] = $this->getRequest()->getParam('events', array());
         $totalAmmount = $this->getRequest()->getParam('quantityMatch');
         $totalProformaInvoiceEntries = count($proformaInvoiceEntriesParams['entries']);
         try {
             $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($idProformaInvoice, $this->i18n->_("Proforma Invoice with id {$idProformaInvoice} not found"));
             $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
             foreach ($proformaInvoiceEntriesParams['entries'] as $index => $values) {
                 $proformaInvoiceEntry = $proformaInvoiceEntries->getByPK($index);
                 $values["id_warehouse_store"] = $proformaInvoiceEntriesParams['warehouseStore'];
                 ProformaInvoiceEntryFactory::populate($proformaInvoiceEntry, $values);
             }
             ProformaInvoiceFactory::populate($proformaInvoice, $proformaInvoiceParams);
             $sapConnectionClient = new SAPConnectorClient();
             $result = $sapConnectionClient->purchaseQuotation($proformaInvoice, $proformaInvoiceEntries);
             if ($result->purchaseQuotationResult->code == 200) {
                 $proformaInvoiceFiles = ProformaInvoiceFileQuery::create()->whereAdd(ProformaInvoiceFile::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
                 $uploadPath = 'public/' . ($filePath = "files/proformas/" . $result->purchaseQuotationResult->id);
                 if ($_FILES["proforma_invoice_file"]["name"] != "") {
                     $fileUploader = new FileUploader("proforma_invoice_file");
                     $fileUploader->saveFile($uploadPath, false);
                     $newFile = FileFactory::createFromArray(array(File::CONTENT => $filePath . $fileUploader->getFileName(), File::TYPE => file::$typeFile["typeFile"]));
                     $this->getFileCatalog()->create($newFile);
                     $newProformaInvoiceFile = ProformaInvoiceFileFactory::createFromArray(array(ProformaInvoiceFile::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoiceFile::ID_FILE => $newFile->getIdFile(), ProformaInvoiceFile::TYPE => ProformaInvoiceFile::$Types["PINew"]));
                     $this->getProformaInvoiceFileCatalog()->create($newProformaInvoiceFile);
                     $proformaInvoiceFile = $proformaInvoiceFiles->getByType(ProformaInvoiceFile::$Types["PINew"]);
                     if ($proformaInvoiceFile->getIdProformaInvoiceFile() > 0) {
                         $this->getProformaInvoiceFileCatalog()->deleteById($proformaInvoiceFile->getIdProformaInvoiceFile());
                         $this->getFileCatalog()->deleteById($proformaInvoiceFile->getIdFile());
                     }
                 }
                 if ($_FILES["proforma_invoice_file_authorized"]["name"] != "") {
                     $fileUploader = new FileUploader("proforma_invoice_file_authorized");
                     $fileUploader->saveFile($uploadPath, false);
                     $newFile = FileFactory::createFromArray(array(File::CONTENT => $filePath . $fileUploader->getFileName(), File::TYPE => file::$typeFile["typeFile"]));
                     $this->getFileCatalog()->create($newFile);
                     $newProformaInvoiceFile = ProformaInvoiceFileFactory::createFromArray(array(ProformaInvoiceFile::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoiceFile::ID_FILE => $newFile->getIdFile(), ProformaInvoiceFile::TYPE => ProformaInvoiceFile::$Types["PIAuthorized"]));
                     $this->getProformaInvoiceFileCatalog()->create($newProformaInvoiceFile);
                     $proformaInvoiceFile = $proformaInvoiceFiles->getByType(ProformaInvoiceFile::$Types["PIAuthorized"]);
                     if ($proformaInvoiceFile->getIdProformaInvoiceFile() > 0) {
                         $this->getProformaInvoiceFileCatalog()->deleteById($proformaInvoiceFile->getIdProformaInvoiceFile());
                         $this->getFileCatalog()->deleteById($proformaInvoiceFile->getIdFile());
                     }
                 }
                 $allPaymentTerms = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
                 try {
                     $this->getProformaInvoicePaymentTermCatalog()->beginTransaction();
                     $paymentTerms = $allPaymentTerms->filterByEventId($erasableEvents);
                     while ($paymentTerms->valid()) {
                         $paymentTerm = $paymentTerms->read();
                         $this->getProformaInvoicePaymentTermCatalog()->deleteById($paymentTerm->getIdProformaInvoicePayment());
                     }
                     $notErasabledPaymentTerms = $allPaymentTerms->filterByEventId($proformaInvoiceNotErasableEvents, $line);
                     $programmedPayments = ProformaInvoiceProgrammedPaymentQuery::create()->whereAdd(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM, $notErasabledPaymentTerms->getPrimaryKeys())->find();
                     while ($proformaInvoiceEntries->valid()) {
                         $proformaInvoiceEntry = $proformaInvoiceEntries->read();
                         $totalPayment = 0;
                         foreach ($proformaInvoicePaymentTermsParams["events"] as $key => $payment) {
                             $amount = str_replace(",", "", $payment['payment']);
                             $proformaInvoicePaymentTermsParams["events"][$key]['percentage'] = $amount / $totalAmmount * 100;
                         }
                         foreach ($proformaInvoicePaymentTermsParams["events"] as $event) {
                             $newPaymentTerm = ProformaInvoicePaymentTermFactory::createFromArray(array(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_ENTRY => $proformaInvoiceEntry->getIdProformaInvoiceEntry(), ProformaInvoicePaymentTerm::LINE => $proformaInvoiceEntry->getVisOrder(), ProformaInvoicePaymentTerm::ID_EVENT => $event["id"], ProformaInvoicePaymentTerm::PIECES => $proformaInvoiceEntry->getQuantity(), ProformaInvoicePaymentTerm::PAYMENT => $proformaInvoiceEntry->getTotalImport() * $event["percentage"] / 100, ProformaInvoicePaymentTerm::CURRENCY => $proformaInvoice->getIdCurrency()));
                             $this->getProformaInvoicePaymentTermCatalog()->create($newPaymentTerm);
                         }
                         $entryPaymentTerms = $notErasabledPaymentTerms->filterByProformaInvoiceEntry($proformaInvoiceEntry);
                         while ($entryPaymentTerms->valid()) {
                             $paymentTerm = $entryPaymentTerms->read();
                             $entryProgrammedPayments = $programmedPayments->filterByPaymentTerm($paymentTerm);
                             while ($entryProgrammedPayments->valid()) {
                                 $payment = $entryProgrammedPayments->read();
                                 $payment->setIdCurrency($proformaInvoice->getIdCurrency());
                                 $payment->setLine($proformaInvoiceEntry->getVisOrder());
                                 $this->getProformaInvoiceProgrammedPaymentCatalog()->update($payment);
                             }
                             $paymentTerm->setCurrency($proformaInvoice->getIdCurrency());
                             $paymentTerm->setIdProformaInvoiceEntry($proformaInvoiceEntry->getIdProformaInvoiceEntry());
                             $paymentTerm->setLine($proformaInvoiceEntry->getVisOrder());
                             $this->getProformaInvoicePaymentTermCatalog()->update($paymentTerm);
                         }
                     }
                     $this->newLogForUpdate($proformaInvoice);
                     $this->getProformaInvoicePaymentTermCatalog()->commit();
                     $this->setFlash('ok', $this->i18n->_("Proforma Invoice with id {$result->purchaseQuotationResult->id} was updated."));
                 } catch (Exception $e) {
                     $this->getProformaInvoicePaymentTermCatalog()->rollBack();
                     $this->setFlash('error', $this->i18n->_($e->getMessage()));
                 }
             } else {
                 $this->setFlash('error', $result->purchaseQuotationResult->code . " - " . $result->purchaseQuotationResult->message);
             }
         } catch (Exception $e) {
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('proforma-invoice/list');
 }
 /**
  *
  * @param int $product
  * @return array $status
  */
 private function updateProductInSAP($idProduct)
 {
     $product = ProductQuery::create()->findByPK($idProduct);
     $connectorClient = new SAPConnectorClient();
     $status = array();
     try {
         $productSapExists = SapProductQuery::create()->whereAdd(SapProduct::ITEMCODE, $product->getItemCode())->count();
         //     		echo SapProductQuery::create()->whereAdd(SapProduct::ITEMCODE, $product->getItemCode())->createSql();
         //     		echo $productSapExists;
         //     		die;
         if (!$productSapExists) {
             $result = $connectorClient->createProduct($product);
         } else {
             $result = $connectorClient->updateProduct($product);
         }
     } catch (Exception $e) {
         $status['code'] = 500;
         $status['message'] = $e->getMessage();
         return $status;
     }
     if ($result->SapProductoResult->code == 200) {
         $status['code'] = $result->SapProductoResult->code;
         $status['message'] = $this->i18n->_('The product ') . $product->getIdProduct() . $this->i18n->_(' has been syncronized with SAP');
     } else {
         $status['code'] = $result->SapProductoResult->code;
         $this->setFlash('warning', $result->SapProductoResult->message);
         $status['message'] = $this->i18n->_($result->SapProductoResult->message);
     }
     return $status;
 }
 /**
  * 
  * 
  */
 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');
 }
 /**
  *
  * @param string $itemCode
  * @param array $prices
  * @return StrClass
  */
 private function updateProductPriceListInSap($itemCode, $prices)
 {
     $prices = array_values($prices);
     $SAPConnector = new SAPConnectorClient();
     $result = $SAPConnector->changeProductPriceList($itemCode, $prices);
     return $result;
 }
 public function rateSupplierAction()
 {
     $params = $this->getRequest()->getParams();
     $array = array();
     $contacts = new SapSupplierContactEmployeeCollection($array);
     $addresses = new SapSupplierAddressCollection($array);
     $supplier = SapSupplierQuery::create()->findByPK($params['idSupplier']);
     $supplier->setContacts($contacts);
     $supplier->setAddresses($addresses);
     $supplier->setQuality($params['quality']);
     $sapConnector = new SAPConnectorClient();
     $result = $sapConnector->rateSupplier($supplier);
     $response = array(message => $result->rateSupplierResult->message, success => $result->rateSupplierResult->success);
     die(json_encode($response));
 }
 public function updateAction()
 {
     $array = array();
     $connectorClient = new SAPConnectorClient();
     $sapSupplierContactEmployeeCollection = new SapSupplierContactEmployeeCollection($array);
     $sapSupplierAddressCollection = new SapSupplierAddressCollection($array);
     $params = $this->getRequest()->getParams();
     $supplier = SapSupplierFactory::createFromArray($params);
     // 		echo '<pre>';
     // 		print_r($supplier);
     // 		die;
     $supplier->setConsistency(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getConsistency());
     $supplier->setTime(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getTime());
     $supplier->setQuality(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getQuality());
     $address = SapSupplierAddressFactory::createFromArray($params);
     $sapSupplierAddressCollection->append($address);
     foreach ($params['contact'] as $contact) {
         if (!empty($contact['FirstName'])) {
             $contactEmployee = SapSupplierContactEmployeeFactory::createFromArray($contact);
             $sapSupplierContactEmployeeCollection->append($contactEmployee);
             unset($contactEmployee);
         }
     }
     $supplier->setAddresses($sapSupplierAddressCollection);
     $supplier->setContacts($sapSupplierContactEmployeeCollection);
     $result = $connectorClient->UpdateSupplier($supplier);
     if ($result->SapProveedorResult->success) {
         $setupForm = 'SetupForm';
         $profileForm = 'ProfileForm';
         $auditReport = 'AuditReport';
         $this->getSupplierCatalog()->beginTransaction();
         $this->savefileAction($setupForm, SapSupplier::$FileTypes[$setupForm], $supplier->getCardcode());
         $this->savefileAction($profileForm, SapSupplier::$FileTypes[$profileForm], $supplier->getCardcode());
         $this->savefileAction($auditReport, SapSupplier::$FileTypes[$auditReport], $supplier->getCardcode());
         // 			print_r(SupplierFileQuery::create()->whereAdd(SupplierFile::ID_SUPPLIER, $sapSupplier->getCardcode())->find()->toArray());
         $this->getSupplierCatalog()->commit();
         $this->setFlash("ok", $this->i18n->_($result->SapProveedorResult->message));
     } else {
         $this->setFlash("error", $this->i18n->_($result->SapProveedorResult->message));
         $this->_redirect('supplier/list');
     }
     $this->setFlash("ok", $this->i18n->_("The supplier " . $supplier->getIdSupplier() . " has been modified"));
     $this->_redirect('supplier/list');
 }
 public function readyToShipmentAction()
 {
     $idPurchaseOrder = $this->getRequest()->getParam("id_purchase_order");
     $blHouseData[PurchaseOrderCommercialInvoice::PIECES] = $this->getRequest()->getParam("pieces");
     $blHouseData[PurchaseOrderCommercialInvoice::CARTONS] = $this->getRequest()->getParam("cartons");
     $blHouseData[PurchaseOrderCommercialInvoice::LOAD] = $this->getRequest()->getParam("load");
     $blHouseData[PurchaseOrderCommercialInvoice::PAYLOAD] = $this->getRequest()->getParam("payload");
     $blHouseData[PurchaseOrderCommercialInvoice::NUM_BL_HOUSE] = $this->getRequest()->getParam("num_bl_house");
     $courtyardArrivalDate = $this->getRequest()->getParam("courtyard_arrival_date");
     $purchaseOrder = PurchaseOrderQuery::create()->findByPKOrThrow($idPurchaseOrder, $this->i18n->_("The Purchase Order with id {$idPurchaseOrder} does not exist"));
     if (PurchaseOrderCommercialInvoiceQuery::create()->whereAdd(PurchaseOrderCommercialInvoice::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->count()) {
         $purchaseOrderCommercialInvoice = PurchaseOrderCommercialInvoiceQuery::create()->whereAdd(PurchaseOrderCommercialInvoice::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->find()->getOne();
     } else {
         $purchaseOrderCommercialInvoice = new PurchaseOrderCommercialInvoice();
     }
     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->find();
     $purchaseOrder->setStatus(PurchaseOrder::$Status["Ready"])->setCourtyardArrivalDate($courtyardArrivalDate);
     $sap = new SAPConnectorClient();
     $result = $sap->purchaseOrder($purchaseOrder, $purchaseOrderEntries);
     if ($result->purchaseOrderResult->code == 200) {
         try {
             $this->getPurchaseOrderCatalog()->beginTransaction();
             if ($_FILES["bl_house_file"]["name"] != "") {
                 $filePath = "files/purchase-order/" . $purchaseOrder->getIdPurchaseOrder();
                 $uploadPath = 'public/' . $filePath;
                 $fileUploader = new FileUploader("bl_house_file");
                 $fileUploader->saveFile($uploadPath, false);
                 $blHouseFile = PurchaseOrderFileFactory::createFromArray(array(PurchaseOrderFile::CONTENT => $filePath . $fileUploader->getFileName(), PurchaseOrderFile::TYPE => File::$typeFile["typeFile"], PurchaseOrderFile::DOCUMENT_TYPE => PurchaseOrderFile::$DocumentType["BLHouse"], PurchaseOrderFile::ID_PURCHASE_ORDER => $purchaseOrder->getIdPurchaseOrder()));
                 $this->getPurchaseOrderFileCatalog()->create($blHouseFile);
                 $this->newLogForUploadBL($purchaseOrder);
             }
             PurchaseOrderCommercialInvoiceFactory::populate($purchaseOrderCommercialInvoice, $blHouseData);
             if ($purchaseOrderCommercialInvoice->getIdPurchaseOrderCommercialInvoice()) {
                 $this->getPurchaseOrderCommercialInvoiceCatalog()->update($purchaseOrderCommercialInvoice);
             } else {
                 $purchaseOrderCommercialInvoice->setIdPurchaseOrder($idPurchaseOrder);
                 $this->getPurchaseOrderCommercialInvoiceCatalog()->create($purchaseOrderCommercialInvoice);
             }
             $this->newLogForReadyToShipment($purchaseOrder);
             $this->getPurchaseOrderCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("The Purchase Order has ready to shipment."));
         } catch (Exception $e) {
             $this->getPurchaseOrderCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     } else {
         $this->setFlash('error', $result->purchaseOrderResult->code . " - " . $result->purchaseOrderResult->message);
     }
     $this->_redirect('purchase-order/list');
 }