Skip to content
Snippets Groups Projects
Commit 647fefd0 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #2482 from yashodha/HR-231

allow other grouping to have subsections in report listings
parents de236665 37c20553
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment