Use function on parent class to assign processors rather than duplication
[civicrm-core.git] / CRM / Member / Form / Membership.php
index e29407f1d0b9c896544c5bcd478b9f73eb7e1128..9f153c633c6234cfcc3b06079fbbc63780ba1b5f 100644 (file)
@@ -177,7 +177,8 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       $this->assign('cdType', TRUE);
       return CRM_Custom_Form_CustomData::preProcess($this);
     }
-
+    // This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
+    $this->assign('formClass', 'membership');
     parent::preProcess();
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
@@ -593,13 +594,10 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
         array('onclick' => "buildReceiptANDNotice( );")
       );
 
+      $this->assignPaymentRelatedVariables();
+
       if ($this->_mode) {
-        //get the valid recurring processors.
-        $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
-        $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
-        $recurProcessor = array_intersect_assoc($this->_processors, $recurring);
-        $autoRenew = array();
-        if (!empty($recurProcessor)) {
+        if (!empty($this->_recurPaymentProcessors)) {
           if (!empty($membershipType)) {
             $sql = '
 SELECT  id,
@@ -625,16 +623,12 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
             'onChange' =>
             "CRM.buildCustomData( 'Membership', this.value ); buildAutoRenew(this.value, null );",
           );
+          $this->assign('allowAutoRenew', TRUE);
         }
       }
     }
-    $allowAutoRenew = FALSE;
-    if ($this->_mode && !empty($recurProcessor)) {
-      $allowAutoRenew = TRUE;
-    }
-    $this->assign('allowAutoRenew', $allowAutoRenew);
+
     $this->assign('autoRenewOptions', json_encode($autoRenew));
-    $this->assign('recurProcessor', json_encode($recurProcessor));
 
     // for max_related: a little JS to show/hide & set default value
     $memTypeJs['onChange'] = "buildMaxRelated(this.value,true); " . $memTypeJs['onChange'];
@@ -741,9 +735,8 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
     );
 
-    //CRM-10223 - allow contribution to be recorded against different contact
-    // causes a conflict in standalone mode so skip in standalone for now
     $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
+
     $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
     $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
 
@@ -755,7 +748,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
 
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
 
-    $this->add('textarea', 'receipt_text_signup', ts('Receipt Message'));
+    $this->add('textarea', 'receipt_text', ts('Receipt Message'));
 
     // Retrieve the name and email of the contact - this will be the TO for receipt email
     if ($this->_contactID) {
@@ -1849,7 +1842,10 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     if (!empty($formValues['send_receipt']) && $receiptSend) {
       $formValues['contact_id'] = $this->_contactID;
       $formValues['contribution_id'] = $contributionId;
-
+      // We really don't need a distinct receipt_text_signup vs receipt_text_renewal as they are
+      // handled in the receipt. But by setting one we avoid breaking templates for now
+      // although at some point we should switch in the templates.
+      $formValues['receipt_text_signup'] = $formValues['receipt_text'];
       // send email receipt
       $mailSend = self::emailReceipt($this, $formValues, $membership);
     }