$this->assign('mode', 'instance');
}
elseif (!$this->noController) {
- list($optionValueID, $optionValue) = CRM_Report_Utils_Report::getValueIDFromUrl();
+ [$optionValueID, $optionValue] = CRM_Report_Utils_Report::getValueIDFromUrl();
$instanceCount = CRM_Report_Utils_Report::getInstanceCount($optionValue);
if (($instanceCount > 0) && $optionValueID) {
$this->assign('instanceUrl',
*/
public function addFilters() {
$filters = $filterGroups = [];
- $count = 1;
foreach ($this->_filters as $table => $attributes) {
- if (isset($this->_columns[$table]['group_title'])) {
- // The presence of 'group_title' is secret code for 'is_a_custom_table'
- // which magically means to 'display in an accordian'
- // here we make this explicit.
- $filterGroups[$table] = [
- 'group_title' => $this->_columns[$table]['group_title'],
- 'use_accordian_for_field_selection' => TRUE,
-
- ];
+ $groupingKey = $this->_columns[$table]['grouping'] ?? '';
+ $filterGroups[$groupingKey]['tables'][$table] = [];
+ // If a prior table hasn't set group title then set it.
+ if (empty($filterGroups[$groupingKey]['group_title'])) {
+ $filterGroups[$groupingKey]['group_title'] = $this->_columns[$table]['group_title'] ?? '';
}
+ // The presence of 'group_title' is secret code for 'display in an accordion'
+ // here we make this explicit.
+ if (!isset($filterGroups[$groupingKey]['use_accordion_for_field_selection'])) {
+ if (isset($this->_columns[$table]['use_accordion_for_field_selection'])) {
+ $filterGroups[$groupingKey]['use_accordion_for_field_selection'] = $this->_columns[$table]['use_accordion_for_field_selection'];
+ }
+ else {
+ $filterGroups[$groupingKey]['use_accordion_for_field_selection'] = isset($this->_columns[$table]['group_title']);
+ }
+ }
+
foreach ($attributes as $fieldName => $field) {
+ $filterGroups[$groupingKey]['tables'][$table][$fieldName] = $field;
+ // Filters is deprecated in favour of filterGroups.
+ $filters[$table][$fieldName] = $field;
// get ready with option value pair
// @ todo being able to specific options for a field (e.g a date field) in the field spec as an array rather than an override
// would be useful
CRM_Utils_Array::value('operatorType', $field),
$fieldName);
- $filters[$table][$fieldName] = $field;
-
switch (CRM_Utils_Array::value('operatorType', $field)) {
case CRM_Report_Form::OP_MONTH:
if (!array_key_exists('options', $field) ||
}
}
}
- if (!empty($filters)) {
+ if (!empty($filterGroups)) {
$this->tabs['Filters'] = [
'title' => ts('Filters'),
'tpl' => 'Filters',
'div_label' => 'set-filters',
];
}
- $this->assign('filters', $filters);
$this->assign('filterGroups', $filterGroups);
+ // Filters is deprecated in favour of filterGroups.
+ $this->assign('filters', $filters);
}
/**
}
if ($relative) {
- list($from, $to) = $this->getFromTo($relative, $from, $to, $fromTime, $toTime);
+ [$from, $to] = $this->getFromTo($relative, $from, $to, $fromTime, $toTime);
}
if ($from) {
$from = $this->_params["{$fieldName}_from"] ?? NULL;
$to = $this->_params["{$fieldName}_to"] ?? NULL;
if (!empty($this->_params["{$fieldName}_relative"])) {
- list($from, $to) = CRM_Utils_Date::getFromTo($this->_params["{$fieldName}_relative"], NULL, NULL);
+ [$from, $to] = CRM_Utils_Date::getFromTo($this->_params["{$fieldName}_relative"], NULL, NULL);
}
if (strlen($to) === 10) {
// If we just have the date we assume the end of that day.
* @param string $tableAlias
*/
public function buildACLClause($tableAlias = 'contact_a') {
- list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ [$this->_aclFrom, $this->_aclWhere] = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
}
/**
}
}
}
+ if (isset($options['grouping'])) {
+ $columns[$tableName]['grouping'] = $options['grouping'];
+ $columns[$tableName]['group_title'] = $options['group_title'] ?? '';
+ }
return $columns;
}
+--------------------------------------------------------------------+
*}
- <div id="report-tab-set-filters" class="civireport-criteria">
- <table class="report-layout">
+<div id="report-tab-set-filters" class="civireport-criteria">
+ <div class="report-layout">
{assign var="counter" value=1}
- {foreach from=$filters item=table key=tableName}
- {assign var="filterCount" value=$table|@count}
+ {foreach from=$filterGroups item=filterGroup}
{* Wrap custom field sets in collapsed accordion pane. *}
- {if !empty($filterGroups.$tableName.group_title) and $filterCount gte 1}
- {* we should close table that contains other filter elements before we start building custom group accordion
- *}
- {if $counter eq 1}
- </table>
- {assign var="counter" value=0}
- {/if}
+ {if $filterGroup.use_accordion_for_field_selection}
<div class="crm-accordion-wrapper crm-accordion collapsed">
<div class="crm-accordion-header">
- {$filterGroups.$tableName.group_title}
+ {$filterGroup.group_title}
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
- <table class="report-layout">
{/if}
- {foreach from=$table item=field key=fieldName}
+ <table class="report-layout">
+ {foreach from=$filterGroup.tables item=table key=tableName}
+ {foreach from=$table item=field key=fieldName}
{assign var=fieldOp value=$fieldName|cat:"_op"}
{assign var=filterVal value=$fieldName|cat:"_value"}
{assign var=filterMin value=$fieldName|cat:"_min"}
</td>
</tr>
{/if}
+ {/foreach}
{/foreach}
- {if !empty($filterGroups.$tableName.group_title)}
- </table>
+ </table>
+ {if $filterGroup.use_accordion_for_field_selection}
</div><!-- /.crm-accordion-body -->
</div><!-- /.crm-accordion-wrapper -->
- {assign var=closed value="1"} {*-- ie table tags are closed-- *}
- {else}
- {assign var=closed value="0"} {*-- ie table tags are not closed-- *}
{/if}
{/foreach}
- {if $closed eq 0 }
- </table>
- {/if}
</div>
+</div>