829 lines
38 KiB
PHP
829 lines
38 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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;
|
|
$studygroup_count = variable_get('booking_studygroup_count','0');
|
|
|
|
$query = db_select('booking_person', 'p');
|
|
//add price info
|
|
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
|
|
//add travel form info if it exists
|
|
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
|
|
|
//add the joins for room allocation info if enabled
|
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
|
{
|
|
$query->leftJoin('booking_room_mapping', 'rm', 'p.nid = rm.booking_nodeid');
|
|
$query->leftJoin('booking_room_definition', 'r', 'rm.booking_roomid = r.rid');
|
|
$query->leftJoin('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
|
}
|
|
|
|
//add the joins to flatten out study groups into columns
|
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
|
{
|
|
for ($i = 1; $i <= $studygroup_count; $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 database fields we always want to retrieve
|
|
$query->fields('p')
|
|
->fields('t')
|
|
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
|
|
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
|
{
|
|
$query->fields('rm', array('booking_room_bedtype'))
|
|
->fields('r', array('rid', 'booking_room_location_id', 'booking_room_number'))
|
|
->fields('l');
|
|
}
|
|
|
|
//now add the study group fields if applicable
|
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
|
{
|
|
for ($i = 1; $i <= $studygroup_count; $i++)
|
|
{
|
|
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
|
|
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
|
|
$query->addField('s' . $i, 'booking_studygroup_role', 'session' . $i . '_role');
|
|
|
|
//$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');
|
|
}
|
|
}
|
|
|
|
//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)));
|
|
|
|
//TODO: Generalise this by using the keys from $node instead of hard coding everything
|
|
|
|
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_barcode' => $node->booking_barcode,
|
|
'booking_luckynum' => $node->booking_luckynum,
|
|
'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_destination_country' => $node->booking_destination_country,
|
|
'booking_travel_insurance' => $node->booking_travel_insurance,
|
|
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
|
'booking_outflight_flightnum' => $node->booking_outflight_flightnum,
|
|
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
|
'booking_outflight_origin' => $node->booking_outflight_origin,
|
|
'booking_outflight_origin_ts' => $node->booking_outflight_origin_ts,
|
|
'booking_outflight_connecting_flightnum' => $node->booking_outflight_connecting_flightnum,
|
|
'booking_outflight_destination' => $node->booking_outflight_destination,
|
|
'booking_outflight_destination_ts' => $node->booking_outflight_destination_ts,
|
|
'booking_rtrnflight_bookingnum' => $node->booking_rtrnflight_bookingnum,
|
|
'booking_rtrnflight_flightnum' => $node->booking_rtrnflight_flightnum,
|
|
'booking_rtrnflight_origin' => $node->booking_rtrnflight_origin,
|
|
'booking_rtrnflight_origin_ts' => $node->booking_rtrnflight_origin_ts,
|
|
'booking_rtrnflight_connecting_flightnum' => $node->booking_rtrnflight_connecting_flightnum,
|
|
'booking_rtrnflight_destination' => $node->booking_rtrnflight_destination,
|
|
'booking_rtrnflight_destination_ts' => $node->booking_rtrnflight_destination_ts,
|
|
'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_payment_complete' => $node->booking_payment_complete,
|
|
'booking_refund_due' => $node->booking_refund_due,
|
|
'booking_refund_processed' => $node->booking_refund_processed,
|
|
'booking_committee_member' => $node->booking_committee_member,
|
|
))
|
|
->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_barcode' => $node->booking_barcode,
|
|
'booking_luckynum' => $node->booking_luckynum == '' ? 0 : $node->booking_luckynum,
|
|
'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_destination_country' => $node->booking_destination_country,
|
|
'booking_travel_insurance' => $node->booking_travel_insurance,
|
|
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
|
'booking_outflight_flightnum' => $node->booking_outflight_flightnum,
|
|
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
|
'booking_outflight_origin' => $node->booking_outflight_origin,
|
|
'booking_outflight_origin_ts' => _datetime_to_ts($node->booking_outflight_origin_ts),
|
|
'booking_outflight_connecting_flightnum' => $node->booking_outflight_connecting_flightnum,
|
|
'booking_outflight_destination' => $node->booking_outflight_destination,
|
|
'booking_outflight_destination_ts' => _datetime_to_ts($node->booking_outflight_destination_ts),
|
|
'booking_rtrnflight_bookingnum' => $node->booking_rtrnflight_bookingnum,
|
|
'booking_rtrnflight_flightnum' => $node->booking_rtrnflight_flightnum,
|
|
'booking_rtrnflight_origin' => $node->booking_rtrnflight_origin,
|
|
'booking_rtrnflight_origin_ts' => _datetime_to_ts($node->booking_rtrnflight_origin_ts),
|
|
'booking_rtrnflight_connecting_flightnum' => $node->booking_rtrnflight_connecting_flightnum,
|
|
'booking_rtrnflight_destination' => $node->booking_rtrnflight_destination,
|
|
'booking_rtrnflight_destination_ts' => _datetime_to_ts($node->booking_rtrnflight_destination_ts),
|
|
'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 == '' ? 0 : $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_payment_complete' => ($node->booking_payment_complete == 1 ? 'Y' : 'N'),
|
|
'booking_refund_processed' => ($node->booking_refund_processed == 1 ? 'Y' : 'N'),
|
|
'booking_committee_member' => ($node->booking_committee_member == 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();
|
|
}
|
|
}
|
|
|
|
//status change triggers start here
|
|
|
|
//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_person_studygroups_cleanup($node->nid);
|
|
|
|
//Remove from any rooms allocated
|
|
_booking_person_rooms_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.');
|
|
}
|
|
//check if someone has moved to booked-in list from waiting-list
|
|
elseif ($previous_status->booking_status == 2 && $node->booking_status == 1)
|
|
{
|
|
watchdog('booking', 'Detected person moving from Waiting list to Booked In');
|
|
|
|
//send them an email
|
|
_booking_promoted_from_waitinglist_email($node->nid);
|
|
|
|
//see if there are others to process also
|
|
$waitinglist_nid = _booking_get_waitinglist_top();
|
|
|
|
//check if there is room on the booked-in list
|
|
while (_booking_check_bookings_full() == False && $waitinglist_nid > 0)
|
|
{
|
|
watchdog('booking', 'There is room on the booked in list, so process the next person on the waiting list, who has a node id of ' . $waitinglist_nid);
|
|
|
|
//update their registration status
|
|
_booking_change_status($waitinglist_nid, 1);
|
|
|
|
//send them an email
|
|
_booking_promoted_from_waitinglist_email($waitinglist_nid);
|
|
|
|
$waitinglist_nid = _booking_get_waitinglist_top();
|
|
}
|
|
|
|
}
|
|
//check if someone has been demoted to the "missed payment deadline" status from being booked-in
|
|
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4)
|
|
{
|
|
watchdog('booking', 'Detected person moving from Booked In list to Missed Payment Deadline list.');
|
|
|
|
//let this person know they're no longer "booked in"
|
|
_booking_missedpayment_email($node->nid);
|
|
|
|
//Remove from any study groups
|
|
_booking_person_studygroups_cleanup($node->nid);
|
|
|
|
//Remove from any rooms allocated
|
|
_booking_person_rooms_cleanup($node->nid);
|
|
|
|
//check if there is room on the booked-in list
|
|
if (_booking_check_bookings_full() == False)
|
|
{
|
|
watchdog('booking', 'Position available, 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.');
|
|
}
|
|
}
|
|
//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_person_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;
|
|
*/
|
|
|
|
//always set the payment required to the "early" price, since the late price is calculated dynamically if required
|
|
|
|
|
|
//update the person with the new total pay required
|
|
db_update('booking_person')
|
|
->fields(array(
|
|
'booking_total_pay_reqd' => $price->booking_price,
|
|
))
|
|
->condition('nid', $node->nid)
|
|
->execute();
|
|
}
|
|
//end trigger processing
|
|
}
|
|
|
|
function _booking_delete($node) {
|
|
|
|
$last = $node->booking_lastname;
|
|
$first = $node->booking_firstname;
|
|
|
|
//clean up other tables first
|
|
_booking_person_rooms_cleanup($node->nid);
|
|
_booking_person_studygroups_cleanup($node->nid);
|
|
|
|
//then clean up primary table
|
|
$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)
|
|
if (_booking_is_earlybird() == true || _booking_amount_owing($node) == 0 || $node->booking_committee_member == 'Y' || $node->booking_welfare_required == 'Y')
|
|
{
|
|
$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('Committee Member:'), t('!ans', array('!ans' => ($node->booking_committee_member == 'Y' ? '<b>Yes</b>' : 'No'))));
|
|
$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('Destination Country:'), $node->booking_destination_country);
|
|
$rows[] = array(t('Travel Insurance details:'), $node->booking_travel_insurance);
|
|
|
|
//outbound flight
|
|
$flight_rows[] = array(t('Internal Flight Booking Reference:'), $node->booking_outflight_bookingnum);
|
|
$flight_rows[] = array(t('Internal Flight Number:'), $node->booking_outflight_flightnum);
|
|
$flight_rows[] = array(t('Internal Flight Origin to Destination:'), $node->booking_outflight_origin);
|
|
$flight_rows[] = array(t('Internal Flight Departure Time:'),
|
|
$node->booking_outflight_origin_ts == 0 ? '' : format_date($node->booking_outflight_origin_ts, 'custom', 'd/m/Y H:i') );
|
|
$flight_rows[] = array(t('Connecting Flight Number:'), $node->booking_outflight_connecting_flightnum);
|
|
$flight_rows[] = array(t('Connecting Flight Origin to Destination:'), $node->booking_outflight_destination);
|
|
$flight_rows[] = array(t('Internal Flight Arrival Time:'),
|
|
$node->booking_outflight_destination_ts == 0 ? '' : format_date($node->booking_outflight_destination_ts, 'custom', 'd/m/Y H:i') );
|
|
//return flight
|
|
$flight_rows[] = array(t('Return Internal Flight Booking Reference:'), $node->booking_rtrnflight_bookingnum);
|
|
$flight_rows[] = array(t('Return Internal Flight Number:'), $node->booking_rtrnflight_flightnum);
|
|
$flight_rows[] = array(t('Return Internal Flight Origin to Destination:'), $node->booking_rtrnflight_origin);
|
|
$flight_rows[] = array(t('Return Internal Flight Departure Time:'),
|
|
$node->booking_rtrnflight_origin_ts == 0 ? '' : format_date($node->booking_rtrnflight_origin_ts, 'custom', 'd/m/Y H:i') );
|
|
$flight_rows[] = array(t('Connecting Flight Number:'), $node->booking_rtrnflight_connecting_flightnum);
|
|
$flight_rows[] = array(t('Connecting Flight Origin to Destination:'), $node->booking_rtrnflight_destination);
|
|
$flight_rows[] = array(t('Return Internal Flight Arrival Time:'),
|
|
$node->booking_rtrnflight_destination_ts == 0 ? '' : format_date($node->booking_rtrnflight_destination_ts, 'custom', 'd/m/Y H:i') );
|
|
|
|
//add the flight info to a new section
|
|
$flight_heading = t("<h2>Internal Flight Details</h2>");
|
|
$node->content['flight-heading'] = array(
|
|
'#markup' => $flight_heading,
|
|
'#weight' => 2,
|
|
);
|
|
$node->content['flight-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $flight_rows)),
|
|
'#weight' => 3,
|
|
);
|
|
}
|
|
|
|
$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('Payment Complete Flag:'), t('!ans', array('!ans' => $node->booking_payment_complete == 'Y' ? 'Yes' : 'No')));
|
|
$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('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);
|
|
$rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum);
|
|
|
|
//display room allocation data if enabled
|
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
|
{
|
|
$room_heading = t("<h2>Room Allocation</h2><p>!link</p>",
|
|
array('!link' => l(t('Edit Room Allocation'), t('admin/booking/!id/edit-room', array('!id' => $node->nid)), array('query' => drupal_get_destination()) )
|
|
));
|
|
$room_rows = array();
|
|
//$room_rows[] = array(t('Room Location'), _booking_room_location_lookup($node->booking_room_location_id));
|
|
$room_rows[] = array(t('Room Location'), $node->booking_roomlocation_descrip);
|
|
$room_rows[] = array(t('Room Number'), $node->booking_room_number);
|
|
$room_rows[] = array(t('Bed Type'), _booking_room_bedtype_lookup($node->booking_room_bedtype));
|
|
|
|
$node->content['room-heading'] = array(
|
|
'#markup' => $room_heading,
|
|
'#weight' => 4,
|
|
);
|
|
|
|
$node->content['room-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $room_rows)),
|
|
'#weight' => 5,
|
|
);
|
|
}
|
|
|
|
//add the travel info if it has been defined for this attendee
|
|
if (! empty($node->tid))
|
|
{
|
|
$travel_heading = t("<h2>Travel Details</h2><p>!link</p>",
|
|
array('!link' => l(t('Edit Travel Details'), t('node/!id/edit', array('!id' => $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' => $travel_heading,
|
|
'#weight' => 6,
|
|
);
|
|
|
|
$node->content['travel-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $travel_rows)),
|
|
'#weight' => 7,
|
|
);
|
|
}
|
|
|
|
//display study session data if enabled
|
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
|
{
|
|
$studygroup_heading = t("<h2>Study Groups</h2><p>!link</p>",
|
|
array('!link' => l(t('Edit Groups'), t('admin/booking/!id/edit-studygroup-membership', array('!id' => $node->nid)))
|
|
));
|
|
|
|
//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 <= variable_get('booking_studygroup_count','0'); $i++)
|
|
{
|
|
//calculate the session references
|
|
$sessionid = "session" . $i;
|
|
$roleid = $sessionid . "_role";
|
|
|
|
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
|
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
|
|
}
|
|
|
|
$node->content['group-heading'] = array(
|
|
'#markup' => $studygroup_heading,
|
|
'#weight' => 8,
|
|
);
|
|
|
|
$node->content['group-details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $group_rows)),
|
|
'#weight' => 9,
|
|
);
|
|
}
|
|
|
|
$node->content['details'] = array(
|
|
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
|
|
'#weight' => 1,
|
|
);
|
|
|
|
//all finished, let's render this mess
|
|
return $node;
|
|
} |