/**
  *
  * @return array
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $productionTimePrintingTechniques = ProductionTimePrintingTechniqueQuery::create()->findByPKOrThrow($id, $this->i18n->_("Not exists the ProductionTimePrintingTechnique with id {$id}"));
     $this->view->setTpl("Form");
     $this->view->productionTime = $productiontimeQuery = ProductionTimePrintingTechniqueQuery::create()->innerJoinProductPrintingArea()->findByPKOrThrow($id, $this->i18n->_("No exists Production Time Printing Technique"));
     $this->view->printingArea = $printingArea = ProductPrintingAreaQuery::create()->findByPKOrElse($productiontimeQuery->getIdProductPrintingArea(), new ProductPrintingArea());
     $this->view->product = ProductQuery::create()->findOneOrElse($printingArea->getIdProduct(), new Product());
     $this->view->technique = PrintingTechniqueQuery::create()->findByPKOrElse($productiontimeQuery->getIdPrintingTechnique(), new PrintingTechnique());
     $this->view->size = $size = PrintingSizeQuery::create()->findByPKOrElse($printingArea->getIdPrintingSize(), new \Application\Model\Bean\PrintingSize());
     // die(print_r($productiontimeQuery));
 }
 /**
  * 
  */
 public function getListResultsAction()
 {
     $storage = $this->getStorageService();
     $params = $this->getRequest()->getParams();
     $page = $params['page'];
     $productQuery = ProductQuery::create()->useFileCache()->filter($params);
     $colors = ColorQuery::create()->find();
     $brands = BrandQuery::create()->find();
     $productCollection = $productQuery->find();
     $freightFareCollection = FreightFareQuery::create()->find();
     $freightTypeCollection = FreightTypeQuery::create()->find();
     $customsTariffCodeCollection = CustomsTariffCodeQuery::create()->find();
     $incotermCollection = IncotermQuery::create()->useFileCache()->find();
     $products = $productQuery->findByPage($page, $this->getMaxPerPage());
     // 		if (!$productStorage)
     // 			$storage->saveValue($productQuery->find(), 'products');
     $productPrintingArea = ProductPrintingAreaQuery::create()->addColumn(ProductPrintingArea::ID_PRODUCT)->whereAdd(ProductPrintingArea::ID_PRODUCT, $products->getKeyMother(), ProductPrintingAreaQuery::IN)->fetchCol();
     //
     $arrayProducts = array();
     while ($products->valid()) {
         $product = $products->read();
         $hasPrintingArea = in_array($product->getKeyMother(), $productPrintingArea) ? 1 : 0;
         $arrayProducts[$product->getIndex()] = $product->toArrayForList() + array("has_printing_area" => $hasPrintingArea);
     }
     die(json_encode($arrayProducts));
 }
 /**
  *
  * @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");
 }
Exemple #4
0
 /**
  * 
  */
 public function hasPrintingArea()
 {
     return ProductPrintingAreaQuery::create()->whereAdd(ProductPrintingArea::ID_PRODUCT, $this->keyMother)->count() ? true : false;
 }
 public function exportToExcelAction()
 {
     $report = new SimpleListReport();
     $params = $this->getRequest()->getParams();
     $productPrintingAreas = ProductPrintingAreaQuery::create()->filter($params)->find();
     $i = 0;
     $tableContent = array();
     while ($productPrintingArea = $productPrintingAreas->read()) {
         $productionTimePrintingTechniqueQuery = ProductionTimePrintingTechniqueQuery::create()->whereAdd(ProductionTimePrintingTechnique::ID_PRODUCT_PRINTING_AREA, $productPrintingArea->getIdProductPrintingArea())->find();
         $j = 1;
         while ($productionTimePrintingTechnique = $productionTimePrintingTechniqueQuery->read()) {
             switch ($j) {
                 case 1:
                     $id_printing_technique = $productionTimePrintingTechnique->getIdPrintingTechnique();
                     $max_area = $productionTimePrintingTechnique->getMaxArea();
                     $max_inks = $productionTimePrintingTechnique->getMaxInks();
                     break;
                 case 2:
                     $id_printing_technique_alternative = $productionTimePrintingTechnique->getIdPrintingTechnique();
                     $max_area_alternative = $productionTimePrintingTechnique->getMaxArea();
                     $max_inks_alternative = $productionTimePrintingTechnique->getMaxInks();
                     break;
             }
             if ($j == 2) {
                 break;
             }
             $j++;
         }
         $product = ProductQuery::create()->findByPK($productPrintingArea->getIdProduct());
         $tableContent[$i][] = $productPrintingArea->getIdProduct();
         $tableContent[$i][] = $product->getKeyMother();
         $tableContent[$i][] = $product->getItemName();
         $tableContent[$i][] = $productPrintingArea->getIdEShop();
         $tableContent[$i][] = $id_printing_technique;
         $tableContent[$i][] = $productPrintingArea->getIncludedLogos();
         $tableContent[$i][] = $productPrintingArea->getIdPrintingSize();
         $tableContent[$i][] = $max_inks;
         $tableContent[$i][] = $id_printing_technique_alternative;
         $tableContent[$i][] = $max_inks_alternative;
         $tableContent[$i][] = $max_area;
         $tableContent[$i][] = $max_area_alternative;
         $tableContent[$i][] = $productPrintingArea->getPrintingOrder();
         $i++;
     }
     $tableHeaders = array('SKU', 'Item', 'Item Name', 'Id E-Shop', 'Printing Technique', 'Included Logos', 'Surface', 'Max Inks', 'Printing Technique Alternative', 'Max Inks Alternative', 'Max Area', 'Max Area Alternative', 'Printing Order');
     $report->setTableTitle('Product Printing Area Report');
     $report->setTableHeaders($tableHeaders);
     $report->setTableContent($tableContent);
     $report->setFilename('product_printing_area_report');
     $report->createSpreadsheet();
     die;
 }