First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,783 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for processing Event.
|
||||
*/
|
||||
class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_Registration {
|
||||
|
||||
/**
|
||||
* Pre-registered additional participant id.
|
||||
*/
|
||||
public $additionalParticipantId = NULL;
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
$participantNo = substr($this->_name, 12);
|
||||
|
||||
//lets process in-queue participants.
|
||||
if ($this->_participantId && $this->_additionalParticipantIds) {
|
||||
$this->_additionalParticipantId = CRM_Utils_Array::value($participantNo, $this->_additionalParticipantIds);
|
||||
}
|
||||
|
||||
$participantCnt = $participantNo + 1;
|
||||
$this->assign('formId', $participantNo);
|
||||
$this->_params = array();
|
||||
$this->_params = $this->get('params');
|
||||
|
||||
$participantTot = $this->_params[0]['additional_participants'] + 1;
|
||||
$skipCount = count(array_keys($this->_params, "skip"));
|
||||
if ($skipCount) {
|
||||
$this->assign('skipCount', $skipCount);
|
||||
}
|
||||
CRM_Utils_System::setTitle(ts('Register Participant %1 of %2', array(1 => $participantCnt, 2 => $participantTot)));
|
||||
|
||||
//CRM-4320, hack to check last participant.
|
||||
$this->_lastParticipant = FALSE;
|
||||
if ($participantTot == $participantCnt) {
|
||||
$this->_lastParticipant = TRUE;
|
||||
}
|
||||
$this->assign('lastParticipant', $this->_lastParticipant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form. For edit/view mode
|
||||
* the default values are retrieved from the database
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = $unsetSubmittedOptions = array();
|
||||
$discountId = NULL;
|
||||
//fix for CRM-3088, default value for discount set.
|
||||
if (!empty($this->_values['discount'])) {
|
||||
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
|
||||
if ($discountId && !empty($this->_values['event']['default_discount_fee_id'])) {
|
||||
$discountKey = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $this->_values['event']['default_discount_fee_id'], 'weight', 'id'
|
||||
);
|
||||
$defaults['amount'] = key(array_slice($this->_values['discount'][$discountId], $discountKey - 1, $discountKey, TRUE));
|
||||
}
|
||||
}
|
||||
if ($this->_priceSetId) {
|
||||
foreach ($this->_feeBlock as $key => $val) {
|
||||
if (empty($val['options'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$optionsFull = CRM_Utils_Array::value('option_full_ids', $val, array());
|
||||
foreach ($val['options'] as $keys => $values) {
|
||||
if ($values['is_default'] && !in_array($keys, $optionsFull)) {
|
||||
if ($val['html_type'] == 'CheckBox') {
|
||||
$defaults["price_{$key}"][$keys] = 1;
|
||||
}
|
||||
else {
|
||||
$defaults["price_{$key}"] = $keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($optionsFull)) {
|
||||
$unsetSubmittedOptions[$val['id']] = $optionsFull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CRM-4320, setdefault additional participant values.
|
||||
if ($this->_allowConfirmation && $this->_additionalParticipantId) {
|
||||
//hack to get set default from eventFees.php
|
||||
$this->_discountId = $discountId;
|
||||
$this->_pId = $this->_additionalParticipantId;
|
||||
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_additionalParticipantId, 'contact_id');
|
||||
|
||||
CRM_Event_BAO_Participant::formatFieldsAndSetProfileDefaults($this->_contactId, $this);
|
||||
$participantDefaults = CRM_Event_Form_EventFees::setDefaultValues($this);
|
||||
$participantDefaults = array_merge($this->_defaults, $participantDefaults);
|
||||
// use primary email address if billing email address is empty
|
||||
if (empty($this->_defaults["email-{$this->_bltID}"]) &&
|
||||
!empty($this->_defaults["email-Primary"])
|
||||
) {
|
||||
$participantDefaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
|
||||
}
|
||||
$defaults = array_merge($defaults, $participantDefaults);
|
||||
}
|
||||
|
||||
$defaults = array_merge($this->_defaults, $defaults);
|
||||
|
||||
//reset values for all options those are full.
|
||||
CRM_Event_Form_Registration::resetElementValue($unsetSubmittedOptions, $this);
|
||||
|
||||
//load default campaign from page.
|
||||
if (array_key_exists('participant_campaign_id', $this->_fields)) {
|
||||
$defaults['participant_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
|
||||
}
|
||||
|
||||
//CRM-17865 set custom field defaults
|
||||
if (!empty($this->_fields)) {
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
|
||||
if (!isset($defaults[$name])) {
|
||||
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults,
|
||||
NULL, CRM_Profile_Form::MODE_REGISTER
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
$button = substr($this->controller->getButtonName(), -4);
|
||||
|
||||
$this->add('hidden', 'scriptFee', NULL);
|
||||
$this->add('hidden', 'scriptArray', NULL);
|
||||
|
||||
if ($this->_values['event']['is_monetary']) {
|
||||
CRM_Event_Form_Registration_Register::buildAmount($this);
|
||||
}
|
||||
$first_name = $last_name = NULL;
|
||||
$pre = $post = array();
|
||||
foreach (array(
|
||||
'pre',
|
||||
'post',
|
||||
) as $keys) {
|
||||
if (isset($this->_values['additional_custom_' . $keys . '_id'])) {
|
||||
$this->buildCustom($this->_values['additional_custom_' . $keys . '_id'], 'additionalCustom' . ucfirst($keys));
|
||||
$$keys = CRM_Core_BAO_UFGroup::getFields($this->_values['additional_custom_' . $keys . '_id']);
|
||||
}
|
||||
foreach (array(
|
||||
'first_name',
|
||||
'last_name',
|
||||
) as $name) {
|
||||
if (array_key_exists($name, $$keys) &&
|
||||
CRM_Utils_Array::value('is_required', CRM_Utils_Array::value($name, $$keys))
|
||||
) {
|
||||
$$name = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$required = ($button == 'skip' ||
|
||||
$this->_values['event']['allow_same_participant_emails'] == 1 &&
|
||||
($first_name && $last_name)
|
||||
) ? FALSE : TRUE;
|
||||
|
||||
//add buttons
|
||||
$js = NULL;
|
||||
if ($this->isLastParticipant(TRUE) && empty($this->_values['event']['is_monetary'])) {
|
||||
$js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
|
||||
}
|
||||
|
||||
//handle case where user might sart with waiting by group
|
||||
//registration and skip some people and now group fit to
|
||||
//become registered so need to take payment from user.
|
||||
//this case only occurs at dynamic waiting status, CRM-4320
|
||||
$statusMessage = NULL;
|
||||
$allowToProceed = TRUE;
|
||||
$includeSkipButton = TRUE;
|
||||
$this->_resetAllowWaitlist = FALSE;
|
||||
|
||||
$pricesetFieldsCount = CRM_Price_BAO_PriceSet::getPricesetCount($this->_priceSetId);
|
||||
|
||||
if ($this->_lastParticipant || $pricesetFieldsCount) {
|
||||
//get the participant total.
|
||||
$processedCnt = self::getParticipantCount($this, $this->_params, TRUE);
|
||||
}
|
||||
|
||||
if (!$this->_allowConfirmation && !empty($this->_params[0]['bypass_payment']) &&
|
||||
$this->_lastParticipant
|
||||
) {
|
||||
|
||||
//get the event spaces.
|
||||
$spaces = $this->_availableRegistrations;
|
||||
|
||||
$currentPageMaxCount = 1;
|
||||
if ($pricesetFieldsCount) {
|
||||
$currentPageMaxCount = $pricesetFieldsCount;
|
||||
}
|
||||
|
||||
//we might did reset allow waiting in case of dynamic calculation
|
||||
// @TODO - does this bypass_payment still exist?
|
||||
if (!empty($this->_params[0]['bypass_payment']) &&
|
||||
is_numeric($spaces) &&
|
||||
$processedCnt > $spaces
|
||||
) {
|
||||
$this->_allowWaitlist = TRUE;
|
||||
$this->set('allowWaitlist', TRUE);
|
||||
}
|
||||
|
||||
//lets allow to become a part of runtime waiting list, if primary selected pay later.
|
||||
$realPayLater = FALSE;
|
||||
if (!empty($this->_values['event']['is_monetary']) && !empty($this->_values['event']['is_pay_later'])) {
|
||||
$realPayLater = CRM_Utils_Array::value('is_pay_later', $this->_params[0]);
|
||||
}
|
||||
|
||||
//truly spaces are greater than required.
|
||||
if (is_numeric($spaces) && $spaces >= ($processedCnt + $currentPageMaxCount)) {
|
||||
if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0 || $this->_requireApproval) {
|
||||
$this->_allowWaitlist = FALSE;
|
||||
$this->set('allowWaitlist', $this->_allowWaitlist);
|
||||
if ($this->_requireApproval) {
|
||||
$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(
|
||||
1 => ++$processedCnt,
|
||||
2 => $spaces,
|
||||
));
|
||||
}
|
||||
else {
|
||||
$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(
|
||||
1 => ++$processedCnt,
|
||||
2 => $spaces,
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$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(
|
||||
1 => ++$processedCnt,
|
||||
2 => $spaces,
|
||||
));
|
||||
$allowToProceed = FALSE;
|
||||
}
|
||||
CRM_Core_Session::setStatus($statusMessage, ts('Registration Error'), 'error');
|
||||
}
|
||||
elseif ($processedCnt == $spaces) {
|
||||
if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0
|
||||
|| $realPayLater || $this->_requireApproval
|
||||
) {
|
||||
$this->_resetAllowWaitlist = TRUE;
|
||||
if ($this->_requireApproval) {
|
||||
$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.");
|
||||
}
|
||||
else {
|
||||
$statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed).");
|
||||
}
|
||||
}
|
||||
else {
|
||||
//hey there is enough space and we require payment.
|
||||
$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.");
|
||||
$includeSkipButton = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for priceset with count
|
||||
if ($pricesetFieldsCount && !empty($this->_values['event']['has_waitlist']) &&
|
||||
!$this->_allowConfirmation
|
||||
) {
|
||||
|
||||
if ($this->_isEventFull) {
|
||||
$statusMessage = ts('This event is currently full. You are registering for the waiting list. You will be notified if spaces become available.');
|
||||
}
|
||||
elseif ($this->_allowWaitlist ||
|
||||
(!$this->_allowWaitlist && ($processedCnt + $pricesetFieldsCount) > $this->_availableRegistrations)
|
||||
) {
|
||||
|
||||
$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.');
|
||||
$confirmedMsg = ts('It looks like there are enough spaces in this event for your group (you will not be wait listed).');
|
||||
if ($this->_requireApproval) {
|
||||
$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.');
|
||||
$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.');
|
||||
}
|
||||
|
||||
$this->assign('waitingMsg', $waitingMsg);
|
||||
$this->assign('confirmedMsg', $confirmedMsg);
|
||||
|
||||
$this->assign('availableRegistrations', $this->_availableRegistrations);
|
||||
$this->assign('currentParticipantCount', $processedCnt);
|
||||
$this->assign('allowGroupOnWaitlist', TRUE);
|
||||
|
||||
$paymentBypassed = NULL;
|
||||
if (!empty($this->_params[0]['bypass_payment']) &&
|
||||
!$this->_allowWaitlist &&
|
||||
!$realPayLater &&
|
||||
!$this->_requireApproval &&
|
||||
!(CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0)
|
||||
) {
|
||||
$paymentBypassed = ts('Please go back to the main registration page, to complete payment information.');
|
||||
}
|
||||
$this->assign('paymentBypassed', $paymentBypassed);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('statusMessage', $statusMessage);
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Go Back'),
|
||||
'spacing' => '  ',
|
||||
),
|
||||
);
|
||||
|
||||
//CRM-4320
|
||||
if ($allowToProceed) {
|
||||
$buttons = array_merge($buttons, array(
|
||||
array(
|
||||
'type' => 'upload',
|
||||
'name' => ts('Continue'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
'js' => $js,
|
||||
),
|
||||
)
|
||||
);
|
||||
if ($includeSkipButton) {
|
||||
$buttons = array_merge($buttons, array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Skip Participant'),
|
||||
'subName' => 'skip',
|
||||
'icon' => 'fa-fast-forward',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->addButtons($buttons);
|
||||
$this->addFormRule(array('CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'), $this);
|
||||
$this->unsavedChangesWarn = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param $self
|
||||
*
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $self) {
|
||||
$errors = array();
|
||||
//get the button name.
|
||||
$button = substr($self->controller->getButtonName(), -4);
|
||||
|
||||
$realPayLater = FALSE;
|
||||
if (!empty($self->_values['event']['is_monetary']) && !empty($self->_values['event']['is_pay_later'])) {
|
||||
$realPayLater = CRM_Utils_Array::value('is_pay_later', $self->_params[0]);
|
||||
}
|
||||
|
||||
if ($button != 'skip') {
|
||||
//Check that either an email or firstname+lastname is included in the form(CRM-9587)
|
||||
CRM_Event_Form_Registration_Register::checkProfileComplete($fields, $errors, $self->_eventId);
|
||||
|
||||
//Additional Participant can also register for an event only once
|
||||
$isRegistered = CRM_Event_Form_Registration_Register::checkRegistration($fields, $self, TRUE);
|
||||
if ($isRegistered) {
|
||||
if ($self->_values['event']['allow_same_participant_emails']) {
|
||||
$errors['_qf_default'] = ts('A person is already registered for this event.');
|
||||
}
|
||||
else {
|
||||
$errors["email-{$self->_bltID}"] = ts('A person with this email address is already registered for this event.');
|
||||
}
|
||||
}
|
||||
|
||||
//get the complete params.
|
||||
$params = $self->get('params');
|
||||
|
||||
//take the participant instance.
|
||||
$addParticipantNum = substr($self->_name, 12);
|
||||
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key != $addParticipantNum) {
|
||||
if (!$self->_values['event']['allow_same_participant_emails']) {
|
||||
//collect all email fields
|
||||
$existingEmails = array();
|
||||
$additionalParticipantEmails = array();
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $key => $val) {
|
||||
if (substr($key, 0, 6) == 'email-' && $val) {
|
||||
$existingEmails[] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($fields as $key => $val) {
|
||||
if (substr($key, 0, 6) == 'email-' && $val) {
|
||||
$additionalParticipantEmails[] = $val;
|
||||
$mailKey = $key;
|
||||
}
|
||||
}
|
||||
//check if any emails are common to both arrays
|
||||
if (count(array_intersect($existingEmails, $additionalParticipantEmails))) {
|
||||
$errors[$mailKey] = ts('The email address must be unique for each participant.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// check with first_name and last_name for additional participants
|
||||
if (!empty($value['first_name']) && ($value['first_name'] == CRM_Utils_Array::value('first_name', $fields)) &&
|
||||
(CRM_Utils_Array::value('last_name', $value) == CRM_Utils_Array::value('last_name', $fields))
|
||||
) {
|
||||
$errors['first_name'] = ts('The first name and last name must be unique for each participant.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check for atleast one pricefields should be selected
|
||||
if (!empty($fields['priceSetId'])) {
|
||||
$allParticipantParams = $params;
|
||||
|
||||
//format current participant params.
|
||||
$allParticipantParams[$addParticipantNum] = self::formatPriceSetParams($self, $fields);
|
||||
$totalParticipants = self::getParticipantCount($self, $allParticipantParams);
|
||||
|
||||
//validate price field params.
|
||||
$priceSetErrors = self::validatePriceSet($self, $allParticipantParams);
|
||||
$errors = array_merge($errors, CRM_Utils_Array::value($addParticipantNum, $priceSetErrors, array()));
|
||||
|
||||
if (!$self->_allowConfirmation &&
|
||||
is_numeric($self->_availableRegistrations)
|
||||
) {
|
||||
if (!empty($self->_params[0]['bypass_payment']) &&
|
||||
!$self->_allowWaitlist &&
|
||||
!$realPayLater &&
|
||||
!$self->_requireApproval &&
|
||||
!(CRM_Utils_Array::value('amount', $self->_params[0], 0) == 0) &&
|
||||
$totalParticipants < $self->_availableRegistrations
|
||||
) {
|
||||
$errors['_qf_default'] = ts("Your event registration will be confirmed. Please go back to the main registration page, to complete payment information.");
|
||||
}
|
||||
//check for availability of registrations.
|
||||
if (!$self->_allowConfirmation && empty($self->_values['event']['has_waitlist']) &&
|
||||
$totalParticipants > $self->_availableRegistrations
|
||||
) {
|
||||
$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(
|
||||
1 => $totalParticipants,
|
||||
2 => $self->_availableRegistrations,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($button == 'skip' && $self->_lastParticipant && !empty($fields['priceSetId'])) {
|
||||
$pricesetFieldsCount = CRM_Price_BAO_PriceSet::getPricesetCount($fields['priceSetId']);
|
||||
if (($pricesetFieldsCount < 1) || $self->_allowConfirmation) {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
if (!empty($self->_values['event']['has_waitlist']) && !empty($self->_params[0]['bypass_payment']) &&
|
||||
!$self->_allowWaitlist &&
|
||||
!$realPayLater &&
|
||||
!$self->_requireApproval &&
|
||||
!(CRM_Utils_Array::value('amount', $self->_params[0], 0) == 0)
|
||||
) {
|
||||
$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.");
|
||||
}
|
||||
}
|
||||
|
||||
if ($button != 'skip' &&
|
||||
$self->_values['event']['is_monetary'] &&
|
||||
!isset($errors['_qf_default']) &&
|
||||
!$self->validatePaymentValues($self, $fields)
|
||||
) {
|
||||
$errors['_qf_default'] = ts("Your payment information looks incomplete. Please go back to the main registration page, to complete payment information.");
|
||||
$self->set('forcePayement', TRUE);
|
||||
}
|
||||
elseif ($button == 'skip') {
|
||||
$self->set('forcePayement', TRUE);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $self
|
||||
* @param $fields
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validatePaymentValues($self, $fields) {
|
||||
|
||||
if (!empty($self->_params[0]['bypass_payment']) ||
|
||||
$self->_allowWaitlist ||
|
||||
empty($self->_fields) ||
|
||||
CRM_Utils_Array::value('amount', $self->_params[0]) > 0
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$validatePayement = FALSE;
|
||||
if (!empty($fields['priceSetId'])) {
|
||||
$lineItem = array();
|
||||
CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
|
||||
if ($fields['amount'] > 0) {
|
||||
$validatePayement = TRUE;
|
||||
// $self->_forcePayement = true;
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
elseif (!empty($fields['amount']) &&
|
||||
(CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) > 0)
|
||||
) {
|
||||
$validatePayement = TRUE;
|
||||
}
|
||||
|
||||
if (!$validatePayement) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
|
||||
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
|
||||
|
||||
if (isset($self->_params[0]['payment_processor'])) {
|
||||
// validate supplied payment instrument values (e.g. credit card number and cvv)
|
||||
$payment_processor_id = $self->_params[0]['payment_processor'];
|
||||
CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing'));
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
|
||||
if ($greetingType = CRM_Utils_Array::value($greeting, $self->_params[0])) {
|
||||
$customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
|
||||
if ($customizedValue == $greetingType && empty($self->_params[0][$greeting . '_custom'])) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::getRegistrationContactID($params, $this, TRUE);
|
||||
}
|
||||
|
||||
if (!empty($params['image_URL'])) {
|
||||
CRM_Contact_BAO_Contact::processImageParams($params);
|
||||
}
|
||||
//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');
|
||||
$params['amount_level'] = $this->getAmountLevel($params, $discountId);
|
||||
if (!empty($this->_values['discount'][$discountId])) {
|
||||
$params['discount_id'] = $discountId;
|
||||
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
|
||||
}
|
||||
elseif (empty($params['priceSetId'])) {
|
||||
$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'] // CRM-11182 - Optional confirmation screen
|
||||
&& !$this->_values['event']['is_monetary']
|
||||
&& CRM_Utils_Array::value('additional_participants', $this->_params[0])
|
||||
&& $this->isLastParticipant()
|
||||
) {
|
||||
$this->processRegistration($this->_params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $additionalParticipant
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &getPages($additionalParticipant) {
|
||||
$details = array();
|
||||
for ($i = 1; $i <= $additionalParticipant; $i++) {
|
||||
$details["Participant_{$i}"] = array(
|
||||
'className' => 'CRM_Event_Form_Registration_AdditionalParticipant',
|
||||
'title' => "Register Additional Participant {$i}",
|
||||
);
|
||||
}
|
||||
return $details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether call current participant is last one.
|
||||
*
|
||||
* @param bool $isButtonJs
|
||||
*
|
||||
* @return bool
|
||||
* ture on success.
|
||||
*/
|
||||
public function isLastParticipant($isButtonJs = FALSE) {
|
||||
$participant = $isButtonJs ? $this->_params[0]['additional_participants'] : $this->_params[0]['additional_participants'] + 1;
|
||||
if (count($this->_params) == $participant) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
1335
sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php
Normal file
1335
sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for processing Event
|
||||
*
|
||||
*/
|
||||
class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Registration {
|
||||
// optional credit card return status code
|
||||
// CRM-6060
|
||||
protected $_cc = NULL;
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
|
||||
|
||||
$this->_cc = CRM_Utils_Request::retrieve('cc', 'String', $this);
|
||||
|
||||
//get the contact and event id and assing to session.
|
||||
$values = array();
|
||||
$csContactID = NULL;
|
||||
if ($this->_participantId) {
|
||||
$params = array('id' => $this->_participantId);
|
||||
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Participant', $params, $values,
|
||||
array('contact_id', 'event_id', 'status_id')
|
||||
);
|
||||
}
|
||||
|
||||
$this->_participantStatusId = CRM_Utils_Array::value('status_id', $values);
|
||||
$this->_eventId = CRM_Utils_Array::value('event_id', $values);
|
||||
$csContactId = CRM_Utils_Array::value('contact_id', $values);
|
||||
|
||||
// make sure we have right permission to edit this user
|
||||
$this->_csContactID = NULL;
|
||||
if ($csContactId && $this->_eventId) {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
if ($csContactId == $session->get('userID')) {
|
||||
$this->_csContactID = $csContactId;
|
||||
}
|
||||
else {
|
||||
if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactId, $this)) {
|
||||
//since we have landing page so get this contact
|
||||
//id in session if user really want to walk wizard.
|
||||
$this->_csContactID = $csContactId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_csContactID) {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
CRM_Core_Error::statusBounce(ts('You do not have permission to access this event registration. Contact the site administrator if you need assistance.'), $config->userFrameworkBaseURL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$params = array('id' => $this->_eventId);
|
||||
$values = array();
|
||||
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $values,
|
||||
array('title')
|
||||
);
|
||||
|
||||
$buttons = array();
|
||||
// only pending status class family able to confirm.
|
||||
|
||||
$statusMsg = NULL;
|
||||
if (array_key_exists($this->_participantStatusId,
|
||||
CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'")
|
||||
)) {
|
||||
|
||||
//need to confirm that though participant confirming
|
||||
//registration - but is there enough space to confirm.
|
||||
$emptySeats = CRM_Event_BAO_Participant::pendingToConfirmSpaces($this->_eventId);
|
||||
$additonalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
|
||||
$requireSpace = 1 + count($additonalIds);
|
||||
if ($emptySeats !== NULL && ($requireSpace > $emptySeats)) {
|
||||
$statusMsg = ts("Oops, it looks like there are currently no available spaces for the %1 event.", array(1 => $values['title']));
|
||||
}
|
||||
else {
|
||||
if ($this->_cc == 'fail') {
|
||||
$statusMsg = '<div class="bold">' . ts('Your Credit Card transaction was not successful. No money has yet been charged to your card.') . '</div><div><br />' . ts('Click the "Confirm Registration" button to complete your registration in %1, or click "Cancel Registration" if you are no longer interested in attending this event.', array(
|
||||
1 => $values['title'],
|
||||
)) . '</div>';
|
||||
}
|
||||
else {
|
||||
$statusMsg = '<div class="bold">' . ts('Confirm your registration for %1.', array(
|
||||
1 => $values['title'],
|
||||
)) . '</div><div><br />' . ts('Click the "Confirm Registration" button to begin, or click "Cancel Registration" if you are no longer interested in attending this event.') . '</div>';
|
||||
}
|
||||
$buttons = array_merge($buttons, array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Confirm Registration'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// status class other than Negative should be able to cancel registration.
|
||||
if (array_key_exists($this->_participantStatusId,
|
||||
CRM_Event_PseudoConstant::participantStatus(NULL, "class != 'Negative'")
|
||||
)) {
|
||||
$cancelConfirm = ts('Are you sure you want to cancel your registration for this event?');
|
||||
$buttons = array_merge($buttons, array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'name' => ts('Cancel Registration'),
|
||||
'spacing' => ' ',
|
||||
'js' => array('onclick' => 'return confirm(\'' . $cancelConfirm . '\');'),
|
||||
),
|
||||
));
|
||||
if (!$statusMsg) {
|
||||
$statusMsg = ts('You can cancel your registration for %1 by clicking "Cancel Registration".', array(1 => $values['title']));
|
||||
}
|
||||
}
|
||||
if (!$statusMsg) {
|
||||
$statusMsg = ts("Oops, it looks like your registration for %1 has already been cancelled.",
|
||||
array(1 => $values['title'])
|
||||
);
|
||||
}
|
||||
$this->assign('statusMsg', $statusMsg);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
//get the button.
|
||||
$buttonName = $this->controller->getButtonName();
|
||||
$participantId = $this->_participantId;
|
||||
|
||||
if ($buttonName == '_qf_ParticipantConfirm_next') {
|
||||
//lets get contact id in session.
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->set('userID', $this->_csContactID);
|
||||
|
||||
$this->postProcessHook();
|
||||
|
||||
//check user registration status is from pending class
|
||||
$url = CRM_Utils_System::url('civicrm/event/register',
|
||||
"reset=1&id={$this->_eventId}&participantId={$participantId}"
|
||||
);
|
||||
CRM_Utils_System::redirect($url);
|
||||
}
|
||||
elseif ($buttonName == '_qf_ParticipantConfirm_submit') {
|
||||
//need to registration status to 'cancelled'.
|
||||
|
||||
$cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'"));
|
||||
$additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
|
||||
|
||||
$participantIds = array_merge(array($participantId), $additionalParticipantIds);
|
||||
$results = CRM_Event_BAO_Participant::transitionParticipants($participantIds, $cancelledId, NULL, TRUE);
|
||||
|
||||
if (count($participantIds) > 1) {
|
||||
$statusMessage = ts("%1 Event registration(s) have been cancelled.", array(1 => count($participantIds)));
|
||||
}
|
||||
else {
|
||||
$statusMessage = ts("Your Event Registration has been cancelled.");
|
||||
}
|
||||
|
||||
if (!empty($results['mailedParticipants'])) {
|
||||
foreach ($results['mailedParticipants'] as $key => $displayName) {
|
||||
$statusMessage .= "<br />" . ts("Email has been sent to : %1", array(1 => $displayName));
|
||||
}
|
||||
}
|
||||
|
||||
$this->postProcessHook();
|
||||
CRM_Core_Session::setStatus($statusMessage);
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/info',
|
||||
"reset=1&id={$this->_eventId}&noFullMsg=1",
|
||||
FALSE, NULL, FALSE, TRUE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
1243
sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php
Normal file
1243
sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for processing Event
|
||||
*
|
||||
*/
|
||||
class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$this->_params = $this->get('params');
|
||||
$this->_lineItem = $this->get('lineItem');
|
||||
$this->_part = $this->get('part');
|
||||
$this->_totalAmount = $this->get('totalAmount');
|
||||
$this->_receiveDate = $this->get('receiveDate');
|
||||
$this->_trxnId = $this->get('trxnId');
|
||||
$finalAmount = $this->get('finalAmount');
|
||||
$this->assign('finalAmount', $finalAmount);
|
||||
$participantInfo = $this->get('participantInfo');
|
||||
$this->assign('part', $this->_part);
|
||||
$this->assign('participantInfo', $participantInfo);
|
||||
$customGroup = $this->get('customProfile');
|
||||
$this->assign('customProfile', $customGroup);
|
||||
$this->assign('individual', $this->get('individual'));
|
||||
|
||||
CRM_Event_Form_Registration_Confirm::assignProfiles($this);
|
||||
|
||||
CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->_values['event']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite action, since we are only showing elements in frozen mode
|
||||
* no help display needed
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAction() {
|
||||
if ($this->_action & CRM_Core_Action::PREVIEW) {
|
||||
return CRM_Core_Action::VIEW | CRM_Core_Action::PREVIEW;
|
||||
}
|
||||
else {
|
||||
return CRM_Core_Action::VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// Assign the email address from a contact id lookup as in CRM_Event_BAO_Event->sendMail()
|
||||
$primaryContactId = $this->get('primaryContactId');
|
||||
if ($primaryContactId) {
|
||||
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($primaryContactId);
|
||||
$this->assign('email', $email);
|
||||
}
|
||||
$this->assignToTemplate();
|
||||
|
||||
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
|
||||
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
|
||||
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
|
||||
$getTaxDetails = FALSE;
|
||||
$taxAmount = 0;
|
||||
|
||||
$lineItemForTemplate = array();
|
||||
if (!empty($this->_lineItem) && is_array($this->_lineItem)) {
|
||||
foreach ($this->_lineItem as $key => $value) {
|
||||
if (!empty($value) && $value != 'skip') {
|
||||
$lineItemForTemplate[$key] = $value;
|
||||
if ($invoicing) {
|
||||
foreach ($value as $v) {
|
||||
if (isset($v['tax_amount']) || isset($v['tax_rate'])) {
|
||||
$taxAmount += $v['tax_amount'];
|
||||
$getTaxDetails = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_priceSetId &&
|
||||
!CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config') &&
|
||||
!empty($lineItemForTemplate)
|
||||
) {
|
||||
$this->assign('lineItem', $lineItemForTemplate);
|
||||
}
|
||||
|
||||
if ($invoicing) {
|
||||
$this->assign('getTaxDetails', $getTaxDetails);
|
||||
$this->assign('totalTaxAmount', $taxAmount);
|
||||
$this->assign('taxTerm', $taxTerm);
|
||||
}
|
||||
$this->assign('totalAmount', $this->_totalAmount);
|
||||
|
||||
$hookDiscount = $this->get('hookDiscount');
|
||||
if ($hookDiscount) {
|
||||
$this->assign('hookDiscount', $hookDiscount);
|
||||
}
|
||||
|
||||
$this->assign('receive_date', $this->_receiveDate);
|
||||
$this->assign('trxn_id', $this->_trxnId);
|
||||
|
||||
//cosider total amount.
|
||||
$this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE);
|
||||
|
||||
$this->assign('defaultRole', FALSE);
|
||||
if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
|
||||
$this->assign('defaultRole', TRUE);
|
||||
}
|
||||
$defaults = array();
|
||||
$fields = array();
|
||||
if (!empty($this->_fields)) {
|
||||
foreach ($this->_fields as $name => $dontCare) {
|
||||
$fields[$name] = 1;
|
||||
}
|
||||
}
|
||||
$fields['state_province'] = $fields['country'] = $fields['email'] = 1;
|
||||
foreach ($fields as $name => $dontCare) {
|
||||
if (isset($this->_params[0][$name])) {
|
||||
$defaults[$name] = $this->_params[0][$name];
|
||||
if (substr($name, 0, 7) == 'custom_') {
|
||||
$timeField = "{$name}_time";
|
||||
if (isset($this->_params[0][$timeField])) {
|
||||
$defaults[$timeField] = $this->_params[0][$timeField];
|
||||
}
|
||||
}
|
||||
elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)
|
||||
&& !empty($this->_params[0][$name . '_custom'])
|
||||
) {
|
||||
$defaults[$name . '_custom'] = $this->_params[0][$name . '_custom'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_submitValues = array_merge($this->_submitValues, $defaults);
|
||||
|
||||
$this->setDefaults($defaults);
|
||||
|
||||
$params['entity_id'] = $this->_eventId;
|
||||
$params['entity_table'] = 'civicrm_event';
|
||||
$data = array();
|
||||
CRM_Friend_BAO_Friend::retrieve($params, $data);
|
||||
if (!empty($data['is_active'])) {
|
||||
$friendText = $data['title'];
|
||||
$this->assign('friendText', $friendText);
|
||||
if ($this->_action & CRM_Core_Action::PREVIEW) {
|
||||
$url = CRM_Utils_System::url('civicrm/friend',
|
||||
"eid={$this->_eventId}&reset=1&action=preview&pcomponent=event"
|
||||
);
|
||||
}
|
||||
else {
|
||||
$url = CRM_Utils_System::url('civicrm/friend',
|
||||
"eid={$this->_eventId}&reset=1&pcomponent=event"
|
||||
);
|
||||
}
|
||||
$this->assign('friendURL', $url);
|
||||
}
|
||||
|
||||
$this->freeze();
|
||||
|
||||
//lets give meaningful status message, CRM-4320.
|
||||
$isOnWaitlist = $isRequireApproval = FALSE;
|
||||
if ($this->_allowWaitlist && !$this->_allowConfirmation) {
|
||||
$isOnWaitlist = TRUE;
|
||||
}
|
||||
if ($this->_requireApproval && !$this->_allowConfirmation) {
|
||||
$isRequireApproval = TRUE;
|
||||
}
|
||||
$this->assign('isOnWaitlist', $isOnWaitlist);
|
||||
$this->assign('isRequireApproval', $isRequireApproval);
|
||||
|
||||
// find pcp info
|
||||
$dao = new CRM_PCP_DAO_PCPBlock();
|
||||
$dao->entity_table = 'civicrm_event';
|
||||
$dao->entity_id = $this->_eventId;
|
||||
$dao->is_active = 1;
|
||||
$dao->find(TRUE);
|
||||
|
||||
if ($dao->id) {
|
||||
$this->assign('pcpLink', CRM_Utils_System::url('civicrm/contribute/campaign', 'action=add&reset=1&pageId=' . $this->_eventId . '&component=event'));
|
||||
$this->assign('pcpLinkText', $dao->link_text);
|
||||
}
|
||||
|
||||
// Assign Participant Count to Lineitem Table
|
||||
$this->assign('pricesetFieldsCount', CRM_Price_BAO_PriceSet::getPricesetCount($this->_priceSetId));
|
||||
|
||||
// can we blow away the session now to prevent hackery
|
||||
$this->controller->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a descriptive name for the page, used in wizard header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Thank You Page');
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue