waiting list signup fixes, CRM-14225
authorkurund <kurund@civicrm.org>
Fri, 14 Mar 2014 07:23:51 +0000 (12:53 +0530)
committerkurund <kurund@civicrm.org>
Fri, 14 Mar 2014 07:23:51 +0000 (12:53 +0530)
----------------------------------------
* CRM-14225: Waitlist signup not working for full paid events
  http://issues.civicrm.org/jira/browse/CRM-14225

CRM/Event/Form/Registration/Register.php

index 306a5bee075d9b51ea747ab381edca33a257eda1..a20c29aeca2d0d1ea957888e6e5c90920b4baa4e 100644 (file)
@@ -71,6 +71,11 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
   public $_ppType;
   public $_snippet;
 
+  /**
+   * @var boolean determines if fee block should be shown or hidden
+   */
+  public $_noFees;
+
   /**
    * Function to set variables up before form is built
    *
@@ -89,8 +94,8 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     // Get payment processors if appropriate for this event
     // We hide the payment fields if the event is full or requires approval,
     // and the current user has not yet been approved CRM-12279
-    $noFees = (($eventFull || $this->_requireApproval) && !$this->_allowConfirmation);
-    CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this, $noFees);
+    $this->_noFees = (($eventFull || $this->_requireApproval) && !$this->_allowConfirmation);
+    CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this, $this->_noFees);
     if ($this->_snippet) {
       return;
     }
@@ -542,6 +547,12 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    * @static
    */
   static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) {
+    // build amount only when needed, skip incase of event full and waitlisting is enabled
+    // and few other conditions check preProcess()
+    if ($form->_noFees) {
+      return;
+    }
+
     //if payment done, no need to build the fee block.
     if (!empty($form->_paymentId)) {
       //fix to diaplay line item in update mode.
@@ -840,7 +851,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     if ($self->_values['event']['is_monetary']) {
-      if (empty($self->_requireApproval) && $fields['amount'] > 0 && !isset($fields['payment_processor'])) {
+      if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 && !isset($fields['payment_processor'])) {
         $errors['payment_processor'] = ts('Please select a Payment Method');
       }
       if (is_array($self->_paymentProcessor)) {
@@ -1038,8 +1049,13 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         $params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
       }
       elseif (empty($params['priceSetId'])) {
-        $params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
-        $params['amount'] = $this->_values['fee'][$params['amount']]['value'];
+        if (!empty($params['amount'])) {
+          $params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
+          $params['amount'] = $this->_values['fee'][$params['amount']]['value'];
+        }
+        else {
+          $params['amount_level'] = $params['amount'] = '';
+        }
       }
       else {
         $lineItem = array();