/** * @service payout_history export * @return Gpf_Rpc_Serializable */ public function getCSVFile(Gpf_Rpc_Params $params) { $this->initParamsForCSVFile($params); $views = $params->get("columns"); $header = array(); for ($i = 2; $i < count($views); $i++) { if ($views[$i][0] === self::ACTIONS) { continue; } $header[] = $views[$i][0]; } if ($this->_fileName != null) { $fileName = $this->_fileName.".csv"; } else { $fileName = "grid.csv"; } $viewResult = new Gpf_Data_RecordSet(); $viewResult->setHeader($header); $result = $this->getResultForCSV(); $csvGenerator = new Gpf_Csv_GeneratorResponse($fileName, $header, null); if ($result->getSize() > 0) { foreach ($result as $record) { $row = new Gpf_Data_Record($header); foreach ($header as $column) { $row->set($column, $record->get($column)); } $csvGenerator->add($row); } } return $csvGenerator->getFile(); }
/** * Returns csv file with data for grid * * @service * * @param $filters * @param $sort_col * @param $sort_asc * @param Gpf_Data_RecordSet $columns * @param Gpf_Data_RecordSer $views * @return Gpf_Rpc_Serializable */ public function getCSVFile(Gpf_Rpc_Params $params) { $this->initParamsForCSVFile($params); if ($this->_fileName != null) { $fileName = $this->_fileName.".csv"; } else { $fileName = "grid.csv"; } $this->createResultSelect(); $result = $this->initResult(); $dataHeader = $this->createHeader($params->get("columns")); $dataHeader = $this->insertRequiredColumnsToCSVHeader($dataHeader); $csvGenerator = new Gpf_Csv_GeneratorResponse($fileName, $dataHeader, null, $this->createExportFileHeader($dataHeader)); foreach ($iterator = $this->createRowsIterator() as $row) { $csvGenerator->add($row); } return $csvGenerator->getFile(); }