X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FReportTemplate.php;h=b52cefa15fe461d2c70c576992cfa097aa6e9533;hb=3bf2c46c41711b0ec2e3135cc4435f18d24ee3e6;hp=5129dec72816081eac65eb36622d6b7113002655;hpb=912a3736c0c169f3d27d9de8495a28983ba9bf4c;p=civicrm-core.git diff --git a/api/v3/ReportTemplate.php b/api/v3/ReportTemplate.php index 5129dec728..b52cefa15f 100644 --- a/api/v3/ReportTemplate.php +++ b/api/v3/ReportTemplate.php @@ -78,6 +78,66 @@ function civicrm_api3_report_template_delete($params) { return civicrm_api3_option_value_delete($params); } +/** + * Retrieve rows from a report template + * + * @param array $params input parameters + * + * @return array details of found instances + * @access public + */ +function civicrm_api3_report_template_getrows($params) { + list($rows, $instance) = _civicrm_api3_report_template_getrows($params); + return civicrm_api3_create_success($rows, $params, 'report_template'); +} + +function _civicrm_api3_report_template_getrows($params) { + $class = civicrm_api3('option_value', 'getvalue', array( + 'option_group_id' => 'report_template', + 'return' => 'name', + 'value' => $params['report_id'], + ) + ); + + $reportInstance = new $class(); + if(!empty($params['instance_id'])) { + $reportInstance->setID($params['instance_id']); + } + $reportInstance->setParams($params); + $reportInstance->noController = TRUE; + $reportInstance->preProcess(); + $reportInstance->setDefaultValues(FALSE); + $reportInstance->setParams(array_merge($reportInstance->getDefaultValues(), $params)); + $options = _civicrm_api3_get_options_from_params($params, TRUE,'report_template','get'); + $reportInstance->setLimitValue($options['limit']); + $reportInstance->setOffsetValue($options['offset']); + $reportInstance->beginPostProcessCommon(); + $sql = $reportInstance->buildQuery(); + $rows = array(); + $reportInstance->buildRows($sql, $rows); + return array($rows, $reportInstance); +} + +function civicrm_api3_report_template_getstatistics($params) { + list($rows, $reportInstance) = _civicrm_api3_report_template_getrows($params); + $stats = $reportInstance->statistics($rows); + return civicrm_api3_create_success($stats, $params, 'report_template'); +} +/** + * Retrieve rows from a report template + * + * @param array $params input parameters + * + * @return array details of found instances + * @access public + */ +function _civicrm_api3_report_template_getrows_spec(&$params) { + $params['report_id'] = array( + 'api.required' => TRUE, + 'title' => 'Report ID - eg. member/lapse', + ); +} + /* function civicrm_api3_report_template_getfields($params) { return civicrm_api3_create_success(array(