code cleanup

This commit is contained in:
2016-06-11 15:33:44 +10:00
parent 7cc1ba9be9
commit d39e6ba4bc

View File

@@ -371,30 +371,7 @@ function booking_update($node) {
'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_luckynum' => $node->booking_luckynum == '' ? 0 : $node->booking_luckynum,
'booking_gender' => $node->booking_gender,
'booking_street' => $node->booking_street,
'booking_suburb' => $node->booking_suburb,
@@ -464,13 +441,11 @@ function booking_update($node) {
//***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)
{
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)
{
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
@@ -505,27 +480,25 @@ function booking_update($node) {
_booking_person_rooms_cleanup($node->nid);
//check if there is room on the booked-in list
if (_booking_check_bookings_full() == False)
{
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
{
//-1 means there was no one on the waiting list
if ($temp_nid != -1) {
//update their registration status
_booking_change_status($temp_nid,1);
//send them an email
_booking_promoted_from_waitinglist_email($temp_nid);
}
}
else
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)
{
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
@@ -550,8 +523,7 @@ function booking_update($node) {
}
//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)
{
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"
@@ -564,29 +536,25 @@ function booking_update($node) {
_booking_person_rooms_cleanup($node->nid);
//check if there is room on the booked-in list
if (_booking_check_bookings_full() == False)
{
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
{
//-1 means there was no one on the waiting list
if ($temp_nid != -1) {
//update their registration status
_booking_change_status($temp_nid,1);
//send them an email
_booking_promoted_from_waitinglist_email($temp_nid);
}
}
else
{
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)
{
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);
@@ -601,8 +569,7 @@ function booking_update($node) {
}
//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)
{
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
@@ -615,11 +582,9 @@ function booking_update($node) {
}
}
//if someone moved from the not-paid list to waiting list by manual update
elseif ($previous_status->booking_status == 0 && $node->booking_status == 2)
{
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')
@@ -648,8 +613,7 @@ function booking_update($node) {
}
//if the payment ID has changed then update the total pay required
if ($previous_status->booking_payment_id != $node->booking_payment_id)
{
if ($previous_status->booking_payment_id != $node->booking_payment_id) {
$total_due = 0;
watchdog('booking', 'Detected payment type change for attendee');
@@ -711,36 +675,35 @@ function booking_view($node, $view_mode) {
//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')
{
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
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)
{
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
else {
$partner_name = "N/A";
}
//also look up the actual name if a boyfriend/girlfriend is defined
if ($node->booking_bf_gf_nid != 0)
{
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
else {
$bf_gf = "N/A";
}
//define column widths along with the header
$header = array(
@@ -759,49 +722,6 @@ function booking_view($node, $view_mode) {
$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')));
@@ -811,8 +731,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
$rows[] = array(t('Random Facts:'), t('!facts', array('!facts' => $node->booking_random_facts)));
if (variable_get('booking_enable_tshirts', 0) == 1)
{
if (variable_get('booking_enable_tshirts', 0) == 1) {
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
}
@@ -827,8 +746,7 @@ function booking_view($node, $view_mode) {
$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'))));
if (variable_get('booking_ask_dependant_children', 0) == 1)
{
if (variable_get('booking_ask_dependant_children', 0) == 1) {
$rows[] = array(t('Bringing dependant children:'), t('!ans', array('!ans' => ($node->booking_dependant_children == 'Y' ? 'Yes' : 'No'))));
}
@@ -839,19 +757,17 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Emergency Contact Email Address:'), $node->booking_guardian_email);
$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)
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)
{
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)
{
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');
@@ -875,8 +791,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Help areas:'), t('!help', array('!help' => $help_areas)));
}
if (variable_get('booking_enable_skills', 1) == 1)
{
if (variable_get('booking_enable_skills', 1) == 1) {
$skill_areas = '';
if ($node->booking_skills_builder == 'Y')
$skill_areas .= 'builder, ';
@@ -895,8 +810,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum);
//display room allocation data if enabled
if (variable_get('booking_enable_roomallocations', 0) == 1)
{
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()) )
));
@@ -918,8 +832,7 @@ function booking_view($node, $view_mode) {
}
//add the travel info if it has been defined for this attendee
if (! empty($node->tid))
{
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)))
));
@@ -961,8 +874,7 @@ function booking_view($node, $view_mode) {
//watchdog('booking', "<pre>Displaying node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
foreach ($studygroups as $studygroup)
{
foreach ($studygroups as $studygroup) {
//calculate the session references
$sessionid = "session" . $studygroup->sid;
$roleid = $sessionid . "_role";
@@ -970,22 +882,9 @@ function booking_view($node, $view_mode) {
$group_rows[] = array(t('<b>' . $studygroup->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
}
/*
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));
}
*/
//only add to the render array if there were some study groups found
if (count($group_rows) > 0)
{
if (count($group_rows) > 0) {
$node->content['group-heading'] = array(
'#markup' => $studygroup_heading,
'#weight' => 8,
@@ -996,7 +895,6 @@ function booking_view($node, $view_mode) {
'#weight' => 9,
);
}
}
$node->content['details'] = array(