本文整理汇总了PHP中CRM_Report_Utils_Report::makeCsv方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Report_Utils_Report::makeCsv方法的具体用法?PHP CRM_Report_Utils_Report::makeCsv怎么用?PHP CRM_Report_Utils_Report::makeCsv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Report_Utils_Report
的用法示例。
在下文中一共展示了CRM_Report_Utils_Report::makeCsv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReportOutputAsCsv
function getReportOutputAsCsv($reportClass, $inputParams)
{
$config = CRM_Core_Config::singleton();
$config->keyDisable = TRUE;
$controller = new CRM_Core_Controller_Simple($reportClass, ts('some title'));
$tmpReportVal = explode('_', $reportClass);
$reportName = array_pop($tmpReportVal);
$reportObj =& $controller->_pages[$reportName];
$tmpGlobals = array();
$tmpGlobals['_REQUEST']['force'] = 1;
$tmpGlobals['_GET'][$config->userFrameworkURLVar] = 'civicrm/placeholder';
$tmpGlobals['_SERVER']['QUERY_STRING'] = '';
if (!empty($inputParams['fields'])) {
$fields = implode(',', $inputParams['fields']);
$tmpGlobals['_GET']['fld'] = $fields;
$tmpGlobals['_GET']['ufld'] = 1;
}
if (!empty($inputParams['filters'])) {
foreach ($inputParams['filters'] as $key => $val) {
$tmpGlobals['_GET'][$key] = $val;
}
}
if (!empty($inputParams['group_bys'])) {
$groupByFields = implode(' ', $inputParams['group_bys']);
$tmpGlobals['_GET']['gby'] = $groupByFields;
}
CRM_Utils_GlobalStack::singleton()->push($tmpGlobals);
try {
$reportObj->storeResultSet();
$reportObj->buildForm();
$rows = $reportObj->getResultSet();
$tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv');
$csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows);
file_put_contents($tmpFile, $csvContent);
} catch (Exception $e) {
// print_r($e->getCause()->getUserInfo());
CRM_Utils_GlobalStack::singleton()->pop();
throw $e;
}
CRM_Utils_GlobalStack::singleton()->pop();
return $tmpFile;
}
示例2: endPostProcess
/**
* End post processing.
*
* @param array|null $rows
*/
public function endPostProcess(&$rows = NULL)
{
if ($this->_storeResultSet) {
$this->_resultSet = $rows;
}
if ($this->_outputMode == 'print' || $this->_outputMode == 'pdf' || $this->_sendmail) {
$content = $this->compileContent();
$url = CRM_Utils_System::url("civicrm/report/instance/{$this->_id}", "reset=1", TRUE);
if ($this->_sendmail) {
$config = CRM_Core_Config::singleton();
$attachments = array();
if ($this->_outputMode == 'csv') {
$content = $this->_formValues['report_header'] . '<p>' . ts('Report URL') . ": {$url}</p>" . '<p>' . ts('The report is attached as a CSV file.') . '</p>' . $this->_formValues['report_footer'];
$csvFullFilename = $config->templateCompileDir . CRM_Utils_File::makeFileName('CiviReport.csv');
$csvContent = CRM_Report_Utils_Report::makeCsv($this, $rows);
file_put_contents($csvFullFilename, $csvContent);
$attachments[] = array('fullPath' => $csvFullFilename, 'mime_type' => 'text/csv', 'cleanName' => 'CiviReport.csv');
}
if ($this->_outputMode == 'pdf') {
// generate PDF content
$pdfFullFilename = $config->templateCompileDir . CRM_Utils_File::makeFileName('CiviReport.pdf');
file_put_contents($pdfFullFilename, CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", TRUE, array('orientation' => 'landscape')));
// generate Email Content
$content = $this->_formValues['report_header'] . '<p>' . ts('Report URL') . ": {$url}</p>" . '<p>' . ts('The report is attached as a PDF file.') . '</p>' . $this->_formValues['report_footer'];
$attachments[] = array('fullPath' => $pdfFullFilename, 'mime_type' => 'application/pdf', 'cleanName' => 'CiviReport.pdf');
}
if (CRM_Report_Utils_Report::mailReport($content, $this->_id, $this->_outputMode, $attachments)) {
CRM_Core_Session::setStatus(ts("Report mail has been sent."), ts('Sent'), 'success');
} else {
CRM_Core_Session::setStatus(ts("Report mail could not be sent."), ts('Mail Error'), 'error');
}
return TRUE;
} elseif ($this->_outputMode == 'print') {
echo $content;
} else {
if ($chartType = CRM_Utils_Array::value('charts', $this->_params)) {
$config = CRM_Core_Config::singleton();
//get chart image name
$chartImg = $this->_chartId . '.png';
//get image url path
$uploadUrl = str_replace('/persist/contribute/', '/persist/', $config->imageUploadURL) . 'openFlashChart/';
$uploadUrl .= $chartImg;
//get image doc path to overwrite
$uploadImg = str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) . 'openFlashChart/' . $chartImg;
//Load the image
$chart = imagecreatefrompng($uploadUrl);
//convert it into formatted png
CRM_Utils_System::setHttpHeader('Content-type', 'image/png');
//overwrite with same image
imagepng($chart, $uploadImg);
//delete the object
imagedestroy($chart);
}
CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", FALSE, array('orientation' => 'landscape'));
}
CRM_Utils_System::civiExit();
} elseif ($this->_outputMode == 'csv') {
CRM_Report_Utils_Report::export2csv($this, $rows);
} elseif ($this->_outputMode == 'group') {
$group = $this->_params['groups'];
$this->add2group($group);
}
}