}
}
}
-
- // get the option value for custom data type
- $customDataType = CRM_Core_OptionGroup::values('custom_data_type', FALSE, FALSE, FALSE, NULL, 'name');
- $this->_roleCustomDataTypeID = array_search('ParticipantRole', $customDataType);
- $this->_eventNameCustomDataTypeID = array_search('ParticipantEventName', $customDataType);
- $this->_eventTypeCustomDataTypeID = array_search('ParticipantEventType', $customDataType);
- $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
- $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
- $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
+ $this->setCustomDataTypes();
if ($this->_mode) {
$this->assign('participantMode', $this->_mode);
if ($this->_mode) {
// exclude events which are not monetary when credit card registration is used
$eventFieldParams['api']['params']['is_monetary'] = 1;
- $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
+ $this->addPaymentProcessorSelect(TRUE, FALSE, FALSE);
$element = $this->addEntityRef('event_id', ts('Event'), $eventFieldParams, TRUE);
if (empty($values['payment_instrument_id'])) {
$errorMsg['payment_instrument_id'] = ts('Payment Method is a required field.');
}
- CRM_Price_BAO_PriceField::priceSetValidation($values['priceSetId'], $values, $errorMsg);
+ if (!empty($values['priceSetId'])) {
+ CRM_Price_BAO_PriceField::priceSetValidation($values['priceSetId'], $values, $errorMsg);
+ }
}
// validate contribution status for 'Failed'.
}
}
+ $statusMsg = $this->submit($params);
+ CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
+ $session = CRM_Core_Session::singleton();
+ $buttonName = $this->controller->getButtonName();
+ if ($this->_context == 'standalone') {
+ if ($buttonName == $this->getButtonName('upload', 'new')) {
+ $urlParams = 'reset=1&action=add&context=standalone';
+ if ($this->_mode) {
+ $urlParams .= '&mode=' . $this->_mode;
+ }
+ if ($this->_eID) {
+ $urlParams .= '&eid=' . $this->_eID;
+ }
+ $session->replaceUserContext(CRM_Utils_System::url('civicrm/participant/add', $urlParams));
+ }
+ else {
+ $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
+ "reset=1&cid={$this->_contactId}&selectedChild=participant"
+ ));
+ }
+ }
+ elseif ($buttonName == $this->getButtonName('upload', 'new')) {
+ $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/participant',
+ "reset=1&action=add&context={$this->_context}&cid={$this->_contactId}"
+ ));
+ }
+ }
+
+ /**
+ * Submit form.
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+ public function submit($params) {
$participantStatus = CRM_Event_PseudoConstant::participantStatus();
// set the contact, when contact is selected
if (!empty($params['contact_id'])) {
$this->_params['mode'] = $this->_mode;
//add contribution record
- $contributions[] = $contribution = CRM_Event_Form_Registration_Confirm::processContribution($this, $this->_params, $result, $contactID, FALSE);
+ $contributions[] = $contribution = CRM_Event_Form_Registration_Confirm::processContribution(
+ $this, $this->_params,
+ $result, $contactID,
+ FALSE, FALSE,
+ $this->_paymentProcessor
+ );
// add participant record
$participants = array();
$this->assign('module', 'Event Registration');
//use of the message template below requires variables in different format
$event = $events = array();
- $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
+ $returnProperties = array('event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
//get all event details.
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
//format submitted data
foreach ($params['custom'] as $fieldID => $values) {
foreach ($values as $fieldValue) {
- $customFields[$fieldID]['id'] = $fieldID;
- $formattedValue = CRM_Core_BAO_CustomField::displayValue($fieldValue['value'], $fieldID, $participants[0]->id);
- $customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
+ $isPublic = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $fieldValue['custom_group_id'], 'is_public');
+ if ($isPublic) {
+ $customFields[$fieldID]['id'] = $fieldID;
+ $formattedValue = CRM_Core_BAO_CustomField::displayValue($fieldValue['value'], $fieldID, $participants[0]->id);
+ $customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
+ }
}
}
$this->_id = $participants[0]->id;
}
+ return $this->getStatusMsg($params, $sent, $updateStatusMsg, $notSent);
+ }
+
+ /**
+ * Set the various IDs relating to custom data types.
+ */
+ public function setCustomDataTypes() {
+ $customDataType = CRM_Core_OptionGroup::values('custom_data_type', FALSE, FALSE, FALSE, NULL, 'name');
+ $this->_roleCustomDataTypeID = array_search('ParticipantRole', $customDataType);
+ $this->_eventNameCustomDataTypeID = array_search('ParticipantEventName', $customDataType);
+ $this->_eventTypeCustomDataTypeID = array_search('ParticipantEventType', $customDataType);
+ $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
+ $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
+ $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
+ }
+
+ /**
+ * Get status message
+ *
+ * @param array $params
+ * @param int $sent
+ * @param string $updateStatusMsg
+ * @param int $notSent
+ *
+ * @return string
+ */
+ protected function getStatusMsg($params, $sent, $updateStatusMsg, $notSent) {
+ $statusMsg = '';
if (($this->_action & CRM_Core_Action::UPDATE)) {
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contributorDisplayName));
if (!empty($params['send_receipt']) && count($sent)) {
}
}
}
- CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
- $session = CRM_Core_Session::singleton();
- $buttonName = $this->controller->getButtonName();
- if ($this->_context == 'standalone') {
- if ($buttonName == $this->getButtonName('upload', 'new')) {
- $urlParams = 'reset=1&action=add&context=standalone';
- if ($this->_mode) {
- $urlParams .= '&mode=' . $this->_mode;
- }
- if ($this->_eID) {
- $urlParams .= '&eid=' . $this->_eID;
- }
- $session->replaceUserContext(CRM_Utils_System::url('civicrm/participant/add', $urlParams));
- }
- else {
- $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
- "reset=1&cid={$this->_contactId}&selectedChild=participant"
- ));
- }
- }
- elseif ($buttonName == $this->getButtonName('upload', 'new')) {
- $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/participant',
- "reset=1&action=add&context={$this->_context}&cid={$this->_contactId}"
- ));
- }
+ return $statusMsg;
}
}