Merge pull request #3626 from yashodha/CRM-14670
[civicrm-core.git] / CRM / Member / Form / Membership.php
index 8969f4cf3d14e9dbd740c92ee3e2aeaf398ad502..ef3acfb08ec2e220312aa6aff300b94fc96ce98d 100644 (file)
@@ -1091,6 +1091,13 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       return;
     }
 
+    $isTest = ($this->_mode == 'test') ? 1 : 0;
+
+    $lineItems = NULL;
+    if (!empty($this->_lineItem)) {
+      $lineItems = $this->_lineItem;
+    }
+
     $config = CRM_Core_Config::singleton();
     // get the submitted form values.
     $this->_params = $formValues = $this->controller->exportValues($this->_name);
@@ -1447,7 +1454,9 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
           $this->_contributorContactID,
           $contributionType,
           TRUE,
-          FALSE
+          FALSE,
+          $isTest,
+          $lineItems
         );
 
         //create new soft-credit record, CRM-13981
@@ -1456,7 +1465,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
         $softParams['amount'] = $contribution->total_amount;
         CRM_Contribute_BAO_ContributionSoft::add($softParams);
 
-        $paymentParams['contactID'] = $contactID;
+        $paymentParams['contactID'] = $this->_contactID;
         $paymentParams['contributionID'] = $contribution->id;
         $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
         $paymentParams['contributionPageID'] = $contribution->contribution_page_id;
@@ -1673,6 +1682,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
 
       $formValues['contact_id'] = $this->_contactID;
 
+      $formValues['contribution_id'] = CRM_Member_BAO_Membership::getMembershipContributionId($membership->id);
       // send email receipt
       $mailSend = self::emailReceipt($this, $formValues, $membership);
     }