3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2018
36 * This class generates form components for processing Event.
38 class CRM_Event_Form_Registration_AdditionalParticipant
extends CRM_Event_Form_Registration
{
41 * Pre-registered additional participant id.
43 public $additionalParticipantId = NULL;
46 * Set variables up before form is built.
50 public function preProcess() {
53 $participantNo = substr($this->_name
, 12);
55 //lets process in-queue participants.
56 if ($this->_participantId
&& $this->_additionalParticipantIds
) {
57 $this->_additionalParticipantId
= CRM_Utils_Array
::value($participantNo, $this->_additionalParticipantIds
);
60 $participantCnt = $participantNo +
1;
61 $this->assign('formId', $participantNo);
62 $this->_params
= array();
63 $this->_params
= $this->get('params');
65 $participantTot = $this->_params
[0]['additional_participants'] +
1;
66 $skipCount = count(array_keys($this->_params
, "skip"));
68 $this->assign('skipCount', $skipCount);
70 CRM_Utils_System
::setTitle(ts('Register Participant %1 of %2', array(1 => $participantCnt, 2 => $participantTot)));
72 //CRM-4320, hack to check last participant.
73 $this->_lastParticipant
= FALSE;
74 if ($participantTot == $participantCnt) {
75 $this->_lastParticipant
= TRUE;
77 $this->assign('lastParticipant', $this->_lastParticipant
);
81 * Set default values for the form. For edit/view mode
82 * the default values are retrieved from the database
87 public function setDefaultValues() {
88 $defaults = $unsetSubmittedOptions = array();
90 //fix for CRM-3088, default value for discount set.
91 if (!empty($this->_values
['discount'])) {
92 $discountId = CRM_Core_BAO_Discount
::findSet($this->_eventId
, 'civicrm_event');
93 if ($discountId && !empty($this->_values
['event']['default_discount_fee_id'])) {
94 $discountKey = CRM_Core_DAO
::getFieldValue("CRM_Core_DAO_OptionValue", $this->_values
['event']['default_discount_fee_id'], 'weight', 'id'
96 $defaults['amount'] = key(array_slice($this->_values
['discount'][$discountId], $discountKey - 1, $discountKey, TRUE));
99 if ($this->_priceSetId
) {
100 foreach ($this->_feeBlock
as $key => $val) {
101 if (empty($val['options'])) {
105 $optionsFull = CRM_Utils_Array
::value('option_full_ids', $val, array());
106 foreach ($val['options'] as $keys => $values) {
107 if ($values['is_default'] && !in_array($keys, $optionsFull)) {
108 if ($val['html_type'] == 'CheckBox') {
109 $defaults["price_{$key}"][$keys] = 1;
112 $defaults["price_{$key}"] = $keys;
116 if (!empty($optionsFull)) {
117 $unsetSubmittedOptions[$val['id']] = $optionsFull;
122 //CRM-4320, setdefault additional participant values.
123 if ($this->_allowConfirmation
&& $this->_additionalParticipantId
) {
124 //hack to get set default from eventFees.php
125 $this->_discountId
= $discountId;
126 $this->_pId
= $this->_additionalParticipantId
;
127 $this->_contactId
= CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Participant', $this->_additionalParticipantId
, 'contact_id');
129 CRM_Event_BAO_Participant
::formatFieldsAndSetProfileDefaults($this->_contactId
, $this);
130 $participantDefaults = CRM_Event_Form_EventFees
::setDefaultValues($this);
131 $participantDefaults = array_merge($this->_defaults
, $participantDefaults);
132 // use primary email address if billing email address is empty
133 if (empty($this->_defaults
["email-{$this->_bltID}"]) &&
134 !empty($this->_defaults
["email-Primary"])
136 $participantDefaults["email-{$this->_bltID}"] = $this->_defaults
["email-Primary"];
138 $defaults = array_merge($defaults, $participantDefaults);
141 $defaults = array_merge($this->_defaults
, $defaults);
143 //reset values for all options those are full.
144 CRM_Event_Form_Registration
::resetElementValue($unsetSubmittedOptions, $this);
146 //load default campaign from page.
147 if (array_key_exists('participant_campaign_id', $this->_fields
)) {
148 $defaults['participant_campaign_id'] = CRM_Utils_Array
::value('campaign_id', $this->_values
['event']);
151 //CRM-17865 set custom field defaults
152 if (!empty($this->_fields
)) {
153 foreach ($this->_fields
as $name => $field) {
154 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($name)) {
155 if (!isset($defaults[$name])) {
156 CRM_Core_BAO_CustomField
::setProfileDefaults($customFieldID, $name, $defaults,
157 NULL, CRM_Profile_Form
::MODE_REGISTER
168 * Build the form object.
172 public function buildQuickForm() {
174 $button = substr($this->controller
->getButtonName(), -4);
176 $this->add('hidden', 'scriptFee', NULL);
177 $this->add('hidden', 'scriptArray', NULL);
179 if ($this->_values
['event']['is_monetary']) {
180 CRM_Event_Form_Registration_Register
::buildAmount($this);
182 $first_name = $last_name = NULL;
183 $pre = $post = array();
188 if (isset($this->_values
['additional_custom_' . $keys . '_id'])) {
189 $this->buildCustom($this->_values
['additional_custom_' . $keys . '_id'], 'additionalCustom' . ucfirst($keys));
190 $
$keys = CRM_Core_BAO_UFGroup
::getFields($this->_values
['additional_custom_' . $keys . '_id']);
196 if (array_key_exists($name, $
$keys) &&
197 CRM_Utils_Array
::value('is_required', CRM_Utils_Array
::value($name, $
$keys))
204 $required = ($button == 'skip' ||
205 $this->_values
['event']['allow_same_participant_emails'] == 1 &&
206 ($first_name && $last_name)
211 if ($this->isLastParticipant(TRUE) && empty($this->_values
['event']['is_monetary'])) {
212 $js = array('onclick' => "return submitOnce(this,'" . $this->_name
. "','" . ts('Processing') . "');");
215 //handle case where user might sart with waiting by group
216 //registration and skip some people and now group fit to
217 //become registered so need to take payment from user.
218 //this case only occurs at dynamic waiting status, CRM-4320
219 $statusMessage = NULL;
220 $allowToProceed = TRUE;
221 $includeSkipButton = TRUE;
222 $this->_resetAllowWaitlist
= FALSE;
224 $pricesetFieldsCount = CRM_Price_BAO_PriceSet
::getPricesetCount($this->_priceSetId
);
226 if ($this->_lastParticipant ||
$pricesetFieldsCount) {
227 //get the participant total.
228 $processedCnt = self
::getParticipantCount($this, $this->_params
, TRUE);
231 if (!$this->_allowConfirmation
&& !empty($this->_params
[0]['bypass_payment']) &&
232 $this->_lastParticipant
235 //get the event spaces.
236 $spaces = $this->_availableRegistrations
;
238 $currentPageMaxCount = 1;
239 if ($pricesetFieldsCount) {
240 $currentPageMaxCount = $pricesetFieldsCount;
243 //we might did reset allow waiting in case of dynamic calculation
244 // @TODO - does this bypass_payment still exist?
245 if (!empty($this->_params
[0]['bypass_payment']) &&
246 is_numeric($spaces) &&
247 $processedCnt > $spaces
249 $this->_allowWaitlist
= TRUE;
250 $this->set('allowWaitlist', TRUE);
253 //lets allow to become a part of runtime waiting list, if primary selected pay later.
254 $realPayLater = FALSE;
255 if (!empty($this->_values
['event']['is_monetary']) && !empty($this->_values
['event']['is_pay_later'])) {
256 $realPayLater = CRM_Utils_Array
::value('is_pay_later', $this->_params
[0]);
259 //truly spaces are greater than required.
260 if (is_numeric($spaces) && $spaces >= ($processedCnt +
$currentPageMaxCount)) {
261 if (CRM_Utils_Array
::value('amount', $this->_params
[0], 0) == 0 ||
$this->_requireApproval
) {
262 $this->_allowWaitlist
= FALSE;
263 $this->set('allowWaitlist', $this->_allowWaitlist
);
264 if ($this->_requireApproval
) {
265 $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.", array(
266 1 => ++
$processedCnt,
271 $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed).", array(
272 1 => ++
$processedCnt,
278 $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.", array(
279 1 => ++
$processedCnt,
282 $allowToProceed = FALSE;
284 CRM_Core_Session
::setStatus($statusMessage, ts('Registration Error'), 'error');
286 elseif ($processedCnt == $spaces) {
287 if (CRM_Utils_Array
::value('amount', $this->_params
[0], 0) == 0
288 ||
$realPayLater ||
$this->_requireApproval
290 $this->_resetAllowWaitlist
= TRUE;
291 if ($this->_requireApproval
) {
292 $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.");
295 $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed).");
299 //hey there is enough space and we require payment.
300 $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.");
301 $includeSkipButton = FALSE;
306 // for priceset with count
307 if ($pricesetFieldsCount && !empty($this->_values
['event']['has_waitlist']) &&
308 !$this->_allowConfirmation
311 if ($this->_isEventFull
) {
312 $statusMessage = ts('This event is currently full. You are registering for the waiting list. You will be notified if spaces become available.');
314 elseif ($this->_allowWaitlist ||
315 (!$this->_allowWaitlist
&& ($processedCnt +
$pricesetFieldsCount) > $this->_availableRegistrations
)
318 $waitingMsg = ts('It looks like you are registering more participants then there are spaces available. All participants will be added to the waiting list. You will be notified if spaces become available.');
319 $confirmedMsg = ts('It looks like there are enough spaces in this event for your group (you will not be wait listed).');
320 if ($this->_requireApproval
) {
321 $waitingMsg = ts('It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.');
322 $confirmedMsg = ts('It looks there are enough spaces in this event for your group (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.');
325 $this->assign('waitingMsg', $waitingMsg);
326 $this->assign('confirmedMsg', $confirmedMsg);
328 $this->assign('availableRegistrations', $this->_availableRegistrations
);
329 $this->assign('currentParticipantCount', $processedCnt);
330 $this->assign('allowGroupOnWaitlist', TRUE);
332 $paymentBypassed = NULL;
333 if (!empty($this->_params
[0]['bypass_payment']) &&
334 !$this->_allowWaitlist
&&
336 !$this->_requireApproval
&&
337 !(CRM_Utils_Array
::value('amount', $this->_params
[0], 0) == 0)
339 $paymentBypassed = ts('Please go back to the main registration page, to complete payment information.');
341 $this->assign('paymentBypassed', $paymentBypassed);
345 $this->assign('statusMessage', $statusMessage);
350 'name' => ts('Go Back'),
351 'spacing' => '  ',
356 if ($allowToProceed) {
357 $buttons = array_merge($buttons, array(
360 'name' => ts('Continue'),
361 'spacing' => ' ',
367 if ($includeSkipButton) {
368 $buttons = array_merge($buttons, array(
371 'name' => ts('Skip Participant'),
373 'icon' => 'fa-fast-forward',
379 $this->addButtons($buttons);
380 $this->addFormRule(array('CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'), $this);
381 $this->unsavedChangesWarn
= TRUE;
387 * @param array $fields
388 * The input form values.
389 * @param array $files
390 * The uploaded files if any.
395 * true if no errors, else array of errors
397 public static function formRule($fields, $files, $self) {
399 //get the button name.
400 $button = substr($self->controller
->getButtonName(), -4);
402 $realPayLater = FALSE;
403 if (!empty($self->_values
['event']['is_monetary']) && !empty($self->_values
['event']['is_pay_later'])) {
404 $realPayLater = CRM_Utils_Array
::value('is_pay_later', $self->_params
[0]);
407 if ($button != 'skip') {
408 //Check that either an email or firstname+lastname is included in the form(CRM-9587)
409 CRM_Event_Form_Registration_Register
::checkProfileComplete($fields, $errors, $self->_eventId
);
411 //Additional Participant can also register for an event only once
412 $isRegistered = CRM_Event_Form_Registration_Register
::checkRegistration($fields, $self, TRUE);
414 if ($self->_values
['event']['allow_same_participant_emails']) {
415 $errors['_qf_default'] = ts('A person is already registered for this event.');
418 $errors["email-{$self->_bltID}"] = ts('A person with this email address is already registered for this event.');
422 //get the complete params.
423 $params = $self->get('params');
425 //take the participant instance.
426 $addParticipantNum = substr($self->_name
, 12);
428 if (is_array($params)) {
429 foreach ($params as $key => $value) {
430 if ($key != $addParticipantNum) {
431 if (!$self->_values
['event']['allow_same_participant_emails']) {
432 //collect all email fields
433 $existingEmails = array();
434 $additionalParticipantEmails = array();
435 if (is_array($value)) {
436 foreach ($value as $key => $val) {
437 if (substr($key, 0, 6) == 'email-' && $val) {
438 $existingEmails[] = $val;
442 foreach ($fields as $key => $val) {
443 if (substr($key, 0, 6) == 'email-' && $val) {
444 $additionalParticipantEmails[] = $val;
448 //check if any emails are common to both arrays
449 if (count(array_intersect($existingEmails, $additionalParticipantEmails))) {
450 $errors[$mailKey] = ts('The email address must be unique for each participant.');
455 // check with first_name and last_name for additional participants
456 if (!empty($value['first_name']) && ($value['first_name'] == CRM_Utils_Array
::value('first_name', $fields)) &&
457 (CRM_Utils_Array
::value('last_name', $value) == CRM_Utils_Array
::value('last_name', $fields))
459 $errors['first_name'] = ts('The first name and last name must be unique for each participant.');
467 //check for atleast one pricefields should be selected
468 if (!empty($fields['priceSetId'])) {
469 $allParticipantParams = $params;
471 //format current participant params.
472 $allParticipantParams[$addParticipantNum] = self
::formatPriceSetParams($self, $fields);
473 $totalParticipants = self
::getParticipantCount($self, $allParticipantParams);
475 //validate price field params.
476 $priceSetErrors = self
::validatePriceSet($self, $allParticipantParams);
477 $errors = array_merge($errors, CRM_Utils_Array
::value($addParticipantNum, $priceSetErrors, array()));
479 if (!$self->_allowConfirmation
&&
480 is_numeric($self->_availableRegistrations
)
482 if (!empty($self->_params
[0]['bypass_payment']) &&
483 !$self->_allowWaitlist
&&
485 !$self->_requireApproval
&&
486 !(CRM_Utils_Array
::value('amount', $self->_params
[0], 0) == 0) &&
487 $totalParticipants < $self->_availableRegistrations
489 $errors['_qf_default'] = ts("Your event registration will be confirmed. Please go back to the main registration page, to complete payment information.");
491 //check for availability of registrations.
492 if (!$self->_allowConfirmation
&& empty($self->_values
['event']['has_waitlist']) &&
493 $totalParticipants > $self->_availableRegistrations
495 $errors['_qf_default'] = ts('Sorry, it looks like this event only has %2 spaces available, and you are trying to register %1 participants. Please change your selections accordingly.', array(
496 1 => $totalParticipants,
497 2 => $self->_availableRegistrations
,
504 if ($button == 'skip' && $self->_lastParticipant
&& !empty($fields['priceSetId'])) {
505 $pricesetFieldsCount = CRM_Price_BAO_PriceSet
::getPricesetCount($fields['priceSetId']);
506 if (($pricesetFieldsCount < 1) ||
$self->_allowConfirmation
) {
510 if (!empty($self->_values
['event']['has_waitlist']) && !empty($self->_params
[0]['bypass_payment']) &&
511 !$self->_allowWaitlist
&&
513 !$self->_requireApproval
&&
514 !(CRM_Utils_Array
::value('amount', $self->_params
[0], 0) == 0)
516 $errors['_qf_default'] = ts("You are going to skip the last participant, your event registration will be confirmed. Please go back to the main registration page, to complete payment information.");
520 if ($button != 'skip' &&
521 $self->_values
['event']['is_monetary'] &&
522 !isset($errors['_qf_default']) &&
523 !$self->validatePaymentValues($self, $fields)
525 $errors['_qf_default'] = ts("Your payment information looks incomplete. Please go back to the main registration page, to complete payment information.");
526 $self->set('forcePayement', TRUE);
528 elseif ($button == 'skip') {
529 $self->set('forcePayement', TRUE);
541 public function validatePaymentValues($self, $fields) {
543 if (!empty($self->_params
[0]['bypass_payment']) ||
544 $self->_allowWaitlist ||
545 empty($self->_fields
) ||
546 CRM_Utils_Array
::value('amount', $self->_params
[0]) > 0
551 $validatePayement = FALSE;
552 if (!empty($fields['priceSetId'])) {
554 CRM_Price_BAO_PriceSet
::processAmount($self->_values
['fee'], $fields, $lineItem);
555 if ($fields['amount'] > 0) {
556 $validatePayement = TRUE;
557 // $self->_forcePayement = true;
561 elseif (!empty($fields['amount']) &&
562 (CRM_Utils_Array
::value('value', $self->_values
['fee'][$fields['amount']]) > 0)
564 $validatePayement = TRUE;
567 if (!$validatePayement) {
573 CRM_Core_Form
::validateMandatoryFields($self->_fields
, $fields, $errors);
575 if (isset($self->_params
[0]['payment_processor'])) {
576 // validate supplied payment instrument values (e.g. credit card number and cvv)
577 $payment_processor_id = $self->_params
[0]['payment_processor'];
578 CRM_Core_Payment_Form
::validatePaymentInstrument($payment_processor_id, $self->_params
[0], $errors, (!$self->_isBillingAddressRequiredForPayLater ?
NULL : 'billing'));
580 if (!empty($errors)) {
584 foreach (CRM_Contact_BAO_Contact
::$_greetingTypes as $greeting) {
585 if ($greetingType = CRM_Utils_Array
::value($greeting, $self->_params
[0])) {
586 $customizedValue = CRM_Core_OptionGroup
::getValue($greeting, 'Customized', 'name');
587 if ($customizedValue == $greetingType && empty($self->_params
[0][$greeting . '_custom'])) {
596 * Process the form submission.
601 public function postProcess() {
602 //get the button name.
603 $button = substr($this->controller
->getButtonName(), -4);
605 //take the participant instance.
606 $addParticipantNum = substr($this->_name
, 12);
608 //user submitted params.
609 $params = $this->controller
->exportValues($this->_name
);
611 if (!$this->_allowConfirmation
) {
612 // check if the participant is already registered
613 $params['contact_id'] = CRM_Event_Form_Registration_Register
::getRegistrationContactID($params, $this, TRUE);
616 if (!empty($params['image_URL'])) {
617 CRM_Contact_BAO_Contact
::processImageParams($params);
619 //carry campaign to partcipants.
620 if (array_key_exists('participant_campaign_id', $params)) {
621 $params['campaign_id'] = $params['participant_campaign_id'];
624 $params['campaign_id'] = CRM_Utils_Array
::value('campaign_id', $this->_values
['event']);
627 // if waiting is enabled
628 if (!$this->_allowConfirmation
&&
629 is_numeric($this->_availableRegistrations
)
631 $this->_allowWaitlist
= FALSE;
632 //get the current page count.
633 $currentCount = self
::getParticipantCount($this, $params);
634 if ($button == 'skip') {
635 $currentCount = 'skip';
638 //get the total count.
639 $previousCount = self
::getParticipantCount($this, $this->_params
, TRUE);
640 $totalParticipants = $previousCount;
641 if (is_numeric($currentCount)) {
642 $totalParticipants +
= $currentCount;
644 if (!empty($this->_values
['event']['has_waitlist']) &&
645 $totalParticipants > $this->_availableRegistrations
647 $this->_allowWaitlist
= TRUE;
649 $this->set('allowWaitlist', $this->_allowWaitlist
);
650 $this->_lineItemParticipantsCount
[$addParticipantNum] = $currentCount;
653 if ($button == 'skip') {
654 //hack for free/zero amount event.
655 if ($this->_resetAllowWaitlist
) {
656 $this->_allowWaitlist
= FALSE;
657 $this->set('allowWaitlist', FALSE);
658 if ($this->_requireApproval
) {
659 $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.");
662 $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.");
664 CRM_Core_Session
::setStatus($status);
667 $this->_params
[$addParticipantNum] = 'skip';
668 if (isset($this->_lineItem
)) {
669 $this->_lineItem
[$addParticipantNum] = 'skip';
670 $this->_lineItemParticipantsCount
[$addParticipantNum] = 'skip';
675 $config = CRM_Core_Config
::singleton();
676 $params['currencyID'] = $config->defaultCurrency
;
678 if ($this->_values
['event']['is_monetary']) {
681 $discountId = CRM_Core_BAO_Discount
::findSet($this->_eventId
, 'civicrm_event');
682 $params['amount_level'] = $this->getAmountLevel($params, $discountId);
683 if (!empty($this->_values
['discount'][$discountId])) {
684 $params['discount_id'] = $discountId;
685 $params['amount'] = $this->_values
['discount'][$discountId][$params['amount']]['value'];
687 elseif (empty($params['priceSetId'])) {
688 $params['amount'] = $this->_values
['fee'][$params['amount']]['value'];
692 CRM_Price_BAO_PriceSet
::processAmount($this->_values
['fee'], $params, $lineItem);
694 //build line item array..
695 //if requireApproval/waitlist is enabled we hide fees for primary participant
696 // (and not for additional participant which might be is a bug)
697 //lineItem are not correctly build for primary participant
698 //this results in redundancy since now lineItems for additional participant will be build against primary participantNum
699 //therefore lineItems must always be build against current participant No
700 $this->_lineItem
[$addParticipantNum] = $lineItem;
704 if (array_key_exists('participant_role', $params)) {
705 $params['participant_role_id'] = $params['participant_role'];
708 if (empty($params['participant_role_id']) && $this->_values
['event']['default_role_id']) {
709 $params['participant_role_id'] = $this->_values
['event']['default_role_id'];
712 if (!empty($this->_params
[0]['is_pay_later'])) {
713 $params['is_pay_later'] = 1;
716 //carry additional participant id, contact id if pre-registered.
717 if ($this->_allowConfirmation
&& $this->_additionalParticipantId
) {
718 $params['contact_id'] = $this->_contactId
;
719 $params['participant_id'] = $this->_additionalParticipantId
;
722 //build the params array.
723 $this->_params
[$addParticipantNum] = $params;
726 //finally set the params.
727 $this->set('params', $this->_params
);
729 if ($this->_lineItem
) {
730 $this->set('lineItem', $this->_lineItem
);
731 $this->set('lineItemParticipantsCount', $this->_lineItemParticipantsCount
);
734 $participantNo = count($this->_params
);
735 if ($button != 'skip') {
736 $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo));
737 CRM_Core_Session
::setStatus($statusMsg, ts('Registration Saved'), 'success');
740 // Check whether to process the registration now, calling processRegistration()
742 !$this->_values
['event']['is_confirm_enabled'] // CRM-11182 - Optional confirmation screen
743 && !$this->_values
['event']['is_monetary']
744 && CRM_Utils_Array
::value('additional_participants', $this->_params
[0])
745 && $this->isLastParticipant()
747 $this->processRegistration($this->_params
);
752 * @param $additionalParticipant
756 public static function &getPages($additionalParticipant) {
758 for ($i = 1; $i <= $additionalParticipant; $i++
) {
759 $details["Participant_{$i}"] = array(
760 'className' => 'CRM_Event_Form_Registration_AdditionalParticipant',
761 'title' => "Register Additional Participant {$i}",
768 * Check whether call current participant is last one.
770 * @param bool $isButtonJs
775 public function isLastParticipant($isButtonJs = FALSE) {
776 $participant = $isButtonJs ?
$this->_params
[0]['additional_participants'] : $this->_params
[0]['additional_participants'] +
1;
777 if (count($this->_params
) == $participant) {