private function wf_crm_admin_form::buildParticipantTab in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/wf_crm_admin_form.inc \wf_crm_admin_form::buildParticipantTab()
Event participant settings
1 call to wf_crm_admin_form::buildParticipantTab()
- wf_crm_admin_form::buildForm in includes/
wf_crm_admin_form.inc - Build admin form for civicrm tab of a webform
File
- includes/
wf_crm_admin_form.inc, line 719 - Webform CiviCRM module's admin form.
Class
- wf_crm_admin_form
- @file Webform CiviCRM module's admin form.
Code
private function buildParticipantTab() {
$this->form['participant'] = array(
'#type' => 'fieldset',
'#title' => t('Event Registration'),
'#group' => 'webform_civicrm',
'#attributes' => array(
'class' => array(
'civi-icon-participant',
),
),
);
$reg_type = wf_crm_aval($this->data, 'participant_reg_type');
$this->form['participant']['participant_reg_type'] = array(
'#type' => 'select',
'#title' => t('Registration Method'),
'#default_value' => $reg_type,
'#options' => array(
t('- None -'),
'all' => t('Register all contacts for the same event(s)'),
'separate' => t('Register each contact separately'),
),
);
$this
->help($this->form['participant']['participant_reg_type'], 'participant_reg_type');
$this->form['participant']['event_type'] = array(
'#type' => 'select',
'#title' => t('Show Events of Type(s)'),
'#options' => array(
'any' => t('- Any Type -'),
) + wf_crm_apivalues('event', 'getoptions', array(
'field' => 'event_type_id',
)),
'#default_value' => wf_crm_aval($this->data, 'reg_options:event_type', 'any'),
'#prefix' => '<div id="event-reg-options-wrapper"><div class="web-civi-checkbox-set">',
'#parents' => array(
'reg_options',
'event_type',
),
'#tree' => TRUE,
'#multiple' => TRUE,
);
$this->form['participant']['show_past_events'] = array(
'#type' => 'select',
'#title' => t('Show Past Events'),
'#default_value' => wf_crm_aval($this->data, 'reg_options:show_past_events', 'now'),
'#parents' => array(
'reg_options',
'show_past_events',
),
'#tree' => TRUE,
'#options' => array(
'now' => t('- None -'),
1 => t('All'),
'-1 day' => t('Past Day'),
'-1 week' => t('Past Week'),
'-1 month' => t('Past Month'),
'-2 month' => t('Past 2 Months'),
'-3 month' => t('Past 3 Months'),
'-6 month' => t('Past 6 Months'),
'-1 year' => t('Past Year'),
'-2 year' => t('Past 2 Years'),
),
);
$this
->help($this->form['participant']['show_past_events'], 'reg_options_show_past_events');
$this->form['participant']['show_future_events'] = array(
'#type' => 'select',
'#title' => t('Show Future Events'),
'#default_value' => wf_crm_aval($this->data, 'reg_options:show_future_events', 1),
'#parents' => array(
'reg_options',
'show_future_events',
),
'#tree' => TRUE,
'#options' => array(
'now' => t('- None -'),
1 => t('All'),
'+1 day' => t('Next Day'),
'+1 week' => t('Next Week'),
'+1 month' => t('Next Month'),
'+2 month' => t('Next 2 Months'),
'+3 month' => t('Next 3 Months'),
'+6 month' => t('Next 6 Months'),
'+1 year' => t('Next Year'),
'+2 year' => t('Next 2 Years'),
),
);
$this
->help($this->form['participant']['show_future_events'], 'reg_options_show_future_events');
$this->form['participant']['show_public_events'] = array(
'#type' => 'select',
'#title' => t('Show Public Events'),
'#default_value' => wf_crm_aval($this->data, 'reg_options:show_public_events', 'title'),
'#parents' => array(
'reg_options',
'show_public_events',
),
'#tree' => TRUE,
'#options' => array(
'all' => t('Public and Private'),
'1' => t('Public'),
'0' => t('Private'),
),
);
$this
->help($this->form['participant']['show_public_events'], 'reg_options_show_public_events');
$this->form['participant']['title_display'] = array(
'#type' => 'select',
'#title' => t('Title Display'),
'#default_value' => wf_crm_aval($this->data, 'reg_options:title_display', 'title'),
'#suffix' => '</div>',
'#parents' => array(
'reg_options',
'title_display',
),
'#tree' => TRUE,
'#options' => array(
'title' => t('Title Only'),
'title type' => t('Title + Event Type'),
'title start dateformatYear' => t('Title + Year'),
'title start dateformatPartial' => t('Title + Month + Year'),
'title start dateformatFull' => t('Title + Start-Date'),
'title start dateformatTime' => t('Title + Start-Time'),
'title start dateformatDatetime' => t('Title + Start-Date-Time'),
'title start end dateformatFull' => t('Title + Start-Date + End'),
'title start end dateformatTime' => t('Title + Start-Time + End'),
'title start end dateformatDatetime' => t('Title + Start-Date-Time + End'),
),
);
$this
->help($this->form['participant']['title_display'], 'reg_options_title_display');
$this->form['participant']['reg_options'] = array(
'#prefix' => '<div class="clearfix"> </div>',
'#suffix' => '</div>',
'#type' => 'fieldset',
'#title' => t('Registration Options'),
'#collapsible' => TRUE,
'#collapsed' => isset($this->data['participant']),
'#tree' => TRUE,
);
$field = array(
'#type' => 'select',
'#title' => t('Show Remaining Space in Events'),
'#default_value' => wf_crm_aval($this->data, 'reg_options:show_remaining', 0),
'#options' => array(
t('Never'),
'always' => t('Always'),
'0_full' => t('When full - 0 spaces left'),
),
);
$this
->help($field, 'reg_options_show_remaining');
foreach (array(
5,
10,
20,
50,
100,
200,
500,
1000,
) as $num) {
$field['#options'][$num] = t('When under !num spaces left', array(
'!num' => $num,
));
}
$this->form['participant']['reg_options']['show_remaining'] = $field;
$this->form['participant']['reg_options']['validate'] = array(
'#type' => 'checkbox',
'#title' => t('Prevent Registration for Past/Full Events'),
'#default_value' => (bool) wf_crm_aval($this->data, 'reg_options:validate'),
);
$this
->help($this->form['participant']['reg_options']['validate'], 'reg_options_validate');
$this->form['participant']['reg_options']['block_form'] = array(
'#type' => 'checkbox',
'#title' => t('Block Form Access when Event(s) are Full/Ended'),
'#default_value' => (bool) wf_crm_aval($this->data, 'reg_options:block_form'),
);
$this->form['participant']['reg_options']['disable_unregister'] = array(
'#type' => 'checkbox',
'#title' => t('Disable unregistering participants from unselected events.'),
'#default_value' => (bool) wf_crm_aval($this->data, 'reg_options:disable_unregister'),
);
$this->form['participant']['reg_options']['allow_url_load'] = array(
'#type' => 'checkbox',
'#title' => t('Allow events to be autoloaded from URL'),
'#default_value' => (bool) wf_crm_aval($this->data, 'reg_options:allow_url_load'),
);
$this
->help($this->form['participant']['reg_options']['block_form'], 'reg_options_block_form');
$this
->help($this->form['participant']['reg_options']['disable_unregister'], 'reg_options_disable_unregister');
$this
->help($this->form['participant']['reg_options']['allow_url_load'], 'reg_options_allow_url_load');
$this
->addAjaxItem('participant', 'participant_reg_type', 'participants');
$this
->addAjaxItem('participant', 'event_type', 'participants');
$this
->addAjaxItem('participant', 'show_past_events', 'participants');
$this
->addAjaxItem('participant', 'show_future_events', 'participants');
$this
->addAjaxItem('participant', 'show_public_events', 'participants');
$this
->addAjaxItem('participant', 'title_display', 'participants');
for ($n = 1; $reg_type && ($n <= count($this->data['contact']) && $reg_type != 'all' || $n == 1); ++$n) {
$this->form['participant']['participants'][$n] = array(
'#type' => 'fieldset',
'#title' => $reg_type == 'all' ? t('Registration') : wf_crm_contact_label($n, $this->data, 'wrap'),
);
$num = wf_crm_aval($this->data, "participant:{$n}:number_of_participant");
if (!$num || $n > 1 && $reg_type == 'all') {
$num = 0;
}
$this->form['participant']['participants'][$n]['participant_' . $n . '_number_of_participant'] = array(
'#type' => 'select',
'#title' => $reg_type == 'all' ? t('Number of Event Sets') : t('Number of Event Sets for !contact', array(
'!contact' => wf_crm_contact_label($n, $this->data, 'wrap'),
)),
'#default_value' => $num,
'#options' => range(0, $this->sets['participant']['max_instances']),
'#prefix' => '<div class="number-of">',
'#suffix' => '</div>',
);
$this
->addAjaxItem("participant:participants:{$n}", 'participant_' . $n . '_number_of_participant', 'div');
$particpant_extensions = array(
1 => 'role_id',
2 => 'event_id',
3 => 'event_type',
);
for ($e = 1; $e <= $num; ++$e) {
$fs = "participant_{$n}_event_{$e}_fieldset";
$this->form['participant']['participants'][$n]['div'][$fs] = array(
'#type' => 'fieldset',
'#title' => t('Event !num', array(
'!num' => $e,
)),
'#attributes' => array(
'id' => $fs,
),
);
foreach ($this->sets as $sid => $set) {
if ($set['entity_type'] == 'participant') {
$sid = 'civicrm_' . $n . '_participant_' . $e . '_' . $sid . '_fieldset';
$class = 'web-civi-checkbox-set';
if (!empty($set['sub_types'])) {
$role_id = wf_crm_aval($this->data, "participant:{$n}:particpant:{$e}:role_id", '');
$event_id = wf_crm_aval($this->data, "participant:{$n}:particpant:{$e}:event_id", '');
$event_type = wf_crm_aval($this->data, 'reg_options:event_type', '');
if ($event_id && $event_id !== 'create_civicrm_webform_element') {
list($event_id, $event_type) = explode('-', $event_id);
}
$ext = $particpant_extensions[$set['extension_of']];
if (!in_array(${$ext}, $set['sub_types'])) {
$class .= ' hidden';
}
$class .= ' extends-condition ' . str_replace('_', '', $ext) . '-' . implode('-', $set['sub_types']);
}
$this->form['participant']['participants'][$n]['div'][$fs][$sid] = array(
'#type' => 'fieldset',
'#title' => $set['label'],
'#attributes' => array(
'id' => $sid,
'class' => array(
$class,
),
),
'js_select' => $this
->addToggle($sid),
);
foreach ($set['fields'] as $fid => $field) {
$id = 'civicrm_' . $n . '_participant_' . $e . '_' . $fid;
$item = $this
->addItem($id, $field);
if ($fid == 'participant_event_id') {
$item['#prefix'] = '<div class="auto-width">';
$item['#suffix'] = '</div>';
}
if ($fid == 'participant_event_id' || $fid == 'participant_role_id') {
$item['#attributes']['onchange'] = "wfCiviAdmin.participantConditional('#{$fs}');";
$item['#attributes']['class'][] = $fid;
${$fid} = wf_crm_aval($item, '#default_value');
}
$this->form['participant']['participants'][$n]['div'][$fs][$sid][$id] = $item;
}
}
}
}
}
}