/**
  *
  */
 public function reactivateAction()
 {
     $id = $this->getRequest()->getParam('id');
     $productPrintingAreaFile = ProductPrintingAreaFileQuery::create()->findByPKOrThrow($id, $this->i18n->_("Not exists the ProductPrintingAreaFile with id {$id}"));
     try {
         $this->getProductPrintingAreaFileCatalog()->beginTransaction();
         $this->getProductPrintingAreaFileCatalog()->update($productPrintingAreaFile);
         $this->getProductPrintingAreaFileCatalog()->commit();
         $this->setFlash('ok', $this->i18n->_("Se reactivo correctamente el ProductPrintingAreaFile"));
     } catch (Exception $e) {
         $this->getProductPrintingAreaFileCatalog()->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     $this->_redirect('product-printing-area-file/list');
 }
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         // 			echo '<pre>';
         // 			print_r($params);
         // 			die;
         // 			$id = $this->getRequest()->getParam('id_product_printing_area');
         // 			$productPrintingArea = ProductPrintingAreaQuery::create()->findByPKOrThrow($id, $this->i18n->_("Not exists the ProductPrintingArea with id {$id}"));
         try {
             $this->getProductPrintingAreaCatalog()->beginTransaction();
             // 				ProductPrintingAreaFactory::populate($productPrintingArea, $params);
             // 				$this->getProductPrintingAreaCatalog()->update($productPrintingArea);
             $documentTypes = ProductPrintingAreaFile::$DocumentType;
             $idEShop = $params['id_e_shop'];
             $urlLogoNet = $params['url_logo_net'];
             $favoriteArea = $params['favoriteArea'];
             $idProduct = $params['id_product'];
             foreach ($params['areas'] as $key => $area) {
                 $favorite = $favoriteArea == $key ? 1 : 0;
                 $productPrintingArea = ProductPrintingAreaFactory::createFromArray($area);
                 $productPrintingArea->setIdProduct($idProduct);
                 $productPrintingArea->setUrlLogoNet($urlLogoNet);
                 $productPrintingArea->setIdEShop($idEShop);
                 $productPrintingArea->setFavorite($favorite);
                 if ($productPrintingArea->getIdProductPrintingArea()) {
                     $this->getProductPrintingAreaCatalog()->update($productPrintingArea);
                 } else {
                     $this->getProductPrintingAreaCatalog()->create($productPrintingArea);
                 }
                 $idsPrintingAreas[] = $productPrintingArea->getIdProductPrintingArea();
                 $path = 'product-printing-area/' . $productPrintingArea->getIdProductPrintingArea() . '/';
                 $favoriteTechnique = $area['favorite'];
                 foreach ($area['techniques'] as $key2 => $technique) {
                     $favorite2 = $favoriteTechnique == $key2 ? 1 : 0;
                     $productionTime = ProductionTimePrintingTechniqueFactory::createFromArray($technique);
                     $productionTime->setIdProductPrintingArea($productPrintingArea->getIdProductPrintingArea());
                     $productionTime->setFavorite($favorite2);
                     if ($productionTime->getIdProductionTimeByPrintingTechnique()) {
                         $this->getProductionTimeByPrintingTechnique()->update($productionTime);
                     } else {
                         $this->getProductionTimeByPrintingTechnique()->create($productionTime);
                     }
                     $idsPrintingTechniques[] = $productionTime->getIdProductionTimeByPrintingTechnique();
                 }
                 $erasableProductionTimePrintingTechniques = ProductionTimePrintingTechniqueQuery::create()->whereAdd(ProductionTimePrintingTechnique::ID_PRODUCTION_TIME_BY_PRINTING_TECHNIQUE, $idsPrintingTechniques, ProductionTimePrintingTechniqueQuery::NOT_IN)->whereAdd(ProductionTimePrintingTechnique::ID_PRODUCT_PRINTING_AREA, $productPrintingArea->getIdProductPrintingArea())->find();
                 while ($erasableProductionTimePrintingTechnique = $erasableProductionTimePrintingTechniques->read()) {
                     $this->getProductionTimeByPrintingTechnique()->deleteById($erasableProductionTimePrintingTechnique->getIdProductionTimeByPrintingTechnique());
                 }
                 foreach ($documentTypes as $name => $documentType) {
                     $name .= $key;
                     $file = $this->saveFile($name, $path, $name);
                     if ($file) {
                         $productPrintingAreaFile = new ProductPrintingAreaFile();
                         $productPrintingAreaFile->setContent($file->getContent());
                         $productPrintingAreaFile->setType($file->getType());
                         $productPrintingAreaFile->setDocumentType($documentType);
                         $productPrintingAreaFile->setIdProductPrintingArea($productPrintingArea->getIdProductPrintingArea());
                         if (ProductPrintingAreaFileQuery::create()->whereAdd(ProductPrintingAreaFile::DOCUMENT_TYPE, $documentType)->whereAdd(ProductPrintingAreaFile::ID_PRODUCT_PRINTING_AREA, $productPrintingArea->getIdProductPrintingArea())->count()) {
                             $this->getProductPrintingAreaFileCatalog()->update($productPrintingAreaFile);
                         } else {
                             $this->getProductPrintingAreaFileCatalog()->create($productPrintingAreaFile);
                         }
                     }
                 }
             }
             $erasableAreas = ProductPrintingAreaQuery::create()->whereAdd(ProductPrintingArea::ID_PRODUCT_PRINTING_AREA, $idsPrintingAreas, ProductPrintingAreaQuery::NOT_IN)->whereAdd(ProductPrintingArea::ID_PRODUCT, $idProduct)->find();
             while ($erasableArea = $erasableAreas->read()) {
                 $erasableArea->setStatus(ProductPrintingArea::$Status['Inactive']);
                 $this->getProductPrintingAreaCatalog()->update($erasableArea);
             }
             $this->getProductPrintingAreaCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("The Product Printing Area with id {$id} has been updated."));
         } catch (Exception $e) {
             // 				$this->getProductPrintingAreaCatalog()->rollBack();
             // 				$this->setFlash('error', $this->i18n->_($e->getMessage()));
             throw $e;
             die;
         }
     }
     $this->_redirect('product/list');
 }