/** * Process the form submission. * * * @return void */ public function postProcess() { //get the button name. $button = substr($this->controller->getButtonName(), -4); //take the participant instance. $addParticipantNum = substr($this->_name, 12); //user submitted params. $params = $this->controller->exportValues($this->_name); if (!$this->_allowConfirmation) { // check if the participant is already registered $params['contact_id'] = CRM_Event_Form_Registration_Register::checkRegistration($params, $this, TRUE, TRUE); } //carry campaign to partcipants. if (array_key_exists('participant_campaign_id', $params)) { $params['campaign_id'] = $params['participant_campaign_id']; } else { $params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']); } // if waiting is enabled if (!$this->_allowConfirmation && is_numeric($this->_availableRegistrations)) { $this->_allowWaitlist = FALSE; //get the current page count. $currentCount = self::getParticipantCount($this, $params); if ($button == 'skip') { $currentCount = 'skip'; } //get the total count. $previousCount = self::getParticipantCount($this, $this->_params, TRUE); $totalParticipants = $previousCount; if (is_numeric($currentCount)) { $totalParticipants += $currentCount; } if (!empty($this->_values['event']['has_waitlist']) && $totalParticipants > $this->_availableRegistrations) { $this->_allowWaitlist = TRUE; } $this->set('allowWaitlist', $this->_allowWaitlist); $this->_lineItemParticipantsCount[$addParticipantNum] = $currentCount; } if ($button == 'skip') { //hack for free/zero amount event. if ($this->_resetAllowWaitlist) { $this->_allowWaitlist = FALSE; $this->set('allowWaitlist', FALSE); if ($this->_requireApproval) { $status = ts("You have skipped last participant and which result into event having enough spaces, but your registration require 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."); } else { $status = ts("You have skipped last participant and which result into event having enough spaces, hence your group become as register participants though you selected on wait list."); } CRM_Core_Session::setStatus($status); } $this->_params[$addParticipantNum] = 'skip'; if (isset($this->_lineItem)) { $this->_lineItem[$addParticipantNum] = 'skip'; $this->_lineItemParticipantsCount[$addParticipantNum] = 'skip'; } } else { $config = CRM_Core_Config::singleton(); $params['currencyID'] = $config->defaultCurrency; if ($this->_values['event']['is_monetary']) { //added for discount $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event'); if (!empty($this->_values['discount'][$discountId])) { $params['discount_id'] = $discountId; $params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label']; $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']; } else { $lineItem = array(); CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem); //build line item array.. //if requireApproval/waitlist is enabled we hide fees for primary participant // (and not for additional participant which might be is a bug) //lineItem are not correctly build for primary participant //this results in redundancy since now lineItems for additional participant will be build against primary participantNum //therefore lineItems must always be build against current participant No $this->_lineItem[$addParticipantNum] = $lineItem; } } if (array_key_exists('participant_role', $params)) { $params['participant_role_id'] = $params['participant_role']; } if (empty($params['participant_role_id']) && $this->_values['event']['default_role_id']) { $params['participant_role_id'] = $this->_values['event']['default_role_id']; } if (!empty($this->_params[0]['is_pay_later'])) { $params['is_pay_later'] = 1; } //carry additional participant id, contact id if pre-registered. if ($this->_allowConfirmation && $this->_additionalParticipantId) { $params['contact_id'] = $this->_contactId; $params['participant_id'] = $this->_additionalParticipantId; } //build the params array. $this->_params[$addParticipantNum] = $params; } //finally set the params. $this->set('params', $this->_params); //set the line item. if ($this->_lineItem) { $this->set('lineItem', $this->_lineItem); $this->set('lineItemParticipantsCount', $this->_lineItemParticipantsCount); } $participantNo = count($this->_params); if ($button != 'skip') { $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo)); CRM_Core_Session::setStatus($statusMsg, ts('Registration Saved'), 'success'); } // Check whether to process the registration now, calling processRegistration() if (!$this->_values['event']['is_confirm_enabled'] && !$this->_values['event']['is_monetary'] && CRM_Utils_Array::value('additional_participants', $this->_params[0]) && $this->isLastParticipant()) { CRM_Event_Form_Registration_Register::processRegistration($this->_params, NULL); } }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { //get the button name. $button = substr($this->controller->getButtonName(), -4); //take the participant instance. $addParticipantNum = substr($this->_name, 12); if ($button == 'skip') { //hack for free/zero amount event. if ($this->_resetAllowWaitlist) { $this->_allowWaitlist = false; $this->set('allowWaitlist', false); if ($this->_requireApproval) { $status = ts("You have skipped last participant and which result into event having enough spaces, but your registration require 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."); } else { $status = ts("You have skipped last participant and which result into event having enough spaces, hence your group become as register participants though you selected on wait list."); } CRM_Core_Session::setStatus($status); } $this->_params[$addParticipantNum] = 'skip'; if (isset($this->_lineItem)) { $this->_lineItem[$addParticipantNum] = 'skip'; } } else { $params = $this->controller->exportValues($this->_name); if ($this->_values['event']['is_monetary']) { //added for discount require_once 'CRM/Core/BAO/Discount.php'; $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event'); if (!empty($this->_values['discount'][$discountId])) { $params['discount_id'] = $discountId; $params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label']; $params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value']; } else { if (empty($params['priceSetId'])) { $params['amount_level'] = $this->_values['fee'][$params['amount']]['label']; $params['amount'] = $this->_values['fee'][$params['amount']]['value']; } else { $lineItem = array(); require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::processAmount($this->_values['fee']['fields'], $params, $lineItem); //build the line item.. if (array_key_exists($addParticipantNum, $this->_lineItem)) { $this->_lineItem[$addParticipantNum] = $lineItem; } else { $this->_lineItem[] = $lineItem; } } } } if (!CRM_Utils_Array::value('participant_role_id', $params) && $this->_values['event']['default_role_id']) { $params['participant_role_id'] = $this->_values['event']['default_role_id']; } if (CRM_Utils_Array::value('is_pay_later', $this->_params[0])) { $params['is_pay_later'] = 1; } //carry additional participant id, contact id if pre-registered. if ($this->_allowConfirmation && $this->_additionalParticipantId) { $params['contact_id'] = $this->_contactID; $params['participant_id'] = $this->_additionalParticipantId; } //build the params array. if (array_key_exists($addParticipantNum, $this->_params)) { $this->_params[$addParticipantNum] = $params; } else { $this->_params[] = $params; } } //finally set the params. $this->set('params', $this->_params); //set the line item. if ($this->_lineItem) { $this->set('lineItem', $this->_lineItem); } $participantNo = count($this->_params); if ($button != 'skip') { require_once "CRM/Core/Session.php"; $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo)); CRM_Core_Session::setStatus("{$statusMsg}"); } //to check whether call processRegistration() if (!$this->_values['event']['is_monetary'] && CRM_Utils_Array::value('additional_participants', $this->_params[0]) && $this->isLastParticipant()) { require_once 'CRM/Event/Form/Registration/Register.php'; CRM_Event_Form_Registration_Register::processRegistration($this->_params, null); } }