1696 lines
71 KiB
PHP
1696 lines
71 KiB
PHP
<?php
|
|
// $Id: yc.forms.inc,v 0.1 2010/07/21
|
|
|
|
/**
|
|
* Handle user registrations
|
|
*/
|
|
function booking_register_page() {
|
|
//get some configuration information
|
|
global $event;
|
|
$output = "";
|
|
$return_array = array();
|
|
|
|
//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();
|
|
|
|
if ($booking_times->booking_register_open < time() && $booking_times->booking_register_close > time())
|
|
{
|
|
//we are within the allowed timeframe for registrations
|
|
//check if this registration will be on the waiting list
|
|
if (_booking_check_bookings_full() == True)
|
|
{
|
|
$output = token_replace(variable_get('booking_registration_waiting_intro_text'), booking_define_tokens());
|
|
}
|
|
else
|
|
{
|
|
//watchdog('booking', 'Booking registration form intro text: @info', array('@info' => var_export(variable_get('booking_registration_intro_text'), TRUE)));
|
|
$output = token_replace(variable_get('booking_registration_intro_text'), booking_define_tokens());
|
|
}
|
|
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
|
|
$return_array[] = array('form' => drupal_get_form('booking_form', true));
|
|
}
|
|
elseif ($booking_times->booking_register_close < time())
|
|
{
|
|
//too late to register
|
|
$output = token_replace(variable_get('default_into_regn_closed_text'), booking_define_tokens());
|
|
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
|
|
}
|
|
else
|
|
{
|
|
//too early to register
|
|
$output = token_replace(variable_get('default_into_regn_not_opened_text'), booking_define_tokens());
|
|
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
|
|
}
|
|
|
|
return $return_array;
|
|
}
|
|
|
|
function booking_form($node, &$form_state, $inserting = FALSE) {
|
|
|
|
global $event;
|
|
$status_options = array();
|
|
$payment_type_options = array();
|
|
$partner_options = array();
|
|
date_default_timezone_set(TIMEZONE);
|
|
|
|
if (!empty($node))
|
|
{
|
|
$data = $node;
|
|
//watchdog('booking', 'Booking registration form loading data from saved node: @info', array('@info' => var_export($node, TRUE)));
|
|
}
|
|
else
|
|
{
|
|
$data = $form_state['input'];
|
|
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
|
}
|
|
|
|
$emergency_contact_type_options = array(
|
|
'parent' => 'Parent',
|
|
'legal_guardian' => 'Legal Guardian',
|
|
'relative' => 'Close Relative');
|
|
|
|
$status_options[0] = t('Not Paid');
|
|
$status_options[1] = t('Booked In');
|
|
$status_options[2] = t('Waiting List');
|
|
$status_options[3] = t('No Longer Coming');
|
|
|
|
//figure out if we're in the earlybird rate section
|
|
$early = db_query("SELECT booking_earlybird_close FROM {booking_event} where eid = :eid", array(
|
|
':eid' => $event->eid))
|
|
->fetchObject();
|
|
if ($early->booking_earlybird_close > time())
|
|
$select_early = 1;
|
|
else
|
|
{
|
|
$select_early = 0;
|
|
//watchdog('booking', 'No longer accepting earlybird prices');
|
|
}
|
|
|
|
$result = db_query("SELECT pid, booking_price_descrip, booking_price, booking_late_price FROM {booking_price} where booking_eventid = :eid " .
|
|
"and booking_price_active=1 and booking_depositonly = 0",
|
|
array(':eid' => $event->eid,));
|
|
|
|
foreach($result as $row)
|
|
{
|
|
$price = $select_early == 1 ? $row->booking_price : $row->booking_late_price;
|
|
$payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')';
|
|
}
|
|
|
|
//form starts here
|
|
$form['your-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Personal details',
|
|
);
|
|
|
|
$form['your-details']['booking_firstname'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('First Name'),
|
|
'#maxlength' => 45,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_firstname) ? $data->booking_firstname : ''
|
|
);
|
|
$form['your-details']['booking_lastname'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Last Name'),
|
|
'#maxlength' => 45,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_lastname) ? $data->booking_lastname : ''
|
|
);
|
|
$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',
|
|
'#title' => t('Date of Birth'),
|
|
'#default_value' => empty($data->booking_dob) ? '' : date("Y-m-d H:i:s", $data->booking_dob),
|
|
'#required' => TRUE,
|
|
'#date_format' => 'd/m/Y',
|
|
'#date_label_position' => 'within',
|
|
'#date_year_range' => '-50:-13'
|
|
);
|
|
|
|
$form['your-details']['booking_payment_id'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Choose your payment type'),
|
|
'#default_value' => $inserting != TRUE ? $data->booking_payment_id : variable_get('booking_payment_id','worker'),
|
|
'#options' => $payment_type_options,
|
|
);
|
|
|
|
// The status field should not be visible unless this registration is being updated...i.e. not at actual registration time...
|
|
if ($inserting != TRUE) {
|
|
$form['your-details']['booking_status'] = array(
|
|
'#type' => 'radios',
|
|
'#title' => t('Registration Status'),
|
|
'#options' => $status_options,
|
|
'#default_value' => !empty($data->booking_status) ? $data->booking_status : '',
|
|
);
|
|
|
|
$form['your-details']['booking_welfare_required'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Welfare Required?'),
|
|
'#description' => t('Select to mark this attendee as requiring special financial consideration'),
|
|
'#default_value' => (!empty($data->booking_welfare_required) && $data->booking_welfare_required == 'Y') ? 1 : 0
|
|
);
|
|
} //end inserting check for booking status
|
|
|
|
//tshirts
|
|
if (variable_get('booking_enable_tshirts', 0) == 1)
|
|
{
|
|
$form['your-details']['booking_shirt_size'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Preferred hoodie size'),
|
|
'#required' => FALSE,
|
|
'#default_value' => variable_get('booking_shirt_size', empty($data->booking_shirt_size) ? '' : $data->booking_shirt_size),
|
|
'#options' => _get_tshirt_options(),
|
|
);
|
|
} //end enable tshirts check
|
|
|
|
$form['your-details']['booking_ecclesia'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Ecclesia'),
|
|
'#maxlength' => 100,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : ''
|
|
);
|
|
$form['your-details']['booking_baptised'] = array(
|
|
'#type' => 'checkbox',
|
|
'#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)
|
|
{
|
|
$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
|
|
{
|
|
//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));
|
|
|
|
//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 : '',
|
|
);
|
|
}
|
|
|
|
|
|
//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 ));
|
|
|
|
//only show the booking agreement tickbox if the node is being created, since this value isn't stored anywhere
|
|
if ($inserting == TRUE)
|
|
{
|
|
/*
|
|
$form['your-details']['booking_regular_cyc'] = array
|
|
(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Regularly Attend CYC '),
|
|
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
|
|
'#title' => t('I regularly attend CYC events/activities'),
|
|
); */
|
|
|
|
$form['your-details']['booking_agreement'] = array
|
|
(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Aims and Expectations'),
|
|
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
|
|
/*
|
|
'#states' => array(
|
|
// Only show this field when the checkbox is unchecked.
|
|
'visible' => array(
|
|
':input[name="booking_agreement"]' => array('checked' => FALSE),
|
|
),
|
|
),
|
|
*/
|
|
'#title' => token_replace(variable_get('booking_registration_aims_rules_checkbox'), booking_define_tokens()),
|
|
'#description' => token_replace(variable_get('booking_registration_aims_rules_text'), booking_define_tokens())
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//not inserting
|
|
$form['booking_agreement'] = array (
|
|
'#type' => 'hidden',
|
|
'#value' => 1,
|
|
);
|
|
|
|
$form['your-details']['booking_amount_paid'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Amount Paid'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_amount_paid) ? $data->booking_amount_paid : ''
|
|
);
|
|
|
|
$form['your-details']['booking_total_pay_reqd'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Total Amount Due'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_total_pay_reqd) ? $data->booking_total_pay_reqd : '0.00'
|
|
);
|
|
//refund info
|
|
$form['your-details']['booking_refund_processed'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Refund Processed?'),
|
|
'#description' => t('Select to mark the processing of any applicable refund as complete'),
|
|
'#default_value' => (!empty($data->booking_refund_processed) && $data->booking_refund_processed == 'Y') ? 1 : 0
|
|
);
|
|
$form['your-details']['booking_refund_due'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Refund Amount Due'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_refund_due) ? $data->booking_refund_due : '0.00'
|
|
);
|
|
|
|
$form['your-details']['booking_barcode'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Barcode'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_barcode) ? $data->booking_barcode : ''
|
|
);
|
|
|
|
$form['your-details']['booking_readinggroup'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Reading Group Allocation'),
|
|
'#maxlength' => 100,
|
|
'#default_value' => !empty($data->booking_readinggroup) ? $data->booking_readinggroup : '',
|
|
);
|
|
} //end not-inserting check
|
|
|
|
if (variable_get('booking_enable_passport', 0) == 1)
|
|
{
|
|
$form['passport-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Passport Details',
|
|
);
|
|
$form['passport-details']['booking_passport_num'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Passport Number'),
|
|
'#maxlength' => 45,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_passport_num) ? $data->booking_passport_num : ''
|
|
);
|
|
$form['passport-details']['booking_passport_issue_location'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('City of Issue (eg Sydney)'),
|
|
'#maxlength' => 120,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_passport_issue_location) ? $data->booking_passport_issue_location : ''
|
|
);
|
|
$form['passport-details']['booking_passport_issue_name'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Exact name as listed on passport'),
|
|
'#maxlength' => 120,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_passport_issue_name) ? $data->booking_passport_issue_name : ''
|
|
);
|
|
$form['passport-details']['booking_passport_expiry_date'] = array(
|
|
'#type' => 'date_select',
|
|
'#title' => t('Passport expiry date'),
|
|
'#default_value' => empty($data->booking_passport_expiry_date) ? '' : date("Y-m-d H:i:s", $data->booking_passport_expiry_date),
|
|
'#required' => FALSE,
|
|
'#date_format' => 'd/m/Y',
|
|
//'#date_label_position' => 'within',
|
|
'#date_year_range' => '+0:+13'
|
|
);
|
|
}
|
|
|
|
$form['contact-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Contact details',
|
|
);
|
|
$form['contact-details']['booking_email'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('E-mail address'),
|
|
'#maxlength' => 100,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_email) ? $data->booking_email : ''
|
|
);
|
|
|
|
$form['contact-details']['booking_phone'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Home Phone Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 35,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_phone) ? $data->booking_phone : ''
|
|
);
|
|
$form['contact-details']['booking_mobile'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Mobile Phone Number'),
|
|
'#size' => 35,
|
|
'#maxlength' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_mobile) ? $data->booking_mobile : ''
|
|
);
|
|
|
|
$form['contact-details']['booking_street'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Street Address'),
|
|
'#maxlength' => 50,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_street) ? $data->booking_street : ''
|
|
);
|
|
$form['contact-details']['booking_suburb'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Suburb'),
|
|
'#maxlength' => 50,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_suburb) ? $data->booking_suburb : ''
|
|
);
|
|
|
|
|
|
if ($inserting == TRUE)
|
|
{
|
|
$form['contact-details']['booking_state'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('State'),
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_state) ? $data->booking_state : BOOKING_DEFAULT_STATE,
|
|
'#options' => _booking_state_options(),
|
|
);
|
|
$form['contact-details']['booking_other_state'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please specify state'),
|
|
'#maxlength' => 50,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_state' is set to other.
|
|
'visible' => array(
|
|
':input[name="booking_state"]' => array('value' => 'Other'),
|
|
),
|
|
),
|
|
'#default_value' => '',
|
|
);
|
|
} else {
|
|
//when modifying the node just show the textfield
|
|
$form['contact-details']['booking_state'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('State'),
|
|
'#maxlength' => 50,
|
|
'#default_value' => !empty($data->booking_state) ? $data->booking_state : '',
|
|
);
|
|
}
|
|
|
|
|
|
$form['contact-details']['booking_postcode'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Postal/Zip code'),
|
|
'#maxlength' => 8,
|
|
'#size' => 10,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_postcode) ? $data->booking_postcode : ''
|
|
);
|
|
$form['contact-details']['booking_country'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Country'),
|
|
'#required' => TRUE,
|
|
'#default_value' => variable_get('booking_country', empty($data->booking_country) ? variable_get('booking_default_country') : $data->booking_country),
|
|
'#options' => _booking_country_options(),
|
|
);
|
|
|
|
//emergency contact details
|
|
$form['emergency'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Emergency Contact Details',
|
|
'#description' => 'Please enter contact details for use in case of emergency',
|
|
);
|
|
$form['emergency']['booking_guardian_name'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Parent/Guardian Name'),
|
|
'#maxlength' => 100,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_name) ? '' : $data->booking_guardian_name
|
|
);
|
|
$form['emergency']['booking_guardian_type'] = array(
|
|
'#type' => 'radios',
|
|
'#title' => t('Relation to you'),
|
|
'#options' => $emergency_contact_type_options,
|
|
'#default_value' => empty($data->booking_guardian_type) ? 'parent' : $data->booking_guardian_type,
|
|
'#required' => TRUE
|
|
);
|
|
$form['emergency']['booking_guardian_phone'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Contact Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_phone) ? '' : $data->booking_guardian_phone
|
|
);
|
|
$form['emergency']['booking_guardian_phone_alt'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Alternate Contact Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => empty($data->booking_guardian_phone_alt) ? '' : $data->booking_guardian_phone_alt
|
|
);
|
|
|
|
if (variable_get('booking_enable_medicare', 1) == 1)
|
|
{
|
|
$form['emergency']['booking_medicare'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Your Medicare Number'),
|
|
'#maxlength' => 15,
|
|
'#size' => 15,
|
|
'#required' => FALSE,
|
|
'#default_value' => empty($data->booking_medicare) ? '' : $data->booking_medicare
|
|
);
|
|
}
|
|
|
|
if (variable_get('booking_enable_helpareas', 1) == 1)
|
|
{
|
|
$form['help-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Help Areas',
|
|
);
|
|
|
|
$form['help-areas']['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 : ''
|
|
);
|
|
$form['help-areas']['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
|
|
);
|
|
$form['help-areas']['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
|
|
);
|
|
$form['help-areas']['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
|
|
);
|
|
$form['help-areas']['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
|
|
);
|
|
$form['help-areas']['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
|
|
);
|
|
$form['help-areas']['booking_nurse'] = array(
|
|
'#type' => 'checkbox',
|
|
'#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)
|
|
{
|
|
$form['mission-experience'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Mission Work Experience',
|
|
);
|
|
$form['mission-experience']['booking_has_mission_experience'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have previous mission work experience'),
|
|
'#default_value' => (!empty($data->booking_has_mission_experience) && $data->booking_has_mission_experience == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['mission-experience']['booking_mission_experience_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t("Please list the places you've done mission work previously"),
|
|
'#maxlength' => 200,
|
|
//'#size' => 100,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_has_mission_experience' checkbox is enabled.
|
|
'visible' => array(
|
|
':input[name="booking_has_mission_experience"]' => array('checked' => TRUE),
|
|
),
|
|
),
|
|
'#default_value' => !empty($data->booking_mission_experience_details) ? $data->booking_mission_experience_details : ''
|
|
);
|
|
$form['skill-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Skills Section',
|
|
);
|
|
$form['skill-areas']['booking_skills_builder'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am an experienced builder'),
|
|
'#default_value' => (!empty($data->booking_skills_builder) && $data->booking_skills_builder == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_cooking'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can assist with cooking'),
|
|
'#default_value' => (!empty($data->booking_skills_cooking) && $data->booking_skills_cooking == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_childminding'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have child minding experience or am happy to work with children and sunday school students'),
|
|
'#default_value' => (!empty($data->booking_skills_childminding) && $data->booking_skills_childminding == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_language'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can speak multiple languages'),
|
|
'#default_value' => (!empty($data->booking_skills_language) && $data->booking_skills_language == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['skill-areas']['booking_skills_language_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please list any languages other than English that you speak'),
|
|
'#maxlength' => 250,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_skills_language"]' => array('checked' => TRUE),
|
|
),
|
|
),
|
|
'#default_value' => !empty($data->booking_skills_language_details) ? $data->booking_skills_language_details : ''
|
|
);
|
|
|
|
$form['skill-areas']['booking_skills_other'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have other skills that can assist in preaching activities'),
|
|
'#default_value' => (!empty($data->booking_skills_other) && $data->booking_skills_other == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_other_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please list any skills you believe will be helpful'),
|
|
'#maxlength' => 250,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_skills_other"]' => array('checked' => TRUE),
|
|
),
|
|
),
|
|
'#default_value' => !empty($data->booking_skills_other_details) ? $data->booking_skills_other_details : ''
|
|
);
|
|
|
|
}
|
|
|
|
$form['misc-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Miscellaneous',
|
|
);
|
|
|
|
if ($inserting == TRUE)
|
|
{
|
|
$form['misc-areas']['booking_dietary_check'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Special dietary requirements'),
|
|
'#default_value' => (!empty($data->booking_dietary) && $data->booking_dietary == 'Y') ? 1 : 0
|
|
);
|
|
|
|
if (variable_get('booking_enable_dietary', 0) == 1)
|
|
{
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please describe your dietary requirements.'),
|
|
'#maxlength' => 120,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_dietary_check"]' => array('checked' => TRUE),
|
|
),
|
|
),
|
|
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : ''
|
|
);
|
|
}
|
|
else
|
|
{
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'container',
|
|
'#children' => variable_get('booking_dietary_text_definition', "Please contact us to specify your dietary requirements."),
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_dietary_check"]' => array('checked' => TRUE),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
$form['misc-areas']['booking_medical_conditions_check'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Special medical conditions'),
|
|
'#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,
|
|
'#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 : ''
|
|
);
|
|
|
|
} else {
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please describe your dietary requirements.'),
|
|
'#maxlength' => 120,
|
|
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : ''
|
|
);
|
|
$form['misc-areas']['booking_medical_conditions'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please list any medical conditions we need to be aware of.'),
|
|
'#maxlength' => 120,
|
|
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : ''
|
|
);
|
|
}
|
|
|
|
if (variable_get('booking_enable_roommate', 0) == 1)
|
|
{
|
|
$form['misc-areas']['booking_room_mate1'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('I would like to share a room with'),
|
|
'#maxlength' => 200,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : '',
|
|
);
|
|
}
|
|
|
|
|
|
if ($inserting == TRUE) {
|
|
$form['submit'] = array(
|
|
'#type' => 'submit',
|
|
'#value' => t('Register'),
|
|
);
|
|
}
|
|
return $form;
|
|
}
|
|
|
|
|
|
|
|
function booking_form_validate($form, &$form_state) {
|
|
return _booking_validate($form_state['values']['form_id'], $form_state['values']);
|
|
}
|
|
|
|
function _booking_validate($node, &$form_state) {
|
|
global $event;
|
|
|
|
//in case the date of birth field hasn't been filled out
|
|
//watchdog('booking', 'Blank date of birth checking: @info', array('@info' => var_export($form_state['booking_dob'], TRUE)));
|
|
$dob_check = $form_state['booking_dob']['day'] != '' && $form_state['booking_dob']['month'] != '' && $form_state['booking_dob']['year'] != '' ? _date_to_ts($form_state['booking_dob']) : 0;
|
|
|
|
//Verify this is not a duplicate registration
|
|
//try and find the person in the database for this event
|
|
$person = db_query("SELECT person.nid, person.booking_tempid " .
|
|
"FROM {booking_person} person " .
|
|
"WHERE booking_firstname = :first AND booking_lastname = :last AND booking_dob = :dob AND booking_event_id = :eid",
|
|
array(':first' => $form_state['booking_firstname'], ':last' => $form_state['booking_lastname'], ':dob' => $dob_check,
|
|
':eid' => $event->eid))
|
|
->fetchObject();
|
|
|
|
if ($person)
|
|
{
|
|
if ((strlen($person->booking_tempid) > 0) && (variable_get('booking_use_paypal', 0) == 1))
|
|
{
|
|
//they have registered but not paid, so give them the payment link
|
|
form_set_error('booking_firstname',
|
|
t('Our records indicate that you are part-way through the registration process. Please !click to complete the process.',
|
|
array('!click' => l('click here', 'confirm/' . $person->booking_tempid)))
|
|
);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
form_set_error('booking_firstname',
|
|
t('Our records indicate that you have already registered. If you believe this to be incorrect, please !contact using the details provided.',
|
|
array('!contact' => l('contact us', 'contact-us')))
|
|
);
|
|
}
|
|
}
|
|
|
|
//verify partner id is in the correct format
|
|
if ($form_state['booking_partner_id'] != '')
|
|
{
|
|
|
|
if (! is_numeric($form_state['booking_partner_id'] ))
|
|
{
|
|
form_set_error('booking_partner_id',
|
|
t('You have entered an invalid partner registration id. Please ensure you are using only the registration reference number your partner received via email. If you believe this to be incorrect, please !contact using the details provided.',
|
|
array('!contact' => l('contact us', 'contact')))
|
|
);
|
|
}
|
|
|
|
//check that the partner exists
|
|
$partner = db_query("SELECT person.nid, person.booking_married " .
|
|
"FROM {booking_person} person " .
|
|
"WHERE nid = :nid AND person.booking_married = 'Y'",
|
|
array(':nid' => $form_state['booking_partner_id']))
|
|
->fetchObject();
|
|
|
|
//watchdog('booking', 'Checking for partner via query: @info', array('@info' => $partner->__toString()));
|
|
|
|
if (! $partner)
|
|
{
|
|
form_set_error('booking_partner_id',
|
|
t('Our records do not indicate that the supplied registration ID of your spouse is correct. Please ensure you are using only the number that relates to their registration. If you believe this to be incorrect, please !contact using the details provided.',
|
|
array('!contact' => l('contact us', 'contact')))
|
|
);
|
|
}
|
|
}
|
|
|
|
//watchdog('booking', 'Form validate data: @info', array('@info' => var_export($form_state, TRUE)));
|
|
$email = (isset($form_state['booking_email']) ? $form_state['booking_email'] : $node->booking_email);
|
|
if (strlen(trim($email)) > 0 && !_valid_email_address($email))
|
|
form_set_error('booking_email', t('You must enter a valid e-mail address. Please ensure you typed your email address correctly.'));
|
|
|
|
//if DOB on form is more recent than DOB limit, display validation error
|
|
if ($dob_check > _booking_max_dob_ts())
|
|
{
|
|
watchdog('booking', "Attempt to register from !first !last, who is too young (!info) to attend event.",
|
|
array ('!first' => $form_state['booking_firstname'], '!last' => $form_state['booking_lastname'], '!info' => var_export($form_state['booking_dob'], TRUE) ) );
|
|
form_set_error('booking_dob', t('Unfortunately you are too young to attend !event.',
|
|
array ('!event' => variable_get('booking_event_name','this event'))));
|
|
}
|
|
|
|
//check the terms and conditions have been agreed to
|
|
if ($form_state['booking_agreement'] == 0)
|
|
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
|
|
|
|
//check the medicare number for people in Australia
|
|
if (variable_get('booking_enable_medicare', 1) == 1 && $form_state['booking_country'] == 'Australia')
|
|
{
|
|
//proper validation routine at http://dyball.wordpress.com/2007/12/05/validation-of-medicare-numbers/
|
|
if (! _valid_medicare_number($form_state['booking_medicare']))
|
|
{
|
|
form_set_error('booking_medicare',
|
|
t('You have entered an invalid medicare number. Please check your medicare card and re-enter the number. ' .
|
|
'If you believe this to be incorrect, please !contact.',
|
|
array('!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Medicare Number')))
|
|
);
|
|
}
|
|
}
|
|
|
|
//verify passport number
|
|
if (variable_get('booking_enable_passport', 0) == 1 && $form_state['booking_country'] == 'Australia')
|
|
{
|
|
if (($form_state['booking_passport_num'] != '') && (! _valid_passport_number($form_state['booking_passport_num'])))
|
|
{
|
|
form_set_error('booking_passport_num',
|
|
t('You have entered an invalid passport number. Please check your passport and re-enter the number. ' .
|
|
'If you believe this to be incorrect, please !contact.',
|
|
array('!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Passport Number')))
|
|
);
|
|
}
|
|
}
|
|
|
|
//check at least one phone number has been entered
|
|
if ( ($form_state['booking_phone'] == '' ) && ($form_state['booking_mobile'] == '') )
|
|
form_set_error('booking_mobile', t('You must enter at least one phone number, either a mobile phone or a home phone number.'));
|
|
if (($form_state['booking_phone'] != '' ) && (!_valid_phone_number($form_state['booking_phone'])))
|
|
form_set_error('booking_phone', t('You have entered an invalid home phone number.'));
|
|
if (($form_state['booking_mobile'] != '' ) && (!_valid_phone_number($form_state['booking_mobile'])))
|
|
form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.'));
|
|
|
|
//verify guardian phone number(s)
|
|
if (($form_state['booking_guardian_phone'] != '' ) && (!_valid_phone_number($form_state['booking_guardian_phone'])))
|
|
form_set_error('booking_guardian_phone', t('You have entered an contact phone number for your emergency contact.'));
|
|
|
|
//verify that a state has been entered if "Other" was selected
|
|
if (($form_state['booking_state'] == 'Other' ) && ($form_state['booking_other_state'] == ''))
|
|
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details. Please put N/A if your country does not have states.'));
|
|
}
|
|
|
|
function booking_form_submit($form, &$form_state) {
|
|
global $event;
|
|
|
|
$values = $form_state['input'];
|
|
|
|
//get DOB from form
|
|
$dob = _datearray_to_ts($values['booking_dob']);
|
|
|
|
//retrieve an object with the booking price
|
|
$payment_total_price = db_query("SELECT booking_price FROM {booking_price} where pid = :pid",
|
|
array(':pid' => $form_state['input']['booking_payment_id']))
|
|
->fetchObject();
|
|
|
|
//make a new node object
|
|
$node = new stdClass();
|
|
$node = node_type_set_defaults();
|
|
$node->title = t('!event registration: !name',
|
|
array('!event' => $event->booking_eventname, '!name' => $values['booking_firstname'] . ' ' . $values['booking_lastname']));
|
|
$node->type = 'booking';
|
|
$node->status = 1; // set published to true
|
|
$node->promote = 0; // prevent display on front page
|
|
$node->language = LANGUAGE_NONE;
|
|
$node->created = REQUEST_TIME;
|
|
$node->changed = REQUEST_TIME;
|
|
|
|
$node->booking_firstname = ucwords(trim($values['booking_firstname']));
|
|
$node->booking_lastname = ucwords(trim($values['booking_lastname']));
|
|
$node->booking_gender = $values['booking_gender'];
|
|
$node->booking_dob = $dob;
|
|
$node->booking_status = 0; //zero means not yet coming. Only change to 1 when a payment is made
|
|
|
|
//passport details
|
|
$node->booking_passport_num = empty($values['booking_passport_num']) ? '' : $values['booking_passport_num'];
|
|
$node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location'];
|
|
$node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name'];
|
|
$node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']);
|
|
|
|
//payment details
|
|
$node->booking_payment_id = $values['booking_payment_id'];
|
|
|
|
//contact details
|
|
$node->booking_street = ucwords($values['booking_street']);
|
|
$node->booking_suburb = ucwords($values['booking_suburb']);
|
|
$node->booking_postcode = $values['booking_postcode'];
|
|
$node->booking_country = $values['booking_country'];
|
|
$node->booking_phone = $values['booking_phone'];
|
|
$node->booking_mobile = $values['booking_mobile'];
|
|
$node->booking_email = strtolower($values['booking_email']);
|
|
$node->booking_ecclesia = ucwords($values['booking_ecclesia']);
|
|
$node->booking_baptised = ($values['booking_baptised'] == 1 ? 'Y' : 'N');
|
|
$node->booking_married = ($values['booking_married'] == 1 ? 'Y' : 'N');
|
|
$node->booking_partner_name = ucwords($values['booking_partner_name']);
|
|
$node->booking_partner_id = empty($values['booking_partner_id']) ? 0 : $values['booking_partner_id'];
|
|
$node->booking_bf_gf_nid = empty($values['booking_bf_gf_nid']) ? 0 : $values['booking_bf_gf_nid'];
|
|
|
|
//allow for user-entered value if the state is not already listed
|
|
if ($values['booking_state'] == 'Other') {
|
|
$node->booking_state = $values['booking_other_state'];
|
|
} else {
|
|
$node->booking_state = ucwords($values['booking_state']);
|
|
}
|
|
|
|
//emergency contact info
|
|
$node->booking_guardian_name = $values['booking_guardian_name'];
|
|
$node->booking_guardian_type = $values['booking_guardian_type'];
|
|
$node->booking_guardian_phone = $values['booking_guardian_phone'];
|
|
$node->booking_guardian_phone_alt = $values['booking_guardian_phone_alt'];
|
|
$node->booking_medicare = empty($values['booking_medicare']) ? 0 : $values['booking_medicare'];
|
|
|
|
//fields that may or may not have been present in the initial form
|
|
$node->booking_welfare_required = empty($values['booking_welfare_required']) ? 'N' : ($values['booking_welfare_required'] == 1 ? 'Y' : 'N');
|
|
$node->booking_refund_processed = empty($values['booking_refund_processed']) ? 'N' : ($values['booking_refund_processed'] == 1 ? 'Y' : 'N');
|
|
$node->booking_refund_due = empty($values['booking_refund_due']) ? '' : $values['booking_refund_due'];
|
|
$node->booking_help_music = empty($values['booking_help_music']) ? '' : $values['booking_help_music'];
|
|
$node->booking_help_meditations = empty($values['booking_help_meditations']) ? '' : $values['booking_help_meditations'];
|
|
$node->booking_help_praying = empty($values['booking_help_praying']) ? '' : $values['booking_help_praying'];
|
|
$node->booking_help_reading = empty($values['booking_help_reading']) ? 'N' : ($values['booking_help_reading'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_chairing = empty($values['booking_help_chairing']) ? 'N' : ($values['booking_help_chairing'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_readgroup_lead = empty($values['booking_help_readgroup_lead']) ? 'N' : ($values['booking_help_readgroup_lead'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_discussgroup_lead = empty($values['booking_help_discussgroup_lead']) ? 'N' : ($values['booking_help_discussgroup_lead'] == 1 ? 'Y' : 'N');
|
|
$node->booking_firstaid = empty($values['booking_firstaid']) ? 'N' : ($values['booking_firstaid'] == 1 ? 'Y' : 'N');
|
|
$node->booking_nurse = empty($values['booking_nurse']) ? 'N' : ($values['booking_nurse'] == 1 ? 'Y' : 'N');
|
|
$node->booking_lifesaver = empty($values['booking_lifesaver']) ? 'N' : ($values['booking_lifesaver'] == 1 ? 'Y' : 'N');
|
|
$node->booking_doctor = empty($values['booking_doctor']) ? 'N' : ($values['booking_doctor'] == 1 ? 'Y' : 'N');
|
|
$node->booking_dietary = empty($values['booking_dietary']) ? 'N/A' : $values['booking_dietary'];
|
|
$node->booking_medical_conditions = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];
|
|
$node->booking_mission_experience_details = empty($values['booking_mission_experience_details']) ? 'N/A' : $values['booking_mission_experience_details'];
|
|
$node->booking_has_mission_experience = empty($values['booking_has_mission_experience']) ? 'N' : ($values['booking_has_mission_experience'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_builder = empty($values['booking_skills_builder']) ? 'N' : ($values['booking_skills_builder'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_cooking = empty($values['booking_skills_cooking']) ? 'N' : ($values['booking_skills_cooking'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_childminding = empty($values['booking_skills_childminding']) ? 'N' : ($values['booking_skills_childminding'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_language = empty($values['booking_skills_language']) ? 'N' : ($values['booking_skills_language'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details'];
|
|
$node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details'];
|
|
|
|
//potential fields for future
|
|
//$node->booking_payment_method = $payment_method;
|
|
$node->booking_room_mate1 = empty($values['booking_room_mate1']) ? '' : $values['booking_room_mate1'];
|
|
$node->booking_room_mate2 = empty($values['booking_room_mate2']) ? '' : $values['booking_room_mate2'];
|
|
$node->booking_shirt_size = empty($values['booking_shirt_size']) ? 'N/A' : $values['booking_shirt_size'];
|
|
|
|
//fields only configured by admin
|
|
$node->booking_readinggroup = !empty($values['booking_readinggroup']) ? $values['booking_readinggroup'] : '';
|
|
$node->booking_timestamp = REQUEST_TIME;
|
|
|
|
//internal fields
|
|
$tempid = _booking_uuidSecure();
|
|
$node->booking_tempid = $tempid;
|
|
$node->booking_event_id = $event->eid;
|
|
$node->booking_amount_paid = 0;
|
|
$node->booking_total_pay_reqd = $payment_total_price->booking_price;
|
|
|
|
//watchdog('booking', 'Node data: @info', array('@info' => var_export($node, TRUE)));
|
|
$foo = node_submit(&$node);
|
|
//watchdog('booking', 'Node data after submit: @info', array('@info' => var_export($foo, TRUE)));
|
|
$blah = node_save($foo);
|
|
//watchdog('booking', 'Node data after save: @info', array('@info' => var_export($blah, TRUE)));
|
|
|
|
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
|
|
if ($node->booking_partner_id != 0)
|
|
{
|
|
$partner = db_query("Select booking_partner_id from {booking_person} where nid = :nid",
|
|
array(':nid' => $node->booking_partner_id))
|
|
->fetchObject();
|
|
if ($partner->booking_partner_id == 0)
|
|
{
|
|
watchdog('booking', 'Updating partner node !partner to refer to this node !nid',
|
|
array('!partner' => $node->booking_partner_id, '!nid' => $node->nid));
|
|
//update the partner id of the partner to refer to this node
|
|
db_update('booking_person')
|
|
->fields(array(
|
|
'booking_partner_id' => $node->nid,
|
|
))
|
|
->condition('nid', $node->booking_partner_id)
|
|
->execute();
|
|
}
|
|
}
|
|
|
|
//check whether we should send an automatic email even though they haven't paid yet
|
|
if (variable_get('booking_auto_confirm_email', 0) == 1)
|
|
{
|
|
//send the person an email
|
|
_booking_registration_email($node->nid, FALSE, FALSE);
|
|
}
|
|
else
|
|
{
|
|
//just send a notification email
|
|
_booking_regn_notifyonly_email($node, FALSE);
|
|
}
|
|
//redirect the user to the confirmation page
|
|
$form_state['redirect'] = array('confirm/' . $tempid);
|
|
}
|
|
|
|
/**
|
|
* Function to query the database for the complete object representing a registration
|
|
*
|
|
* @param $node_ids - a list of node IDs to query for
|
|
* @return list of objects
|
|
*/
|
|
function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
|
{
|
|
global $event;
|
|
|
|
$query = db_select('booking_person', 'p');
|
|
//perform an inner join
|
|
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
|
|
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
|
|
|
//add the fields for study groups
|
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
|
{
|
|
//work out how many study groups there are
|
|
$studygroups = db_query("SELECT count(*) as numgroups from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
|
|
->fetchObject();
|
|
//$studygroups = db_query("SELECT s.* from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
|
|
// ->fetchAllAssoc('sid');
|
|
//watchdog('booking', "<pre>Loading node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
|
|
|
|
//for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
|
|
for ($i = 1; $i <= $studygroups->numgroups; $i++)
|
|
{
|
|
$query->leftJoin('booking_studygroup_mapping', 's' . $i,
|
|
'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i);
|
|
}
|
|
|
|
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
|
if (! is_null($node_ids))
|
|
{
|
|
$query->condition('p.nid', $node_ids, 'IN');
|
|
}
|
|
else
|
|
{
|
|
$query->condition('p.booking_event_id', $event->eid, '=');
|
|
}
|
|
|
|
//add the fields we want
|
|
$query->fields('p')
|
|
->fields('t')
|
|
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
|
|
|
//now add the study group fields
|
|
for ($i = 1; $i <= $studygroups->numgroups; $i++)
|
|
{
|
|
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
|
|
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
|
|
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
|
|
$query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader');
|
|
$query->addField('s' . $i, 'booking_is_helper', 'session' . $i . '_helper');
|
|
}
|
|
}
|
|
//not looking after study groups so don't add all the extra fields
|
|
else
|
|
{
|
|
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
|
if (! is_null($node_ids))
|
|
{
|
|
$query->condition('p.nid', $node_ids, 'IN');
|
|
}
|
|
else
|
|
{
|
|
$query->condition('p.booking_event_id', $event->eid, '=');
|
|
}
|
|
|
|
//add the fields we want
|
|
$query->fields('p')
|
|
->fields('t')
|
|
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
|
}
|
|
|
|
//get the query result as either an associative array
|
|
if ($fetchAssoc == TRUE)
|
|
{
|
|
$result = $query->execute()->fetchAllAssoc('nid');
|
|
}
|
|
else
|
|
{
|
|
$result = $query->execute();
|
|
}
|
|
|
|
//watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
|
return $result;
|
|
}
|
|
|
|
function booking_load($nodes) {
|
|
global $event;
|
|
|
|
$result = booking_load_query(array_keys($nodes));
|
|
|
|
//add that data to the array of node references
|
|
foreach ($result as $record)
|
|
{
|
|
//watchdog('booking', "<pre>Loading node:\n@info</pre>", array('@info' => print_r( $record, true)));
|
|
// run through each result row and add in the needed attributes
|
|
foreach ($record as $key => $value)
|
|
{
|
|
$nodes[$record->nid]->$key = $value;
|
|
}
|
|
}
|
|
|
|
watchdog('booking', 'Final loaded node: @info', array('@info' => var_export($nodes, TRUE)));
|
|
// no return necessary since $nodes array members reference objects global to this function
|
|
}
|
|
|
|
function _booking_insert($node) {
|
|
//watchdog('booking', 'Inserting node: @info', array('@info' => var_export($node, TRUE)));
|
|
|
|
db_insert('booking_person')
|
|
->fields(array(
|
|
'nid' => $node->nid,
|
|
'booking_event_id' => $node->booking_event_id,
|
|
'booking_firstname' => $node->booking_firstname,
|
|
'booking_lastname' => $node->booking_lastname,
|
|
'booking_dob' => $node->booking_dob,
|
|
'booking_passport_num' => $node->booking_passport_num,
|
|
'booking_passport_issue_location' => $node->booking_passport_issue_location,
|
|
'booking_passport_issue_name' => $node->booking_passport_issue_name,
|
|
'booking_passport_expiry_date' => $node->booking_passport_expiry_date,
|
|
'booking_gender' => $node->booking_gender,
|
|
'booking_street' => $node->booking_street,
|
|
'booking_suburb' => $node->booking_suburb,
|
|
'booking_postcode' => $node->booking_postcode,
|
|
'booking_state' => $node->booking_state,
|
|
'booking_country' => $node->booking_country,
|
|
'booking_phone' => $node->booking_phone,
|
|
'booking_mobile' => $node->booking_mobile,
|
|
'booking_email' => $node->booking_email,
|
|
'booking_timestamp' => $node->booking_timestamp,
|
|
'booking_ecclesia' => $node->booking_ecclesia,
|
|
'booking_baptised' => $node->booking_baptised,
|
|
'booking_married' => $node->booking_married,
|
|
'booking_partner_name' => $node->booking_partner_name,
|
|
'booking_partner_id' => $node->booking_partner_id,
|
|
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
|
'booking_room_mate1' => $node->booking_room_mate1,
|
|
'booking_room_mate2' => $node->booking_room_mate2,
|
|
'booking_shirt_size' => empty($node->booking_shirt_size) ? 'N/A' : $node->booking_shirt_size,
|
|
'booking_help_music' => $node->booking_help_music,
|
|
'booking_help_praying' => $node->booking_help_praying,
|
|
'booking_help_meditations' => $node->booking_help_meditations,
|
|
'booking_help_reading' => $node->booking_help_reading,
|
|
'booking_help_chairing' => $node->booking_help_chairing,
|
|
'booking_help_readgroup_lead' => $node->booking_help_readgroup_lead,
|
|
'booking_help_discussgroup_lead' => $node->booking_help_discussgroup_lead,
|
|
'booking_readinggroup' => $node->booking_readinggroup,
|
|
'booking_tempid' => $node->booking_tempid,
|
|
'booking_payment_id' => $node->booking_payment_id,
|
|
'booking_amount_paid' => $node->booking_amount_paid,
|
|
'booking_total_pay_reqd' => $node->booking_total_pay_reqd,
|
|
'booking_guardian_name' => $node->booking_guardian_name,
|
|
'booking_guardian_type' => $node->booking_guardian_type,
|
|
'booking_guardian_phone' => $node->booking_guardian_phone,
|
|
'booking_guardian_phone_alt' => $node->booking_guardian_phone_alt,
|
|
'booking_medicare' => empty($node->booking_medicare) ? '' : $node->booking_medicare,
|
|
'booking_lifesaver' => $node->booking_lifesaver,
|
|
'booking_firstaid' => $node->booking_firstaid,
|
|
'booking_nurse' => $node->booking_nurse,
|
|
'booking_doctor' => $node->booking_doctor,
|
|
'booking_dietary' => $node->booking_dietary,
|
|
'booking_medical_conditions' => $node->booking_medical_conditions,
|
|
'booking_has_mission_experience' => $node->booking_has_mission_experience,
|
|
'booking_mission_experience_details' => $node->booking_mission_experience_details,
|
|
'booking_skills_builder' => $node->booking_skills_builder,
|
|
'booking_skills_cooking' => $node->booking_skills_cooking,
|
|
'booking_skills_childminding' => $node->booking_skills_childminding,
|
|
'booking_skills_language' => $node->booking_skills_language,
|
|
'booking_skills_language_details' => $node->booking_skills_language_details,
|
|
'booking_skills_other' => $node->booking_skills_other,
|
|
'booking_skills_other_details' => $node->booking_skills_other_details,
|
|
'booking_status' => $node->booking_status,
|
|
'booking_welfare_required' => $node->booking_welfare_required,
|
|
'booking_refund_due' => $node->booking_refund_due,
|
|
'booking_refund_processed' => $node->booking_refund_processed,
|
|
))
|
|
->execute();
|
|
}
|
|
|
|
/**
|
|
* Convert $node attribute values (from form) into appropriate formats for persistence
|
|
*
|
|
* @param $node from form submission
|
|
* @return nothing
|
|
*/
|
|
function _booking_update($node) {
|
|
global $event;
|
|
|
|
//before we update this user, check what their previous registration status was
|
|
$previous_status = db_query("SELECT booking_status, booking_payment_id, booking_total_pay_reqd, booking_amount_paid FROM {booking_person} where nid = :nid", array(
|
|
':nid' => $node->nid))
|
|
->fetchObject();
|
|
|
|
//watchdog('booking', 'Updating node: @info', array('@info' => var_export($node, TRUE)));
|
|
db_update('booking_person')
|
|
->fields(array (
|
|
'booking_firstname' => $node->booking_firstname,
|
|
'booking_lastname' => $node->booking_lastname,
|
|
'booking_dob' => _date_to_ts($node->booking_dob),
|
|
'booking_passport_num' => $node->booking_passport_num,
|
|
'booking_passport_issue_location' => $node->booking_passport_issue_location,
|
|
'booking_passport_issue_name' => $node->booking_passport_issue_name,
|
|
'booking_passport_expiry_date' => _date_to_ts($node->booking_passport_expiry_date),
|
|
'booking_gender' => $node->booking_gender,
|
|
'booking_street' => $node->booking_street,
|
|
'booking_suburb' => $node->booking_suburb,
|
|
'booking_postcode' => $node->booking_postcode,
|
|
'booking_state' => $node->booking_state,
|
|
'booking_country' => $node->booking_country,
|
|
'booking_phone' => $node->booking_phone,
|
|
'booking_mobile' => $node->booking_mobile,
|
|
'booking_email' => $node->booking_email,
|
|
'booking_timestamp' => $node->booking_timestamp,
|
|
'booking_ecclesia' => $node->booking_ecclesia,
|
|
'booking_baptised' => ($node->booking_baptised == 1 ? 'Y' : 'N'),
|
|
'booking_married' => ($node->booking_married == 1 ? 'Y' : 'N'),
|
|
'booking_partner_name' => $node->booking_partner_name,
|
|
'booking_partner_id' => $node->booking_partner_id,
|
|
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
|
'booking_room_mate1' => $node->booking_room_mate1,
|
|
'booking_room_mate2' => $node->booking_room_mate2,
|
|
'booking_shirt_size' => $node->booking_shirt_size,
|
|
'booking_help_music' => $node->booking_help_music,
|
|
'booking_help_praying' => ($node->booking_help_praying == 1 ? 'Y' : 'N'),
|
|
'booking_help_meditations' => ($node->booking_help_meditations == 1 ? 'Y' : 'N'),
|
|
'booking_help_reading' => ($node->booking_help_reading == 1 ? 'Y' : 'N'),
|
|
'booking_help_chairing' => ($node->booking_help_chairing == 1 ? 'Y' : 'N'),
|
|
'booking_help_readgroup_lead' => ($node->booking_help_readgroup_lead == 1 ? 'Y' : 'N'),
|
|
'booking_help_discussgroup_lead' => ($node->booking_help_discussgroup_lead == 1 ? 'Y' : 'N'),
|
|
'booking_readinggroup' => $node->booking_readinggroup,
|
|
'booking_tempid' => $node->booking_tempid,
|
|
'booking_payment_id' => $node->booking_payment_id,
|
|
'booking_total_pay_reqd' => $node->booking_total_pay_reqd,
|
|
'booking_amount_paid' => $node->booking_amount_paid,
|
|
'booking_refund_due' => $node->booking_refund_due,
|
|
'booking_guardian_name' => $node->booking_guardian_name,
|
|
'booking_guardian_type' => $node->booking_guardian_type,
|
|
'booking_guardian_phone' => $node->booking_guardian_phone,
|
|
'booking_guardian_phone_alt' => $node->booking_guardian_phone_alt,
|
|
'booking_medicare' => $node->booking_medicare,
|
|
'booking_lifesaver' => ($node->booking_lifesaver == 1 ? 'Y' : 'N'),
|
|
'booking_firstaid' => ($node->booking_firstaid == 1 ? 'Y' : 'N'),
|
|
'booking_nurse' => ($node->booking_nurse == 1 ? 'Y' : 'N'),
|
|
'booking_doctor' => ($node->booking_doctor == 1 ? 'Y' : 'N'),
|
|
'booking_dietary' => $node->booking_dietary,
|
|
'booking_medical_conditions' => $node->booking_medical_conditions,
|
|
'booking_has_mission_experience' => ($node->booking_has_mission_experience == 1 ? 'Y' : 'N'),
|
|
'booking_mission_experience_details' => $node->booking_mission_experience_details,
|
|
'booking_skills_builder' => ($node->booking_skills_builder == 1 ? 'Y' : 'N'),
|
|
'booking_skills_cooking' => ($node->booking_skills_cooking == 1 ? 'Y' : 'N'),
|
|
'booking_skills_childminding' => ($node->booking_skills_childminding == 1 ? 'Y' : 'N'),
|
|
'booking_skills_language' => ($node->booking_skills_language == 1 ? 'Y' : 'N'),
|
|
'booking_skills_language_details' => $node->booking_skills_language_details,
|
|
'booking_skills_other' => ($node->booking_skills_other == 1 ? 'Y' : 'N'),
|
|
'booking_skills_other_details' => $node->booking_skills_other_details,
|
|
'booking_welfare_required' => ($node->booking_welfare_required == 1 ? 'Y' : 'N'),
|
|
'booking_refund_processed' => ($node->booking_refund_processed == 1 ? 'Y' : 'N'),
|
|
'booking_status' => $node->booking_status,
|
|
|
|
))
|
|
->condition('nid', $node->nid)
|
|
->execute();
|
|
|
|
//***now process some post-update triggers***
|
|
|
|
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
|
|
if ($node->booking_partner_id != 0)
|
|
{
|
|
$partner = db_query("Select booking_partner_id from {booking_person} where nid = :nid",
|
|
array(':nid' => $node->booking_partner_id))
|
|
->fetchObject();
|
|
if ($partner->booking_partner_id == 0)
|
|
{
|
|
watchdog('booking', 'Updating partner node !partner to refer to this node !nid',
|
|
array('!partner' => $node->booking_partner_id, '!nid' => $node->nid));
|
|
//update the partner id of the partner to refer to this node
|
|
db_update('booking_person')
|
|
->fields(array(
|
|
'booking_partner_id' => $node->nid,
|
|
))
|
|
->condition('nid', $node->booking_partner_id)
|
|
->execute();
|
|
}
|
|
}
|
|
|
|
//check if someone has moved to not-coming list from the booked-in list
|
|
if ($previous_status->booking_status == 1 && $node->booking_status == 3)
|
|
{
|
|
watchdog('booking', 'Detected person moving from Booked In list to No Longer Coming');
|
|
|
|
//let this person know their request has been processed
|
|
_booking_demoted_to_notcoming_email($node->nid);
|
|
|
|
//Calculate refund
|
|
$refund = _booking_process_refund($node);
|
|
drupal_set_message(t('Refund calculated for !first !last is $!refund.',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
|
|
|
|
//Remove from any study groups
|
|
_booking_studygroups_cleanup($node->nid);
|
|
|
|
//check if there is room on the booked-in list
|
|
if (_booking_check_bookings_full() == False)
|
|
{
|
|
watchdog('booking', 'Looks like there was room on the booked in list, so lets tell the next person');
|
|
//find the first person on the waiting list
|
|
$temp_nid = _booking_get_waitinglist_top();
|
|
|
|
if ($temp_nid != -1) //-1 means there was no one on the waiting list
|
|
{
|
|
//update their registration status
|
|
_booking_change_status($temp_nid,1);
|
|
|
|
//send them an email
|
|
_booking_promoted_from_waitinglist_email($temp_nid);
|
|
}
|
|
}
|
|
else
|
|
watchdog('booking', 'Still no room on the booked in list though.');
|
|
}
|
|
//if someone is moving to the not-coming list from the waiting list
|
|
elseif ($previous_status->booking_status == 2 && $node->booking_status == 3)
|
|
{
|
|
watchdog('booking', 'Detected person moving from waiting list to No Longer Coming');
|
|
//let this person know their request has been processed
|
|
_booking_demoted_to_notcoming_email($node->nid);
|
|
|
|
//Calculate refund
|
|
$refund = _booking_process_refund($node);
|
|
drupal_set_message(t('Refund calculated for !first !last is $!refund.',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname, '!refund' => $refund)));
|
|
|
|
//Remove from any study groups
|
|
_booking_studygroups_cleanup($node->nid);
|
|
}
|
|
//if we're not automatically sending emails on registration
|
|
//and someone moved from not-paid to booked-in (ie, manual payment process)
|
|
elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1)
|
|
{
|
|
watchdog('booking', 'Detected person moving from Not Paid list to Booked In list');
|
|
|
|
//make sure the booked in list isn't full
|
|
if (_booking_check_bookings_full() == False)
|
|
{
|
|
watchdog('booking', 'Confirmed room on the booked in list');
|
|
//send them an email
|
|
_booking_registration_email($node->nid, FALSE, FALSE);
|
|
//_booking_promoted_from_waitinglist_email($node->nid);
|
|
}
|
|
}
|
|
//if someone moved from the not-paid list to waiting list by manual update
|
|
elseif ($previous_status->booking_status == 0 && $node->booking_status == 2)
|
|
{
|
|
watchdog('booking', 'Detected person moving from Not Paid list to Waiting List');
|
|
|
|
|
|
//create a manual payment entry of zero dollars
|
|
//so things like the waiting list report work
|
|
$result = db_insert('booking_payment')
|
|
->fields(array(
|
|
'booking_person_nid' => $node->nid,
|
|
'booking_eventid' => $event->eid,
|
|
'booking_mc_gross' => '0.00',
|
|
'booking_mc_currency' => 'AUD',
|
|
'booking_mc_fee' => '0.00',
|
|
'booking_quantity' => 1,
|
|
'booking_invoice' => 'ManualPayment',
|
|
'booking_payer_id' => '',
|
|
'booking_payment_date' => REQUEST_TIME,
|
|
'booking_payment_status' => '',
|
|
'booking_first_name' => $node->booking_firstname,
|
|
'booking_last_name' => $node->booking_lastname,
|
|
'booking_buyer_email' => '',
|
|
'booking_payer_status' => '',
|
|
'booking_item_name' => '',
|
|
'booking_ipn_track_id' => '',
|
|
))
|
|
->execute();
|
|
|
|
//send them an email
|
|
_booking_registration_email($node->nid, FALSE, FALSE);
|
|
}
|
|
|
|
//if the payment ID has changed then update the total pay required
|
|
if ($previous_status->booking_payment_id != $node->booking_payment_id)
|
|
{
|
|
$total_due = 0;
|
|
watchdog('booking', 'Detected payment type change for attendee');
|
|
|
|
//look up the total pay required for the new payment id
|
|
$price = db_select('booking_price', 'p')
|
|
->condition('p.pid', $node->booking_payment_id,'=')
|
|
->fields('p', array('booking_price', 'booking_late_price'))
|
|
->execute()
|
|
->fetchObject();
|
|
|
|
//check for early bird rate or full rate
|
|
if (_booking_is_earlybird() == TRUE)
|
|
$total_due = $price->booking_price;
|
|
else
|
|
$total_due = $price->booking_late_price;
|
|
|
|
//update the person with the new total pay required
|
|
db_update('booking_person')
|
|
->fields(array(
|
|
'booking_total_pay_reqd' => $total_due,
|
|
))
|
|
->condition('nid', $node->nid)
|
|
->execute();
|
|
}
|
|
|
|
}
|
|
|
|
function _booking_delete($node) {
|
|
|
|
$last = $node->booking_lastname;
|
|
$first = $node->booking_firstname;
|
|
|
|
$num_deleted = db_delete('booking_person')
|
|
->condition('nid', $node->nid)
|
|
->execute();
|
|
|
|
$message = t("Successfully deleted !num row(s), corresponding to '!last, !first'",
|
|
array('!num' => $num_deleted, '!last' => $last, '!first' => $first));
|
|
|
|
drupal_set_message($message, $type = 'status');
|
|
|
|
}
|
|
|
|
|
|
function booking_view($node, $view_mode) {
|
|
global $event;
|
|
$rows = array();
|
|
$travel_rows = array();
|
|
|
|
//calculate the price owed by this person
|
|
if (_booking_is_earlybird() == true || _booking_amount_owing($node->nid) == 0)
|
|
{
|
|
$price = $node->booking_price;
|
|
}
|
|
else
|
|
$price = $node->booking_late_price;
|
|
//include the price description to display with this view
|
|
$payment_type = $node->booking_price_descrip . ' ($' . $price . ')';
|
|
|
|
//look up the actual name for a linked partner
|
|
if ($node->booking_partner_id != 0)
|
|
{
|
|
$query = db_query("Select booking_firstname, booking_lastname from {booking_person} where nid = :nid",
|
|
array(':nid' => $node->booking_partner_id))
|
|
->fetchObject();
|
|
$partner_name = $query->booking_firstname . " " . $query->booking_lastname;
|
|
}
|
|
else
|
|
$partner_name = "N/A";
|
|
|
|
//also look up the actual name if a boyfriend/girlfriend is defined
|
|
if ($node->booking_bf_gf_nid != 0)
|
|
{
|
|
$query = db_query("Select booking_firstname, booking_lastname from {booking_person} where nid = :nid",
|
|
array(':nid' => $node->booking_bf_gf_nid))
|
|
->fetchObject();
|
|
$bf_gf = $query->booking_firstname . " " . $query->booking_lastname;
|
|
}
|
|
else
|
|
$bf_gf = "N/A";
|
|
|
|
//define column widths along with the header
|
|
$header = array(
|
|
array('data' => t('Attribute'), 'width' => '40%'),
|
|
array('data' => t('Value'), 'width' => '60%'),
|
|
);
|
|
|
|
//now populate the table
|
|
$rows[] = array(t('Date/Time registered:'), t('!timestamp', array('!timestamp' => format_date($node->booking_timestamp, 'custom', 'd/m/Y H:i'))));
|
|
$rows[] = array(t('Name:'), t('!first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)));
|
|
$rows[] = array(t('Gender:'), t('!gender', array('!gender' => $node->booking_gender == 'M' ? 'Male' : 'Female')));
|
|
$rows[] = array(t('Status:'), t('!status', array('!status' => _booking_status_generate($node->booking_status))));
|
|
$rows[] = array(t('Welfare Required:'), $node->booking_welfare_required == 'Y' ? 'Yes' : 'No');
|
|
$rows[] = array(t('Barcode:'), t('!id', array('!id' => $node->booking_barcode)));
|
|
$rows[] = array(t('Date of birth:'), t('!dob', array('!dob' => format_date($node->booking_dob, 'custom', 'd/m/Y'))));
|
|
$rows[] = array(t('Email address:'), t('!email', array('!email' => $node->booking_email)));
|
|
|
|
if (variable_get('booking_enable_passport', 1) == 1)
|
|
{
|
|
$rows[] = array(t('Passport Number:'), $node->booking_passport_num);
|
|
$rows[] = array(t('Passport Expiry:'), t('!timestamp', array('!timestamp' => _booking_convert_ts($node->booking_passport_expiry_date)->format('d/m/Y'))));
|
|
$rows[] = array(t('Passport Exact Issued Name:'), $node->booking_passport_issue_name);
|
|
$rows[] = array(t('Passport Issue Location:'), $node->booking_passport_issue_location);
|
|
}
|
|
|
|
$rows[] = array(t('Payment Type Selected:'), t('!amount_paid', array('!amount_paid' => $payment_type)));
|
|
$rows[] = array(t('Amount Paid:'), t('!amount_paid', array('!amount_paid' => $node->booking_amount_paid)));
|
|
$rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd)));
|
|
$rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due)));
|
|
$rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No'))));
|
|
|
|
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
|
|
|
|
if (variable_get('booking_enable_tshirts', 0) == 1)
|
|
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
|
|
|
|
|
|
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
|
|
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
|
|
$rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country',
|
|
array('!street' => $node->booking_street, '!suburb' => $node->booking_suburb,
|
|
'!state' => ($node->booking_state == 'N/A' ? '' : $node->booking_state),
|
|
'!code' => $node->booking_postcode,
|
|
'!country' => $node->booking_country)));
|
|
$rows[] = array(t('Ecclesia:'), t('!ecclesia', array('!ecclesia' => $node->booking_ecclesia)));
|
|
$rows[] = array(t('Baptised:'), t('!ans', array('!ans' => ($node->booking_baptised == 'Y' ? 'Yes' : 'No'))));
|
|
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
|
|
//$rows[] = array(t("If married, attending partner's name:"), t('!name', array('!name' => $node->booking_partner_name)));
|
|
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
|
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
|
$rows[] = array(t('Emergency Contact Name:'), $node->booking_guardian_name);
|
|
$rows[] = array(t('Emergency Contact Relationship:'), $node->booking_guardian_type);
|
|
$rows[] = array(t('Emergency Contact Phone:'), $node->booking_guardian_phone);
|
|
$rows[] = array(t('Emergency Contact Alternate Phone:'), $node->booking_guardian_phone_alt);
|
|
if (variable_get('booking_enable_medicare', 1) == 1)
|
|
$rows[] = array(t('Medicare Number:'), $node->booking_medicare);
|
|
|
|
$rows[] = array(t('Special Dietary Requirements:'), $node->booking_dietary);
|
|
$rows[] = array(t('Special Medical Conditions:'), $node->booking_medical_conditions);
|
|
|
|
if (variable_get('booking_enable_roommate', 0) == 1)
|
|
{
|
|
$rows[] = array(t('Preferred room-mates:'), t('!room', array('!room' => $node->booking_room_mate1 . ' ' . $node->booking_room_mate2)));
|
|
}
|
|
|
|
if (variable_get('booking_enable_helpareas', 1) == 1)
|
|
{
|
|
$rows[] = array(t('Qualified Life Saver:'), $node->booking_lifesaver == 'Y' ? 'Yes' : 'No');
|
|
$rows[] = array(t('Qualified First Aider:'), $node->booking_firstaid == 'Y' ? 'Yes' : 'No');
|
|
$rows[] = array(t('Qualified Nurse:'), $node->booking_nurse == 'Y' ? 'Yes' : 'No');
|
|
$rows[] = array(t('Qualified Doctor:'), $node->booking_doctor == 'Y' ? 'Yes' : 'No');
|
|
$help_areas = '';
|
|
if ($node->booking_help_music)
|
|
$help_areas .= 'music: ' . $node->booking_help_music . ', ';
|
|
if ($node->booking_help_reading == 'Y')
|
|
$help_areas .= 'reading, ';
|
|
if ($node->booking_help_chairing == 'Y')
|
|
$help_areas .= 'chairing, ';
|
|
if ($node->booking_help_readgroup_lead == 'Y')
|
|
$help_areas .= 'reading group leading, ';
|
|
if ($node->booking_help_discussgroup_lead == 'Y')
|
|
$help_areas .= 'discussion group leading, ';
|
|
if ($node->booking_help_praying == 'Y')
|
|
$help_areas .= 'praying, ';
|
|
if ($node->booking_help_meditations == 'Y')
|
|
$help_areas .= 'meditations, ';
|
|
|
|
$rows[] = array(t('Help areas:'), t('!help', array('!help' => $help_areas)));
|
|
}
|
|
|
|
if (variable_get('booking_enable_skills', 1) == 1)
|
|
{
|
|
$skill_areas = '';
|
|
if ($node->booking_skills_builder == 'Y')
|
|
$skill_areas .= 'builder, ';
|
|
if ($node->booking_skills_cooking == 'Y')
|
|
$skill_areas .= 'cook, ';
|
|
if ($node->booking_skills_childminding == 'Y')
|
|
$skill_areas .= 'child minding, ';
|
|
if ($node->booking_skills_language == 'Y')
|
|
$skill_areas .= 'speaks languages: ' . $node->booking_skills_language_details . ', ';
|
|
if ($node->booking_skills_other == 'Y')
|
|
$skill_areas .= 'other skills: ' . $node->booking_skills_other_details . ', ';
|
|
$rows[] = array(t('Mission related skills:'), t('!value', array('!value' => $skill_areas)));
|
|
$rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details);
|
|
}
|
|
$rows[] = array(t('Temporary UUID:'), $node->booking_tempid);
|
|
|
|
//add the travel info if it has been defined for this attendee
|
|
if (! empty($node->tid))
|
|
{
|
|
$travel_rows[] = array(t('Transport Type:'), $node->booking_transport_type);
|
|
$travel_rows[] = array(t('Catching the train to Study Week:'), $node->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No');
|
|
$travel_rows[] = array(t('Inbound Flight Number:'), $node->booking_flightnum_inbound == '' ? 'N/A' : $node->booking_flightnum_inbound);
|
|
$travel_rows[] = array(t('Flight Arrival:'), t('!date',
|
|
array('!date' => $node->booking_flight_datetime_inbound == 0 ? 'N/A' : format_date($node->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i'))));
|
|
$travel_rows[] = array(t('Outbound Flight Number:'), $node->booking_flightnum_outbound == '' ? 'N/A' : $node->booking_flightnum_outbound);
|
|
$travel_rows[] = array(t('Flight Departure:'), t('!date',
|
|
array('!date' => $node->booking_flight_datetime_outbound == 0 ? 'N/A' : format_date($node->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'))));
|
|
$travel_rows[] = array(t('Accommodation before Study Week Required:'), $node->booking_accom_before_reqd == 1 ? 'Yes' : 'No');
|
|
$travel_rows[] = array(t('Accommodation after Study Week Required:'), $node->booking_accom_after_reqd == 1 ? 'Yes' : 'No');
|
|
|
|
$node->content['travel-heading'] = array(
|
|
'#markup' => "<h2>Travel Details</h2>",
|
|
'#weight' => 2,
|
|
);
|
|
|
|
$node->content['travel-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $travel_rows)),
|
|
'#weight' => 3,
|
|
);
|
|
}
|
|
|
|
//display study session data if enabled
|
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
|
{
|
|
|
|
//look up the titles of the study groups
|
|
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
|
array(':eid' => $event->eid));
|
|
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
|
|
|
watchdog('booking', "<pre>Displaying node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
|
|
|
|
for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
|
|
{
|
|
$role = "";
|
|
|
|
//calculate the session references
|
|
$sessionid = "session" . $i;
|
|
$leaderid = $sessionid . "_leader";
|
|
$helperid = $sessionid . "_helper";
|
|
$reserveleaderid = $sessionid . "_reserveleader";
|
|
|
|
if ($node->$leaderid == 'Y')
|
|
$role = "Leader";
|
|
elseif ($node->$helperid == 'Y')
|
|
$role = "Helper";
|
|
elseif ($node->$reserveleaderid == 'Y')
|
|
$role = "Reserve Leader";
|
|
|
|
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
|
$group_rows[] = array(t('Role'), $role);
|
|
}
|
|
|
|
$node->content['group-heading'] = array(
|
|
'#markup' => "<h2>Study Groups</h2>",
|
|
'#weight' => 4,
|
|
);
|
|
|
|
$node->content['group-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $group_rows)),
|
|
'#weight' => 5,
|
|
);
|
|
}
|
|
|
|
$node->content['details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
|
|
'#weight' => 1,
|
|
);
|
|
|
|
//all finished, let's render this mess
|
|
return $node;
|
|
}
|