/**
* Function to retrieve the list of soft contributions for given contact.
*
- * @param int $contact_id contact id
- *
- * @param int $isTest
+ * @param int $contact_id contact id
+ * @param int $isTest
+ * @param string $filter additional filter criteria, later used in where clause
*
* @return array
* @static
*/
- static function getSoftContributionList($contact_id, $isTest = 0) {
+ static function getSoftContributionList($contact_id, $filter = NULL, $isTest = 0) {
$query = '
SELECT ccs.id, ccs.amount as amount,
ccs.contribution_id,
LEFT JOIN civicrm_contact contact ON
ccs.contribution_id = cc.id AND cc.contact_id = contact.id
LEFT JOIN civicrm_financial_type cct ON cc.financial_type_id = cct.id
- WHERE cc.is_test = %2 AND ccs.contact_id = %1
- ORDER BY cc.receive_date DESC';
+ ';
+
+ $where = "
+ WHERE cc.is_test = %2 AND ccs.contact_id = %1";
+ if ($filter) {
+ $where .= $filter;
+ }
+
+ $query .= "{$where} ORDER BY cc.receive_date DESC";
$params = array(
1 => array($contact_id, 'Integer'),
}
$this->assign('isTest', $isTest);
- $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $isTest);
+ $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest);
if (!empty($softCreditList)) {
$softCreditTotals = array();
$contributionParams['batch_id'] = $params['batch_id'];
}
+ if (!empty($params['contribution_contact_id'])) {
+ // deal with possibility of a different person paying for contribution
+ $contributionParams['contact_id'] = $params['contribution_contact_id'];
+ }
+
if (!empty($params['processPriceSet']) &&
!empty($params['lineItems'])
) {
//CRM-13981, allow different person as a soft-contributor of chosen type
if ($this->_contributorContactID != $this->_contactID) {
+ $params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])) {
$softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
- $softParams['contact_id'] = $this->_contributorContactID;
+ $softParams['contact_id'] = $this->_contactID;
}
}
if (!empty($formValues['record_contribution'])) {
//assign contribution contact id to the field expected by recordMembershipContribution
if($this->_contributorContactID != $this->_contactID){
+ $formValues['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])){
$formValues['soft_credit'] = array(
'soft_credit_type_id' => $this->_params['soft_credit_type_id'],
- 'contact_id' => $this->_contributorContactID,
+ 'contact_id' => $this->_contactID,
);
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$this->_accessContribution = TRUE;
$this->assign('accessContribution', TRUE);
+
+ //show associated soft credit when contribution payment is paid by different person
+ if ($this->_id && $this->_contactId) {
+ $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
+ $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
+ if (!empty($softCreditList)) {
+ $this->assign('softCredit', TRUE);
+ $this->assign('softCreditRows', $softCreditList);
+ }
+ }
}
else {
$this->_accessContribution = FALSE;
$this->assign('accessContribution', FALSE);
+ $this->assign('softCredit', FALSE);
}
if ($this->_action & CRM_Core_Action::VIEW) {
*}
{if $softCreditRows}
{strip}
-<table class="form-layout-compressed">
- <tr>
- <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>
- </tr>
-</table>
-<p></p>
+{if $context neq 'membership'}
+ <table class="form-layout-compressed">
+ <tr>
+ <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>
+ </tr>
+ </table>
+ <p></p>
+{/if}
<table class="selector row-highlight">
<tr class="columnheader">
{include file="CRM/Contribute/Form/Selector.tpl" context="Search"}
{/if}
+ {if $softCredit}
+ {include file="CRM/Contribute/Page/ContributionSoft.tpl" context="membership"}
+ {/if}
+
{if $has_related}
{include file="CRM/Member/Form/MembershipRelated.tpl" context="Search"}
{/if}