Merge pull request #1444 from deepak-srivastava/logrev
[civicrm-core.git] / CRM / Member / Form / MembershipRenewal.php
index b9fada68d281dea640e7ecb302fa903366c3d0e1..7b8ab3fce3a1301f8482d878c7b18623121c9ec4 100644 (file)
@@ -72,6 +72,16 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
    */
   protected $_context;
 
+  /**
+   * An array to hold a list of datefields on the form
+   * so that they can be converted to ISO in a consistent manner
+   *
+   * @var array
+   */
+  protected $_dateFields = array(
+    'receive_date' => array('default' => 'now'),
+  );
+
   public function preProcess() {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
@@ -157,7 +167,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
       }
       // also check for billing information
       // get the billing location type
-      $locationTypes = CRM_Core_PseudoConstant::locationType();
+      $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
       // CRM-8108 remove ts around Billing location type
       //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
       $this->_bltID = array_search('Billing', $locationTypes);
@@ -436,7 +446,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       $this->add('text', 'total_amount', ts('Amount'));
       $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
 
-      $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate'));
+      $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
 
       $this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
       $this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer');
@@ -500,7 +510,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       // causes a conflict in standalone mode so skip in standalone for now
       $this->addElement('checkbox', 'contribution_contact', ts('Record Payment from a Different Contact?'));
       $this->add( 'select', 'honor_type_id', ts('Membership payment is : '),
-        array( '' => ts( '-') ) + CRM_Core_PseudoConstant::honor() );
+        array( '' => ts( '-') ) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id') );
       require_once 'CRM/Contact/Form/NewContact.php';
       CRM_Contact_Form_NewContact::buildQuickForm($this,1, null, false,'contribution_');
   }
@@ -563,12 +573,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     }
 
     $now = CRM_Utils_Date::getToday( null, 'YmdHis');
-    if (CRM_Utils_Array::value('receive_date', $this->_params)) {
-      $formValues['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date']);
-    }
-    else {
-      $formValues['receive_date'] = $now;
-    }
+    $this->convertDateFieldsToMySQL($formValues);
     $this->assign('receive_date', $formValues['receive_date']);
 
     if (CRM_Utils_Array::value('send_receipt', $this->_params)) {
@@ -747,7 +752,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       $lineItem = array();
       $priceSetId = null;
       CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
-      CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'],
+      CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
         $this->_params, $lineItem[$priceSetId]
       );
       //CRM-11529 for quick config backoffice transactions
@@ -773,9 +778,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       }
       $formValues['contact_id'] = $this->_contactID;
 
-      CRM_Member_BAO_Membership::recordMembershipContribution( $formValues,
-        CRM_Core_DAO::$_nullArray,
-        $renewMembership->id );
+      CRM_Member_BAO_Membership::recordMembershipContribution(array_merge($formValues, array('membership_id' => $renewMembership->id)));
     }
 
     if (CRM_Utils_Array::value('send_receipt', $formValues)) {