Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-10-01-19-08-00
[civicrm-core.git] / CRM / Contribute / Form / ContributionView.php
index 362b7680f180a886df5519ed5e793f33379249c5..0fa8506c6f0a513cec8955b9fd64331f451c9b15 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -70,18 +70,6 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       }
     }
 
-    if (!empty($values['honor_contact_id'])) {
-      $sql    = "SELECT display_name FROM civicrm_contact WHERE id = %1";
-      $params = array(1 => array($values['honor_contact_id'], 'Integer'));
-      $dao    = CRM_Core_DAO::executeQuery($sql, $params);
-      if ($dao->fetch()) {
-        $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=$values[honor_contact_id]");
-        $values['honor_display'] = "<A href = $url>" . $dao->display_name . "</A>";
-      }
-      $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
-      $values['honor_type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $values), $honor);
-    }
-
     if (!empty($values['contribution_recur_id'])) {
       $sql    = "SELECT  installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
       $params = array(1 => array($values['contribution_recur_id'], 'Integer'));
@@ -128,13 +116,25 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       $values['billing_address'] = $addressDetails[0]['display'];
     }
 
-    //get soft credit record if exists.
-    $values['softContributions'] = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id']);
+    //assign soft credit record if exists.
+    $SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
+    if (!empty($SCRecords['soft_credit'])) {
+      $this->assign('softContributions', $SCRecords['soft_credit']);
+      unset($SCRecords['soft_credit']);
+    }
+
+    //assign pcp record if exists
+    foreach ($SCRecords as $name => $value) {
+      $this->assign($name, $value);
+    }
 
     $lineItems = array();
     if ($id) {
-      $lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1);
-      empty($lineItem) ? null :$lineItems[] =  $lineItem;
+      $lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
+      if (!empty($lineItem)) {
+        $lineItems[] = $lineItem;
+      }
+
     }
     $this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
     $values['totalAmount'] = $values['total_amount'];
@@ -206,4 +206,3 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
     );
   }
 }
-