Skip to content

Commit

Permalink
Superficial code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed May 9, 2024
1 parent 0b197cb commit 51eafcc
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions CRM/Extendedreport/Form/Report/ExtendedReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ protected function aggregateSelect(): void {
$this->addRowHeader(1, $fieldDetails, $fieldDetails['alias'], $fieldDetails['title']);
}

foreach ($columnFields as $fieldDetails) { //only one but we don't know the name
foreach ($columnFields as $fieldDetails) {
//only one but we don't know the name
if (array_key_exists($this->_params['aggregate_column_headers'], $this->getMetadataByType('aggregate_columns'))) {
$spec = $this->getMetadataByType('aggregate_columns')[$this->_params['aggregate_column_headers']];
}
Expand Down Expand Up @@ -1169,15 +1170,15 @@ public function storeGroupByArray(): void {
if (!empty($fieldData['frequency']) && !empty($this->_params['group_bys_freq'])) {
$groupByFrequency = CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq']);
switch ($groupByFrequency) {
case 'FISCALYEAR' :
case 'FISCALYEAR':
$this->_groupByArray[$groupByKey . '_start'] = $this->fiscalYearOffset($fieldData['dbAlias']);
break;

case 'YEAR' :
case 'YEAR':
$this->_groupByArray[$groupByKey . '_start'] = " $groupByFrequency({$fieldData['dbAlias']})";
break;

default :
default:
$this->_groupByArray[$groupByKey . '_start'] =
"EXTRACT(YEAR_$groupByFrequency FROM {$fieldData['dbAlias']})";
break;
Expand Down Expand Up @@ -1334,9 +1335,9 @@ public function addColumns(): void {
foreach ($this->getMetadataByType('fields') as $fieldName => $field) {
$tableName = $field['table_key'];
$colGroups[$tableName]['use_accordian_for_field_selection'] = TRUE;
$colGroups[$tableName]['fields'][$fieldName] = CRM_Utils_Array::value('title', $field);
$colGroups[$tableName]['fields'][$fieldName] = $field['title'] ?? '';
$colGroups[$tableName]['group_title'] = $field['group_title'];
$options[$fieldName] = CRM_Utils_Array::value('title', $field);
$options[$fieldName] = $field['title'] ?? '';

}

Expand Down Expand Up @@ -2238,7 +2239,8 @@ protected function addNullToFilterOptions(string $table, string $fieldName, stri
*/
private function addRowHeader(string $tableAlias, array $selectedField, string $fieldAlias, string $title = ''): void {
if (empty($tableAlias)) {
$this->_select = 'SELECT 1 '; // add a fake value just to save lots of code to calculate whether a comma is required later
$this->_select = 'SELECT 1 ';
// add a fake value just to save lots of code to calculate whether a comma is required later
$this->_rollup = NULL;
$this->_noGroupBY = TRUE;
return;
Expand All @@ -2248,14 +2250,13 @@ private function addRowHeader(string $tableAlias, array $selectedField, string $
$this->_groupByArray[] = $fieldAlias;
}
$this->_groupBy = "GROUP BY $fieldAlias " . $this->_rollup;
$this->_columnHeaders[$fieldAlias] = ['title' => $title,];
$this->_columnHeaders[$fieldAlias] = ['title' => $title];
$key = array_search($fieldAlias, $this->_noDisplay);
if (is_int($key)) {
unset($this->_noDisplay[$key]);
}
}


/**
* @param $rows
*/
Expand Down Expand Up @@ -2904,11 +2905,11 @@ protected function getColumns($type, $options = []): array {
$columns = $this->$fn($options);

foreach ([
'filters',
'group_by',
'order_by',
'join_filters',
] as $metadataType) {
'filters',
'group_by',
'order_by',
'join_filters',
] as $metadataType) {
if (!$options[$metadataType]) {
foreach ($columns as &$table) {
if (isset($table[$metadataType])) {
Expand Down Expand Up @@ -6188,7 +6189,6 @@ protected function alterNickName($value, $row): string {
return "<div id=contact-$contactID class='crm-entity'><span class='crm-editable crmf-nick_name crm-editable-enabled' data-action='create'>" . $value . "</span></div>";
}


/**
* Retrieve text for contribution type from pseudoconstant.
*
Expand Down Expand Up @@ -6280,9 +6280,6 @@ protected function alterCampaignType($value): string {
return (string) $values[$value];
}

/*
* Retrieve text for payment instrument from pseudoconstant
*/
/**
* @param int|null $value
*
Expand Down

0 comments on commit 51eafcc

Please sign in to comment.