From: Kurund Jalmi Date: Thu, 2 May 2013 21:31:49 +0000 (-0700) Subject: worked on CRM-12463, more cleanup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7ccf88297076db767fd381a796d8b7f74f11d24d;p=civicrm-core.git worked on CRM-12463, more cleanup --- diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 77ce7a3868..102540d670 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -141,7 +141,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio * @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', @@ -149,6 +149,36 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio '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(); @@ -171,6 +201,8 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $count++; } } + */ + return $softContribution; } diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index e909556b9c..be1fe301b6 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -129,22 +129,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { } //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) { diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index 2cc49b1f38..2e6e2e2b0e 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -54,8 +54,7 @@ class CRM_Contribute_Form_SoftCredit { $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++; diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 3eb438a3c9..7e695d2858 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -387,6 +387,8 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa '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']; diff --git a/templates/CRM/Contribute/Form/ContributionView.tpl b/templates/CRM/Contribute/Form/ContributionView.tpl index cb23e46dc0..210862dc32 100644 --- a/templates/CRM/Contribute/Form/ContributionView.tpl +++ b/templates/CRM/Contribute/Form/ContributionView.tpl @@ -209,15 +209,14 @@
{foreach from=$softContributions.soft_credit item="softCont"} - {if $softCont } - - - - - - - {/if} + + + + {/foreach}
{ts}Soft Credit To{/ts}{$softCont.softCreditToName}{ts}Amount{/ts}{$softCont.soft_credit_amount|crmMoney:$currency}
+ {$softCont.contact_name} + + {$softCont.amount|crmMoney:$currency}