| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
/**
- * The fields involved in this page
+ * The fields involved in this page.
*/
public $_fields;
/**
- * The defaults involved in this page
+ * The defaults involved in this page.
*/
public $_defaults;
public $_paymentFields = array();
/**
- * Set variables up before form is built
+ * Set variables up before form is built.
*
* @return void
*/
}
if ($this->_priceSetId && !empty($this->_feeBlock)) {
foreach ($this->_feeBlock as $key => $val) {
+ if (empty($val['options'])) {
+ continue;
+ }
+ $optionFullIds = CRM_Utils_Array::value('option_full_ids', $val, array());
foreach ($val['options'] as $keys => $values) {
if ($values['is_default'] && empty($values['is_full'])) {
}
}
}
+ $unsetSubmittedOptions[$val['id']] = $optionFullIds;
}
+ //reset values for all options those are full.
+ CRM_Event_Form_Registration::resetElementValue($unsetSubmittedOptions, $this);
}
//set default participant fields, CRM-4320.
}
/**
- * Build the form object
+ * Build the form object.
*
* @return void
*/
}
$contactID = $this->getContactID();
- $this->assign('contact_id', $contactID);
- $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
+ if ($contactID) {
+ $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);
$currentOptionsCount = self::getPriceSetOptionCount($form);
$recordedOptionsCount = CRM_Event_BAO_Participant::priceSetOptionsCount($form->_eventId, $skipParticipants);
$optionFullTotalAmount = 0;
-
+ $currentParticipantNo = (int) substr($form->_name, 12);
foreach ($form->_feeBlock as & $field) {
$optionFullIds = array();
$fieldId = $field['id'];
$totalCount = $currentTotalCount + $dbTotalCount;
$isFull = FALSE;
if ($maxValue &&
- (($totalCount > $maxValue) || ($totalCount + $count > $maxValue))
+ (($totalCount >= $maxValue) &&
+ (empty($form->_lineItem[$currentParticipantNo][$optId]['price_field_id']) || $dbTotalCount >= $maxValue))
) {
$isFull = TRUE;
$optionFullIds[$optId] = $optId;
}
/**
- * Global form rule
+ * Global form rule.
*
* @param array $fields
* The input form values.
}
// priceset validations
- if (!empty($fields['priceSetId'])) {
+ if (!empty($fields['priceSetId']) &&
+ !$self->_requireApproval && !$self->_allowWaitlist
+ ) {
//format params.
$formatted = self::formatPriceSetParams($self, $fields);
$ppParams = array($formatted);
if (!empty($self->_paymentFields)) {
CRM_Core_Form::validateMandatoryFields($self->_paymentFields, $fields, $errors);
}
- CRM_Core_Payment_Form::validateCreditCard($fields, $errors);
+ CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessorID, $fields, $errors, $self);
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
}
/**
- * Process the form submission
+ * Process the form submission.
*
*
* @return void
if ($params['tax_amount']) {
$this->set('tax_amount', $params['tax_amount']);
}
- $this->set('lineItem', array($lineItem));
+ $submittedLineItems = $this->get('lineItem');
+ if (!empty($submittedLineItems) && is_array($submittedLineItems)) {
+ $submittedLineItems[0] = $lineItem;
+ }
+ else {
+ $submittedLineItems = array($lineItem);
+ }
+ $this->set('lineItem', $submittedLineItems);
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$params['payment_action'] = 'Sale';
$params['invoiceID'] = $invoiceID;
}
-
- $this->_params = array();
- $this->_params[] = $params;
+ $this->_params = $this->get('params');
+ if (!empty($this->_params) && is_array($this->_params)) {
+ $this->_params[0] = $params;
+ }
+ else {
+ $this->_params = array();
+ $this->_params[] = $params;
+ }
$this->set('params', $this->_params);
if ($this->_paymentProcessor &&
}
/**
- * Process Registration of free event
+ * Process Registration of free event.
*
* @param array $params
* Form values.
}
/**
- * Method to check if the user is already registered for the event
+ * Method to check if the user is already registered for the event.
* and if result found redirect to the event info page
*
* @param array $fields
}
}
}
+
}