Merge pull request #6456 from eileenmcnaughton/CRM-16993
[civicrm-core.git] / CRM / Member / Form / Membership.php
index d4d8b0e39fda8e59fd46d45a089b51eb0f57e795..5767b89d9d02923078b41e85bf4d22bb737e42bd 100644 (file)
@@ -630,7 +630,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
 
       $this->add('select', 'payment_instrument_id',
-        ts('Paid By'),
+        ts('Payment Method'),
         array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
         FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
       );
@@ -804,7 +804,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
     }
 
     if (!empty($params['record_contribution']) && empty($params['payment_instrument_id'])) {
-      $errors['payment_instrument_id'] = ts('Paid By is a required field.');
+      $errors['payment_instrument_id'] = ts('Payment Method is a required field.');
     }
 
     if (!empty($params['is_different_contribution_contact'])) {
@@ -1157,11 +1157,6 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
     $allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
     $allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
 
-    $lineItems = NULL;
-    if (!empty($this->_lineItem)) {
-      $lineItems = $this->_lineItem;
-    }
-
     if ($this->_id) {
       $ids['membership'] = $params['id'] = $this->_id;
     }
@@ -1493,15 +1488,23 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
         $financialType = new CRM_Financial_DAO_FinancialType();
         $financialType->id = $params['financial_type_id'];
         $financialType->find(TRUE);
+
         $contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this,
           $paymentParams,
-          $result,
-          $this->_contributorContactID,
+          NULL,
+          array(
+            'contact_id' => $this->_contributorContactID,
+            'line_item' => $lineItem,
+            'is_test' => $isTest,
+            'campaign_id' => CRM_Utils_Array::value('campaign_id', $paymentParams),
+            'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $this->_params),
+            'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)),
+            'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $paymentParams),
+            'payment_instrument_id' => $this->_paymentProcessor['payment_instrument_id'],
+          ),
           $financialType,
           TRUE,
           FALSE,
-          $isTest,
-          $lineItems,
           $this->_bltID
         );
 
@@ -1611,6 +1614,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
         // process -
         // @see http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=261062657#Payments&AccountsRoadmap-Movetowardsalwaysusinga2-steppaymentprocess
         $membershipParams['contribution_status_id'] = CRM_Utils_Array::value('payment_status_id', $result);
+        unset($membershipParams['lineItems']);
         $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids);
         $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams);
         unset($params['lineItems']);
@@ -1793,7 +1797,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
     CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
     //CRM-15187
     // dusplay message when membership type is changed
-    if ($this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
+    if (($this->_action & CRM_Core_Action::UPDATE) && $this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
       CRM_Core_Session::setStatus(
         ts('The financial types associated with the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its financial type.'),
         ts('Warning')