public function indexAction()
 {
     $this->accessRights(13);
     //Accept Parent Module, Return Main Menu Lists with Active Menu Indicator
     $this->childModuleAccessRights(40, 'view');
     //Accept Child Module ID & it's Actions: add, edit, view, disable
     $this->adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $result = $this->getMarketHighlightTable()->fetchMarketHighlight($this->adapter);
     $request = $this->getRequest();
     $marketform = new MarketHighlightForm();
     if ($request->isPost()) {
         $from = $_POST['search_from'];
         $to = $_POST['search_to'];
         $marketform->get('search_from')->setValue($from);
         $marketform->get('search_to')->setValue($to);
         $result = $this->getMarketHighlightTable()->fetchMarketHighlight($this->adapter, $from, $to);
     }
     return array('markethighlight' => $result, 'form_markethighlight' => $marketform, 'access_rights' => $this->getSubModuleAccessRights(40));
 }
 public function reportMarketHighlightExcelAction()
 {
     $this->accessRights(20);
     //Accept Parent Module, Return Main Menu Lists with Active Menu Indicator
     $this->adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $marketform = new MarketHighlightForm();
     //Get Post Data & Redirect to Filter Function
     $request = $this->getRequest();
     //Get form object
     if ($request->isPost()) {
         $from = $_POST['market_highlight_from_excel'];
         $to = $_POST['market_highlight_to_excel'];
         $marketform->get('search_from')->setValue($from);
         $marketform->get('search_to')->setValue($to);
         $result = $this->getMarketHighlightTable()->fetchMarketHighlight($this->adapter, $from, $to);
     }
     //error_reporting(0);
     $objPHPExcel = new \PHPExcel();
     ############################### Set properties ##################################
     $objPHPExcel->getProperties()->setCreator($this->currentUserFullName());
     $objPHPExcel->getProperties()->setTitle("Market Highlight Report");
     $objPHPExcel->getActiveSheet()->setTitle('Market Highlight Report');
     ############################### /Set properties #################################
     $objPHPExcel->setActiveSheetIndex(0);
     ################################## HEADER TABLE #################################
     $this->setCompanyLogo($objPHPExcel);
     //Set Company Logo
     $objPHPExcel->getActiveSheet()->setCellValue('B3', "Market Highlight Report");
     $objPHPExcel->getActiveSheet()->getStyle('B3')->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->getStyle('B3')->getFont()->setSize(16);
     ################################## /HEADER TABLE ################################
     ################################## Table #####################################
     $objPHPExcel->getActiveSheet()->SetCellValue('B5', 'DATE')->SetCellValue('C5', 'FOREX')->SetCellValue('D5', 'AEV')->SetCellValue('E5', 'AP')->SetCellValue('F5', 'UBP');
     $objPHPExcel->getActiveSheet()->getStyle("A35:E35")->getFont()->setBold(true);
     //Make Label Bold
     $cell_number = 5;
     foreach ($result as $market_highlight_value) {
         $cell_number++;
         $objPHPExcel->getActiveSheet()->SetCellValue('B' . $cell_number, $market_highlight_value['mh_date'])->SetCellValue('C' . $cell_number, $market_highlight_value['forex'])->SetCellValue('D' . $cell_number, $market_highlight_value['aev'])->SetCellValue('E' . $cell_number, $market_highlight_value['ap'])->SetCellValue('F' . $cell_number, $market_highlight_value['ubp']);
     }
     ################################## Table ####################################
     ################################## Save Excel  #################################
     $this->authResizeColumn($objPHPExcel);
     //Auto Resize Column
     $this->downloadFile('export-market-highlight.xlsx');
     //Download File
     $objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel);
     $objWriter->save("php://output");
     //Download File
     die;
     ################################## /Save Excel #################################
 }