From 397448d47cb0665a88427bcfacc466012de8850d Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 28 Feb 2014 17:17:18 +1100 Subject: [PATCH] Add travel info to booking node view --- booking.admin.inc | 10 ++++++++-- booking.emails.inc | 4 +++- booking.helper.inc | 2 +- booking.paypal.inc | 18 ++++++++++-------- booking.register.inc | 21 ++++++++++++++++++--- booking.studygroups.inc | 20 +++++++++++++++----- 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index fcf7d8f..6b46db4 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -114,7 +114,7 @@ function booking_admin() { $form['misc']['booking_auto_confirm_email'] = array ( '#type' => 'radios', '#title' => t('Automatic Registration Email'), - '#description' => t('Automatically send a confirmation email when a user registers for an event? (If No, email will be sent when status manually changed from Not Coming to Paid). Recommended to set this to Yes if "Show on lists once booked in" is set to No.'), + '#description' => t('Automatically send a confirmation email when a user registers for an event? (If No, email will be sent when status changed from Not Coming to Paid, either manually or via paypal plugin). Recommended to set this to Yes if "Show on lists once booked in" is set to No and paypal is not being used.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_confirm_email', 0), ); @@ -240,6 +240,7 @@ function booking_manual_email() $email_options_array['registration'] = 'Manual Registration'; $email_options_array['balance'] = 'Manual Balance Outstanding'; $email_options_array['complete'] = 'Manual Payment Complete'; + $email_options_array['travelcomplete'] = 'Manual Travel Form Complete'; //add in the custom email types for ($i = 1; $i <= CUSTOM_EMAIL_COUNT; $i++) @@ -336,7 +337,12 @@ function booking_manual_email_submit($form, &$form_state) { { watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key)); _booking_registration_email($key, true, true); - } + } + elseif ($form_state['values']['email-type'] == 'travelcomplete') + { + watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key)); + _booking_travelform_confirmation_email($key); + } elseif (strpos($form_state['values']['email-type'], 'custom') !== false) { watchdog('booking', 'Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key)); diff --git a/booking.emails.inc b/booking.emails.inc index 2d62260..660d03a 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -19,7 +19,7 @@ //load the node matching this id $node = node_load($nid); - watchdog('booking', 'Sending notification email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)); + watchdog('booking', 'Sending registration email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)); //waiting list has already been calculated, stored in node $waiting_list = $node->booking_status == 2 ? TRUE : FALSE; @@ -62,6 +62,8 @@ global $event; global $user; $language = user_preferred_language($user); + + watchdog('booking', 'Sending notification email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)); //calculate the from email address $from = t('!event Registrations ', array('!event' => $event->booking_eventname, diff --git a/booking.helper.inc b/booking.helper.inc index fb1fd7d..4b99ca0 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -606,7 +606,7 @@ function _booking_amount_owing($nid, $amount_paid = 0) else { $amount_owing = $amount_owing / (1 - 0.034); - watchdog('booking', "This is an international registration."); + //watchdog('booking', "This is an international registration."); } } else diff --git a/booking.paypal.inc b/booking.paypal.inc index 8df513d..40c87f5 100644 --- a/booking.paypal.inc +++ b/booking.paypal.inc @@ -122,7 +122,7 @@ function _booking_process_payment($data) { return; } - watchdog('booking', 'Adding payment for user with node id: !id; event id: !eid', array('!id' => $nid, '!eid' => $eid)); + //watchdog('booking', 'Adding payment for user with node id: !id; event id: !eid', array('!id' => $nid, '!eid' => $eid)); $result = db_insert('booking_payment') ->fields(array( @@ -145,11 +145,7 @@ function _booking_process_payment($data) { )) ->execute(); - //Get the person's info - //$payment = db_query("SELECT booking_amount_paid, booking_status, booking_total_pay_reqd, booking_partner_id FROM {booking_person} where nid = :nid", - // array(':nid' => $nid)) - // ->fetchObject(); - + //Get the person's info $payment = db_select('booking_person', 'p') ->condition('p.nid', $nid, '=') ->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd', 'booking_partner_id')) @@ -241,15 +237,21 @@ function _booking_process_payment($data) { //send an email to the spouse _booking_registration_email($payment->booking_partner_id, TRUE); } + /* elseif (variable_get('booking_enable_combined_pricing', 0) == 1) { watchdog('booking', 'Combined pricing is enabled, but this person has a partner id of !id.', array('!id' => $payment->booking_partner_id)); } //end spouse check + */ } - //if this was an initial payment we need to send a notification + //if this was an initial payment we might need to send a notification elseif ($balance_payment == FALSE) { - _booking_registration_email($nid, FALSE); + //send a notification email if we didn't automatically send one earlier + if (variable_get('booking_auto_confirm_email', 0) == 0) + { + _booking_registration_email($nid, FALSE); + } } else //this person still has an outstanding balance so just send a confirmation email { diff --git a/booking.register.inc b/booking.register.inc index 4ff0b96..f6c8f68 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1009,12 +1009,13 @@ function booking_form_submit($form, &$form_state) { } } - //check whether we should send an automatic email + //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 + } + else { //just send a notification email _booking_regn_notifyonly_email($node, FALSE); @@ -1047,7 +1048,7 @@ function booking_load($nodes) { //add that data to the array of node references foreach ($result as $record) { - //watchdog('booking', "
Loading node:\n@info
", array('@info' => print_r( $record, true))); + watchdog('booking', "
Loading node:\n@info
", array('@info' => print_r( $record, true))); // run through each result row and add in the needed attributes foreach ($record as $key => $value) { @@ -1491,6 +1492,20 @@ function booking_view($node, $view_mode) { $rows[] = array(t('Mission related skills:'), t('!value', array('!value' => $skill_areas))); $rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details); } + //print the travel info if it has been defined for this attendee + if (! empty($node->tid)) + { + $rows[] = array(t('Transport Type:'), $node->booking_transport_type); + $rows[] = array(t('Catching the train to Study Week:'), $node->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No'); + $rows[] = array(t('Inbound Flight Number:'), $node->booking_flightnum_inbound == '' ? 'N/A' : $node->booking_flightnum_inbound); + $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')))); + $rows[] = array(t('Outbound Flight Number:'), $node->booking_flightnum_outbound == '' ? 'N/A' : $node->booking_flightnum_outbound); + $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')))); + $rows[] = array(t('Accommodation before Study Week Required:'), $node->booking_accom_before_reqd == 1 ? 'Yes' : 'No'); + $rows[] = array(t('Accommodation after Study Week Required:'), $node->booking_accom_after_reqd == 1 ? 'Yes' : 'No'); + } $rows[] = array(t('Temporary UUID:'), $node->booking_tempid); diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 360b4ee..3d15442 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -525,8 +525,10 @@ function booking_studygroups_calculate() { $age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob); booking_assign_attendee_group($person->booking_node_id, $person->booking_session_id, 'male', $age, $working_list, $session_count); - //get any potential spouse info + //get any potential spouse or boyfriend/girlfriend $spouse_id = $working_list[$person->booking_node_id]->booking_partner_id; + $bf_gf_id = $working_list[$person->booking_node_id]->booking_bf_gf_nid; + if ($spouse_id > 0) { drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).', @@ -537,9 +539,16 @@ function booking_studygroups_calculate() { $age = _booking_get_age_years($working_list[$spouse_id]->booking_dob); booking_assign_attendee_group($spouse_id, $person->booking_session_id, 'female', $age, $working_list, $session_count); } - - //TODO: search for a boyfriend/girlfriend - + elseif ($bf_gf_id > 0) + { + drupal_set_message(t('BF/GF with id !id assigned to session !session (currently with !num people).', + array('!id' => $spouse_id, '!session' => $person->booking_session_id, + '!num' => $session_count[$person->booking_session_id]['total']) + )); + //allocate the boyfriend/girlfriend to the same session + booking_assign_attendee_group($bf_gf_id, $person->booking_session_id, $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female', + _booking_get_age_years($working_list[$bf_gf_id]->booking_dob), $working_list, $session_count); + } } } @@ -658,7 +667,8 @@ function booking_studygroups_calculate() { foreach($working_list as $person) { - + //watchdog('booking', "
Working list person:\n@info
", array('@info' => print_r( $person, true))); + //TODO: a check to update existing records rather than inserting new one // if already in $group_mapping then just run an update query here