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

@@ -321,9 +321,23 @@ function booking_admin() {
'#type' => 'radios',
'#title' => t('Enable help area questions?'),
'#description' => t('Select whether to include questions about areas people are willing to help with in the booking form.'),
'#options' => array (0 => t('No'), t('Yes')),
'#options' => array (0 => t('No'), 1 => t('Yes')),
'#default_value' => variable_get('booking_enable_helpareas', 0),
);
$form['regn_options']['booking_enabled_helparea_options'] = array (
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Select help areas to enable'),
'#description' => t('Select which questions to include in the booking form.'),
'#options' => _booking_get_help_areas(),
'#default_value' => variable_get('booking_enabled_helparea_options', ''),
'#states' => array(
// Only show this field when the 'booking_enable_helpareas' checkbox is enabled.
'visible' => array(
':input[name="booking_enable_helpareas"]' => array('value' => 1),
),
),
);
$form['regn_options']['booking_enable_skills'] = array (
'#type' => 'radios',
'#title' => t('Enable special skills information?'),

View File

@@ -53,6 +53,21 @@ function _booking_status_lookup($input)
return array_search($input, _booking_status_generate());
}
/**
* Helper function to provide a list of helping areas for the registration form
*/
function _booking_get_help_areas() {
return array(
'booking_help_music' => 'Music',
'booking_help_reading' => 'Reading',
'booking_help_chairing' => 'Chairing',
'booking_help_praying' => 'Praying',
'booking_help_meditations' => 'Meditations',
'booking_firstaid' => 'First Aid',
'booking_nurse' => 'Nurse',
);
}
/**
* Helper function to provide a list of emergency contact types for the registration form
*/
@@ -108,6 +123,7 @@ function _booking_studygroup_role_lookup($input = NULL)
/**
* Helper function to look up description of room location based on id
* DEPRECATED - THIS DATA HAS MOVED TO DATABASE TABLE
* @param $input integer containing room id
* @return string for corresponding room location
*/

View File

@@ -491,6 +491,14 @@ function booking_update_7227() {
db_add_field('booking_person', 'booking_payment_complete', $spec);
}
/**
* Increase maximum length of booking_medical_conditions field to 1000 characters
*/
function booking_update_7228() {
$spec = array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE);
db_change_field('booking_person', 'booking_medical_conditions', 'booking_medical_conditions', $spec);
}
/**
* Implementation of hook_install().
*/
@@ -574,7 +582,7 @@ function booking_schema() {
'booking_readinggroup' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_shirt_size' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
'booking_dietary' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_medical_conditions' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_medical_conditions' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
//address details
'booking_street' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
'booking_suburb' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),

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
@@ -705,6 +705,61 @@ if (variable_get('booking_enable_passport', 0) == 1)
'#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),
),
),
'#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 {