Add ability for admin to choose help areas via gui, enhance medical condition field in regn form

This commit is contained in:
2015-07-23 18:49:18 +10:00
parent 7f5237a195
commit c8d91ea5c6
4 changed files with 110 additions and 12 deletions

View File

@@ -58,8 +58,8 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
date_default_timezone_set(date_default_timezone(FALSE));
//calculate what years to show in the date of birth field
$min_dob_years = _booking_year_offset(variable_get('booking_min_dob','1970-01-01 00:00:00'));
$max_dob_years = _booking_year_offset(variable_get('booking_max_dob','1970-01-01 00:00:00'));
$min_dob_years = _booking_year_offset(variable_get('booking_min_dob','1970-01-01 00:00:00')) + 1;
$max_dob_years = _booking_year_offset(variable_get('booking_max_dob','1970-01-01 00:00:00')) - 1;
$date_year_range = "-" . $min_dob_years . ':-' . $max_dob_years;
//determine whether loading saved node or form submission
@@ -704,7 +704,62 @@ if (variable_get('booking_enable_passport', 0) == 1)
'#type' => 'fieldset',
'#title' => 'Help Areas',
);
//retrieve help areas that have been enabled by admin
$enabled_help_areas = variable_get('booking_enabled_helparea_options', NULL);
//watchdog('booking', "<pre>Retreiving help area options:\n@info</pre>", array('@info' => print_r( $enabled_help_areas, true)));
//define help areas
$help_areas = array(
'booking_help_music' => array(
'#type' => 'textfield',
'#title' => t('I can help with music by playing the following musical instrument(s)'),
'#maxlength' => 200,
'#required' => FALSE,
'#default_value' => !empty($data->booking_help_music) ? $data->booking_help_music : '',
),
'booking_help_reading' => array(
'#type' => 'checkbox',
'#title' => t('I can help with reading'),
'#default_value' => (!empty($data->booking_help_reading) && $data->booking_help_reading == 'Y') ? 1 : 0
),
'booking_help_chairing' => array(
'#type' => 'checkbox',
'#title' => t('I can help with chairing'),
'#default_value' => (!empty($data->booking_help_chairing) && $data->booking_help_chairing == 'Y') ? 1 : 0
),
'booking_help_praying' => array(
'#type' => 'checkbox',
'#title' => t('I can help with praying'),
'#default_value' => (!empty($data->booking_help_praying) && $data->booking_help_praying == 'Y') ? 1 : 0
),
'booking_help_meditations' => array(
'#type' => 'checkbox',
'#title' => t('I can help with evening meditations'),
'#default_value' => (!empty($data->booking_help_meditations) && $data->booking_help_meditations == 'Y') ? 1 : 0
),
'booking_firstaid' => array(
'#type' => 'checkbox',
'#title' => t('I am a qualified First Aid Officer'),
'#default_value' => (!empty($data->booking_firstaid) && $data->booking_firstaid == 'Y') ? 1 : 0
),
'booking_nurse' => array(
'#type' => 'checkbox',
'#title' => t('I am a qualified Nurse'),
'#default_value' => (!empty($data->booking_nurse) && $data->booking_nurse == 'Y') ? 1 : 0
),
);
//include enabled help areas in the form
foreach ($help_areas as $key => $value)
{
if (in_array($key, $enabled_help_areas))
{
$form['help-areas'][$key] = $value;
}
}
/*
$form['help-areas']['booking_help_music'] = array(
'#type' => 'textfield',
'#title' => t('I can help with music by playing the following musical instrument(s)'),
@@ -742,6 +797,8 @@ if (variable_get('booking_enable_passport', 0) == 1)
'#title' => t('I am a qualified Nurse'),
'#default_value' => (!empty($data->booking_nurse) && $data->booking_nurse == 'Y') ? 1 : 0
);
*/
}
if (variable_get('booking_enable_skills', 1) == 1)
@@ -872,20 +929,23 @@ if (variable_get('booking_enable_passport', 0) == 1)
$form['misc-areas']['booking_medical_conditions_check'] = array(
'#type' => 'checkbox',
'#title' => t('I have special medical condition(s)'),
'#title' => t('I have special medical condition(s), including allergies'),
'#default_value' => (!empty($data->booking_medical_conditions) && $data->booking_medical_conditions == 'Y') ? 1 : 0
);
$form['misc-areas']['booking_medical_conditions'] = array(
'#type' => 'textfield',
'#title' => t('Please list any medical conditions we need to be aware of.'),
'#maxlength' => 120,
'#type' => 'textarea',
'#title' => t('Please list any medical conditions we need to be aware of. For allegies, please list the reaction to the allergen(s).'),
'#cols' => 60,
'#rows' => 5,
'#resizable' => FALSE,
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name="booking_medical_conditions_check"]' => array('checked' => TRUE),
':input[name="booking_medical_conditions_check"]' => array('checked' => TRUE),
),
),
),
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : ''
'#attributes' => array('maxlength' => 1000),
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : '',
);
} else {