Skip to content

Commit

Permalink
Merge pull request #22179 from eileenmcnaughton/smarty6
Browse files Browse the repository at this point in the history
[Smarty variables]  Fix contribution tab to work with escape by default
  • Loading branch information
eileenmcnaughton authored Dec 1, 2021
2 parents f97b0d0 + d54658f commit f39b93b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions templates/CRM/Contribute/Form/Selector.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{/if}
{foreach from=$columnHeaders item=header}
<th scope="col">
{if isset($header.sort)}
{if $header.sort}
{assign var='key' value=$header.sort}
{$sort->_response.$key.link}
{elseif (!empty($header.name))}
Expand Down Expand Up @@ -57,12 +57,12 @@
</td>
{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'}
<td class="crm-contribution-status">
{$row.contribution_status}<br/>
Expand All @@ -71,13 +71,13 @@
{/if}
</td>
{else}
{if isset($column.type) && $column.type == 'date'}
{if $column.type == 'date'}
<td class="crm-contribution-{$columnName}">
{$row.$columnName|crmDate}
</td>
{else}
<td class="crm-{$columnName} crm-{$columnName}_{if isset($row.columnName)}{$row.columnName}{/if}">
{if isset($row.$columnName)}{$row.$columnName}{/if}
<td class="crm-{$columnName} crm-{$columnName}_{if $row.columnName}{$row.columnName}{/if}">
{$row.$columnName}
</td>
{/if}
{/if}
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Contribute/Page/ContributionTotals.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
<th class="right"> &nbsp; {ts}# Completed{/ts} &ndash; {$contributionSummary.total.count}</th>
<th class="right contriTotalRight"> &nbsp; {ts}Avg{/ts} &ndash; {$contributionSummary.total.avg}</th>
{/if}
{if isset($contributionSummary.cancel.amount)}
{if $contributionSummary.cancel.amount}
<th class="disabled right contriTotalRight"> &nbsp; {ts}Cancelled/Refunded{/ts} &ndash; {$contributionSummary.cancel.amount}</th>
{/if}
</tr>
{if isset($contributionSummary.soft_credit.count)}
{if $contributionSummary.soft_credit.count}
{include file="CRM/Contribute/Page/ContributionSoftTotals.tpl" softCreditTotals=$contributionSummary.soft_credit}
{/if}
{/if}
Expand Down
14 changes: 12 additions & 2 deletions tests/phpunit/CRM/Contact/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ public function getSortOptions() {
*
* @throws \CRM_Core_Exception
*/
public function testGetSummaryQueryWithFinancialACLDisabled() {
public function testGetSummaryQueryWithFinancialACLDisabled(): void {
$this->createContributionsForSummaryQueryTests();

// Test the function directly
Expand All @@ -1128,6 +1128,11 @@ public function testGetSummaryQueryWithFinancialACLDisabled() {
'amount' => '$ 100.00',
'avg' => '$ 50.00',
],
'soft_credit' => [
'count' => 0,
'avg' => 0,
'amount' => 0,
],
], $summary);
}

Expand All @@ -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();
Expand Down Expand Up @@ -1166,6 +1171,11 @@ public function testGetSummaryQueryWithFinancialACLEnabled() {
'amount' => '$ 50.00',
'avg' => '$ 50.00',
],
'soft_credit' => [
'count' => 0,
'avg' => 0,
'amount' => 0,
],
], $summary);
$this->disableFinancialACLs();
}
Expand Down

0 comments on commit f39b93b

Please sign in to comment.