diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index cbe7debf28a0..54e6c641e25b 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5136,7 +5136,7 @@ public function summaryContribution($context = NULL) { $this->appendFinancialTypeWhereAndFromToQueryStrings($where, $from); - $summary = ['total' => []]; + $summary = ['total' => [], 'soft_credit' => ['count' => 0, 'avg' => 0, 'amount' => 0]]; $this->addBasicStatsToSummary($summary, $where, $from); if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) { @@ -6701,7 +6701,7 @@ protected function addBasicCancelStatsToSummary(&$summary, $where, $from) { GROUP BY currency"; $dao = CRM_Core_DAO::executeQuery($query); - + $summary['cancel'] = ['count' => 0, 'amount' => 0, 'avg' => 0]; if ($dao->N <= 1) { if ($dao->fetch()) { $summary['cancel']['count'] = $dao->cancel_count; diff --git a/templates/CRM/Contribute/Form/Selector.tpl b/templates/CRM/Contribute/Form/Selector.tpl index 0ab49308ebea..d5d39808d54d 100644 --- a/templates/CRM/Contribute/Form/Selector.tpl +++ b/templates/CRM/Contribute/Form/Selector.tpl @@ -22,7 +22,7 @@ {/if} {foreach from=$columnHeaders item=header} - {if isset($header.sort)} + {if $header.sort} {assign var='key' value=$header.sort} {$sort->_response.$key.link} {elseif (!empty($header.name))} @@ -57,12 +57,12 @@ {foreach from=$columnHeaders item=column} {assign var='columnName' value=''} - {if isset($column.field_name)} + {if $column.field_name} {assign var='columnName' value=$column.field_name} {/if} {if !$columnName}{* if field_name has not been set skip, this helps with not changing anything not specifically edited *} {elseif $columnName === 'total_amount'}{* rendered above as soft credit columns = confusing *} - {elseif isset($column.type) && $column.type === 'actions'}{* rendered below as soft credit column handling = not fixed *} + {elseif $column.type === 'actions'}{* rendered below as soft credit column handling = not fixed *} {elseif $columnName == 'contribution_status'} {$row.contribution_status}
@@ -71,13 +71,13 @@ {/if} {else} - {if isset($column.type) && $column.type == 'date'} + {if $column.type == 'date'} {$row.$columnName|crmDate} {else} - - {if isset($row.$columnName)}{$row.$columnName}{/if} + + {$row.$columnName} {/if} {/if} diff --git a/templates/CRM/Contribute/Page/ContributionTotals.tpl b/templates/CRM/Contribute/Page/ContributionTotals.tpl index 0a105df7774b..f95aa06c10b3 100644 --- a/templates/CRM/Contribute/Page/ContributionTotals.tpl +++ b/templates/CRM/Contribute/Page/ContributionTotals.tpl @@ -29,11 +29,11 @@   {ts}# Completed{/ts} – {$contributionSummary.total.count}   {ts}Avg{/ts} – {$contributionSummary.total.avg} {/if} - {if isset($contributionSummary.cancel.amount)} + {if $contributionSummary.cancel.amount}   {ts}Cancelled/Refunded{/ts} – {$contributionSummary.cancel.amount} {/if} - {if isset($contributionSummary.soft_credit.count)} + {if $contributionSummary.soft_credit.count} {include file="CRM/Contribute/Page/ContributionSoftTotals.tpl" softCreditTotals=$contributionSummary.soft_credit} {/if} {/if} diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index 2147bb609ad3..82e1f779414a 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -1103,7 +1103,7 @@ public function getSortOptions() { * * @throws \CRM_Core_Exception */ - public function testGetSummaryQueryWithFinancialACLDisabled() { + public function testGetSummaryQueryWithFinancialACLDisabled(): void { $this->createContributionsForSummaryQueryTests(); // Test the function directly @@ -1128,6 +1128,11 @@ public function testGetSummaryQueryWithFinancialACLDisabled() { 'amount' => '$ 100.00', 'avg' => '$ 50.00', ], + 'soft_credit' => [ + 'count' => 0, + 'avg' => 0, + 'amount' => 0, + ], ], $summary); } @@ -1136,7 +1141,7 @@ public function testGetSummaryQueryWithFinancialACLDisabled() { * * @throws \CRM_Core_Exception */ - public function testGetSummaryQueryWithFinancialACLEnabled() { + public function testGetSummaryQueryWithFinancialACLEnabled(): void { $where = $from = NULL; $this->createContributionsForSummaryQueryTests(); $this->enableFinancialACLs(); @@ -1166,6 +1171,11 @@ public function testGetSummaryQueryWithFinancialACLEnabled() { 'amount' => '$ 50.00', 'avg' => '$ 50.00', ], + 'soft_credit' => [ + 'count' => 0, + 'avg' => 0, + 'amount' => 0, + ], ], $summary); $this->disableFinancialACLs(); }