/** * @author Jose luis * @return array $colors */ private function getCountries() { $query = CountryQuery::create()->fetchAll(); $array[''] = $this->i18n->_('Select a Country'); foreach ($query as $value) { $id = $value['id_country']; $array[$id] = $value['name']; } return $array; }
/** * */ public function exportToExcelAction() { $params = $this->getRequest()->getParams(); $proformasInvoice = ProformaInvoiceQuery::create()->filter($params)->find(); $proformasInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformasInvoice->getPrimaryKeys(), ProformaInvoiceEntryQuery::IN)->find(); $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $proformasInvoice->getDistinctSuppliers(), SupplierQuery::IN)->find(); $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $proformasInvoiceEntries->getIdProducts(), ProductQuery::IN)->find(); $currencies = CurrencyQuery::create()->find(); $countries = CountryQuery::create()->find(); require_once 'PHPExcel.php'; $objPHPExcel = new PHPExcel(); $activeSheet = $objPHPExcel->setActiveSheetIndex(0); $activeSheet->setCellValue('A1', $this->i18n->_('Proforma Invoice Folio'))->setCellValue('B1', $this->i18n->_('Proforma Invoice Number'))->setCellValue('C1', $this->i18n->_('Proforma Invoice Status'))->setCellValue('D1', $this->i18n->_('Supplier Code'))->setCellValue('E1', $this->i18n->_('Supplier Name'))->setCellValue('F1', $this->i18n->_('Destination Country'))->setCellValue('G1', $this->i18n->_('Creation Date'))->setCellValue('H1', $this->i18n->_('Line Number'))->setCellValue('I1', $this->i18n->_('Line Status'))->setCellValue('J1', $this->i18n->_('Parent Key'))->setCellValue('K1', $this->i18n->_('Product Key'))->setCellValue('L1', $this->i18n->_('Description'))->setCellValue('M1', $this->i18n->_('Quantity'))->setCellValue('N1', $this->i18n->_('Open Price'))->setCellValue('O1', $this->i18n->_('Import'))->setCellValue('P1', $this->i18n->_('Currency')); $i = 2; while ($proformasInvoice->valid()) { $proformaInvoice = $proformasInvoice->read(); $supplier = $suppliers->getByPK($proformaInvoice->getIdSupplier()); $country = $countries->getByPK($proformaInvoice->getIdDestinationCountry()); $proformaInvoiceEntries = $proformasInvoiceEntries->getByIdProformaInvoice($proformaInvoice->getIdProformaInvoice()); $currency = $currencies->getByPkOrEmpty($proformaInvoice->getIdCurrency()); $entriesCount = $i; while ($proformaInvoiceEntries->valid()) { $proformaInvoiceEntry = $proformaInvoiceEntries->read(); $product = $products->getByPK($proformaInvoiceEntry->getIdProduct()); $activeSheet->setCellValue('A' . $entriesCount, $proformaInvoice->getIdProformaInvoice())->setCellValue('B' . $entriesCount, $proformaInvoice->getFolio())->setCellValue('C' . $entriesCount, $proformaInvoice->getStatusName())->setCellValue('D' . $entriesCount, $supplier->getCardCode())->setCellValue('E' . $entriesCount, $supplier->getCardname())->setCellValue('F' . $entriesCount, utf8_encode($country->getName()))->setCellValue('G' . $entriesCount, $proformaInvoice->getDocDate())->setCellValue("H" . $entriesCount, $proformaInvoiceEntry->getLine())->setCellValue("I" . $entriesCount, $proformaInvoiceEntry->getStatusName())->setCellValue("J" . $entriesCount, $product->getKeyMother())->setCellValue("K" . $entriesCount, $product->getItemCode())->setCellValue("L" . $entriesCount, $product->getItemName())->setCellValue("M" . $entriesCount, $proformaInvoiceEntry->getQuantity())->setCellValue("N" . $entriesCount, $proformaInvoiceEntry->getPrice())->setCellValue("O" . $entriesCount, $proformaInvoiceEntry->getQuantity() * $proformaInvoiceEntry->getPrice())->setCellValue("P" . $entriesCount, $currency->getCurrCode()); $entriesCount++; } $i = $entriesCount; } header("Content-Type: application/vnd.ms-excel"); $date = \Zend_Date::now(); $fileName = $this->i18n->_("Proforma_invoice_report") . $date->get("ddMMyyyy"); header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\""); header("Cache-Control: max-age=0"); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save("php://output"); exit; }
public function getCountry() { $country = null; if (CountryQuery::create()->whereAdd(Country::CODE, $this->idCountry)->count()) { $country = CountryQuery::create()->findByPK($this->idCountry)->getName(); } return $country; }
/** * @author Erick Guevara Martínez */ public function getAccessRoleCountriesAction() { $idAccesRole = $this->getRequest()->getParam("id_access_role"); $accessRoleCountries = AccessRoleQuery::create()->innerJoinAccesRoleCountry()->addColumn("AccessRole2Country.id_country")->whereAdd("AccessRole2Country.id_access_role", $idAccesRole)->fetchCol(); if (count($accessRoleCountries) > 0) { $countries = CountryQuery::create()->whereAdd(Country::CODE, $accessRoleCountries)->find(); } else { $countries = new CountryCollection(); } die(Zend_Json::encode(array("accessRoleCountries" => $countries->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'; }
/** * * @param unknown_type $idFolioImport * @return string */ private function getFolioImportCountry($idFolioImport) { $port = FolioImportQuery::create()->findByPK($idFolioImport)->getIdPortCustom(); $idCountry = PortCustomQuery::create()->findByPK($port)->getIdCountry(); $value = CountryQuery::create()->findByPK($idCountry)->getName(); return $value; }
public function exportToExcelAction() { $params = $this->getRequest()->getParams(); $allPurchaseOrderEntries = PurchaseOrderEntryQuery::create()->find(); $purchaseOrders = PurchaseOrderQuery::create()->filter($params)->addDescendingOrderBy(PurchaseOrder::PURCHASE_ORDER_DATE)->whereAdd("PurchaseOrder.DocType", "I")->whereAdd("PurchaseOrderEntry.ItemCode", "TR%", 'NOT LIKE')->whereAdd("PurchaseOrderEntry.WhsCode", "9999", PurchaseOrderQuery::NOT_LIKE)->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $allPurchaseOrderEntries->getDistinctPurchaseOrder(), PurchaseOrderQuery::IN)->find(); $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $allPurchaseOrderEntries->getProducts(), ProductQuery::IN)->find(); $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::ID_SUPPLIER, $purchaseOrders->getDistinctSuppliers(), SapSupplierQuery::IN)->find(); $warehousesStores = WarehouseStoreQuery::create()->whereAdd(WarehouseStore::CODE, $allPurchaseOrderEntries->getDistinctIdWarehouseStore(), WarehouseStoreQuery::IN)->find(); $warehouses = WarehouseQuery::create()->whereAdd(Warehouse::CODE, $warehousesStores->getDistinctWarehouses(), WarehouseQuery::IN)->find(); $currencies = CurrencyQuery::create()->find(); $countries = CountryQuery::create()->find(); require_once 'PHPExcel.php'; $objPHPExcel = new PHPExcel(); $activeSheet = $objPHPExcel->setActiveSheetIndex(0); $activeSheet->setCellValue('A1', $this->i18n->_('Purchase Order Folio'))->setCellValue('B1', $this->i18n->_('Destination Country'))->setCellValue('C1', $this->i18n->_('Supplier Code'))->setCellValue('D1', $this->i18n->_('Supplier Name'))->setCellValue('E1', $this->i18n->_('Creation Date'))->setCellValue('F1', $this->i18n->_('Status'))->setCellValue('G1', $this->i18n->_('Entry Line'))->setCellValue('H1', $this->i18n->_('Product Code'))->setCellValue('I1', $this->i18n->_('Product Description'))->setCellValue('J1', $this->i18n->_('Amount'))->setCellValue('K1', $this->i18n->_('Price'))->setCellValue('L1', $this->i18n->_('Import'))->setCellValue('M1', $this->i18n->_('Currency'))->setCellValue('N1', $this->i18n->_('Location'))->setCellValue('O1', $this->i18n->_('Warehouse')); $activeSheet->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $i = 2; while ($purchaseOrders->valid()) { $purchaseOrder = $purchaseOrders->read(); $currency = $currencies->getByPkOrEmpty($purchaseOrder->getIdCurrency()); $supplier = $suppliers->getByPkOrElse($purchaseOrder->getIdSupplier(), new SapSupplier()); $country = $countries->getByPK($purchaseOrder->getIdDestinationCountry()); $purchaseOrderEntries = $allPurchaseOrderEntries->filterByPurchaseOrderPk($purchaseOrder->getIdPurchaseOrder()); $entriesCount = $i; while ($purchaseOrderEntries->valid()) { $purchaseOrderEntry = $purchaseOrderEntries->read(); $product = $products->getByPK($purchaseOrderEntry->getIdProduct()) ? $products->getByPK($purchaseOrderEntry->getIdProduct()) : new Product(); $warehouseStore = $warehousesStores->getByPkOrElse($purchaseOrderEntry->getIdWarehouseStore(), new WarehouseStore()); $warehouse = $warehouseStore->getLocation() > 0 ? $warehouses->getByPK($warehouseStore->getLocation()) : new WarehouseStore(); $activeSheet->setCellValue('A' . $entriesCount, $purchaseOrder->getSapDocumentNumber())->setCellValue('B' . $entriesCount, utf8_encode($country->getName()))->setCellValue('C' . $entriesCount, $supplier->getCardCode())->setCellValue('D' . $entriesCount, $supplier->getCardname())->setCellValue('E' . $entriesCount, $purchaseOrder->getPurchaseOrderDate())->setCellValue('F' . $entriesCount, $purchaseOrder->getStatusName())->setCellValue("G" . $entriesCount, $purchaseOrderEntry->getLine())->setCellValue("H" . $entriesCount, $product->getItemCode())->setCellValue("I" . $entriesCount, $product->getItemName())->setCellValue("J" . $entriesCount, $purchaseOrderEntry->getAmount())->setCellValue("K" . $entriesCount, $purchaseOrderEntry->getPrice())->setCellValue("L" . $entriesCount, $purchaseOrderEntry->getImport())->setCellValue("M" . $entriesCount, $currency->getCurrCode())->setCellValue("N" . $entriesCount, $warehouse->getName())->setCellValue("O" . $entriesCount, $warehouseStore->getName()); $entriesCount++; } $i = $entriesCount; } $columns = range('A', 'O'); foreach ($columns as $column) { $activeSheet->getColumnDimension($column)->setAutoSize(true); } header("Content-Type: application/vnd.ms-excel"); $date = \Zend_Date::now(); $fileName = $this->i18n->_("Purchase_orders_report") . $date->get("ddMMyyyy"); header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\""); header("Cache-Control: max-age=0"); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save("php://output"); exit; }
private function getCountries() { $query = CountryQuery::create()->fetchAll(); // print_r($query); // die; $values[''] = $this->i18n->_('All'); foreach ($query as $value) { $i++; $id = $value['Code']; $values[$id] = $value['Name']; } return $values; }
/** * */ public function getListResultsAction() { $params = $this->getRequest()->getParams(); $countries = CountryQuery::create()->filter($params)->findByPage($params['page'], $this->getMaxPerPage()); die(json_encode($countries->toArray())); }
/** * */ public function exportToExcelAction() { $post['name'] = utf8_decode($this->getRequest()->getParam('name')); $post['name'] = '%' . $post['name'] . '%'; $post['status'] = $this->getRequest()->getParam('status'); $post['sap_id_bussiness_associate'] = $this->getRequest()->getParam('sap_id_bussiness_associate') . '%'; $customsBrokers = CustomsBrokerQuery::create()->filter($post)->find(); if (!$customsBrokers->isEmpty()) { $i = 1; while ($customsBroker = $customsBrokers->read()) { $address = AddressQuery::create()->innerJoinCompany()->whereAdd('Address2Company.id_company', $customsBroker->getIdCompany())->find()->getOne(); $company = CompanyQuery::create()->innerJoinAddress()->whereAdd('Company2Address.id_company', $customsBroker->getIdCompany())->find()->getOne(); $country = \Application\Query\CountryQuery::create()->whereAdd(\Application\Model\Bean\Country::CODE, $address->getCountry())->find()->getOne(); $data[$i] = array($company->getSapIdBussinessassociate(), $customsBroker->getName(), $country ? $country->getName() : null, $address->getState(), $address->getStreet(), $address->getSettlement(), $address->getDistrict(), $address->getCity(), $address->getZipCode(), $customsBroker->getStatusName()); $i++; } $header = array($this->i18n->_('SAP ID Business Associate'), $this->i18n->_('Name'), $this->i18n->_('Country'), $this->i18n->_('State'), $this->i18n->_('Street'), $this->i18n->_('Settlement'), $this->i18n->_('District'), $this->i18n->_('City'), $this->i18n->_('Zip Code'), $this->i18n->_('Status')); $title = $this->i18n->_('Customs Brokers Report'); $filename = 'customs_brokers_report'; $customsBrokersReport = new SimpleListReport(); $customsBrokersReport->setTableHeaders($header); $customsBrokersReport->setTableContent($data); $customsBrokersReport->setTableTitle($title); $customsBrokersReport->setFilename($filename); $customsBrokersReport->createSpreadsheet(); } else { $filter = $this->createFilterForUrl($post); $this->setFlash("error", $this->i18n->_('No records')); $this->_redirect('customs-broker/list'); } }
public function newAction() { $this->view->contentTitle = 'New Forwarder'; // Create a forwarder object $this->view->forwarder = new Forwarder(); $this->view->setTpl('Form'); $this->view->viewAction = "create"; $this->view->countries = \Application\Query\CountryQuery::create()->find()->toCombo(); $this->view->ports = $ports = array("" => "Select Port") + \Application\Query\PortCustomQuery::create()->actives()->find()->toCombo(); $courtyards = new stdClass(); $courtyards->couryard = new Courtyard(); $this->view->courtyards = $courtyards; // $contacts = ContactQuery::create()->whereAdd(Contact::ID_COMPANY,null)->find()->toCombo(); $contacts = array(); //die(print_r($contacts)); $this->view->contacts = array("" => '** Select a Contact **') + $contacts; $this->view->contactList = $contacts; }
/** * */ public function exportToExcelAction() { $params = $this->getRequest()->getParams(); $params['name'] = "%" . $params['name'] . "%"; $query = PortCustomQuery::create()->filter($params)->find(); $report = new SimpleListReport(); $headers = array('Code', 'Name', 'International Code', 'Air', 'Ground', 'Sea', 'Country', 'Status'); foreach ($query as $key => $object) { $content[$key][] = $object->getCode(); $content[$key][] = utf8_encode($object->getName()); $content[$key][] = $object->getInternationalCode(); if ($object->getAir() == 1) { $content[$key][] = Symbols::$checkMark; } else { $content[$key][] = Symbols::$crossMark; } if ($object->getGround() == 1) { $content[$key][] = Symbols::$checkMark; } else { $content[$key][] = Symbols::$crossMark; } if ($object->getSea() == 1) { $content[$key][] = Symbols::$checkMark; } else { $content[$key][] = Symbols::$crossMark; } if (CountryQuery::create()->whereAdd(Country::CODE, $object->getIdCountry())->count()) { $content[$key][] = utf8_encode(CountryQuery::create()->findByPK($object->getIdCountry())->getName()); } else { $content[$key][] = $this->i18n->_('Not Available'); } $content[$key][] = $object->getStatusName(); } $title = $this->i18n->_('Ports Report'); $filename = 'ports_report'; $report->setTableHeaders($headers); $report->setTableContent($content); $report->setTableTitle($title); $report->setFilename($filename); // $report->setTableColumnsWidth($columsWidth); $report->createSpreadsheet(); }
public function exportToExcelAction() { $params = $this->getRequest()->getParams(); $requisitions = RequisitionQuery::create()->filter($params)->whereAdd(Requisition::STATUS, Requisition::$Status["Inactive"], BaseQuery::NOT_EQUAL)->find(); $requisitionIds = RequisitionQuery::create()->filter($params)->whereAdd(Requisition::STATUS, Requisition::$Status["Inactive"], BaseQuery::NOT_EQUAL)->fetchCol(); $allRequisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_REQUISITION, $requisitionIds, RequisitionEntryQuery::IN)->find(); $currencies = CurrencyQuery::create()->find(); $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $allRequisitionEntries->getDistinctProducts(), ProductQuery::IN)->find(); $countries = CountryQuery::create()->find(); $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $allRequisitionEntries->getDistinctSuppliers(), SupplierQuery::IN)->find(); require_once 'PHPExcel.php'; $objPHPExcel = new PHPExcel(); $activeSheet = $objPHPExcel->setActiveSheetIndex(0); $activeSheet->setCellValue('A1', $this->i18n->_('Requisition Folio'))->setCellValue('B1', $this->i18n->_('Requisition Status'))->setCellValue('C1', $this->i18n->_('Reference'))->setCellValue('D1', $this->i18n->_('Creation Date'))->setCellValue('E1', $this->i18n->_('Destination'))->setCellValue('F1', $this->i18n->_('Parent Key'))->setCellValue('G1', $this->i18n->_('Product Status'))->setCellValue('H1', $this->i18n->_('Product Code'))->setCellValue('I1', $this->i18n->_('Product Description'))->setCellValue('J1', $this->i18n->_('Line Status'))->setCellValue('K1', $this->i18n->_('Supplier Default Code'))->setCellValue('L1', $this->i18n->_('Supplier Default Name'))->setCellValue('M1', $this->i18n->_('Ammount'))->setCellValue('N1', $this->i18n->_('Target Price'))->setCellValue('O1', $this->i18n->_('Price'))->setCellValue('P1', $this->i18n->_('Import'))->setCellValue('Q1', $this->i18n->_('currency')); $i = 2; while ($requisitions->valid()) { $requisition = $requisitions->read(); $requisitionEntries = $allRequisitionEntries->filterByIdRequisition($requisition->getIdRequisition()); $country = $countries->getByPK($requisition->getIdDestinationCountry()); $entriesCount = $i; while ($requisitionEntries->valid()) { $requisitionEntry = $requisitionEntries->read(); $product = $products->containsIndex($requisitionEntry->getIdProduct()) ? $products->getByPK($requisitionEntry->getIdProduct()) : new Product(); $supplier = $requisitionEntry->getIdSupplierDefault() > 0 ? $suppliers->getByPkOrElse($requisitionEntry->getIdSupplierDefault(), new SapSupplier()) : new SapSupplier(); $currency = $currencies->getByPK($requisitionEntry->getIdCurrency()); $activeSheet->setCellValue("F" . $entriesCount, $product->getKeyMother())->setCellValue("G" . $entriesCount, $product->getStatus())->setCellValue("H" . $entriesCount, $product->getItemCode())->setCellValue("I" . $entriesCount, $product->getItemName())->setCellValue("J" . $entriesCount, $requisitionEntry->getStatusName())->setCellValue("K" . $entriesCount, $supplier->getCardCode())->setCellValue("L" . $entriesCount, $supplier->getCardname())->setCellValue("M" . $entriesCount, $requisitionEntry->getQuantity())->setCellValue("N" . $entriesCount, $product->getCost())->setCellValue("O" . $entriesCount, $requisitionEntry->getPrice())->setCellValue("P" . $entriesCount, $requisitionEntry->getImport())->setCellValue("Q" . $entriesCount, $currency->getCurrCode()); $entriesCount++; } $activeSheet->mergeCells('A' . $i . ':A' . ($entriesCount - 1))->setCellValue('A' . $i, $requisition->getIdRequisition())->mergeCells('B' . $i . ':B' . ($entriesCount - 1))->setCellValue('B' . $i, $requisition->getStatusName())->mergeCells('C' . $i . ':C' . ($entriesCount - 1))->setCellValue('C' . $i, $requisition->getNumRequisition())->mergeCells('D' . $i . ':D' . ($entriesCount - 1))->setCellValue('D' . $i, $requisition->getDate())->mergeCells('E' . $i . ':E' . ($entriesCount - 1))->setCellValue('E' . $i, utf8_encode($country->getName())); $i = $entriesCount; } header("Content-Type: application/vnd.ms-excel"); $date = \Zend_Date::now(); $fileName = $this->i18n->_("Requisitions_report") . $date->get("ddMMyyyy"); header("Content-Disposition: attachment; filename=\"{$fileName}.xlsx\""); header("Cache-Control: max-age=0"); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save("php://output"); exit; }