/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { // build profiles first so that we can determine address fields etc // and then show copy address checkbox $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost'); if (!empty($this->_fields) && !empty($this->_values['custom_pre_id'])) { $profileAddressFields = array(); foreach ($this->_fields as $key => $value) { CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $this->_values['custom_pre_id'])); } $this->set('profileAddressFields', $profileAddressFields); } // Build payment processor form if ($this->_ppType) { CRM_Core_Payment_ProcessorForm::buildQuickForm($this); // Return if we are in an ajax callback if ($this->_snippet) { return; } } $contactID = $this->getContactID(); $this->assign('contact_id', $contactID); $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID)); $this->add('hidden', 'scriptFee', NULL); $this->add('hidden', 'scriptArray', NULL); $bypassPayment = $allowGroupOnWaitlist = $isAdditionalParticipants = FALSE; if ($this->_values['event']['is_multiple_registrations']) { // don't allow to add additional during confirmation if not preregistered. if (!$this->_allowConfirmation || $this->_additionalParticipantIds) { // Hardcode maximum number of additional participants here for now. May need to make this configurable per event. // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self") $additionalOptions = array('' => '1', 1 => '2', 2 => '3', 3 => '4', 4 => '5', 5 => '6', 6 => '7', 7 => '8', 8 => '9', 9 => '10'); $element = $this->add('select', 'additional_participants', ts('How many people are you registering?'), $additionalOptions, NULL, array('onChange' => "allowParticipant()")); $isAdditionalParticipants = TRUE; } } //hack to allow group to register w/ waiting if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) { $bypassPayment = TRUE; //case might be group become as a part of waitlist. //If not waitlist then they require admin approve. $allowGroupOnWaitlist = TRUE; $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations)); if ($this->_requireApproval) { $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.')); } } //case where only approval needed - no waitlist. if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) { $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.')); } //lets display status to primary page only. $this->assign('waitlistMsg', $this->_waitlistMsg); $this->assign('requireApprovalMsg', $this->_requireApprovalMsg); $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist); $this->assign('isAdditionalParticipants', $isAdditionalParticipants); //lets get js on two different qf elements. $showHidePayfieldName = NULL; $showHidePaymentInformation = FALSE; if ($this->_values['event']['is_monetary']) { self::buildAmount($this); } $pps = array(); //@todo this processor adding fn is another one duplicated on contribute - a shared // common class would make this sort of thing extractable $onlinePaymentProcessorEnabled = FALSE; if (!empty($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $key => $name) { if ($name['billing_mode'] == 1) { $onlinePaymentProcessorEnabled = TRUE; } $pps[$key] = $name['name']; } } if ($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) { //@todo we are blocking for multiple registrations because we haven't tested $this->addCidZeroOptions($onlinePaymentProcessorEnabled); } if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) && ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist)) { $pps[0] = $this->_values['event']['pay_later_text']; } if ($this->_values['event']['is_monetary']) { if (count($pps) > 1) { $this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, " "); } elseif (!empty($pps)) { $ppKeys = array_keys($pps); $currentPP = array_pop($ppKeys); $this->addElement('hidden', 'payment_processor', $currentPP); } } //lets add some qf element to bypass payment validations, CRM-4320 if ($bypassPayment) { $this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment')); } $this->assign('bypassPayment', $bypassPayment); $this->assign('showHidePaymentInformation', $showHidePaymentInformation); $userID = $this->getContactID(); if (!$userID) { $createCMSUser = FALSE; if ($this->_values['custom_pre_id']) { $profileID = $this->_values['custom_pre_id']; $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user'); } if (!$createCMSUser && $this->_values['custom_post_id']) { if (!is_array($this->_values['custom_post_id'])) { $profileIDs = array($this->_values['custom_post_id']); } else { $profileIDs = $this->_values['custom_post_id']; } foreach ($profileIDs as $pid) { if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) { $profileID = $pid; $createCMSUser = TRUE; break; } } } if ($createCMSUser) { CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE); } } //we have to load confirm contribution button in template //when multiple payment processor as the user //can toggle with payment processor selection $billingModePaymentProcessors = 0; if (!CRM_Utils_System::isNull($this->_paymentProcessors)) { foreach ($this->_paymentProcessors as $key => $values) { if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) { $billingModePaymentProcessors++; } } } if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) { $allAreBillingModeProcessors = TRUE; } else { $allAreBillingModeProcessors = FALSE; } if (!$allAreBillingModeProcessors || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment) { //freeze button to avoid multiple calls. $js = NULL; if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) { $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); } $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE, 'js' => $js))); } $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this); // add pcp fields if ($this->_pcpId) { CRM_PCP_BAO_PCP::buildPcp($this->_pcpId, $this); } }