* @return array of soft contribution ids, amounts, and associated contact ids
* @static
*/
- static function getSoftContribution($params, $all = FALSE) {
+ static function getSoftContribution($contributionID, $all = FALSE) {
$pcpFields = array(
'pcp_id',
'pcp_display_in_roll',
'pcp_personal_note',
);
+ $query = '
+ SELECT ccs.id, pcp_id, pcp_display_in_roll, pcp_roll_nickname, pcp_personal_note, amount, contact_id, c.display_name
+ FROM civicrm_contribution_soft ccs INNER JOIN civicrm_contact c on c.id = ccs.contact_id
+ WHERE contribution_id = %1;
+ ';
+
+ $params = array(1 => array($contributionID, 'Integer'));
+
+ $dao = CRM_Core_DAO::executeQuery($query, $params);
+
+ $softContribution = array();
+ $count = 1;
+ while ($dao->fetch()) {
+ if ($all) {
+ foreach ($pcpFields as $val) {
+ $softContribution['pcp'][$val] = $dao->$val;
+ }
+ }
+
+ $softContribution['soft_credit'][$count] = array(
+ 'contact_id' => $dao->contact_id,
+ 'soft_credit_id' => $dao->id,
+ 'amount' => $dao->amount,
+ 'contact_name' => $dao->display_name
+ );
+ $count++;
+ }
+
+ /*
+ * FIX API before deleting this
$cs = new CRM_Contribute_DAO_ContributionSoft();
$cs->copyValues($params);
$softContribution = array();
$count++;
}
}
+ */
+
return $softContribution;
}
}
//get soft credit record if exists.
- $softParams = array('contribution_id' => CRM_Utils_Array::value('contribution_id', $values));
- $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($softParams);
- if (!empty($softContribution)) {
- foreach($softContribution['soft_credit'] 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;
- }
+ $values['softContributions'] = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id']);
$lineItems = array();
if ($id) {
$showSoftCreditRow = 2;
$showCreateNew = true;
if ($form->_action & CRM_Core_Action::UPDATE) {
- $csParams = array('contribution_id' => $form->_id);
- $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($csParams, TRUE);
+ $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
'contact_id' => $formatted['soft_credit_to'],
'contribution_id' => $ids['contribution'],
);
+
+ //FIXE ME: Need to fix this logic
$existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit);
if (CRM_Utils_Array::value('soft_credit_id', $existingSoftCredit)) {
$formatted['softID'] = $existingSoftCredit['soft_credit_id'];
<div class="crm-accordion-body">
<table class="crm-info-panel">
{foreach from=$softContributions.soft_credit item="softCont"}
- {if $softCont }
- <tr>
- <td class="label">{ts}Soft Credit To{/ts}</td>
- <td><a href="{crmURL p="civicrm/contact/view" q="reset=1&cid=`$softCont.soft_credit_to`"}"
- id="view_contact" title="{ts}View contact record{/ts}">{$softCont.softCreditToName}</a></td>
- <td class="label">{ts}Amount{/ts}</td>
- <td>{$softCont.soft_credit_amount|crmMoney:$currency}</td>
- </tr>
- {/if}
+ <tr>
+ <td>
+ <a href="{crmURL p="civicrm/contact/view" q="reset=1&cid=`$softCont.contact_id`"}"
+ id="view_contact" title="{ts}View contact record{/ts}">{$softCont.contact_name}
+ </a>
+ </td>
+ <td>{$softCont.amount|crmMoney:$currency}</td>
+ </tr>
{/foreach}
</table>
</div>