$cs = CRM_Core_DAO::executeQuery($query, $params);
- $count = 0;
+ $count = $countCancelled = 0;
$amount = $average = $cancelAmount = array();
while ($cs->fetch()) {
if ($cs->amount > 0) {
$count++;
- $amount[] = $cs->amount;
- $average[] = $cs->average;
- $currency[] = $cs->currency;
+ $amount[] = CRM_Utils_Money::format($cs->amount, $cs->currency);
+ $average[] = CRM_Utils_Money::format($cs->average, $cs->currency);
}
}
$cancelAmountSQL = CRM_Core_DAO::executeQuery($query, $params);
while ($cancelAmountSQL->fetch()) {
if ($cancelAmountSQL->amount > 0) {
- $count++;
- $cancelAmount[] = $cancelAmountSQL->amount;
+ $countCancelled++;
+ $cancelAmount[] = CRM_Utils_Money::format($cancelAmountSQL->amount, $cancelAmountSQL->currency);
}
}
- if ($count > 0) {
+ if ($count > 0 || $countCancelled > 0) {
return array(
+ $count,
+ $countCancelled,
implode(', ', $amount),
implode(', ', $average),
- implode(', ', $currency),
implode(', ', $cancelAmount),
);
}
if (!empty($softCreditList)) {
$softCreditTotals = array();
- list($softCreditTotals['amount'],
+ list($softCreditTotals['count'],
+ $softCreditTotals['cancel']['count'],
+ $softCreditTotals['amount'],
$softCreditTotals['avg'],
- $softCreditTotals['currency'],
- $softCreditTotals['cancelAmount'] // to get cancel amount
+ $softCreditTotals['cancel']['amount'] // to get cancel amount
) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
$this->assign('softCredit', TRUE);
{strip}
{if $context neq 'membership'}
<table class="form-layout-compressed">
- <tr>
- {if $softCreditTotals.amount}
- <th class="contriTotalLeft">{ts}Total Soft Credits{/ts} – {$softCreditTotals.amount|crmMoney:$softCreditTotals.currency}</th>
- <th class="right" width="10px"> </th>
- <th class="right contriTotalRight"> {ts}Avg Soft Credits{/ts} – {$softCreditTotals.avg|crmMoney:$softCreditTotals.currency}</th>
- {/if}
- {if $softCreditTotals.cancelAmount}
- <th class="right contriTotalRight"> {ts}Total Cancelled Soft Credits{/ts} – {$softCreditTotals.cancelAmount|crmMoney:$softCreditTotals.currency}</th>
- {/if}
- </tr>
+ {include file="CRM/Contribute/Page/ContributionSoftTotals.tpl"}
</table>
<p></p>
{/if}
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{* Display soft credit totals for a contact or search result-set *}
+
+<tr>
+ {if $softCreditTotals.amount}
+ <th class="contriTotalLeft right">{ts}Total Soft Credit Amount{/ts} – {$softCreditTotals.amount}</th>
+ <th class="right"> {ts}# Completed Soft Credits{/ts} – {$softCreditTotals.count}</th>
+ <th class="right contriTotalRight"> {ts}Avg Soft Credit Amount{/ts} – {$softCreditTotals.avg}</th>
+ {/if}
+ {if $softCreditTotals.cancel.amount}
+ <th class="disabled right contriTotalRight"> {ts}Cancelled/Refunded{/ts} – {$softCreditTotals.cancel.amount}</th>
+ {/if}
+</tr>
{/if}
</tr>
{if $contributionSummary.soft_credit.count}
- <tr>
- <th class="contriTotalLeft right">{ts}Total Soft Credit Amount{/ts} – {$contributionSummary.soft_credit.amount}</th>
- <th class="right"> {ts}# Completed Soft Credits{/ts} – {$contributionSummary.soft_credit.count}</th>
- <th class="right contriTotalRight"> {ts}Avg Soft Credit Amount{/ts} – {$contributionSummary.soft_credit.avg}</th>
- </tr>
+ {include file="CRM/Contribute/Page/ContributionSoftTotals.tpl" softCreditTotals=$contributionSummary.soft_credit}
{/if}
{/if}