예제 #1
0
 protected function genericSampleNPDNotification(NPDEvent $event, $notificationTypeId, $status)
 {
     $npd = $event->getNPD();
     $sampleObjects = SampleQuery::create()->whereAdd(Sample::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd(Sample::STATUS, $status)->addAscendingOrderBy(Sample::DEADLINE)->find();
     $npdSupplierIds = NpdSheetSupplierQuery::create()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->fetchCol();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $npdSupplierIds, SupplierQuery::IN)->find()->toCombo();
     $colors = \Application\Query\ColorQuery::create()->find()->toCombo();
     $samples = array();
     foreach ($sampleObjects as $sample) {
         if (!$sample instanceof Sample) {
             $sample = new Sample();
         }
         $samples[] = array('Supplier' => utf8_decode($suppliers[$sample->getIdSupplier()]), 'Quantity' => $sample->getQuantity(), 'Color' => $colors[$sample->getIdColor()], 'Remarks' => utf8_decode($sample->getNotes()), 'Deadline' => $sample->getDeadline(), 'Cost' => $sample->getCost(), 'ShippedQuantity' => $sample->getShippedQuantity());
     }
     $vars = array('id_npd_sheet' => $npd->getIdNpdSheet(), 'creation_date' => $npd->getCreationDateAsZendDate()->get("dd-MM-yyyy HH:mm"), 'name' => utf8_decode($npd->getName()), 'description' => utf8_decode($npd->getDescription()), 'samples' => $samples);
     $this->createNotification($notificationTypeId, $vars);
 }
예제 #2
0
 /**
  *
  * @return array
  */
 public function newAction()
 {
     $params = $this->getRequest()->getParams();
     $product['key'] = $params['composition'];
     $product['id_product_group'] = $params['id_product_group'];
     $product['id_family'] = $params['id_family'];
     $product['id_subfamily'] = $params['id_subfamily'];
     $product['id_brand'] = $params['id_brand'];
     $product['brand_code'] = $params['id_brand'] ? BrandQuery::create()->findByPK($product['id_brand'])->getName() : null;
     $product['productGroupCode'] = $productGroupCode = $product['id_product_group'] ? ProductGroupQuery::create()->findByPK($product['id_product_group'])->getCode() : null;
     $product['familyCode'] = $familyCode = $product['id_family'] ? FamilyQuery::create()->findByPK($product['id_family'])->getCode() : null;
     $product['subfamilyCode'] = $subfamilyCode = $product['id_subfamily'] ? SubfamilyQuery::create()->findByPK($product['id_subfamily'])->getCode() : "";
     $idNpd = $params['id_npd_sheet'];
     $pendingProduct = $params['pendingProduct'];
     if ($idNpd) {
         $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpd, $this->i18n->_("Npd with id {$idNpd} does no exist"));
         $npdSuppliersQuery = \Application\Query\NpdSheetSupplierQuery::create()->whereAdd(\Application\Model\Bean\NpdSheetSupplier::ID_NPD_SHEET, $idNpd);
         //obtiene el precio autorizado del npd
         $authorizedBudget = \Application\Query\SupplierBudgetQuery::create()->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSuppliersQuery->fetchIds(), BaseQuery::IN)->whereAdd(SupplierBudget::IS_AUTHORIZED, 1)->findOne();
         //obtiene el supplier autorizado
         $authorizedSupplier = $npdSuppliersQuery->addColumn("NpdSheetSupplier.*")->whereAdd(\Application\Model\Bean\NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedBudget->getIdNpdSupplier())->findOne();
         if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $authorizedSupplier->getIdSupplier())->count()) {
             $supplier = SapSupplierQuery::create()->findByPK($authorizedSupplier->getIdSupplier());
         } else {
             $supplier = new SapSupplier();
         }
         $currency = CurrencyQuery::create()->whereAdd(Currency::CURRCODE, $npdSheet->getIdCurrency())->findOne();
         $product['id_npd_sheet'] = $npdSheet->getIdNpdSheet();
         if (!$this->getRequest()->isPost()) {
             $product['id_product_group'] = $npdSheet->getIdProductGroup();
             $product['id_family'] = $npdSheet->getIdFamily();
             $product['id_subfamily'] = $npdSheet->getIdSubfamily();
             $product['id_brand'] = $npdSheet->getIdBrand();
         }
         $product['target_price'] = $npdSheet->getPrice();
         $product['long_description'] = $npdSheet->getLongDescription();
         $pendingProduct ? $pendingProduct : ($npdProduct = true);
         $npdFileQuery = \Application\Query\FileQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheet.id_npd_sheet', $params["id_npd_sheet"])->whereAdd('File.Type', file::$typeFile["typeFile"])->findOne();
         if ($product['id_brand']) {
             $product['brand_code'] = BrandQuery::create()->findByPK($product['id_brand'])->getName();
         }
         if ($product['id_color']) {
             $product['colorCode'] = ColorQuery::create()->findByPK($product['id_color'])->getCode();
         }
         if ($npdFileQuery) {
             $filePath = $npdFileQuery->getContent();
             $idFile = $npdFileQuery->getIdFile();
         }
         $itemsQuery = \Application\Query\ColorQuery::create()->innerJoinNpdSheet()->whereAdd("Color2NpdSheet.id_npd_sheet", $idNpd)->find();
         $itemCode = $product['productGroupCode'] . $product['subfamilyCode'] . $product['familyCode'] . $product['key'] . $product['brand_code'];
         $i = 0;
         while ($item = $itemsQuery->read()) {
             $npdItem = NpdSheetItemQuery::create()->findByColor($item->getIdColor(), $npdSheet->getIndex());
             $items[$i]['idColor'] = $item->getIdColor();
             $items[$i]['colorCode'] = $item->getCode();
             $items[$i]['itemName'] = $npdItem ? $npdItem->getName() : $npdSheet->getName();
             $items[$i]['itemCode'] = $itemCode . $item->getCode();
             $items[$i]['vim'] = $npdItem ? $npdItem->getVim() : "";
             $items[$i]['idNpdSheetItem'] = $npdItem ? $npdItem->getIndex() : "";
             $i++;
         }
         if ($pendingProduct) {
             $controller = "product";
             $action = "create";
         } else {
             $controller = "npd-sheet";
             $action = "new-product";
         }
         $product['itemName'] = $npdSheet->getName();
     } else {
         $npSheet = new NpdSheet();
         $authorizedBudget = new SupplierBudget();
         $authorizedSupplier = new NpdSheetSupplier();
         $supplier = new Supplier();
         $currency = new Currency();
         $npdProduct = false;
         $controller = "product";
         $action = "create";
     }
     $this->view->npdSheetFile = $filePath;
     $this->view->product = $product;
     $this->view->incoterms = $this->getIncoterms();
     $this->view->years = $this->getLastYears();
     $this->view->brands = $this->getBrands();
     $this->view->countries = $this->getCountries();
     $this->view->currencies = $this->getCurrencies();
     $this->view->productGroups = $this->getProductGroup();
     $this->view->families = $this->getFamilies($product['id_product_group']);
     $this->view->subfamilies = $this->getSubFamilies($product['id_family']);
     $this->view->defaultShipping = $this->getDefaultShipping();
     $this->view->customsTariffCodes = $this->getCustomsTariffCode();
     $this->view->colors = $this->getColors();
     $this->view->status = $this->getStatus();
     $this->view->authorizedBudget = $authorizedBudget;
     $this->view->authorizedSupplier = $authorizedSupplier;
     $this->view->supplier = $supplier->toArray();
     $this->view->currency = $currency->getCurrCode();
     $this->view->contentTitle = $this->i18n->_('New Product');
     $this->view->edit = false;
     $this->view->new = "ok";
     $this->view->controller = $controller;
     $this->view->action = $action;
     $this->view->npdProduct = $npdProduct;
     $this->view->items = $items;
     $this->view->pendingProduct = $pendingProduct;
     $this->view->setTpl('Form');
 }
예제 #3
0
 /**
  *
  * @return array
  */
 public function createAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         try {
             $this->getNpdSheetSupplierCatalog()->beginTransaction();
             foreach ($params["supplier"] as $index => $supplier) {
                 $idSupplier = $supplier['id_supplier'];
                 $idNpdSupplier = $supplier['id_npd_supplier'];
                 //     		    $supplierParams = Application\Query\SapSupplierQuery::create()->findByPKOrThrow($idSupplier,$this->i18n->_("It does not exist the supplier with id {$idSupplier}"));
                 if ($idNpdSupplier > 0) {
                     $npdSupplierParams = Application\Query\NpdSheetSupplierQuery::create()->findByPKOrElse($idNpdSupplier, new NpdSheetSupplier());
                     $npdSheetSupplier = NpdSheetSupplierFactory::populate($npdSupplierParams, $supplier);
                     $this->getNpdSheetSupplierCatalog()->update($npdSupplierParams);
                     foreach ($_FILES as $name => $value) {
                         if (strstr($name, "image_" . $index . "_") != false && $value["name"] != "") {
                             $fileUploader = new FileUploader($name);
                             if (strstr($name, "image") != false) {
                                 $uploadPath = 'public/files/npd/' . $supplier['id_npd_sheet'] . '/imagesSupplier';
                                 $fileUploader->saveFile($uploadPath, true);
                                 $type = File::$typeFile["typeImage"];
                             }
                             $sheetFile = new File();
                             $sheetFile->setType($type)->setContent('files/npd/' . $supplier['id_npd_sheet'] . '/imagesSupplier' . $fileUploader->getFileName());
                             $this->getCatalog("FileCatalog")->create($sheetFile);
                             $this->getNpdSheetSupplierCatalog()->linkToFile($idNpdSupplier, $sheetFile->getIdFile());
                         }
                     }
                     //Videos
                     //search if npd supplier have videos
                     $npdVideos = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $idNpdSupplier)->whereAdd("File." . File::TYPE, File::$typeFile["typeLink"])->fetchAll();
                     // if npd supplier have videos then delete it all
                     foreach ($npdVideos as $npdVideo) {
                         $this->getFileCatalog()->unlinkFromNpdSheetSupplier($npdVideo["id_file"], $idNpdSupplier);
                         $this->getFileCatalog()->deleteById($npdVideo["id_file"]);
                     }
                     //die("<pre>".print_r($supplier, true)."</pre>");
                     // insert new videos
                     $supplier["video"] = (array) $supplier["video"];
                     foreach ($supplier["video"] as $video) {
                         if ($video != "") {
                             //insert a new video with Type -> video
                             $sheetFile = new File();
                             $sheetFile->setType(File::$typeFile["typeLink"])->setContent($video);
                             //make relationship file - npdSupplier
                             $this->getFileCatalog()->create($sheetFile);
                             $this->getNpdSheetSupplierCatalog()->linkToFile($idNpdSupplier, $sheetFile->getIdFile());
                         }
                     }
                     //Moq and Price
                     //search if npd supplier have moq and price
                     $npdMoqPrices = SupplierBudgetQuery::create()->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $idNpdSupplier)->fetchAll();
                     //if npd supplier have moq and price then delete it all
                     foreach ($npdMoqPrices as $npdMoqPrice) {
                         $this->getSupplierBudgetCatalog()->deleteById($npdMoqPrice["id_supplier_budget"]);
                     }
                     //insert new moq and price
                     foreach ($supplier["moqPrice"] as $moqprice) {
                         $npdMoq = new SupplierBudget();
                         $npdMoq->setIdNpdSupplier($idNpdSupplier)->setMoq($moqprice["moq"])->setLeadTime($moqprice["leadtime"])->setPrice($moqprice["price"])->setIdCurrency($supplier["id_currency"]);
                         $this->getSupplierBudgetCatalog()->create($npdMoq);
                     }
                     $this->getNpdSheetSupplierCatalog()->unlinkAllColor($idNpdSupplier);
                 } else {
                     $newSuppliers = $supplier;
                     $npdSheetSupplier = NpdSheetSupplierFactory::createFromArray($newSuppliers);
                     $this->getNpdSheetSupplierCatalog()->create($npdSheetSupplier);
                     $newSupplier = $npdSheetSupplier->getIdNpdSupplier();
                     foreach ($_FILES as $name => $value) {
                         if (strstr($name, "image_" . $index . "_") != false && $value["name"] != "") {
                             $fileUploader = new FileUploader($name);
                             if (strstr($name, "image") != false) {
                                 $uploadPath = 'public/files/npd/' . $supplier['id_npd_sheet'] . '/imagesSupplier';
                                 $fileUploader->saveFile($uploadPath, true);
                                 $type = File::$typeFile["typeImage"];
                             }
                             $uploadPath = 'files/npd/' . $supplier['id_npd_sheet'] . '/imagesSupplier';
                             $sheetFile = new File();
                             $sheetFile->setType($type)->setContent($uploadPath . $fileUploader->getFileName());
                             $this->getCatalog("FileCatalog")->create($sheetFile);
                             $this->getNpdSheetSupplierCatalog()->linkToFile($newSupplier, $sheetFile->getIdFile());
                         }
                     }
                     foreach ($supplier["video"] as $video) {
                         if ($video != "") {
                             //insert a new video with Type -> video
                             $sheetFile = new File();
                             $sheetFile->setType(File::$typeFile["typeLink"])->setContent($video);
                             //make relationship file - npdSupplier
                             $this->getFileCatalog()->create($sheetFile);
                             $this->getNpdSheetSupplierCatalog()->linkToFile($newSupplier, $sheetFile->getIdFile());
                         }
                     }
                     //insert new moq and price
                     foreach ($supplier["moqPrice"] as $moqprice) {
                         $npdMoq = new SupplierBudget();
                         $npdMoq->setIdNpdSupplier($newSupplier)->setMoq($moqprice["moq"])->setLeadTime($moqprice["leadtime"])->setPrice($moqprice["price"])->setIdCurrency($supplier["id_currency"]);
                         $this->getSupplierBudgetCatalog()->create($npdMoq);
                     }
                 }
             }
             $this->getNpdSheetSupplierCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("The Supplier has been saved"));
         } catch (Exception $e) {
             // Roll back any change in database
             $this->getNpdSheetSupplierCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
             throw $e;
         }
     }
     $this->_redirect('npd-sheet/list');
 }
예제 #4
0
 public function detailsSupplierAction()
 {
     $idNpd = $this->getRequest()->getParam('idNpd');
     $id = $this->getRequest()->getParam('id');
     $npdSheetSupplierQuery = NpdSheetSupplierQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_supplier', $id);
     if ($idNpd) {
         $npdSheetSupplierQuery->whereAdd('NpdSheetSupplier.id_npd_sheet', $idNpd);
     }
     $npdSuppliers = $npdSheetSupplierQuery->find();
     foreach ($npdSuppliers as $npdSupplier) {
         $NPDSheetSupplierFilesQuery = FileQuery::create()->addColumns(array("File.*"))->innerJoinNpdSheetSupplier()->whereAdd('NpdSheetSupplier.' . NpdSheetSupplier::ID_NPD_SHEET, $npdSupplier->getIdNpdSheet())->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll();
         //     		while ($file = $NPDSheetSupplierFilesQuery->read()) {
         //     			$filesArray[] = array( "id" => $file->getIdFile());
         //     		}
     }
     die(Zend_Json::encode($NPDSheetSupplierFilesQuery));
 }
예제 #5
0
 public function exportToExcelPendingProductAction()
 {
     $post['id_product_group'] = urldecode($this->getRequest()->getParam('id_product_group'));
     $post['reference'] = urldecode($this->getRequest()->getParam('reference'));
     $post['status'] = $this->getRequest()->getParam('status');
     $npdsheets = NpdSheetQuery::create()->filter($post)->addDescendingOrderBy(NpdSheet::ID_NPD_SHEET)->whereAdd(NpdSheet::STATUS, NpdSheet::$Status['Pending Product'])->find();
     if (!$npdsheets->isEmpty()) {
         $i = 1;
         while ($npdsheet = $npdsheets->read()) {
             $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $npdsheet->getIdProductGroup())->findOne();
             $family = FamilyQuery::create()->whereAdd(Family::ID_FAMILY, $npdsheet->getIdFamily())->findOne();
             $subfamily = SubfamilyQuery::create()->whereAdd(Subfamily::ID_SUBFAMILY, $npdsheet->getIdSubfamily())->findOne();
             $npdSupplier = NpdSheetSupplierQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdsheet->getIdNpdSheet())->find()->getPrimaryKeys();
             if ($npdSupplier) {
                 $authorizedPrice = SupplierBudgetQuery::create()->innerJoinNpdSheetSupplier()->whereAdd('SupplierBudget.id_npd_supplier', $npdSupplier, Criteria::IN)->whereAdd('SupplierBudget.is_authorized', 1)->findOne();
             }
             if (!$authorizedPrice) {
                 $authorizedPrice = new SupplierBudget();
             }
             if (NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->count()) {
                 $npdSupplier = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SUPPLIER, $authorizedPrice->getIdNpdSupplier())->findOne();
             } else {
                 $npdSupplier = null;
             }
             if ($npdSupplier) {
                 if (SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->count()) {
                     $supplier = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplier->getIdSupplier())->findOne()->getSupplierCardCodeWithCardName();
                 }
             }
             $data[$i] = array($npdsheet->getIdNpdSheet(), $npdsheet->getStatusName(), $npdsheet->getReference(), $npdsheet->getCreationDateAsZendDate()->get('YYYY-MM-dd'), $productGroup->getCode() . '-' . $productGroup->getName(), $family->getCode() . '-' . $family->getName(), $subfamily ? $subfamily->getCode() . '-' . $subfamily->getName() : $this->i18n->_('Not Available'), $npdsheet->getName(), $npdsheet->getPrice(), $authorizedPrice->getPrice(), $supplier ? $supplier : null);
             $i++;
         }
         $header = array($this->i18n->_('ID'), $this->i18n->_('Status'), $this->i18n->_('Reference'), $this->i18n->_('Creation date'), $this->i18n->_('Product Group'), $this->i18n->_('Family'), $this->i18n->_('Subfamily'), $this->i18n->_('Product'), $this->i18n->_('Target Price'), $this->i18n->_('Authorized Price'), $this->i18n->_('Prefered Supplier'));
         $title = $this->i18n->_('NPDs Report');
         $fileName = $this->i18n->_('Npds_report');
         $tableColumnsWidth = array('mini');
         $report = new SimpleListReport();
         $report->setTableTitle($title);
         $report->setTableHeaders($header);
         $report->setTableContent($data);
         $report->setFilename($fileName);
         $report->setTableColumnsWidth($tableColumnsWidth);
         $report->createSpreadsheet();
     } else {
         $filter = $this->createFilterForUrl($post);
         $this->setFlash("warning", $this->i18n->_('No records found'));
         $this->_redirect('npd-sheet/pending-product');
     }
 }
예제 #6
0
 function orderFormAction()
 {
     $this->view->page = $page = $this->getRequest()->getParam('page') ?: 1;
     $this->view->contentTitle = $this->i18n->_('New Sample Order');
     $npdSheets = NpdSheetQuery::create()->addDescendingOrderBy(NpdSheet::STATUS)->addDescendingOrderBy(NpdSheet::CREATION_DATE)->whereAdd(NpdSheet::STATUS, NpdSheet::$Status['Closed'], BaseQuery::NOT_EQUAL)->find();
     $colors = array();
     $npdSuppliers = array();
     while ($npdSheet = $npdSheets->read()) {
         $colors[$npdSheet->getIdNpdSheet()] = ColorQuery::create()->addColumns(array("Color.*"))->whereAdd("NpdSheet." . NpdSheet::ID_NPD_SHEET, $npdSheet->getIdNpdSheet())->innerJoinNpdSheet()->find();
         if (NpdSheetSupplierQuery::create()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdSheet->getIdNpdSheet())->find()->count()) {
             $npdSupplierIds = NpdSheetSupplierQuery::create()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->innerJoinNpdSheet()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdSheet->getIdNpdSheet())->fetchCol();
         } else {
             $npdSheets->remove($npdSheet->getIdNpdSheet());
         }
         $npdSuppliers[$npdSheet->getIdNpdSheet()] = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $npdSupplierIds, SapSupplierQuery::IN)->find();
         $unitCost[$npdSheet->getIdNpdSheet()] = \Application\Query\SupplierBudgetQuery::create()->innerJoinNpdSheetSupplier()->whereAdd('NpdSheetSupplier.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd('SupplierBudget.is_authorized', 1)->addColumns(array('SupplierBudget.price', 'NpdSheetSupplier.id_supplier'))->fetchAll();
     }
     $this->view->npdSuppliers = array("Any") + $npdSuppliers;
     $this->view->npdSheets = $npdSheets;
     $this->view->colors = $colors;
     $this->view->unitCost = $unitCost;
 }
예제 #7
0
 public function toExcelAction()
 {
     $id = $this->getRequest()->getParam("id");
     $focusGroup = FocusGroupQuery::create()->findByPKOrThrow($id, $this->i18n->_("The FocusGroup with id {$id} wasn't found"));
     $poll = PollQuery::create()->findByPKOrThrow($focusGroup->getIdPoll(), $this->i18n->_("The Poll with id {$focusGroup->getIdPoll()} wasn't found"));
     $participants = RespondentQuery::create()->innerJoinFocusGroup()->whereAdd('FocusGroup.' . FocusGroup::ID_FOCUS_GROUPS, $focusGroup->getIdFocusGroups())->find();
     $npds = NpdSheetQuery::create()->innerJoinFocusGroup()->whereAdd('FocusGroup.' . FocusGroup::ID_FOCUS_GROUPS, $focusGroup->getIdFocusGroups(), BaseQuery::EQUAL)->find()->toObjectArray();
     $images = array();
     $suppliers = array();
     foreach ($npds as $npd) {
         $npdSupplier = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->findOne();
         if ($npdSupplier) {
             $supplier = SapSupplierQuery::create()->findByPK($npdSupplier->getIdSupplier());
         }
         $query = FileQuery::create()->addColumns(array("File.*"))->innerJoinNpdSheetSupplier()->whereAdd("File." . File::TYPE, $type, FileQuery::EQUAL)->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet());
         if ($supplier) {
             $query->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_SUPPLIER, $supplier->getIdSupplier());
             $suppliers[$npd->getIdNpdSheet()] = $supplier;
         }
         $images[$npd->getIdNpdSheet()] = $query->findOne();
         if (!$images[$npd->getIdNpdSheet()]) {
             if (null != ($npdImages = NpdSheetQuery::getNpdSheetFileObjects($npd->getIdNpdSheet(), File::$typeFile["typeImage"]))) {
                 $images[$npd->getIdNpdSheet()] = $npdImages->getOne();
             }
         }
     }
     $questions = QuestionQuery::create()->innerJoinPoll()->whereAdd("PollQuestions.id_poll", $poll->getIdPoll(), BaseQuery::EQUAL)->orderBy("PollQuestions.order")->find();
     $colors = ColorQuery::create()->find()->toCombo();
     require_once 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $activeSheet = $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet->mergeCells('A1:A2')->setCellValue('A1', $this->i18n->_('NPD ID'))->mergeCells('B1:B2')->setCellValue('B1', $this->i18n->_('Supplier'))->mergeCells('C1:C2')->setCellValue('C1', $this->i18n->_('Image'))->mergeCells('D1:D2')->setCellValue('D1', $this->i18n->_('Description'))->mergeCells('E1:E2')->setCellValue('E1', $this->i18n->_('MX Price'));
     $i = 5;
     foreach ($participants as $participant) {
         $last = $i + $questions->count() - 1;
         $activeSheet->mergeCells($this->getExcelColumn($i) . '1:' . $this->getExcelColumn($last) . '1');
         $activeSheet->setCellValue($this->getExcelColumn($i) . '1', $participant->getName());
         foreach ($questions as $question) {
             $activeSheet->setCellValue($this->getExcelColumn($i) . '2', $question->getDescription());
             $i++;
         }
     }
     $i = 3;
     foreach ($npds as $npd) {
         $activeSheet->setCellValue("A{$i}", $npd->getIdNpdSheet());
         if ($suppliers[$npd->getIdNpdSheet()]) {
             $activeSheet->setCellValue("B{$i}", $suppliers[$npd->getIdNpdSheet()]->getName());
         }
         if ($images[$npd->getIdNpdSheet()]) {
             $link = new PHPExcel_Cell_Hyperlink();
             $link->setUrl($this->getFullBaseUrl() . '/' . $images[$npd->getIdNpdSheet()]->getContent());
             $activeSheet->setCellValue("C{$i}", $this->getFullBaseUrl() . '/' . $images[$npd->getIdNpdSheet()]->getContent())->setHyperlink("C{$i}", $link);
         }
         $activeSheet->setCellValue("D{$i}", $npd->getDescription());
         $activeSheet->setCellValue("E{$i}", $npd->getPrice());
         $j = 5;
         foreach ($participants as $participant) {
             $questions->rewind();
             while ($question = $questions->read()) {
                 if ($pollResponse = PollResponseQuery::create()->whereAdd(PollResponse::ID_FOCUS_GROUP, $focusGroup->getIdFocusGroups())->whereAdd(PollResponse::ID_POLL, $focusGroup->getIdPoll())->whereAdd(PollResponse::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd(PollResponse::ID_RESPONDENT, $participant->getIdRespondent())->whereAdd(PollResponse::ID_QUESTION, $question->getIdQuestion())->findOne()) {
                     $q = new Question();
                     if ($question->getIdType() == Question::$Type['Yes/No']) {
                         switch ($pollResponse->getResponse()) {
                             case "true":
                                 $pollResponse->setResponse('Si');
                                 break;
                             case "false":
                                 $pollResponse->setResponse('No');
                                 break;
                         }
                     }
                     if ($question->getIdType() == Question::$Type['Multiple']) {
                         $multipleResponseQuery = QuestionMultipleResponseQuery::create()->whereAdd(QuestionMultipleResponse::ID_QUESTION, $question->getIdQuestion())->find();
                         while ($multipleResponse = $multipleResponseQuery->read()) {
                             if ($pollResponse->getResponse() == $multipleResponse->getIdResponse()) {
                                 $pollResponse->setResponse($multipleResponse->getDescription());
                             }
                         }
                     }
                     $activeSheet->setCellValue($this->getExcelColumn($j) . $i, $pollResponse->getResponse());
                 }
                 $j++;
             }
         }
         $i++;
     }
     header("Content-Type: application/vnd.ms-excel");
     header("Content-Disposition: attachment; filename=\"{$focusGroup->getName()}.xlsx\"");
     header("Cache-Control: max-age=0");
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save("php://output");
     exit;
 }