diff --git a/CRM/Report/Page/InstanceList.php b/CRM/Report/Page/InstanceList.php index 6b586cc22d7a7c9d71e5afc20f92e2c6d6504b74..3c0e2db792cb8b0418b9fa8ca2816f8a10cea03c 100644 --- a/CRM/Report/Page/InstanceList.php +++ b/CRM/Report/Page/InstanceList.php @@ -57,6 +57,7 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { **/ protected $_compID = NULL; + protected $_grouping = NULL; /** * ID of parent report template if list is filtered by template * @@ -91,7 +92,8 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { if ($this->compID == 99) { $report .= " AND v.component_id IS NULL "; $this->_compName = 'Contact'; - } else { + } + else { $report .= " AND v.component_id = {$this->compID} "; $cmpName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Component', $this->compID, 'name', 'id' @@ -102,10 +104,17 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { } } } + elseif ($this->grouping) { + $report .= " AND v.grouping = '{$this->grouping}' "; + } $sql = " - SELECT inst.id, inst.title, inst.report_id, inst.description, v.label, - ifnull( SUBSTRING(comp.name, 5), 'Contact' ) as compName + SELECT inst.id, inst.title, inst.report_id, inst.description, v.label, v.grouping, +CASE + WHEN comp.name IS NOT NULL THEN SUBSTRING(comp.name, 5) + WHEN v.grouping IS NOT NULL THEN v.grouping + ELSE 'Contact' + END as compName FROM civicrm_option_group g LEFT JOIN civicrm_option_value v ON v.option_group_id = g.id AND @@ -120,20 +129,19 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { ORDER BY v.weight"; $dao = CRM_Core_DAO::executeQuery($sql, array( - 1 => array(CRM_Core_Config::domainID(), 'Integer'), - )); - + 1 => array(CRM_Core_Config::domainID(), 'Integer'), + )); $config = CRM_Core_Config::singleton(); - $rows = array(); - $url = 'civicrm/report/instance'; + $rows = array(); + $url = 'civicrm/report/instance'; while ($dao->fetch()) { if (in_array($dao->report_id, self::$_exceptions)) { continue; } $enabled = in_array("Civi{$dao->compName}", $config->enableComponents); - if ($dao->compName == 'Contact') { + if ($dao->compName == 'Contact' || $dao->compName == $dao->grouping) { $enabled = TRUE; } //filter report listings by permissions @@ -158,7 +166,6 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { } } } - return $rows; } @@ -171,6 +178,8 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { //Filters by source report template or by component $this->ovID = CRM_Utils_Request::retrieve('ovid', 'Positive', $this); $this->compID = CRM_Utils_Request::retrieve('compid', 'Positive', $this); + $this->grouping = CRM_Utils_Request::retrieve('grp', 'String', $this); + $rows = $this->info(); $this->assign('list', $rows); diff --git a/CRM/Report/Page/TemplateList.php b/CRM/Report/Page/TemplateList.php index e654d820f3763a45241de8ecc8780bc2fe95fa55..30b79009e769d6042d3885dbda67449142a61624 100644 --- a/CRM/Report/Page/TemplateList.php +++ b/CRM/Report/Page/TemplateList.php @@ -39,7 +39,7 @@ */ class CRM_Report_Page_TemplateList extends CRM_Core_Page { - public static function &info($compID = NULL) { + public static function &info($compID = NULL, $grouping = NULL) { $all = CRM_Utils_Request::retrieve('all', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET' ); @@ -52,10 +52,18 @@ class CRM_Report_Page_TemplateList extends CRM_Core_Page { $compClause = " AND v.component_id = {$compID} "; } } - + elseif ($grouping) { + $compClause = " AND v.grouping = '{$grouping}' "; + } $sql = " SELECT v.id, v.value, v.label, v.description, v.component_id, - inst.id as instance_id, ifnull( SUBSTRING(comp.name, 5), 'Contact' ) as component_name + CASE + WHEN comp.name IS NOT NULL THEN SUBSTRING(comp.name, 5) + WHEN v.grouping IS NOT NULL THEN v.grouping + ELSE 'Contact' + END as component_name, + v.grouping, + inst.id as instance_id FROM civicrm_option_value v INNER JOIN civicrm_option_group g ON (v.option_group_id = g.id AND g.name = 'report_template') @@ -74,7 +82,7 @@ LEFT JOIN civicrm_component comp $rows = array(); $config = CRM_Core_Config::singleton(); while ($dao->fetch()) { - if ($dao->component_name != 'Contact' && + if ($dao->component_name != 'Contact' && $dao->component_name != $dao->grouping && !in_array("Civi{$dao->component_name}", $config->enableComponents) ) { continue; @@ -99,7 +107,8 @@ LEFT JOIN civicrm_component comp */ function run() { $compID = CRM_Utils_Request::retrieve('compid', 'Positive', $this); - $rows = self::info($compID); + $grouping = CRM_Utils_Request::retrieve('grp', 'String', $this); + $rows = self::info($compID, $grouping); $this->assign('list', $rows); return parent::run();