diff --git a/booking.admin.inc b/booking.admin.inc index 75e6ce6..462634e 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -329,13 +329,17 @@ function booking_manual_email() 'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'), 'booking_fully_paid' => array('data' => t('Fully paid?')), 'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'), + 'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'), ); - $query = db_select('booking_person', 'p') - ->fields('p') - ->fields('pr', array('booking_price', 'booking_late_price')) - ->condition('p.booking_event_id', $event->eid, '='); + $query = db_select('booking_person', 'p'); $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); + $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); + + $query->fields('p') + ->fields('pr', array('booking_price', 'booking_late_price')) + ->fields('t') + ->condition('p.booking_event_id', $event->eid, '='); $table_sort = $query->extend('TableSort')->orderbyHeader($header); $result = $table_sort->execute(); @@ -357,6 +361,7 @@ function booking_manual_email() 'amount_reqd' => $data->booking_total_pay_reqd, 'booking_fully_paid' => $paid == 0 ? 'Yes' : 'No', 'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No', + 'travel_form' => $data->tid > 0 ? 'Yes' : 'No', ); //$values[$data->nid] = ($paid == 0 || $data->booking_status != 1) ? FALSE : TRUE; } diff --git a/booking.register.inc b/booking.register.inc index 1b03f50..dd2f46c 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1368,6 +1368,32 @@ function _booking_update($node) { 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) { diff --git a/booking.travel.inc b/booking.travel.inc index 19d3ca1..7b03009 100644 --- a/booking.travel.inc +++ b/booking.travel.inc @@ -309,36 +309,42 @@ function travel_form_validate($form, &$form_state) { if (! is_numeric($form_state['values']['booking_bf_gf_nid'] )) { form_set_error('booking_bf_gf_nid', - t('You have entered an invalid registration id for your boyfriend/girlfriend. Please ensure you are using only the registration reference number your boyfriend/girlfriend received via email. If you believe this to be incorrect, please !contact using the details provided.', - array('!contact' => l('contact us', 'contact'))) + t('You have entered an invalid registration id for your boyfriend/girlfriend. ' . + 'Please ensure you are using only the registration reference number your boyfriend/girlfriend received via email. For example, your registration ID is !id. ' . + 'If you believe this to be incorrect, please !contact using the details provided.', + array('!id' => $form_state['values']['personid'], '!contact' => l('contact us', 'contact'))) ); watchdog('booking', "
Travel form non-numeric bf/gf\n@info
", array('@info' => print_r( $form_state['values'], true))); } - //don't allow them to specify their own node id - if ($form_state['values']['personid'] == $form_state['values']['booking_bf_gf_nid']) + elseif ($form_state['values']['personid'] == $form_state['values']['booking_bf_gf_nid']) { form_set_error('booking_bf_gf_nid', - t('You have entered your own registration id. Please ensure you enter only the registration reference number your boyfriend/girlfriend received via email when registering, not your own registration id.') + t('You have entered your own registration id.' . + 'Please ensure you enter only the registration reference number your boyfriend/girlfriend received via email when registering, not your own registration id.') ); watchdog('booking', "
Travel form bf/gf same as person id\n@info
", array('@info' => print_r( $form_state['values'], true))); } - - //check that the partner exists - $partner = db_query("SELECT person.nid " . - "FROM {booking_person} person " . - "WHERE nid = :nid", - array(':nid' => $form_state['values']['booking_bf_gf_nid'])) - ->fetchObject(); - if (! $partner) + else { - form_set_error('booking_bf_gf_nid', - t('We cannot find a matching registration id for your boyfriend/girlfriend. 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', "
Travel form unknown bf/gf id\n@info
", array('@info' => print_r( $form_state['values'], true))); - } - } + //check that the partner exists + $partner = db_query("SELECT person.nid " . + "FROM {booking_person} person " . + "WHERE nid = :nid", + array(':nid' => $form_state['values']['booking_bf_gf_nid'])) + ->fetchObject(); + if (! $partner) + { + form_set_error('booking_bf_gf_nid', + t('We cannot find a matching registration id for your boyfriend/girlfriend. ' . + 'Please ensure you are using only the number that relates to their registration. For example, your registration ID is !id. ' . + 'If you believe this to be incorrect, please !contact using the details provided.', + array('!id' => $form_state['values']['personid'], '!contact' => l('contact us', 'contact'))) + ); + watchdog('booking', "
Travel form unknown bf/gf id\n@info
", array('@info' => print_r( $form_state['values'], true))); + } //end missing partner handling + } //end bf/gf validation + } //end bf/gf checking //check to make sure flight info is entered if it is selected if (isset($form_state['values']['booking_transport_type']) && $form_state['values']['booking_transport_type'] == 'Flying')