public function formAction()
 {
     $id = $this->getRequest()->getParam('id');
     try {
         if (empty($id)) {
             throw new ProductAntidumpingDutyException($this->i18n->_('The product id was not defined'));
         }
         $product = ProductQuery::create()->findByPK($id);
         if (!$product instanceof Product) {
             throw new ProductAntidumpingDutyException($this->i18n->_('The Product was not found'));
         }
         $productAntidumpingDuty = ProductAntidumpingDutyQuery::create()->findByParentKey($product->getKeyMother());
         if (!$productAntidumpingDuty instanceof ProductAntidumpingDuty) {
             $productAntidumpingDuty = new ProductAntidumpingDuty();
         }
         $productAntidumpingDuty->setParentKey($product->getKeyMother());
         $comboHeader = $this->i18n->_('Select One');
         $header = array('' => $comboHeader);
         $this->view->currencies = CurrencyQuery::create()->find()->toCombo($comboHeader);
         $this->view->types = $header + array_flip(ProductAntidumpingDuty::$Type);
         $this->view->rules = $header + array_flip(ProductAntidumpingDuty::$Rule);
         $this->view->contentTitle = $this->i18n->_('Compensatory Fee');
         $this->view->productAntidumpingDuty = $productAntidumpingDuty;
     } catch (ProductAntidumpingDutyException $e) {
         $this->setFlash('error', $e->getMessage());
         $this->_redirect('product/list');
     }
 }
Пример #2
0
 /**
  *
  */
 public function exportToExcelAction()
 {
     $post = $this->getRequest()->getParams();
     $post['id_transit'] = "%" . $post['id_transit'] . "%";
     $freightFares = FreightFareQuery::create()->filter($post)->find();
     $i = 1;
     while ($freightFare = $freightFares->read()) {
         $port = \Application\Query\PortCustomQuery::create()->whereAdd(PortCustom::ID_PORT_CUSTOM, $freightFare->getFobPort())->findOne();
         $destination = \Application\Query\PortCustomQuery::create()->whereAdd(PortCustom::ID_PORT_CUSTOM, $freightFare->getDestinationPort())->findOne();
         $freightTYpe = FreightTypeQuery::create()->whereAdd(FreightType::ID_FREIGHT_TYPE, $freightFare->getIdFreightType())->findOne();
         $forwarder = ForwarderQuery::create()->whereAdd(Forwarder::ID_FORWARDER, $freightFare->getIdForwarder())->findOne();
         $currency = \Application\Query\CurrencyQuery::create()->whereAdd(\Application\Model\Bean\Currency::CURRCODE, $freightFare->getIdCurrency())->findOne();
         $data[$i] = array($freightFare->getIdFreightFare(), $freightFare->getIdTransit(), $port->getName(), $destination->getName(), $freightTYpe->getName(), $freightFare->getNotes(), $freightFare->getTt(), $freightFare->getFrecuency(), $forwarder->getName(), $freightFare->getGoodThrough(), $freightFare->getUnitName(), $freightFare->getUNitCost(), $freightFare->getPeak(), $freightFare->getStatusName());
         $i++;
     }
     $header = array($this->i18n->_('ID'), $this->i18n->_('ID-Transit'), $this->i18n->_('FOB Port'), $this->i18n->_('Destination Port'), $this->i18n->_('Freight Type'), $this->i18n->_('Notes'), $this->i18n->_('Transit Time'), $this->i18n->_('Frecuency'), $this->i18n->_('Forwarder'), $this->i18n->_('Good Through'), $this->i18n->_('Unit'), $this->i18n->_('Unit Cost'), $this->i18n->_('Peak/Unit'), $this->i18n->_('Status'));
     $title = $this->i18n->_('Freight Fares Report');
     $fileName = $this->i18n->_('Freight_fares_report');
     $tableColumnsWidth = array('mini', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'medium', 'mini', 'mini', 'mini');
     $report = new SimpleListReport();
     $report->setTableTitle($title);
     $report->setTableHeaders($header);
     $report->setTableContent($data);
     $report->setFilename($fileName);
     $report->setTableColumnsWidth($tableColumnsWidth);
     $report->createSpreadsheet();
 }
Пример #3
0
 public function paidBills(array $filters, $page = 1, $maxPerPage)
 {
     $payments = $this->getProgrammedPayments($filters, true);
     $currencies = CurrencyQuery::create()->find();
     $condensedProgrammedPayments = $this->getCondensedProgrammedPayments($payments, false);
     $suppliers = $this->getSuppliers($payments);
     $offset = $page * $maxPerPage - $maxPerPage;
     $pageDates = array_slice($condensedProgrammedPayments->getDatesAndIndex("asc"), $offset, $maxPerPage);
     $paymentsByDate = array();
     foreach ($pageDates as $pageDate) {
         $condensedProgrammedPayment = $condensedProgrammedPayments->getByPK($pageDate["index"]);
         $supplier = $suppliers->getByPkOrElse($condensedProgrammedPayment->getIdSupplier(), new SapSupplier());
         $paymentsByDate[] = array("dueDate" => $condensedProgrammedPayment->getDueDate(), "idSupplier" => $supplier->getCardCode(), "supplierName" => $supplier->getCardname(), "type" => $condensedProgrammedPayment->getType(), "typeName" => $condensedProgrammedPayment->getTypeName(), "idDocument" => $condensedProgrammedPayment->getIdDocument(), "sapDocnum" => $condensedProgrammedPayment->getSapDocnum(), "currency" => $condensedProgrammedPayment->getCurrency(), "ammount" => $condensedProgrammedPayment->getAmmount(), "credits" => $condensedProgrammedPayment->getCredits(), "pendingBalance" => $condensedProgrammedPayment->getPendingBalance(), "idEvent" => $condensedProgrammedPayment->getIdEvent(), "programmedPaymentIds" => $condensedProgrammedPayment->getProgrammedPaymentIds(), "status" => $condensedProgrammedPayment->getStatus());
     }
     return $paymentsByDate;
 }
Пример #4
0
 /**
  *
  */
 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;
 }
Пример #5
0
 /**
  * @author Jose luis
  */
 public function getCurrencyAction()
 {
     $id = $this->getRequest()->getParam('id');
     $idCurrency = SapSupplierQuery::create()->findByPK($id)->getCurrency();
     if (CurrencyQuery::create()->whereAdd(Currency::CURRCODE, $idCurrency)->find()->count()) {
         $currency = CurrencyQuery::create()->findByPK($idCurrency)->getCurrName();
     } else {
         $currency = '';
     }
     die(json_encode($currency));
 }
 public function toPaymentAction()
 {
     try {
         //die("<pre>".print_r($this->getRequest()->getParams(), true));
         $ids = Zend_Json::decode(stripslashes($this->getRequest()->getParam("ids", "[]")));
         $this->view->returnAction = $returnAction = $this->getRequest()->getParam("returnAction", "list");
         $events = EventQuery::create()->find();
         $programmedPayments = ProgrammedPaymentQuery::create()->whereAdd(ProgrammedPayment::ID_PROGRAMMED_PAYMENT, $ids)->find();
         //die("<pre>".print_r($programmedPayments, true));
         $actualPayments = ActualPaymentQuery::create()->whereAdd(ActualPayment::ID_PROGRAMMED_PAYMENT, $programmedPayments->getProgrammedPaymentIds())->find();
         $programmedPaymentManager = new ProgrammedPaymentManager();
         $condensedPayments = $programmedPaymentManager->getCondensedProgrammedPayments($programmedPayments, false);
         $payments = array();
         //die("<pre>".print_r($condensedPayments, true));
         while ($condensedPayments->valid()) {
             $condensedPayment = $condensedPayments->read();
             $payment = array("condensedIndex" => $condensedPayment->getIndex(), "documentType" => $condensedPayment->getTypeName(), "docNum" => $condensedPayment->getSapDocnum(), "event" => $events->getByPK($condensedPayment->getIdEvent())->getName(), "ammount" => $condensedPayment->getAmmount(), "credits" => $condensedPayment->getCredits(), "pendingBalance" => $condensedPayment->getPendingBalance());
             foreach ($condensedPayment->getProgrammedPaymentIds() as $idProgrammedPayment) {
                 $programmedPayment = $programmedPayments->getByPK($idProgrammedPayment);
                 $actualPayment = $actualPayments->filterByProgrammedPayment($programmedPayment);
                 $payment["payments"][$idProgrammedPayment]["id"] = $idProgrammedPayment;
                 $payment["payments"][$idProgrammedPayment]["toPay"] = $programmedPayment->getAmmount() - $actualPayment->getTotalAmmount();
             }
             $payments[] = $payment;
         }
         $this->view->payments = $payments;
         //die("<pre>".print_r($payments, true));
         $idSupplier = $this->getRequest()->getParam("supplier");
         $this->view->supplier = SapSupplierQuery::create()->findByPKOrThrow($idSupplier, $this->i18n->_("SapSupplier with CardCode {$idSupplier} not found."));
         $idCurrency = $this->getRequest()->getParam("currency");
         $this->view->currency = CurrencyQuery::create()->findByPKOrThrow($idCurrency, $this->i18n->_("Currency with DocCurr {$idCurrency} not found."));
     } catch (Exception $e) {
         $this->setFlash("error", $this->i18n->_($e->getMessage()));
         $this->getHelper('redirector')->goto($returnAction);
     }
 }
Пример #7
0
 /**
  *
  */
 public function programmedPaymentAction()
 {
     $landedCostCodes = LandedCostCodeQuery::create()->find();
     $products = ProductServiceQuery::create()->addColumn(Product::ITEM_CODE)->addColumn(Product::ITEM_NAME)->whereAdd(Product::ITEM_CODE, "TR%")->find();
     $warehouseEntry = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, 102)->find();
     $id = $this->getRequest()->getParam('id');
     $onsubmit = $this->getBaseUrl() . '/' . $this->getRequest()->getParam('controller') . '/save-programmed-payment/id/' . $id;
     $columns = array(ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::AMMOUNT, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::DUE_DATE, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_COMPANY, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_CURRENCY, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_PROGRAMMED_PAYMENT, FolioImportProgrammedPayment::TABLENAME . '.' . FolioImportProgrammedPayment::ID_FOLIO_IMPORT);
     $folioImportProgrammedPaymentsQuery = FolioImportProgrammedPaymentQuery::create()->whereAdd('FolioImportProgrammedPayment.' . FolioImportProgrammedPayment::ID_FOLIO_IMPORT, $id)->innerJoinProgrammedPayment()->find();
     if (!$folioImportProgrammedPaymentsQuery) {
         $folioImportProgrammedPayments = new FolioImportProgrammedPaymentCollection();
         $this->view->programmedPayments = $programmedPayments = $folioImportProgrammedPayments;
         $count = 0;
     } else {
         $this->view->programmedPayments = $programmedPayments = $folioImportProgrammedPaymentsQuery;
         $count = $folioImportProgrammedPaymentsQuery->count();
     }
     $concepts = ProductServiceQuery::create()->addColumn(Product::ITEM_CODE)->addColumn(Product::ITEM_NAME)->whereAdd(Product::ITEM_CODE, "TR%")->fetchPairs();
     $this->view->index = $count;
     $this->view->onsubmit = $onsubmit;
     $this->view->concepts = $concepts;
     //$landedCostCodes->toCombo($this->i18n->_('Select One'));
     $this->view->currencies = CurrencyQuery::create()->find()->toCombo('Currency');
     $this->view->idFolioImport = $id;
     $this->view->contentTitle = $this->i18n->_('Additional Payments');
     $this->view->statusPay = $status = ProgrammedPayment::$Status;
 }
Пример #8
0
 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';
 }
Пример #9
0
 /**
  * 
  */
 public function temporalSupplierEditAction()
 {
     $id = $this->getRequest()->getParam('id');
     $this->view->currencies = CurrencyQuery::create()->find()->toCombo('All');
     $this->view->contentTitle = $this->i18n->_('Temporal Suppliers Edit');
     $this->view->onsubmit = $this->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/' . 'temporal-supplier-update';
     $this->view->supplier = TemporalSupplierQuery::create()->findByPK($id)->toArray();
     $this->view->setTpl('Temporal-supplier-new');
 }
Пример #10
0
 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;
 }
 /**
  *
  * @return array
  */
 public function newAction()
 {
     $this->view->contentTitle = $this->i18n->_('New Simple Claim Report');
     $this->view->onsubmit = 'warehouse-entrance-claim-report/create';
     $this->view->currencies = CurrencyQuery::create()->find()->toCombo('All');
 }
Пример #12
0
 public function getcurrenciesAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $currencyQuery = CurrencyQuery::create()->actives();
         if (isset($params["currencies"]) && $params["currencies"] != "") {
             $currencyQuery->where()->setOR();
             $currencyQuery->whereAdd(Currency::CURRCODE, $params["currencies"], BaseQuery::EQUAL);
         }
         die(Zend_Json::encode(array("response" => $currencyQuery->find()->toCombo())));
     }
 }
Пример #13
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();
 }
Пример #14
0
 /**
  *
  * Gets all Suppliers from SAP, searches the DB for the cardcode, then updates or creates
  */
 public function syncSuppliersAction()
 {
     $r = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDTYPE, "s", SapSupplierQuery::EQUAL)->find();
     echo "<pre>";
     $errors = 0;
     $new = 0;
     $updated = 0;
     while ($r->valid()) {
         $save = 0;
         $sapSupplier = $r->read();
         echo "Name: " . $sapSupplier->getCardname() . " Code: " . $sapSupplier->getCardcode() . "\n";
         $supplier = SupplierQuery::create()->whereAdd(Supplier::SAP_ID_BUSSINESS_ASSOCIATE, $sapSupplier->getCardcode(), SupplierQuery::EQUAL)->findOne();
         if (!$supplier instanceof Supplier) {
             $supplier = new Supplier();
             $save = 1;
         }
         $currency = CurrencyQuery::create()->whereAdd(Currency::CODE, substr($sapSupplier->getCardcode(), 0, 3))->findOne();
         if (!$currency instanceof Currency) {
             echo " Error! No Currency: " . substr($sapSupplier->getCardcode(), 0, 3) . "\n";
             $errors++;
             continue;
         }
         $supplier->setIdCurrency($currency->getIdCurrency());
         $supplier->setCardName($sapSupplier->getCardname());
         $supplier->setConsistency(0);
         $supplier->setIdApprovalStatus(1);
         $supplier->setIdPaymentTerm(1);
         $supplier->setName($sapSupplier->getCardname());
         $supplier->setQuality(0);
         $supplier->setRfc($sapSupplier->getLicTradNum());
         $supplier->setSapIdBussinessAssociate($sapSupplier->getCardcode());
         $supplier->setStatus(1);
         $supplier->setTime(0);
         $supplier->setIdDefaultPort(1);
         $supplier->setTypePerson($sapSupplier->getCmpPrivate());
         try {
             $this->getSupplierCatalog()->beginTransaction();
             if ($save) {
                 $this->getSupplierCatalog()->create($supplier);
                 $new++;
             } else {
                 $this->getSupplierCatalog()->update($supplier);
                 $updated++;
             }
             $this->getSupplierCatalog()->commit();
         } catch (Exception $e) {
             $this->getSupplierCatalog()->rollBack();
             echo "\nError al intentar guardar el proveedor: " . $e->getMessage();
         }
     }
     echo "\n\nTotals:\nErrors: " . $errors . "\nNew: " . $new . "\nUpdated: " . $updated;
     die;
 }
Пример #15
0
 public function zoomInAction()
 {
     if ($this->getRequest()->isPost()) {
         $keyMother = $this->getRequest()->getParam("key_mother");
         $itemCode = $this->getRequest()->getParam("item_code");
         $products = ProductQuery::create()->find();
         $keyMotherProducts = $products->filterByKeyMother($keyMother);
         $restock = RestockQuery::create()->findOne();
         $allRestockEntries = RestockEntryQuery::create()->find();
         $restockEntries = $allRestockEntries->filterByArrayIdProduct($keyMotherProducts->getPrimaryKeys());
         $freightTypes = FreightTypeQuery::create()->actives()->find();
         $restockFinalResultsManager = new RestockFinalResultsManager($allRestockEntries, $products);
         $product = $products->getByPK($itemCode);
         $restockAbcClass = RestockAbcClassQuery::create()->find();
         $freightFares = FreightFareQuery::create()->find();
         $freightFare = $freightFares->getByPK($product->getDefaultFreightFare());
         $fobPort = PortCustomQuery::create()->findByPKOrElse($freightFare->getFobPort(), new PortCustom());
         $fobPortFreightFares = $freightFares->filterByFobPort($fobPort);
         $freightTypeList = $freightTypes->containsIndex($freightFare->getIdFreightType()) ? $freightTypes->getByPK($freightFare->getIdFreightType()) : new FreightType();
         if ($product->getIdSupplier() != "") {
             $supplier = SapSupplierQuery::create()->findByPK($product->getIdSupplier());
         } else {
             $supplier = new SapSupplier();
         }
         $keyMotherInfo["keyMother"] = $product->getKeyMother();
         $keyMotherInfo["PurchaseKeyMother"] = $restockFinalResultsManager->getTotalPurchaseByKeyMother($keyMother);
         $keyMotherInfo["catalog"] = $product->getCodPro();
         $keyMotherInfo["port"] = $fobPort->getName();
         $keyMotherInfo["freightList"] = $freightTypeList->getName();
         $keyMotherInfo["supplier"] = $supplier->getCardCode() . " - " . $supplier->getCardname();
         $keyMotherInfo["supplierPurchase"] = $restockFinalResultsManager->getTotalPurchaseByIdSupplier($supplier->getIdSupplier());
         $keyMotherInfo["fobPortPurchase"] = $restockFinalResultsManager->getTotalByIdFreigthFare($fobPortFreightFares->getPrimaryKeys());
         while ($restockEntries->valid()) {
             $restockEntry = $restockEntries->read();
             $product = $products->getByPK($restockEntry->getIdProduct());
             $restockInfo[$restockEntry->getIndex()]["idRestockEntry"] = $restockEntry->getIdRestockEntry();
             $restockInfo[$restockEntry->getIndex()]["mcParts"] = $product->getMcParts();
             $restockInfo[$restockEntry->getIndex()]["volume"] = $product->getVolume();
             $restockInfo[$restockEntry->getIndex()]["status"] = $product->getStatus();
             $restockInfo[$restockEntry->getIndex()]["itemCode"] = $product->getItemCode();
             $restockInfo[$restockEntry->getIndex()]["name"] = $product->getItemName();
             $restockInfo[$restockEntry->getIndex()]["onStock"] = $restockEntry->getInvRelat();
             $restockInfo[$restockEntry->getIndex()]["VIM"] = $product->getIndividualVim();
             $restockInfo[$restockEntry->getIndex()]["VIMMin"] = $restockEntry->getVimMin();
             $restockInfo[$restockEntry->getIndex()]["VIMMax"] = $restockEntry->getVimMax();
             $restockInfo[$restockEntry->getIndex()]["newQuantityMin"] = $restockEntry->getNewQuantityMin();
             $restockInfo[$restockEntry->getIndex()]["newImportMin"] = $restockEntry->getPriceMin();
             $restockInfo[$restockEntry->getIndex()]["newQuantityMax"] = $restockEntry->getNewQuantityMax();
             $restockInfo[$restockEntry->getIndex()]["newImportMax"] = $restockEntry->getPriceMax();
             $restockInfo[$restockEntry->getIndex()]["coverMin"] = $restockEntry->getMinCoverPercent();
             $restockInfo[$restockEntry->getIndex()]["coverMax"] = $restockEntry->getMaxCoverPercent();
             $restockInfo[$restockEntry->getIndex()]["ABCMin"] = $restockAbcClass->getByPK($restockEntry->getAbcMix())->getName();
             $restockInfo[$restockEntry->getIndex()]["desition"] = $restockEntry->getDesitionName();
             $restockInfo[$restockEntry->getIndex()]["lastFOB"] = $product->getCost();
             $restockInfo[$restockEntry->getIndex()]["targetFOB"] = $restockEntry->getMinTargetPrice();
             $restockInfo[$restockEntry->getIndex()]["quantityPurchase"] = $restockEntry->getPurchaseQuantity();
             $restockInfo[$restockEntry->getIndex()]["importPurchase"] = $restockEntry->getPurchasePrice();
             $restockInfo[$restockEntry->getIndex()]["quantityPercent"] = $restockEntry->getPurchaseQuantityPercernt();
             $restockInfo[$restockEntry->getIndex()]["importPercent"] = $restockEntry->getPurchasePricePercent();
             $restockInfo[$restockEntry->getIndex()]["quantitySetted"] = $restockEntry->getQuantity();
             $restockInfo[$restockEntry->getIndex()]["purchaseSetted"] = $restockFinalResultsManager->getTotalCartonsByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["importPurchaseSetted"] = $restockFinalResultsManager->getPurchaseSettedByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["isManual"] = $product->isManual();
             $restockInfo[$restockEntry->getIndex()]["cbm"] = $totalVolume = $restockFinalResultsManager->getTotalVolumeByIdRestockEntry($restockEntry->getIdRestockEntry());
             $restockInfo[$restockEntry->getIndex()]["suggestedFreight"] = implode(" / ", $freightTypes->getSuggestedFreights($totalVolume)->toCombo());
             $restockInfo[$restockEntry->getIndex()]["checked"] = $restockEntry->getChecked();
         }
         $requisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), RequisitionEntryQuery::IN)->whereAdd(RequisitionEntry::STATUS, array(RequisitionEntry::$Status["Closed"], RequisitionEntry::$Status["Canceled"], RequisitionEntry::$Status["Inactive"]), RequisitionEntryQuery::NOT_IN)->find()->toArrayForZoomIn();
         $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), ProformaInvoiceEntryQuery::IN)->whereAdd(ProformaInvoiceEntry::LINE_STATUS, ProformaInvoiceEntry::$LineStatus["Open"])->find()->toArrayForZoomIn();
         $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PRODUCT, $keyMotherProducts->getPrimaryKeys(), PurchaseOrderEntryQuery::IN)->whereAdd(PurchaseOrderEntry::LINE_STATUS, PurchaseOrderEntry::$LineStatus["Open"])->find()->toArrayForZoomIn();
         $documents = array_merge(array_merge($requisitionEntries, $proformaInvoiceEntries), $purchaseOrderEntries);
         $currencies = CurrencyQuery::create()->find()->toArray();
         die(Zend_Json::encode(array("keyMother" => $keyMotherInfo, "restock" => $restockInfo, "documents" => $documents, "currecies" => $currencies)));
     }
 }
Пример #16
0
 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;
 }