Travel form tweaks

This commit is contained in:
2014-06-11 12:37:07 +10:00
parent 18ce42a14f
commit 5267f368b2
3 changed files with 61 additions and 24 deletions

View File

@@ -329,13 +329,17 @@ function booking_manual_email()
'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'), 'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
'booking_fully_paid' => array('data' => t('Fully paid?')), 'booking_fully_paid' => array('data' => t('Fully paid?')),
'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'), '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') $query = db_select('booking_person', 'p');
->fields('p')
->fields('pr', array('booking_price', 'booking_late_price'))
->condition('p.booking_event_id', $event->eid, '=');
$query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); $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); $table_sort = $query->extend('TableSort')->orderbyHeader($header);
$result = $table_sort->execute(); $result = $table_sort->execute();
@@ -357,6 +361,7 @@ function booking_manual_email()
'amount_reqd' => $data->booking_total_pay_reqd, 'amount_reqd' => $data->booking_total_pay_reqd,
'booking_fully_paid' => $paid == 0 ? 'Yes' : 'No', 'booking_fully_paid' => $paid == 0 ? 'Yes' : 'No',
'welfare_required' => $data->booking_welfare_required == 'Y' ? '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; //$values[$data->nid] = ($paid == 0 || $data->booking_status != 1) ? FALSE : TRUE;
} }

View File

@@ -1368,6 +1368,32 @@ function _booking_update($node) {
else else
watchdog('booking', 'Still no room on the booked in list though.'); 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 //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)
{ {

View File

@@ -309,36 +309,42 @@ function travel_form_validate($form, &$form_state) {
if (! is_numeric($form_state['values']['booking_bf_gf_nid'] )) if (! is_numeric($form_state['values']['booking_bf_gf_nid'] ))
{ {
form_set_error('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.', t('You have entered an invalid registration id for your boyfriend/girlfriend. ' .
array('!contact' => l('contact us', 'contact'))) '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', "<pre>Travel form non-numeric bf/gf\n@info</pre>", array('@info' => print_r( $form_state['values'], true))); watchdog('booking', "<pre>Travel form non-numeric bf/gf\n@info</pre>", array('@info' => print_r( $form_state['values'], true)));
} }
//don't allow them to specify their own node id //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', 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', "<pre>Travel form bf/gf same as person id\n@info</pre>", array('@info' => print_r( $form_state['values'], true))); watchdog('booking', "<pre>Travel form bf/gf same as person id\n@info</pre>", array('@info' => print_r( $form_state['values'], true)));
} }
else
//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', //check that the partner exists
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.', $partner = db_query("SELECT person.nid " .
array('!contact' => l('contact us', 'contact'))) "FROM {booking_person} person " .
); "WHERE nid = :nid",
watchdog('booking', "<pre>Travel form unknown bf/gf id\n@info</pre>", array('@info' => print_r( $form_state['values'], true))); 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', "<pre>Travel form unknown bf/gf id\n@info</pre>", 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 //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') if (isset($form_state['values']['booking_transport_type']) && $form_state['values']['booking_transport_type'] == 'Flying')