示例#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
 /**
  * 
  */
 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));
 }
示例#3
0
 /**
  * @return json
  */
 public function getListResultsAction()
 {
     $params = $this->getRequest()->getParams();
     $colors = ColorQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find();
     while ($color = $colors->read()) {
         $color->setName(utf8_encode($color->getName()));
     }
     die(json_encode($colors->toArray()));
 }
示例#4
0
 public function orderSamplesAction()
 {
     $this->view->contentTitle = 'Order Samples';
     $colorsQuery = ColorQuery::create()->actives()->find();
     $colors[""] = "**  Select a color  **";
     foreach ($colorsQuery as $color) {
         $colors[$color->getIdColor()] = $color->getName();
     }
     $this->view->colors = $colors;
 }
 protected function getSupplierColors($idNPDSupplier)
 {
     return ColorQuery::create()->innerJoinNpdSheetSupplier()->whereAdd("NpdSheetSupplier." . NpdSheetSupplier::ID_NPD_SUPPLIER, $idNPDSupplier, BaseQuery::EQUAL)->find();
 }
示例#6
0
 public function npdKeyAction()
 {
     $this->view->setTpl('Npd-key');
     $this->view->contentTitle = 'NPD Key';
     $idNPDSheet = $this->getRequest()->getParam('id');
     $this->view->productNewKey = $this->getRequest()->getParam('product-new-key');
     if (!empty($idNPDSheet)) {
         $this->view->npdSheet = $npdSheet = NpdSheetQuery::create()->findByPK($idNPDSheet);
     }
     $params = $this->getRequest()->getParams();
     if ($this->getRequest()->isPost()) {
         $this->view->post = $post = $this->getRequest()->getParams();
         $this->view->subGroup = $subFamily = SubfamilyQuery::create()->findByPK($post['id_subfamily']);
         $this->view->family = $family = FamilyQuery::create()->findByPK($post['id_family']);
         $this->view->productGroup = $productGroup = ProductGroupQuery::create()->findByPK($post['id_product_group']);
         $this->view->idPg = $family->getIdFamily();
         $this->view->IdSd = $subFamily->getIdSubfamily();
     } else {
         if (!empty($npdSheet)) {
             if ($npdSheet->getIdSubfamily() > 0) {
                 $this->view->subGroup = $subFamily = SubfamilyQuery::create()->findByPK($npdSheet->getIdSubfamily());
             } else {
                 $this->view->subGroup = $subFamily = new Subfamily();
             }
             $this->view->family = $family = FamilyQuery::create()->findByPK($npdSheet->getIdFamily());
             $this->view->productGroup = $productGroup = ProductGroupQuery::create()->findByPK($family->getIdProductGroup());
             $this->view->idPg = $family->getIdFamily();
             /*if($subFamily > 0){
             		 $idSd = $subFamily->getIdSubfamily();
             		}
             		$this->view->IdSd = $idSd;*/
         }
     }
     // Get Product Groups
     $productGroupQuery = ProductGroupQuery::create();
     $productGroupQuery->where()->setOR();
     $productGroupQuery->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $productGroup->getIdProductGroup(), ProductGroupQuery::EQUAL);
     $productGroupCombo = $productGroupQuery->actives()->find()->toCombo();
     $this->view->productGroups = $productGroupCombo;
     // Get Families
     $familyQuery = FamilyQuery::create();
     $familyQuery->where()->setOR();
     $familyQuery->whereAdd(Family::ID_PRODUCT_GROUP, $family->getIdProductGroup(), FamilyQuery::EQUAL);
     $familyQuery->where()->setAND();
     $familyQuery->whereAdd(ProductGroup::ID_PRODUCT_GROUP, $productGroup->getIdProductGroup());
     $familyCombo = $familyQuery->actives()->find()->toCombo();
     // Get subgfamilies
     $subfamiliesQuery = SubfamilyQuery::create();
     if ($subFamily->getIdSubfamily() > 0) {
         $subfamiliesQuery->where()->setOR();
         $subfamiliesQuery->whereAdd(Subfamily::ID_SUBFAMILY, $subFamily->getIdSubfamily(), SubfamilyQuery::EQUAL);
         $subfamiliesQuery->where()->setAND();
     }
     $subfamiliesQuery->whereAdd(Family::ID_FAMILY, $family->getIdFamily());
     $subGroupCombo = array("" => "Select Subfamily") + $subfamiliesQuery->actives()->find()->toCombo();
     // Get Colors NPD
     $colorsNpd = ColorQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheet.' . NpdSheet::ID_NPD_SHEET, $idNPDSheet)->find();
     $productColors = ColorQuery::create()->find()->toCombo();
     $select = array('' => $this->i18n->_('** Select **'));
     $this->view->colors = $select + $colorsNpd->toCombo();
     $this->view->brands = $brands = $select + \Application\Query\BrandQuery::create()->actives()->find()->toCombo();
     $this->view->productColors = $productColors;
     //search families for list products
     $idProductGroup = $this->getRequest()->getParam('id_product_group');
     $clvProductGroup = $this->getRequest()->getParam('clv_family');
     $idCategory = $this->getRequest()->getParam('clv_category');
     $clvSubcategory = $this->getRequest()->getParam('clv_subcategory');
     $clvcomposition = $this->getRequest()->getParam('clv_composition');
     $clvBrand = $this->getRequest()->getParam('clv_brand');
     $clvColor = $this->getRequest()->getParam('clv_color');
     $idColor = $this->getRequest()->getParam('id_color');
     if (isset($clvColor)) {
         $colorCode = $this->i18n->_("Not available");
     } else {
         $colorCode = $clvColor;
     }
     $productsFam = ProductQuery::create()->distinct()->addColumns(array('Product.' . Product::ID_PRODUCT_GROUP, 'ProductGroup.' . ProductGroup::CODE))->innerJoinProductGroup()->addAscendingOrderBy('Product.' . Product::ID_PRODUCT_GROUP)->fetchAll();
     foreach ($productsFam as $i => $productFam) {
         if ($productsFam[$i]["id_product_group"] == $idProductGroup) {
             $productGroupIds = array("prevFamily" => $productsFam[$i - 1]["id_product_group"], "productFamily" => $productsFam[$i]["id_product_group"], "nextFamily" => $productsFam[$i + 1]["id_product_group"]);
         }
     }
     $wantedProducts = ProductQuery::create();
     $wantedProducts->where()->setOR();
     $seachProducts = $wantedProducts->whereAdd('Product.' . Product::ID_PRODUCT_GROUP, $productGroupIds['productFamily'])->addColumns(array('Product.' . Product::ITEM_CODE, 'Product.' . Product::ITEM_NAME, 'Product.' . Product::STATUS, 'Product.' . Product::KEY_MOTHER, 'Product.' . Product::ID_COLOR))->whereAdd('Product.' . Product::ID_PRODUCT_GROUP, $productGroupIds['prevFamily'])->whereAdd('Product.' . Product::ID_PRODUCT_GROUP, $productGroupIds['nextFamily'])->fetchAll();
     $newProduct = array(array('item_code' => $clvProductGroup . $idCategory . $clvSubcategory . $clvcomposition . $clvBrand . $clvColor, 'item_name' => $npdSheet->getName(), 'status' => 'H', 'key_mother' => $clvProductGroup . $idCategory . $clvSubcategory . $clvcomposition, 'id_color' => $colorCode));
     //order total products
     $products = array_merge($seachProducts, $newProduct);
     array_multisort($products);
     //save index new product
     foreach ($products as $key => $val) {
         if ($newProduct[0]['item_code'] == $val['item_code']) {
             $index = $key;
         }
     }
     $parentKeys = ProductQuery::create()->whereAdd(Product::KEY_MOTHER, $newProduct[0]['key_mother'])->find()->count();
     $idSupplierAut = SupplierBudgetQuery::create()->innerJoinNpdSheetSupplier()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->whereAdd('NpdSheetSupplier.' . NpdSheetSupplier::ID_NPD_SHEET, $idNPDSheet)->whereAdd('SupplierBudget.' . SupplierBudget::IS_AUTHORIZED, 1)->fetchAll();
     // die(print_r($idSupplierAut));
     if ($idSupplierAut) {
         $currency = CurrencyQuery::create()->whereAdd(Currency::ID_CURRENCY, SapSupplierQuery::create()->findByPK($idSupplierAut[0]['id_supplier'])->getIdCurrency())->findOne();
     } else {
         $this->setFlash('error', $this->i18n->_("there is no authorized supplier"));
         return $this->getHelper('redirector')->goto('list');
     }
     $this->view->new = $newProduct[0]['key_mother'];
     $this->view->families = $familyCombo;
     $this->view->subgroups = $subGroupCombo;
     $this->view->products = $products;
     $this->view->index = $index;
     $this->view->parentKeys = $parentKeys;
     $this->view->supplier = $idSupplierAut[0]['id_supplier'];
     $this->view->currency = $currency->getName();
 }
示例#7
0
 /**
  * 
  * @return \Application\Model\Collection\ColorCollection
  */
 public function setColorCollection()
 {
     $this->colors = ColorQuery::create()->whereAdd(Color::ID_COLOR, $this->getDistinctColors(), ColorQuery::IN)->find();
 }
示例#8
0
 /**
  *
  * Gets all Products from SAP, searches the DB for the itemcode, then updates or creates
  */
 public function syncProductsAction()
 {
     $r = SapProductQuery::create()->whereAdd(SapProduct::INVNTITEM, "Y")->find();
     $errors = 0;
     $new = 0;
     $updated = 0;
     echo "<pre>";
     echo "Name, itemcode, clave madre, resultado, mensaje \n";
     while ($r->valid()) {
         $save = 0;
         $sapProduct = $r->read();
         echo "\"" . trim($sapProduct->getItemname()) . "\", " . $sapProduct->getItemcode() . ", " . $sapProduct->getUMadre9() . ", ";
         if (strlen($sapProduct->getItemcode()) != 11) {
             echo "1, Error! ItemCode invalido: len " . strlen($sapProduct->getItemcode()) . "\n";
             $errors++;
             continue;
         }
         $product = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $sapProduct->getItemcode(), ProductQuery::EQUAL)->findOne();
         if (!$product instanceof Product) {
             $product = new Product();
             $save = 1;
         }
         $brand = BrandQuery::create()->whereAdd(Brand::CODE, substr($sapProduct->getItemcode(), 7, 2))->findOne();
         if (!$brand instanceof Brand) {
             echo "2, Error! No Brand: " . substr($sapProduct->getItemcode(), 7, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdBrand($brand->getIdBrand());
         $color = ColorQuery::create()->whereAdd(Color::CODE, substr($sapProduct->getItemcode(), 9, 2))->findOne();
         if (!$color instanceof Color) {
             echo "3, Error! No Color: " . substr($sapProduct->getItemcode(), 9, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdColor($color->getIdColor());
         $customsTariffCode = CustomsTariffCodeQuery::create()->whereAdd(CustomsTariffCode::CODE, $sapProduct->getCstGrpCode())->findOne();
         if (!$customsTariffCode instanceof CustomsTariffCode) {
             echo "4, Error! No Tax Code: " . $sapProduct->getCstGrpCode() . "\n";
             $errors++;
             continue;
         }
         $product->setIdCustomsTariffCode($customsTariffCode->getIdCustomsTariffCode());
         $productGroup = ProductGroupQuery::create()->whereAdd(ProductGroup::CODE, substr($sapProduct->getItemcode(), 0, 2))->findOne();
         if (!$productGroup instanceof ProductGroup) {
             echo "5, Error! No ProductGroup: " . substr($sapProduct->getItemcode(), 0, 2) . "\n";
             $errors++;
             continue;
         }
         $product->setIdProductGroup($productGroup->getIdProductGroup());
         $family = FamilyQuery::create()->whereAdd(Family::CODE, substr($sapProduct->getItemcode(), 2, 1))->whereAdd(Family::ID_PRODUCT_GROUP, $productGroup->getIdProductGroup())->findOne();
         if (!$family instanceof Family) {
             echo "6, Error! No Family: " . substr($sapProduct->getItemcode(), 2, 1) . "\n";
             $errors++;
             continue;
         }
         $product->setIdFamily($family->getIdFamily());
         $subfamily = SubfamilyQuery::create()->whereAdd(Subfamily::CODE, substr($sapProduct->getItemcode(), 3, 1))->whereAdd(Subfamily::ID_FAMILY, $family->getIdFamily())->findOne();
         if (!$subfamily instanceof Subfamily) {
             echo "7, Error! No SubFamily: " . substr($sapProduct->getItemcode(), 3, 1) . "\n";
             $errors++;
             continue;
         }
         $product->setIdSubfamily($subfamily->getIdSubfamily());
         $product->setBuyUnit($sapProduct->getBuyUnitMsr());
         $product->setCost(0);
         $product->setIdCurrency(1);
         $product->setIdIncoterm(1);
         $product->setImportant(0);
         $product->setInventaryItem($sapProduct->getInvntItem() == 'Y' ? 1 : 0);
         $product->setInventoryUnit($sapProduct->getInvntryUom());
         $product->setItemCode($sapProduct->getItemcode());
         $product->setItemName($sapProduct->getItemname());
         $product->setKeyMother(substr($sapProduct->getItemcode(), 0, 7));
         $product->setMcDepth($sapProduct->getUMCProfundida());
         $product->setMcFront($sapProduct->getUMCFrente());
         $product->setMcHeight($sapProduct->getUMCAltura());
         $product->setMcParts($sapProduct->getUPzasXCaja());
         $product->setMcWeight($sapProduct->getUMCPeso());
         $product->setNumBuy($sapProduct->getNumInBuy());
         $product->setNumSales($sapProduct->getNumInSales());
         $product->setPurchaseItem($sapProduct->getPrchseItem() == 'Y' ? 1 : 0);
         $product->setPzaDepth($sapProduct->getUPzaprofu());
         $product->setPzaDiameter($sapProduct->getUPzadiametro());
         $product->setPzaFront($sapProduct->getUPzafrente());
         $product->setPzaHeight($sapProduct->getUPpzaaltura());
         $product->setPzaWeight($sapProduct->getUPesoXPza());
         $product->setRescue(0);
         $product->setSaiUnit($sapProduct->getSAlUnitMsr());
         $product->setSellItem($sapProduct->getSellItem() == 'Y' ? 1 : 0);
         $product->setStatus($sapProduct->getSWW());
         if ($save) {
             $this->getProductCatalog()->create($product);
             $new++;
         } else {
             $this->getProductCatalog()->update($product);
             $updated++;
         }
         echo "0, Ok! \n";
     }
     echo "\n\nTotals:\nErrors: " . $errors . "\nNew: " . $new . "\nUpdated: " . $updated;
     die;
 }
示例#9
0
 /**
  * 
  */
 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();
 }
示例#10
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;
 }
示例#11
0
文件: Sample.php 项目: Eximagen/sochi
 /**
  * 
  * @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());
 }
示例#12
0
 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();
 }