public function formAction() { $id = $this->getRequest()->getParam('id'); try { if (empty($id)) { throw new ProductAntidumpingDutyException($this->i18n->_('The product id was not defined')); } $product = ProductQuery::create()->findByPK($id); if (!$product instanceof Product) { throw new ProductAntidumpingDutyException($this->i18n->_('The Product was not found')); } $productAntidumpingDuty = ProductAntidumpingDutyQuery::create()->findByParentKey($product->getKeyMother()); if (!$productAntidumpingDuty instanceof ProductAntidumpingDuty) { $productAntidumpingDuty = new ProductAntidumpingDuty(); } $productAntidumpingDuty->setParentKey($product->getKeyMother()); $comboHeader = $this->i18n->_('Select One'); $header = array('' => $comboHeader); $this->view->currencies = CurrencyQuery::create()->find()->toCombo($comboHeader); $this->view->types = $header + array_flip(ProductAntidumpingDuty::$Type); $this->view->rules = $header + array_flip(ProductAntidumpingDuty::$Rule); $this->view->contentTitle = $this->i18n->_('Compensatory Fee'); $this->view->productAntidumpingDuty = $productAntidumpingDuty; } catch (ProductAntidumpingDutyException $e) { $this->setFlash('error', $e->getMessage()); $this->_redirect('product/list'); } }
/** * * @param int $idFolioImport */ public function __construct($idFolioImport, $USDToMXN, $EURtoUSD) { $this->folioImport = FolioImportQuery::create()->findByPK($idFolioImport); if ($USDToMXN) { $this->USDToMXN = $USDToMXN; } if ($EURtoUSD) { $this->EURtoUSD = $EURtoUSD; } $this->purchaseOrders = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_FOLIO_IMPORT, $idFolioImport)->find(); $this->purchaseOrdersEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $this->getPurchaseOrders()->getPrimaryKeys())->find(); $this->products = $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $this->getPurchaseOrdersEntries()->getProducts())->find(); $this->productAntidumpingDuties = ProductAntidumpingDutyQuery::create()->whereAdd(ProductAntidumpingDuty::PARENT_KEY, $products->getKeyMother())->find(); }