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 #################################
 }
 public function editAction()
 {
     $this->accessRights(13);
     //Accept Parent Module, Return Main Menu Lists with Active Menu Indicator
     $this->childModuleAccessRights(40, 'edit');
     //Accept Child Module ID & it's Actions: add, edit, view, disable
     $id = (int) $this->params()->fromRoute('id', 0);
     try {
         $markethighlight = $this->getMarketHighlightTable()->getMarketHighlight($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('markethighlight', array('action' => 'index'));
     }
     $form_markethighlight = new MarketHighlightForm();
     $form_markethighlight->bind($markethighlight);
     $request = $this->getRequest();
     if ($request->isPost()) {
         // prepare audit trail parameters
         $from = (array) $markethighlight;
         $to = $this->getRequest()->getPost()->toArray();
         $diff = array_diff_assoc($to, $from);
         unset($diff['addbuttonmarkethighlight'], $diff['market_highlights_id']);
         $changes = $this->prepare_modified_data($from, $to, $diff);
         // end of audit trail parameters
         $form_markethighlight->setInputFilter($markethighlight->getInputFilter());
         $form_markethighlight->setData($request->getPost());
         // check if input filter passed the validation
         if ($form_markethighlight->isValid()) {
             $this->getMarketHighlightTable()->saveMarketHighlight($markethighlight);
             $this->save_to_audit_trail('Market Highlight for' . $to['mh_date'], $changes['pre'], $changes['post'], 'edit', 40);
             $this->flashMessenger()->addMessage(['content' => 'market highlight has been updated', 'type' => 'success']);
         }
         return $this->redirect()->toRoute('markethighlight');
     }
 }