/** * * @return array */ public function listAction() { $this->view->page = $page = $this->getRequest()->getParam('page') ?: 1; if ($this->getRequest()->isPost()) { $this->view->post = $post = $this->getRequest()->getParams(); } $total = PollResponseQuery::create()->filter($post)->count(); $this->view->pollResponses = $pollResponses = PollResponseQuery::create()->filter($post)->page($page, $this->getMaxPerPage())->find(); $this->view->paginator = $this->createPaginator($total, $page); $this->view->polls = \Application\Query\PollQuery::create()->find()->toCombo(); $this->view->questions = \Application\Query\QuestionQuery::create()->find()->toCombo(); $this->view->npdSheets = \Application\Query\NpdSheetQuery::create()->find()->toCombo(); $this->view->respondents = \Application\Query\RespondentQuery::create()->find()->toCombo(); }
public function addSupplierAction() { //view information NPD $this->view->id = $idNpdSheet = $this->getRequest()->getParam('id'); $this->view->contentTitle = 'Add Supplier'; $this->generateUrl('npd', 'create'); $this->view->setTpl("Add-supplier"); $this->view->npd = $npdSheet = NpdSheetQuery::create()->findByPKOrThrow($idNpdSheet, $this->i18n->_("It does not exist the NpdSheet with id {$idNpdSheet}")); $family = FamilyQuery::create()->findByPK($npdSheet->getIdFamily()); $this->view->family = $family->getName(); if ($npdSheet->getIdSubfamily()) { $this->view->subfamily = SubfamilyQuery::create()->findByPK($npdSheet->getIdSubfamily())->getName(); } else { $this->view->subfamily = $this->i18n->_("Any"); } $this->view->productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup())->getName(); $this->view->videos = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeLink"])->find(); $this->view->npdColors = ColorQuery::create()->innerJoinNpdSheet()->whereAdd('Color2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->find(); $this->view->country = CountryQuery::create()->find()->toCombo(); $this->view->npdSheetImages = NpdSheetQuery::getNpdSheetFileObjects($npdSheet->getIdNpdSheet(), File::$typeFile["typeImage"]); $this->view->npdSheetFiles = NpdSheetQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheet." . NpdSheet::ID_NPD_SHEET, $npdSheet->getIdNpdSheet())->fetchAll(); $this->view->file = $file = FileQuery::create()->innerJoinNpdSheet()->whereAdd('File2NpdSheet.id_npd_sheet', $npdSheet->getIdNpdSheet())->whereAdd(File::TYPE, File::$typeFile["typeFile"])->findOne(); //Form add supplier $npdSuppliers = $npdSuppliers = NpdSheetSupplierQuery::create()->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $idNpdSheet)->find(); $allColors = array("" => "** Select a Color **") + ColorQuery::create()->actives()->find()->toCombo(); //Videos from supplier foreach ($npdSuppliers as $npdSupplier) { //Get File Video for NPDSheetSupplier $NPDSheetSupplierFilesQuery = NpdSheetSupplierQuery::create()->addColumns(array("File.*"))->innerJoinFile()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier())->fetchAll(); $NPDSheetSupplierFiles[$npdSupplier->getIdNpdSupplier()] = $NPDSheetSupplierFilesQuery; $assignedColors = $this->getSupplierColors($npdSupplier->getIdNpdSupplier()); $i = 0; foreach ($assignedColors->toCombo() as $idColor => $colorName) { $colors[$npdSupplier->getIdNpdSupplier()][$i]["options"] = $allColors + array($idColor => $colorName); $colors[$npdSupplier->getIdNpdSupplier()][$i]["selected"] = $idColor; $i++; } if (count($colors[$npdSupplier->getIdNpdSupplier()]) == 0) { $colors[$npdSupplier->getIdNpdSupplier()][0]["options"] = $allColors; } //Moq and price $npdMoqPriceQuery = SupplierBudgetQuery::create(); $npdMoqPriceQuery->whereAdd(SupplierBudget::ID_NPD_SUPPLIER, $npdSupplier->getIdNpdSupplier()); $npdMoqPrice[$npdSupplier->getIdNpdSupplier()] = $npdMoqPriceQuery->find(); } if ($npdSuppliers->count() > 0) { $this->view->npdSuppliers = $npdSuppliers; $this->view->NPDSheetSupplierFiles = $NPDSheetSupplierFiles; //die(print_r($colors)); $this->view->fileTypes = File::$typeFile; $this->view->colors = $colors; $this->view->npdMoqPrice = $npdMoqPrice; } else { $npdSuppliers = new stdClass(); $npdSuppliers->couryard = new NpdSheetSupplier(); $this->view->npdSuppliers = $npdSuppliers; $this->view->defaultColor = $allColors; } $suppliers = Application\Query\SapSupplierQuery::create()->find(); $temporalSupplierQuery = TemporalSupplierQuery::create()->find(); $temporalSupplierArray = array(); $temporalSupplierNamesArray = array(); while ($temporalSupplier = $temporalSupplierQuery->read()) { $temporalSupplierNamesArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getIdTemporalSap() . ' - ' . $temporalSupplier->getName(); $temporalSupplierArray[$temporalSupplier->getIdTemporalSap()] = $temporalSupplier->getName(); } // $suppliersToAjax += $temporalSupplierArray; $this->view->supplierNames = $suppliers->toAutoCompleteCombo() + $temporalSupplierNamesArray; $this->view->supplierTabs = $suppliers->toCombo() + $temporalSupplierArray; $this->view->fobPorts = array("" => "Select Fob Port") + Application\Query\PortCustomQuery::create()->actives()->whereAdd('PortCustom.' . PortCustom::IS_DEPARTURE, 1)->find()->toCombo(); $this->view->incoterms = array("" => "Select Incoterm") + \Application\Query\IncotermQuery::create()->find()->toCombo(); $this->view->currencies = array("" => "Select Currency") + \Application\Query\CurrencyQuery::create()->find()->toCombo(); $this->view->actionForm = 'create'; }
/** * */ public function newKeyAction() { $post['NPD'] = $this->getRequest()->getParam('npd', ''); $post['idProductGroup'] = $this->getRequest()->getParam('id_product_group', ''); $post['idFamily'] = $this->getRequest()->getParam('id_family', ''); $post['idSubfamily'] = $this->getRequest()->getParam('id_subfamily', ''); $post['clvcomposition'] = $this->getRequest()->getParam('composition', ''); $post['idBrand'] = $this->getRequest()->getParam('id_brand', ''); $this->view->contentTitle = $this->i18n->_('Item Code'); $this->view->NPDSheet = $NPDSheet = !empty($post['NPD']) ? NpdSheetQuery::create()->findByPKOrThrow($post['NPD'], $this->i18n->_("The NPDSheet with Id {$post['NPD']} does not exist.")) : new NpdSheet(); $this->view->proceed = false; if ($this->getRequest()->isPost()) { $this->view->productGroup = $produtGroup = ProductGroupQuery::create()->findByPKOrThrow($post['idProductGroup'], $this->i18n->_("The ProductGroup with Id {$post['idProductGroup']} does not exist.")); $this->view->family = $family = FamilyQuery::create()->findByPKOrThrow($post['idFamily'], $this->i18n->_("The Family with Id {$post['idFamily']} does not exist.")); $this->view->subfamily = $subfamily = SubfamilyQuery::create()->findByPKOrThrow($post['idSubfamily'], $this->i18n->_("The Subfamily with Id {$post['idSubfamily']} does not exist.")); $this->view->brand = $brand = BrandQuery::create()->findByPKOrThrow($post['idBrand'], $this->i18n->_("The Brand with Id {$post['idBrand']} does not exist.")); $this->view->proceed = true; } else { if ($NPDSheet->getIdNpdSheet() > 0) { $this->view->productGroup = $produtGroup = ProductGroupQuery::create()->findByPKOrThrow($NPDSheet->getIdProductGroup(), $this->i18n->_("The ProductGroup with Id {$NPDSheet->getIdProductGroup()} does not exist.")); //die("<pre>".print_r($produtGroup, true)."</pre>"); $this->view->family = $family = $NPDSheet->getIdFamily() > 0 ? FamilyQuery::create()->findByPKOrThrow($NPDSheet->getIdFamily(), $this->i18n->_("The Family with Id {$NPDSheet->getIdFamily()} does not exist.")) : new Family(); $this->view->subfamily = $subfamily = $NPDSheet->getIdSubfamily() > 0 ? SubfamilyQuery::create()->findByPKOrThrow($NPDSheet->getIdSubfamily(), $this->i18n->_("The Subfamily with Id {$NPDSheet->getIdSubfamily()} does not exist.")) : new Subfamily(); //die($NPDSheet->getIdBrand()); $this->view->brand = $brand = $NPDSheet->getIdBrand() > 0 ? BrandQuery::create()->findByPKOrThrow($NPDSheet->getIdBrand(), $this->i18n->_("The Brand with Id {$NPDSheet->getIdBrand()} does not exist.")) : new Brand(); } else { $this->view->productGroup = $produtGroup = new ProductGroup(); $this->view->family = $family = new Family(); $this->view->subfamily = $subfamily = new Subfamily(); $this->view->brand = $brand = new Brand(); } } $productsFam = ProductQuery::create()->distinct()->addColumn(Product::ID_PRODUCT_GROUP)->fetchCol(); $productGroupQuery = ProductGroupQuery::create(); $productGroupQuery->where()->setOr(); $productsFam = $productGroupQuery->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $productsFam, ProductGroupQuery::IN)->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $post['idProductGroup'])->addAscendingOrderBy(ProductGroup::CODE)->fetchAll(); foreach ($productsFam as $key => $productFam) { if ($productFam['id_product_group'] == $post['idProductGroup']) { $productGroupIds = array("prevFamily" => $productsFam[$key - 1]['id_product_group'], "productFamily" => $productsFam[$key]['id_product_group'], "nextFamily" => $productsFam[$key + 1]['id_product_group']); break; } } //die("<pre>".print_r($productGroupIds, true)."</pre>"); $wantedProducts = ProductQuery::create(); $wantedProducts->where()->setOR(); $seachProducts = $wantedProducts->addColumns(array(Product::ITEM_CODE, Product::ITEM_NAME, Product::STATUS, "U_Madre_09" => 'SUBSTRING(' . Product::ITEM_CODE . ', 0, 8)', Product::ID_COLOR, Product::ID_COLOR))->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['productFamily'])->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['prevFamily'])->whereAdd(Product::ID_PRODUCT_GROUP, $productGroupIds['nextFamily'])->addAscendingOrderBy(Product::ITEM_CODE)->fetchAll(); $newProduct = array(array('ItemCode' => $produtGroup->getCode() . $family->getCode() . $subfamily->getCode() . $post['clvcomposition'] . $brand->getName(), 'ItemName' => $NPDSheet->getName() ? $NPDSheet->getName() : $this->i18n->_('Not set'), 'SWW' => 'H', 'U_Madre_09' => $produtGroup->getCode() . $family->getCode() . $subfamily->getCode() . $post['clvcomposition'], 'U_Color' => $colorCode, 'index' => true)); //order total products $products = array_merge($seachProducts, $newProduct); usort($products, function ($a, $b) { return strcmp($a['ItemCode'], $b['ItemCode']); }); // echo '<pre>'; // print_r($seachProducts); // die; //die("<pre>".print_r($products, true)."</pre>"); $prepend = $produtGroup->getCode() . $family->getCode() . $subfamily->getCode(); $lastItem = $newProduct[0]['U_Madre_09']; $nextComposition = $post['clvcomposition']; foreach ($seachProducts as $key => $val) { if (strstr($val['U_Madre_09'], $newProduct[0]['U_Madre_09'])) { $this->view->proceed = false; } if (strstr($val['U_Madre_09'], $lastItem)) { $nextComposition += 1; if ($nextComposition % 2 == 0) { $nextComposition += 1; } $lastItem = $prepend . $nextComposition; } } // echo $lastItem;die; foreach ($products as $key => $product) { if ($product['ItemCode'] == $newProduct[0]['ItemCode']) { $this->view->index = $key; } } $this->view->productGroups = $this->getProductGroup(); $families = array("" => $this->i18n->_("Select a Family")); if ($family->getIdFamily() > 0) { $families += FamilyQuery::create()->whereAdd(Family::ID_PRODUCT_GROUP, $family->getIdProductGroup())->find()->toCombo(); } $this->view->families = $families; $subfamilies = array("" => $this->i18n->_("Select a Subfamily")); if ($subfamily->getIdSubfamily() > 0) { $subfamilies += SubfamilyQuery::create()->whereAdd(Subfamily::ID_FAMILY, $subfamily->getIdFamily())->find()->toComboUTF8(); } else { $subfamilies += SubfamilyQuery::create()->whereAdd(Subfamily::ID_FAMILY, $family->getIdFamily())->find()->toComboUTF8(); } $this->getRequest()->getParam("pending_product") == true ? $pendingProduct = true : ($pendingProduct = false); $this->view->nextComposition = $nextComposition; $this->view->pendingProduct = $pendingProduct; $this->view->subfamilies = $subfamilies; $this->view->brands = $this->getBrands(); $this->view->products = $products; $this->view->colors = ColorQuery::create()->find(); $this->view->setTpl('../npd-sheet/Npd-key'); }
/** * @return \Application\Model\Collection\NpdSheetCollection */ public function setNpdCollection() { $this->npds = NpdSheetQuery::create()->whereAdd(NpdSheet::ID_NPD_SHEET, $this->getDistinctNPDSheets(), NpdSheetQuery::IN)->find(); }
public function statusauthorizeAction() { $npdSheet = NpdSheetQuery::create()->findByPK($this->getRequest()->getParam('id')); try { $this->getNpdSheetCatalog()->beginTransaction(); //Change status NPD to Closed $npdSheet->setStatus(NpdSheet::$Status['Authorized']); $this->getNpdSheetCatalog()->update($npdSheet); $this->getNpdSheetCatalog()->commit(); $this->setFlash('ok', $this->i18n->_("Se autorizo el NPD")); } catch (Exception $e) { $this->getNpdSheetCatalog()->rollBack(); $this->setFlash('error', $this->i18n->_($e->getMessage())); } $this->_redirect('npd-sheet/list'); }
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'); } }
/** * */ public function exportToExcelSentSamplesAction() { $params = $this->getRequest()->getParams(); $sampleShipmentQuery = SampleShipmentQuery::create()->addDescendingOrderBy(SampleShipment::ID_SAMPLE_SHIPMENT)->filter($params)->find(); $i = 1; while ($sampleShipment = $sampleShipmentQuery->read()) { $content[$i] = array('Guide', $sampleShipment->getGuide(), '', '', '', '', ''); $i++; $content[$i] = array('Courier', $sampleShipment->getCourier(), '', '', '', '', ''); $i++; $content[$i] = array('Shipment Date', $sampleShipment->getShipmentDate(), '', '', '', '', ''); $i++; $content[$i] = array('Notes', $sampleShipment->getNote(), '', '', '', '', ''); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; $content[$i] = array('Id Npd Sheet', 'Description', 'Supplier', 'Color', 'Quantity', 'Cost', 'Ammount'); $i++; $sampleQuery = SampleQuery::create()->whereAdd(Sample::ID_SAMPLE_SHIPMENT, $sampleShipment->getIdSampleShipment())->find(); while ($sample = $sampleQuery->read()) { $npd = NpdSheetQuery::create()->findByPK($sample->getIdNpdSheet()); if (ColorQuery::create()->whereAdd(Color::ID_COLOR, $sample->getIdColor())->count()) { $color = ColorQuery::create()->findByPK($sample->getIdColor()); } else { $color = new Color(); $color->setName('Any'); } $content[$i] = array($sample->getIdNpdSheet(), $npd->getDescription(), $sample->getIdSupplier(), $color->getName(), $sample->getQuantity(), '$' . number_format($sample->getCost(), 4) . $npd->getIdCurrency(), '$' . number_format($sample->getTotalAmmount(), 4) . $npd->getIdCurrency()); $i++; } $content[$i] = array('', '', '', '', '', 'Total', '$' . number_format($sampleQuery->getTotalAmmount(), 4) . $npd->getIdCurrency()); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; } $header = array('', '', '', '', '', '', ''); $tableColumnsWidth = array('small', 'medium', 'small', 'small', 'small', 'medium', 'medium'); // $content $title = $this->i18n->_('Sent Samples Report'); $fileName = $this->i18n->_('sent_samples_report'); $report = new SimpleListReport(); $report->setTableTitle($title); $report->setTableHeaders($header); $report->setTableContent($content); $report->setTableColumnsWidth($tableColumnsWidth); $report->setFilename($fileName); $report->createSpreadsheet(); }
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; }
/** * * @param NpdSheet $npd * @param SapSupplier $supplier * @param Color $color * @return array */ public function toArrayForList() { if (!empty($this->idNpdSheet)) { $npd = NpdSheetQuery::create()->findByPK($this->getIdNpdSheet()); } if (!$npd instanceof NpdSheet) { $npd = new NpdSheet(); } if (!empty($this->idSupplier)) { $supplier = SapSupplierQuery::create()->findByPK($this->getIdSupplier()); } if (!$supplier instanceof SapSupplier) { $supplier = new SapSupplier(); } if (!empty($this->idColor)) { $color = ColorQuery::create()->findByPK($this->getIdColor()); } if (!$color instanceof Color) { $color = new Color(); } return array('npd_status' => $npd->getStatusName(), 'name' => utf8_encode($npd->getName()), 'reference' => utf8_encode($npd->getReference()), 'supplier' => utf8_encode($supplier->getName()), 'color' => utf8_encode($color->getName()), 'id_sample' => $this->getIdSample(), 'id_npd_sheet' => $this->getIdNpdSheet(), 'quantity' => $this->getQuantity(), 'folio' => $this->getFolio(), 'notes' => utf8_encode($this->getNotes()), 'status' => $this->getStatus(), 'status_name' => $this->getStatusName(), 'deadline' => $this->getDeadline(), 'shipped_quantity' => $this->getShippedQuantity(), 'is_ordered' => $this->isOrdered(), 'is_requested_to_supplier' => $this->isRequestedToSupplier(), 'is_sent' => $this->isSent()); }
private function getSamplesInformation() { $this->SetFillColor(245, 245, 245); $this->SetLineWidth(0.1); $fill = true; $this->Cell(25, 10, 'Id Npd Sheet', 'TB', 0, 'C', $fill); $this->Cell(25, 10, 'Description', 'TB', 0, 'L', $fill); $this->Cell(25, 10, 'Supplier', 'TB', 0, 'R', $fill); $this->Cell(25, 10, 'Color', 'TB', 0, 'R', $fill); $this->Cell(25, 10, 'Quantity', 'TB', 0, 'R', $fill); $this->Cell(35, 10, 'Cost', 'TB', 0, 'R', $fill); $this->Cell(30, 10, 'Ammount', 'TB', 0, 'R', $fill); $this->Ln(); $fill = false; $this->SetFillColor(225, 225, 225); $borders = 'T'; $height = 6; while ($sample = $this->samples->read()) { if (NpdSheetQuery::create()->whereAdd(NpdSheet::ID_NPD_SHEET, $sample->getIdNpdSheet())->count()) { $npd = NpdSheetQuery::create()->findByPK($sample->getIdNpdSheet()); } else { $npd = new NpdSheet(); } if (ColorQuery::create()->whereAdd(Color::ID_COLOR, $sample->getIdColor())->count()) { $color = ColorQuery::create()->findByPK($sample->getIdColor()); } else { $color = new Color(); $color->setName('Any'); } $rowHeight = 0; $x = $this->GetX(); $y = $this->GetY(); $this->MultiCell(25, $height, $npd->getIdNpdSheet(), $borders, 'R', $fill, 0); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(30, $height, $npd->getName(), $borders, 'R', $fill, 0); $x += 30; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(20, $height, $sample->getIdSupplier(), $borders, 'R', $fill); $x += 20; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(25, $height, $color->getName(), $borders, 'R', $fill); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(25, $height, $sample->getQuantity(), $borders, 'R', $fill); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(35, $height, "\$" . number_format($sample->getCost(), 4) . $npd->getIdCurrency(), $borders, 'R', $fill); $x += 35; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(30, $height, "\$" . number_format($sample->getTotalAmmount(), 4) . $npd->getIdCurrency(), $borders, 'R', $fill); $x += 30; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->Ln($rowHeight); } $this->samples->rewind(); $this->Cell(25, $height, ' ', 'TB', 0, 'C', $fill); $this->Cell(25, $height, '', 'TB', 0, 'L', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(35, $height, 'Total', 'TB', 0, 'R', $fill); $this->Cell(30, $height, "\$" . number_format($this->samples->getTotalAmmount(), 4) . $npd->getIdCurrency(), 'TB', 0, 'R', $fill); $this->Ln(); }