diff --git a/booking.admin.inc b/booking.admin.inc index 9c4e9b0..ee7a21e 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -119,6 +119,13 @@ function booking_admin() { '#options' => _booking_gender_options(), '#default_value' => variable_get('booking_default_gender', 'M'), ); + $form['misc']['booking_allow_couples'] = array ( + '#type' => 'radios', + '#title' => t('Allow married couples?'), + '#description' => t('Select whether to cater for married couples in the registration form'), + '#options' => array (0 => t('No'), t('Yes')), + '#default_value' => variable_get('booking_allow_couples', 0), + ); $form['misc']['booking_default_country'] = array ( '#type' => 'select', '#title' => t('Select Default Country'), diff --git a/booking.install b/booking.install index 4f37f01..ed4fb72 100644 --- a/booking.install +++ b/booking.install @@ -1,7 +1,7 @@ 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '5', 'scale' => '2'); + $spec = array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'); db_add_field( 'booking_price', 'booking_late_price', $spec); } @@ -513,7 +513,7 @@ $result = db_insert('booking_event') */ function booking_uninstall() { // Remove tables. - drupal_uninstall_schema('booking'); + //drupal_uninstall_schema('booking'); } @@ -529,6 +529,7 @@ function booking_schema() { 'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE), 'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'), 'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), + 'booking_committee_member' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), 'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), 'booking_barcode' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE), 'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), @@ -564,6 +565,18 @@ function booking_schema() { 'booking_help_readgroup_lead' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), 'booking_help_praying' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), 'booking_help_meditations' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + //other helping areas + 'booking_has_mission_experience' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_mission_experience_details' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + + 'booking_skills_builder' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_skills_cooking' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_skills_childminding' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_skills_language' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_skills_language_details' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_skills_other' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_skills_other_details' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + //emergency contact info 'booking_guardian_name' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE), 'booking_guardian_type' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE), @@ -583,7 +596,32 @@ function booking_schema() { //'booking_payment_method' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE), 'booking_total_pay_reqd' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'), 'booking_amount_paid' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'), - 'booking_deposit_timestamp' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_deposit_timestamp' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_refund_processed' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), + 'booking_refund_due' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'), + //passport info + 'booking_passport_expiry_date' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_passport_num' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE), + 'booking_passport_issue_location' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_passport_issue_name' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + //flight info + 'booking_outflight_bookingnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_origin' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_origin' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_origin_ts' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_outflight_connecting_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_destination' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_outflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + + 'booking_rtrnflight_bookingnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_origin' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_origin_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_connecting_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_destination' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_rtrnflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + ), 'primary key' => array('nid'), ); @@ -650,6 +688,27 @@ function booking_schema() { 'primary key' => array('vid'), ); + $schema['booking_variety_times'] = array( + 'fields' => array( + 'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_variety_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), + 'booking_variety_time_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => TRUE), + 'booking_variety_start' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_variety_end' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + ), + 'primary key' => array('tid'), + ); + + $schema['booking_variety_regn'] = array( + 'fields' => array( + 'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_variety_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + ), + 'primary key' => array('rid'), + ); + $schema['booking_travel'] = array( 'fields' => array( 'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), @@ -669,6 +728,31 @@ function booking_schema() { 'primary key' => array('tid'), ); + //This lists all the study groups + $schema['booking_studygroup_list'] = array( + 'fields' => array( + 'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_studygroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_num_group_sessions' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 1), + ), + 'primary key' => array('sid'), + ); + + //this maps people to particular study groups + $schema['booking_studygroup_mapping'] = array( + 'fields' => array( + 'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_session_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', default => 0), + 'booking_is_leader' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_is_helper' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + ), + 'primary key' => array('sid'), + ); + return $schema; } diff --git a/booking.register.inc b/booking.register.inc index 2407e26..929c846 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -10,6 +10,10 @@ function booking_register_page() { $output = ""; $return_array = array(); + //set the page title + $bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event'; + drupal_set_title($bookingTitle . ' Booking Form'); + //figure out if we're allowed to accept bookings $booking_times = db_query("SELECT booking_register_open, booking_register_close FROM {booking_event} where eid = :eid", array(':eid' => $event->eid))->fetchObject(); @@ -125,18 +129,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) { '#default_value' => variable_get('booking_gender', empty($data->booking_gender) ? variable_get('booking_default_gender') : $data->booking_gender), '#options' => _booking_gender_options(), ); - /* - $form['your-details']['booking_gender'] = array( - '#type' => 'select', - '#title' => t('Gender'), - '#required' => TRUE, - '#default_value' => variable_get('booking_gender', empty($data->booking_gender) ? 'M' : $data->booking_gender), - '#options' => array( - 'M' => 'Male', - 'F' => 'Female', - ), - ); - */ + //If we're loading this from an existing node, we need to convert the timestamp into the proper format $form['your-details']['booking_dob'] = array( '#type' => 'date_select', @@ -234,34 +227,19 @@ function booking_form($node, &$form_state, $inserting = FALSE) { '#title' => t('I am baptised'), '#default_value' => (!empty($data->booking_baptised) && $data->booking_baptised == 'Y') ? 1 : 0 ); - $form['your-details']['booking_married'] = array( - '#type' => 'checkbox', - '#title' => t('I am married'), - '#default_value' => (!empty($data->booking_married) && $data->booking_married == 'Y') ? 1 : 0 - ); - $form['your-details']['booking_partner_name'] = array( - '#type' => 'textfield', - '#title' => t('If your partner is coming to !event also, please enter their name here. They must register and pay seperately.', - array('!event' => $event->booking_eventname)), - '#maxlength' => 120, - '#required' => FALSE, - '#states' => array( - // Only show this field when the 'booking_married' checkbox is enabled. - 'visible' => array( - ':input[name="booking_married"]' => array('checked' => TRUE), - ), - ), - '#default_value' => !empty($data->booking_partner_name) ? $data->booking_partner_name : '' - ); - - if ($inserting == TRUE) + + if (variable_get('booking_allow_couples', 0) == 1) { - $form['your-details']['booking_partner_id'] = array( + $form['your-details']['booking_married'] = array( + '#type' => 'checkbox', + '#title' => t('I am married'), + '#default_value' => (!empty($data->booking_married) && $data->booking_married == 'Y') ? 1 : 0 + ); + $form['your-details']['booking_partner_name'] = array( '#type' => 'textfield', - '#title' => t('If your partner has already registered for !event, please enter their registration id (number only) from the email they were sent. Otherwise, leave blank', - array('!event' => $event->booking_eventname)), - '#maxlength' => 15, - '#size' => 4, + '#title' => t('If your partner is coming to !event also, please enter their name here. They must register and pay seperately.', + array('!event' => $event->booking_eventname)), + '#maxlength' => 120, '#required' => FALSE, '#states' => array( // Only show this field when the 'booking_married' checkbox is enabled. @@ -270,40 +248,58 @@ function booking_form($node, &$form_state, $inserting = FALSE) { ), ), '#default_value' => !empty($data->booking_partner_name) ? $data->booking_partner_name : '' - ); - } - else - { - //add the empty element first - $partner_options[] = ''; + ); - //get a list of possible partners - $partners = db_query("SELECT nid, booking_firstname, booking_lastname, booking_partner_id FROM {booking_person} " . - "where booking_event_id = :eid and booking_married='Y' order by booking_lastname, booking_firstname", - array(':eid' => $event->eid)); + if ($inserting == TRUE) + { + $form['your-details']['booking_partner_id'] = array( + '#type' => 'textfield', + '#title' => t('If your partner has already registered for !event, please enter their registration id (number only) from the email they were sent. Otherwise, leave blank', + array('!event' => $event->booking_eventname)), + '#maxlength' => 15, + '#size' => 4, + '#required' => FALSE, + '#states' => array( + // Only show this field when the 'booking_married' checkbox is enabled. + 'visible' => array( + ':input[name="booking_married"]' => array('checked' => TRUE), + ), + ), + '#default_value' => !empty($data->booking_partner_name) ? $data->booking_partner_name : '' + ); + } + else //not inserting so allow administrator to choose a person + { + //add the empty element first + $partner_options[] = ''; - //convert that into an array - foreach($partners as $row) - $partner_options[$row->nid] = $row->booking_firstname . ' ' . $row->booking_lastname; - //create a select field - $form['your-details']['booking_partner_id'] = array( - '#type' => 'select', - '#title' => t('Choose Spouse'), - '#default_value' => $data->booking_partner_id, - '#options' => $partner_options, - ); - - //add the boyfriend/girlfriend field in here too - $form['your-details']['booking_bf_gf_nid'] = array( - '#type' => 'textfield', - '#title' => t('Registration ID of Boyfriend/Girlfriend to be placed in the same discussion groups as you.'), - '#maxlength' => 15, - '#size' => 4, - '#required' => FALSE, - '#default_value' => !empty($data->booking_bf_gf_nid) ? $data->booking_bf_gf_nid : '', - ); - } + //get a list of possible partners + $partners = db_query("SELECT nid, booking_firstname, booking_lastname, booking_partner_id FROM {booking_person} " . + "where booking_event_id = :eid and booking_married='Y' order by booking_lastname, booking_firstname", + array(':eid' => $event->eid)); + + //convert that into an array + foreach($partners as $row) + $partner_options[$row->nid] = $row->booking_firstname . ' ' . $row->booking_lastname; + //create a select field + $form['your-details']['booking_partner_id'] = array( + '#type' => 'select', + '#title' => t('Choose Spouse'), + '#default_value' => $data->booking_partner_id, + '#options' => $partner_options, + ); + //add the boyfriend/girlfriend field in here too + $form['your-details']['booking_bf_gf_nid'] = array( + '#type' => 'textfield', + '#title' => t('Registration ID of Boyfriend/Girlfriend to be placed in the same discussion groups as you.'), + '#maxlength' => 15, + '#size' => 4, + '#required' => FALSE, + '#default_value' => !empty($data->booking_bf_gf_nid) ? $data->booking_bf_gf_nid : '', + ); + } + } //end allow couples check //watchdog('booking', 'Booking registration form payment type: @info. Payment id: !id', // array('@info' => $payment_type_options[$data->booking_payment_id], '!id' => $data->booking_payment_id )); @@ -951,7 +947,7 @@ function _booking_validate($node, &$form_state) { } //verify partner id is in the correct format - if ($form_state['booking_partner_id'] != '') + if (isset($form_state['booking_partner_id']) && $form_state['booking_partner_id'] != '') { if (! is_numeric($form_state['booking_partner_id'] ))