public function __construct($locale) { $this->setDocumentType(parent::CSV_FORMAT); parent::__construct($locale); }
/** * * @param sfWebRequest $request * @param StatExportForm $form */ protected function processExport(sfWebRequest $request, StatExportForm $form) { //We get the parameters: $req_param = $request->getParameter($form->getName()); $req_param['from'] = $request->getParameter('formattedFrom'); $req_param['to'] = $request->getParameter('formattedTo'); //Check if there is imputations between the dates that have been specified: $imputationsGlobal = Doctrine_Query::create()->select('COUNT(*) as number')->from('ImputationArchive i')->where('i.imputation_date BETWEEN ? AND ?', array($req_param['from'], $req_param['to']))->fetchOne(); $numberImputations = $imputationsGlobal->getNumber(); //If any, process to the export: if ($numberImputations != 0 || $req_param['ressource'] == ExportDocument::BALANCE_RESSOURCE) { $export = ExportDocument::instanciateDocument($req_param['format'], $this->getUser()->getCulture()); $export->export($req_param['ressource'], $req_param['from'], $req_param['to']); return sfView::NONE; } else { //Else, inform the user: $this->getUser()->setFlash('notice', 'No uses found between these two dates.'); $this->setTemplate('exportIndex'); } }