From: Jon goldberg - Linux laptop Date: Tue, 30 Apr 2013 23:20:47 +0000 (-0700) Subject: Add support to Contribution view for multiple soft credits X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=10b7c07e8c8f58096ca1dcde2d8484633954d9d6;p=civicrm-core.git Add support to Contribution view for multiple soft credits --- diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index efed315036..d24bca8ed5 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -53,12 +53,6 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { $this->assign('context', $context); CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids); - - $softParams = array('contribution_id' => CRM_Utils_Array::value('contribution_id', $values)); - $softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams, TRUE); -// if ($softContribution) { -// $values = array_merge($values, $softContribution); -// } CRM_Contribute_BAO_Contribution::resolveDefaults($values); if (CRM_Utils_Array::value('contribution_page_id', $values)) { @@ -135,18 +129,21 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { } //get soft credit record if exists. - //FIXME: The next line seems really inefficient. Can't we just check the length of the array? - if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams)) { - - $softContribution['softCreditToName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $softContribution['soft_credit_to'], 'display_name' - ); - //hack to avoid dispalyName conflict - //for viewing softcredit record. - $softContribution['displayName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $values['contact_id'], 'display_name' - ); - $values = array_merge($values, $softContribution); + $softParams = array('contribution_id' => CRM_Utils_Array::value('contribution_id', $values)); + $softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams); + if (!empty($softContribution)) { + foreach($softContribution as &$individualSoftContribution) { + $individualSoftContribution['softCreditToName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', + $individualSoftContribution['soft_credit_to'], 'display_name' + ); + //hack to avoid displayName conflict + //for viewing softcredit record. + $individualSoftContribution['displayName'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', + $values['contact_id'], 'display_name' + ); + + } + $values['softContributions'] = $softContribution; } $lineItems = array(); diff --git a/templates/CRM/Contribute/Form/ContributionView.tpl b/templates/CRM/Contribute/Form/ContributionView.tpl index 2b930414e2..34a0ea099d 100644 --- a/templates/CRM/Contribute/Form/ContributionView.tpl +++ b/templates/CRM/Contribute/Form/ContributionView.tpl @@ -192,19 +192,23 @@ {/if} - {if $softCreditToName and !$pcp_id} {* We show soft credit name with PCP section if contribution is linked to a PCP. *} + {if $softContributions and !$pcp_id} {* We show soft credit name with PCP section if contribution is linked to a PCP. *}
{ts}Soft Credit{/ts}
+ {foreach from=$softContributions item="softCont"} + {if $softCont } - + - + + {/if} + {/foreach}
{ts}Soft Credit To{/ts}{$softCreditToName}{$softCont.softCreditToName} {ts}Amount{/ts}{$soft_credit_amount|crmMoney:$currency}{$softCont.soft_credit_amount|crmMoney:$currency}