Ejemplo n.º 1
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $id = $this->getRequest()->getParam('id');
         $printingTechnique = PrintingTechniqueQuery::create()->findByPKOrThrow($id, $this->i18n->_("Not exists the PrintingTechnique with id {$id}"));
         try {
             $this->getPrintingTechniqueCatalog()->beginTransaction();
             PrintingTechniqueFactory::populate($printingTechnique, $params);
             $this->getPrintingTechniqueCatalog()->update($printingTechnique);
             foreach ($params['printingSizes'] as $idPrintingSize => $price) {
                 if (PrintingTechniqueSizeQuery::create()->whereAdd(PrintingTechniqueSize::ID_PRINTING_SIZE, $idPrintingSize)->whereAdd(PrintingTechniqueSize::ID_PRINTING_TECHNIQUE, $id)->count()) {
                     $printingTechniqueSize = PrintingTechniqueSizeQuery::create()->whereAdd(PrintingTechniqueSize::ID_PRINTING_SIZE, $idPrintingSize)->whereAdd(PrintingTechniqueSize::ID_PRINTING_TECHNIQUE, $id)->findOne();
                     $printingTechniqueSize->setPrice($price);
                     $this->getPrintingTechniqueSizeCatalog()->update($printingTechniqueSize);
                 } else {
                     $printingTechniqueSize = new PrintingTechniqueSize();
                     $printingTechniqueSize->setIdPrintingTechnique($printingTechnique->getIdPrintingTechnique());
                     $printingTechniqueSize->setIdPrintingSize($idPrintingSize);
                     $printingTechniqueSize->setPrice($price);
                     $this->getPrintingTechniqueSizeCatalog()->create($printingTechniqueSize);
                 }
             }
             // 				echo '<pre>';
             // 				print_r($printingTechnique);
             // 				print_r($params);
             // 				die;
             $this->getPrintingTechniqueCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("It has been updated the Printing Technique with id " . $printingTechnique->getIdPrintingTechnique()));
         } catch (Exception $e) {
             $this->getPrintingTechniqueCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('printing-technique/list');
 }
Ejemplo n.º 2
0
 /**
  *
  * @return array
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id_product');
     if (ProductPriceListQuery::create()->whereAdd(ProductPriceList::ID_PRODUCT, $id)->count()) {
         $productPriceList = ProductPriceListQuery::create()->whereAdd(ProductPriceList::ID_PRODUCT, $id)->findOneOrElse($id, new ProductPriceList());
     } else {
         $productPriceList = new ProductPriceList();
         $productPriceList->setIdProduct($id);
     }
     $product = ProductQuery::create()->findByPK($id);
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $product->getKeyMother(), ProductQuery::LIKE)->find();
     $productPriceListHistoryArray = array();
     while ($p = $products->read()) {
         for ($i = 1; $i <= 12; $i++) {
             $productPriceListHistoryQuery = ProductPriceListHistoryQuery::create()->whereAdd(ProductPriceListHistory::ITEMCODE, $p->getItemCode())->whereAdd(ProductPriceListHistory::PRICELIST, $i)->whereAdd(ProductPriceListHistory::PRICE, '0.0', ProductPriceListHistoryQuery::NOT_EQUAL)->orderBy(ProductPriceListHistory::LOGINSTANCE, ProductPriceListHistoryQuery::DESC)->findByPage(1, 10);
             $j = 0;
             while ($productPriceListHistory = $productPriceListHistoryQuery->read()) {
                 $productPriceListHistoryArray[$p->getItemCode()][$i][$j]['price'] = $productPriceListHistory->getPrice();
                 $productPriceListHistoryArray[$p->getItemCode()][$i][$j]['date'] = $productPriceListHistory->getUpdateDate();
                 $j++;
             }
         }
     }
     // 		echo '<pre>';
     // 		print_r($productPriceList);
     // 		die;
     $productPrintingArea = ProductPrintingAreaQuery::create()->whereAdd(ProductPrintingArea::ID_PRODUCT, $product->getKeyMother())->findOne();
     $printingTechnique = ProductionTimePrintingTechniqueQuery::create()->whereAdd(ProductionTimePrintingTechnique::ID_PRODUCT_PRINTING_AREA, $productPrintingArea->getIdProductPrintingArea())->getFavorite()->findOne();
     $rangeAndVolume = RangeAndVolumeQuery::create()->whereAdd(RangeAndVolume::RANGE, $product->getCost(), RangeAndVolumeQuery::GREATER_THAN)->orderBy(RangeAndVolume::RANGE, RangeAndVolumeQuery::ASC)->findOne();
     $technique = PrintingTechniqueQuery::create()->findByPK($printingTechnique->getIdPrintingTechnique());
     $size = PrintingSizeQuery::create()->findByPK($productPrintingArea->getIdPrintingSize());
     $printingPrice = PrintingTechniqueSizeQuery::create()->whereAdd(PrintingTechniqueSize::ID_PRINTING_SIZE, $size->getIdPrintingSize())->whereAdd(PrintingTechniqueSize::ID_PRINTING_TECHNIQUE, $technique->getIdPrintingTechnique())->findOne();
     $salesParameters = SalesParameterQuery::create()->find();
     $this->view->id_product = $id;
     $this->view->contentTitle = $this->i18n->_('Edit Product Price List');
     $this->view->products = $products->toArray();
     $this->view->priceListHistory = $productPriceListHistoryArray;
     $this->view->productPrintingArea = $productPrintingArea->toArray();
     $this->view->printingTechnique = $printingTechnique->toArray();
     $this->view->rangeAndVolume = $rangeAndVolume->toArray();
     $this->view->technique = $technique->getAbbreviation();
     $this->view->size = $size->getName();
     $this->view->printingPrice = $printingPrice->getPrice();
     $this->view->statuses = Product::$StatusFullName;
     $this->view->onsubmit = $this->getBaseUrl() . "/product-price-list/update";
     $this->view->freightFactor = $salesParameters->getByPK(SalesParameter::$SalesParameters['FreightFactorAndPromptPayment'])->getValue();
     if (!$productPriceList->getExchangeRateUsdToPesos()) {
         $productPriceList->setExchangeRateUsdToPesos($salesParameters->getByPK(SalesParameter::$SalesParameters['ExchangeRate'])->getValue());
     }
     if (!$productPriceList->getExchangeRateEurToUsd()) {
         $productPriceList->setExchangeRateEurToUsd($salesParameters->getByPK(SalesParameter::$SalesParameters['ExchangeRateEurtoUsd'])->getValue());
     }
     if (!$productPriceList->getMarginEximagen()) {
         $productPriceList->setMarginEximagen($salesParameters->getByPK(SalesParameter::$SalesParameters['EximagenRange'])->getValue());
     }
     /**
      *
      * @todo cambiar estos valores
      */
     $result = $this->getLandedCost($id, $productPriceList);
     if (!$result['result']) {
         $this->setFlash('warning', $this->i18n->_('You must edit the Product before the Product Printing List') . $result['message']);
         $this->_redirect('product/list');
     }
     $landedCost = $result['result'];
     $this->view->productPriceList = $productPriceList->toArray();
     //         $this->view->priceHistory = $this->getPriceHistoryAsCombo($id);
     $this->view->landedCost = $landedCost;
     $this->view->landedCostInfo = $this->getValuesUsedForLandedCost($id, $productPriceList);
     $url = $this->generateUrl('price-list', 'update', compact('id'));
     $this->view->form = $form;
     $this->view->setTpl("New");
 }
 /**
  *
  */
 public function reactivateAction()
 {
     $id = $this->getRequest()->getParam('id');
     $printingTechniqueSize = PrintingTechniqueSizeQuery::create()->findByPKOrThrow($id, $this->i18n->_("Not exists the PrintingTechniqueSize with id {$id}"));
     try {
         $this->getPrintingTechniqueSizeCatalog()->beginTransaction();
         $this->getPrintingTechniqueSizeCatalog()->update($printingTechniqueSize);
         $this->getPrintingTechniqueSizeCatalog()->commit();
         $this->setFlash('ok', $this->i18n->_("Se reactivo correctamente el PrintingTechniqueSize"));
     } catch (Exception $e) {
         $this->getPrintingTechniqueSizeCatalog()->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     $this->_redirect('printing-technique-size/list');
 }