Пример #1
0
 /**
  * 
  * @param $from
  * @param $to
  */
 protected function _exportQuantitativeStatement($from, $to)
 {
     $active_sheet = $this->getDocument()->getActiveSheet();
     $acts = Doctrine_Query::create()->select('a.designation')->from('Act a')->where('a.disabled = ?', 0)->orderBy('a.designation')->execute();
     $numberOfActs = Doctrine_Query::create()->select('COUNT(*) as total')->from('Act a')->where('a.disabled = ?', 0)->fetchOne();
     $statement = Statistics::getQuantitativeStatementValuesByAct($from, $to);
     /*Print all the acts at the top:*/
     $this->_exportQuantitativeStatementHeader($statement);
     $columns = Statistics::getQuantitativeStatementColumns($from, $to);
     $total = Statistics::getTotalQuantitativeStatementValues($from, $to);
     foreach ($columns as $stat_type => $stat) {
         $this->_exportQuantitativeStatementRessourceByString($columns, $statement, $stat_type, $total);
     }
     foreach ($columns as $stat_type => $stat) {
         $this->_exportQuantitativeStatementRessourceById($columns, $statement, $stat_type, $total);
     }
     //Specific exportations:
     $this->_exportQuantitativeStatementByCountry($columns, $statement, $total, $from, $to);
     $this->nextLine(3);
     $this->_exportQuantitativeStatementByDay($columns, $statement, $total);
     $this->nextLine(3);
     $this->_exportQuantitativeStatementByBuilding($columns, $statement, $total);
     $this->nextLine(3);
     //Details per category:
     $detailsPerCategory = Statistics::getQuantitativeDetailsPerCategory($from, $to);
     $this->_exportDetailsPerCategory($columns, $detailsPerCategory, $total);
     $this->nextLine(3);
     //Details per time slot:
     $detailsPerTimeSlot = Statistics::getQuantitativeDetailsPerTimeSlot($from, $to);
     $this->_exportDetailsPerTimeSlot($columns, $detailsPerTimeSlot, $total);
     $this->nextLine(3);
     //Page setup:
     $page_setup = new PHPExcel_Worksheet_PageSetup();
     $page_setup->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
     $page_setup->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
     $page_setup->setHorizontalCentered(true);
     $active_sheet->setPageSetup($page_setup);
     $active_sheet->setShowGridlines(true);
     $active_sheet->setPrintGridlines(true);
     //Margins:
     $active_sheet->getPageMargins()->setTop(0.4);
     $active_sheet->getPageMargins()->setRight(0.2);
     $active_sheet->getPageMargins()->setLeft(0.2);
     $active_sheet->getPageMargins()->setBottom(0.4);
 }
Пример #2
0
 public function executeQuantitativeStatement(sfWebRequest $request)
 {
     $from = $request->getParameter('formattedFrom');
     $to = $request->getParameter('formattedTo');
     $countries = array();
     $citiesTable = array();
     $cities = array();
     $this->acts = Doctrine_Query::create()->select('a.designation')->from('Act a')->where('a.disabled = ?', 0)->orderBy('a.designation')->execute();
     $this->numberOfActs = Doctrine_Query::create()->select('COUNT(*) as total')->from('Act a')->where('a.disabled = ?', 0)->fetchOne();
     $imputations = Doctrine_Query::create()->select('i.*')->from('ImputationArchive i')->where('imputation_date BETWEEN ? AND ?', array($from, $to))->execute();
     foreach ($imputations as $imputation) {
         $country = $imputation->getUserArchive()->getCountry();
         $city = $imputation->getUserArchive()->getCityName();
         if (!in_array($country, $countries)) {
             $countries[] = $country;
         }
         if (!in_array($city, $citiesTable)) {
             $citiesTable[] = $city;
             $cities[$country][] = $city;
         }
     }
     $this->countries = $countries;
     $this->cities = $cities;
     $this->statement = Statistics::getQuantitativeStatementValuesByAct($from, $to);
     $this->detailsPerCategory = Statistics::getQuantitativeDetailsPerCategory($from, $to);
     $this->detailsPerTimeSlot = Statistics::getQuantitativeDetailsPerTimeSlot($from, $to);
     $this->total = Statistics::getTotalQuantitativeStatementValues($from, $to);
     $this->columns = Statistics::getQuantitativeStatementColumns($from, $to);
     $this->from = $from;
     $this->to = $to;
     $this->setLayout('emptyLayout');
 }