if (!$params['is_online_registration']) {
$params['is_email_confirm'] = FALSE;
}
+ if (!empty($params['allow_selfcancelxfer'])) {
+ $params['selfcancelxfer_time'] = !empty($params['selfcancelxfer_time']) ? $params['selfcancelxfer_time'] : 0;
+ }
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'],
if ($participantNum = array_search('participant', $participantCount)) {
unset($participantCount[$participantNum]);
}
+ // Change $this->_values['participant'] to include additional participant values
+ $ids = $participantValues = array();
+ $participantParams = array('id' => $participantID);
+ CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
+ $this->_values['participant'] = $participantValues[$participantID];
+
$this->assign('isPrimary', 0);
$this->assign('customProfile', NULL);
//Additional Participant should get only it's payment information
$this->_contact_email = $email;
$details = array();
$details = CRM_Event_BAO_Participant::participantDetails($this->_from_participant_id);
+ $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
$query = "
SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date
FROM civicrm_participant cp
LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id
- LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = 13
+ LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}
WHERE cp.id = {$this->_from_participant_id}";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
//check that either an email or firstname+lastname is included in the form(CRM-9587)
$to_contact_id = self::checkProfileComplete($fields, $errors, $self);
//To check if the user is already registered for the event(CRM-2426)
- self::checkRegistration($fields, $self, $to_contact_id);
+ self::checkRegistration($fields, $self, $to_contact_id, $errors);
//return parent::formrule($fields, $files, $self);
return empty($errors) ? TRUE : $errors;
}
*
* return @void
*/
- public static function checkRegistration($fields, $self, $contact_id) {
+ public static function checkRegistration($fields, $self, $contact_id, &$errors) {
// verify whether this contact already registered for this event
- $session = CRM_Core_Session::singleton();
$contact_details = CRM_Contact_BAO_Contact::getContactDetails($contact_id);
$display_name = $contact_details[0];
$query = "select event_id from civicrm_participant where contact_id = " . $contact_id;
if (!empty($to_event_id)) {
foreach ($to_event_id as $id) {
if ($id == $self->_event_id) {
- $status = $display_name . ts(" is already registered for this event");
- $session->setStatus($status, ts('Oops.'), 'alert');
+ $errors['email'] = $display_name . ts(" is already registered for this event");
}
}
}
$this->set('values', $this->_part_values);
//fetch Event by event_id, verify that this event can still be xferred/cancelled
$this->_event_id = $this->_part_values['event_id'];
+ $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
$this->_contact_id = $this->_part_values['participant_contact_id'];
$this->assign('action', $this->_action);
if ($this->_participant_id) {
$this->_contact_email = $email;
$details = array();
$details = CRM_Event_BAO_Participant::participantDetails($this->_participant_id);
+ $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
+ $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participant_id, 'contribution_id', 'participant_id');
+ $this->assign('contributionId', $contributionId);
$query = "
SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, cp.status_id
FROM civicrm_participant cp
LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id
- LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = 13
+ LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}
WHERE cp.id = {$this->_participant_id}";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
//verify participant status is still Registered
if ($details['status'] != "Registered") {
$status = "You are no longer registered for " . $this->_event_title;
- $session->setStatus($status, ts('Event status error.'), 'alert');
+ CRM_Core_Session::setStatus($status, ts('Event status error.'), 'alert');
+ CRM_Utils_System::redirect($url);
}
$query = "select start_date as start, selfcancelxfer_time as time from civicrm_event where id = " . $this->_event_id;
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
$time_limit = $dao->time;
$start_date = $dao->start;
}
+ $start_time = new Datetime($start_date);
+ $timenow = new Datetime();
+ if (!empty($start_time) && $start_time < $timenow) {
+ $status = ts("The event has been started, cannot transfer or cancel this event");
+ $session->setStatus($status, ts('Oops.'), 'alert');
+ CRM_Utils_System::redirect($url);
+ }
if (!empty($time_limit) && $time_limit > 0) {
- $timenow = new Datetime("");
- $start_time = new Datetime($start_date);
$interval = $timenow->diff($start_time);
$days = $interval->format('%d');
$hours = $interval->format('%h');
if ($hours <= $time_limit && $days < 1) {
- $status = ts("Less than ") . $time_limit . ts(" hours to start time, cannot transfer or cancel this event");
+ $status = ts("Less than %1 hours to start time, cannot transfer or cancel this event", array(1 => $time_limit));
$session->setStatus($status, ts('Oops.'), 'alert');
+ CRM_Utils_System::redirect($url);
}
}
$this->assign('details', $details);
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name));
$statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email));
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
+ $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
+ CRM_Utils_System::redirect($url);
}
}
<title>Self Service Update</title>
<page_callback>CRM_Event_Form_SelfSvcUpdate</page_callback>
<access_callback>1</access_callback>
- <is_public>true</is_public>
<page_type>1</page_type>
<weight>880</weight>
</item>
<page_callback>CRM_Event_Form_SelfSvcTransfer</page_callback>
<page_type>1</page_type>
<access_callback>1</access_callback>
- <is_public>true</is_public>
<weight>890</weight>
</item>
<item>
-{* TO DO: Add upgrade logic to update event_online msg templates and insert participant_transferred and cancelled msg templates. *}
\ No newline at end of file
+{php}
+ $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.7.beta1.msg_template/message_templates';
+ $templates = array();
+ $ovNames = array(
+ 'event' => array(
+ 'participant_transferred' => ts('Events - Registration Transferred Notice', array('escape' => 'sql')),
+ ),
+ );
+
+ $this->assign('ovNames', $ovNames);
+ $this->assign('dir', $dir);
+
+ foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
+ $parts = explode('_', basename($filename, '.tpl'));
+ $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
+ }
+ $this->assign('templates', $templates);
+{/php}
+{foreach from=$ovNames key=name item=ignore}
+ SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
+ SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @tpl_ogid_{$name};
+ SELECT @max_wt := max(weight) from civicrm_option_value where option_group_id=@tpl_ogid_{$name};
+{/foreach}
+
+INSERT INTO civicrm_option_value
+ (option_group_id, name, {localize field='label'}label{/localize}, value, weight) VALUES
+{foreach from=$ovNames key=gName item=ovs name=for_groups}
+{foreach from=$ovs key=vName item=label name=for_values}
+ (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize}, (SELECT @max_val := @max_val+1), (SELECT @max_wt := @max_wt+1)) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
+{/foreach}
+{/foreach}
+
+{foreach from=$ovNames key=gName item=ovs}
+{foreach from=$ovs key=vName item=label}
+ SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
+{/foreach}
+{/foreach}
+
+INSERT INTO civicrm_msg_template
+ (msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved) VALUES
+{foreach from=$ovNames key=gName item=ovs name=for_groups}
+{foreach from=$ovs key=vName item=title name=for_values}
+ {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.7.beta1.msg_template/message_templates/`$vName`_subject.tpl"}
+ {fetch assign=text file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.7.beta1.msg_template/message_templates/`$vName`_text.tpl"}
+ {fetch assign=html file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.7.beta1.msg_template/message_templates/`$vName`_html.tpl"}
+ ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1, 0),
+ ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0, 1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
+{/foreach}
+{/foreach}
+
+{foreach from=$templates item=tpl}
+ {fetch assign=content file=$tpl.filename}
+ SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
+ SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
+ UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
+{/foreach}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<div>
<table class="form-layout">
- <tr class="crm-selfsvcupdate-form-block-email">
+ <tr class="crm-selfsvcupdate-form-block-email">
<td class="label">{$form.email.label}</td>
- <td>{$form.email.html}</td>
+ <td>{$form.email.html}</td>
</tr>
- <tr class="crm-selfsvcupdate-form-block-participant">
+ <tr class="crm-selfsvcupdate-form-block-participant">
<td class="label">{$form.participant.label}</td>
- <td>{$form.participant.html}</td>
+ <td>{$form.participant.html}</td>
</tr>
<tr class="crm-selfsvcupdate-form-block-participant">
<td class="label">{$form.action.label}</td>
- <td>{$form.action.html}</td>
+ <td>{$form.action.html}</td>
</tr>
<table class="crm-selfsvcupdate-form-details"><col width="30"><col width="50"><col width="20"><col width="10"><col width="10"><col width="12"><col width="10">
<tr><th>Participant</th><th>Event</th><th>Fee Level</th><th>Fee Amt</th><th>Reg Date</th><th>Status</th><th>Role</th>
</table>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
+{literal}
+<script type="text/javascript">
+ var contributionID = {/literal}'{$contributionId}'{literal};
+ CRM.$(function($) {
+ $('#action').on('change', function() {
+ selected = $(this).find("option:selected").text();
+ if (selected == 'Cancel' && contributionID) {
+ CRM.alert(ts('Cancellations are not refundable.'), 'Warning', 'alert');
+ }
+ });
+ });
+</script>
+{/literal}