Fix lineitem fetch on ContributionView page.
authoreileen <emcnaughton@wikimedia.org>
Thu, 27 Oct 2016 11:00:06 +0000 (00:00 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 27 Oct 2016 11:24:05 +0000 (00:24 +1300)
Make the way in which is_quick_config it used explicit (do we want to display line items) rather than hidden
in a parameter in the getLineItem call

CRM/Contribute/Form/ContributionView.php
CRM/Price/BAO/LineItem.php
templates/CRM/Contribute/Form/ContributionView.tpl

index 2f001debd8089d677f08cbb91aaf14c43010e226..f21e4d219c778bb41f26fb3dbcea0a26cd25bcc1 100644 (file)
@@ -151,14 +151,15 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
     }
 
     $lineItems = array();
+    $displayLineItems = FALSE;
     if ($id) {
-      $lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
-      if (!empty($lineItem)) {
-        $lineItems[] = $lineItem;
-      }
-
+      $lineItems = array(CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id)));
+      $firstLineItem = reset($lineItems[0]);
+      $priceSet = civicrm_api3('PriceSet', 'getsingle', array('id' => $firstLineItem['price_set_id'], 'return' => 'is_quick_config, id'));
+      $displayLineItems = !$priceSet['is_quick_config'];
     }
-    $this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
+    $this->assign('lineItem', $lineItems);
+    $this->assign('displayLineItems', $displayLineItems);
     $values['totalAmount'] = $values['total_amount'];
 
     //do check for campaigns
index 586fbd68d6edef523ce83dabbe0152c038b8f862..76dd390a76a9a4e555a6e3f2a6cc8ceb0b68bf63 100644 (file)
@@ -214,6 +214,7 @@ AND li.entity_id = {$entityId}
       li.entity_id,
       pf.label as field_title,
       pf.html_type,
+      pf.price_set_id,
       pfv.membership_type_id,
       pfv.membership_num_terms,
       li.price_field_id,
@@ -298,6 +299,7 @@ AND li.entity_id = {$entityId}
         'membership_type_id' => $dao->membership_type_id,
         'membership_num_terms' => $dao->membership_num_terms,
         'tax_amount' => $dao->tax_amount,
+        'price_set_id' => $dao->price_set_id,
       );
       $lineItems[$dao->id]['tax_rate'] = CRM_Price_BAO_LineItem::calculateTaxRate($lineItems[$dao->id]);
       $lineItems[$dao->id]['subTotal'] = $lineItems[$dao->id]['qty'] * $lineItems[$dao->id]['unit_price'];
index 52cc51e32f6a0f583b7be46642a6444c7afe40bb..8f3cef9c3c87a514b0e2069865315b141d37f94b 100644 (file)
@@ -73,7 +73,7 @@
     <td class="label">{ts}Financial Type{/ts}</td>
     <td>{$financial_type}{if $is_test} {ts}(test){/ts} {/if}</td>
   </tr>
-  {if $lineItem}
+  {if $displayLineItems}
     <tr>
       <td class="label">{ts}Contribution Amount{/ts}</td>
       <td>{include file="CRM/Price/Page/LineItem.tpl" context="Contribution"}