Skip to content

Commit

Permalink
Fix filter grouping
Browse files Browse the repository at this point in the history
This requires / works with civicrm/civicrm-core#20820
  • Loading branch information
eileenmcnaughton committed Jul 9, 2021
1 parent fb6790f commit f0fc18d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
21 changes: 18 additions & 3 deletions CRM/Extendedreport/Form/Report/ActivityExtended.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php


use CRM_Extendedreport_ExtensionUtil as E;

/**
* Class CRM_Extendedreport_Form_Report_ActivityExtended
*/
Expand All @@ -26,43 +29,56 @@ public function __construct() {
'prefix' => '',
'prefix_label' => 'Source Contact ::',
'filters' => TRUE,
'grouping' => 'source',
'group_title' => E::ts('Source Contact'),
]
) + $this->getColumns(
'Email',
[
'prefix' => '',
'prefix_label' => 'Source Contact Email ::',
'filters' => TRUE,
'grouping' => 'source',
'group_title' => E::ts('Source Contact'),
]
) + $this->getColumns(
) + $this->getColumns(
'Contact',
[
'prefix' => 'target_',
'group_by' => TRUE,
'prefix_label' => 'Target Contact ::',
'filters' => TRUE,
'grouping' => 'target',
'group_title' => E::ts('Target Contact'),
]
) + $this->getColumns(
'Email',
[
'prefix' => 'target_',
'prefix_label' => 'Target Contact Email ::',
'filters' => TRUE,
'grouping' => 'target',
'group_title' => E::ts('Target Contact'),
]
) + $this->getColumns(
'Contact', [
'prefix' => 'assignee_',
'prefix_label' => 'Assignee Contact ::',
'filters' => TRUE,
'grouping' => 'assignee',
'group_title' => E::ts('Assignee Contact'),
]
) + $this->getColumns(
'Email',
[
'prefix' => 'assignee_',
'prefix_label' => 'Assignee Contact Email ::',
'filters' => TRUE,
'grouping' => 'assignee',
'group_title' => E::ts('Assignee Contact'),
]
) + $this->getColumns('Activity', ['group_by' => TRUE]);

parent::__construct();
}

Expand All @@ -85,8 +101,7 @@ public function from() {
LEFT JOIN civicrm_case
ON case_activity_civireport.case_id = civicrm_case.id ";
}



$this->joinEmailFromContact();
$this->joinEmailFromContact('target_');
$this->joinEmailFromContact('assignee_');
Expand Down
21 changes: 13 additions & 8 deletions CRM/Extendedreport/Form/Report/ExtendedReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -1310,13 +1310,18 @@ public function addFilters() {
$count = 1;
foreach ($this->getMetadataByType($filterString) as $fieldName => $field) {
$table = $field['table_key'];
$groupingKey = $field['group_title'] ?? '';
if ($filterString === 'filters') {
$filterGroups[$table] = [
'group_title' => $this->_columns[$field['table_key']]['group_title'],
'use_accordian_for_field_selection' => TRUE,
];
$filterGroups[$groupingKey]['group_title'] = $field['group_title'] ?? '';
if (isset($field['use_accordion_for_field_selection'])) {
$filterGroups[$groupingKey]['use_accordion_for_field_selection'] = $field['table_key']['use_accordion_for_field_selection'];
}
else {
$filterGroups[$groupingKey]['use_accordion_for_field_selection'] = TRUE;
}
}
$prefix = ($filterString === 'join_filters') ? 'join_filter_' : '';
$filterGroups[$groupingKey]['tables'][$table][$prefix . $fieldName] = $field;
$filters[$table][$prefix . $fieldName] = $field;
$this->addFilterFieldsToReport($field, $fieldName, $table, $count, $prefix);
}
Expand Down Expand Up @@ -3206,14 +3211,14 @@ protected function buildColumns($specs, $tableName, $daoName = NULL, $tableAlias
$columns[$tableName]['prefix_label'] = isset($options['prefix_label']) ? $options['prefix_label'] : '';
$columns[$tableName]['is_required_for_acls'] = $options['is_required_for_acls'] ?? FALSE;
if (isset($options['group_title'])) {
$groupTitle = $options['group_title'];
$columns[$tableName]['group_title'] = $options['group_title'];
$columns[$tableName]['grouping'] = $options['grouping'];
}
else {

// We can make one up but it won't be translated....
$groupTitle = ucfirst(str_replace('_', ' ', str_replace('civicrm_', '', $tableName)));
$columns[$tableName]['group_title'] = ucfirst(str_replace('_', ' ', str_replace('civicrm_', '', $tableName)));
}
$columns[$tableName]['group_title'] = $groupTitle;

return $columns;
}

Expand Down

0 comments on commit f0fc18d

Please sign in to comment.