diff --git a/booking.emails.inc b/booking.emails.inc
index a3dfc90..b43f17b 100644
--- a/booking.emails.inc
+++ b/booking.emails.inc
@@ -337,7 +337,7 @@ function _booking_travelform_confirmation_email($nid)
$subject = t('!event Travel Details Received', array('!event' => $event->booking_eventname));
$params['subject'] = $subject;
- $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
+ $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')));
//retrieve the body of the email
$params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens);
diff --git a/booking.module b/booking.module
index 4305aa4..b3bbc7a 100644
--- a/booking.module
+++ b/booking.module
@@ -22,6 +22,7 @@ define('BOOKING_PAYPAL_IPN_PATH', 'system/booking_paypal/ipn');
define('TIMEZONE', 'Australia/Sydney');
define('BOOKING_DEFAULT_STATE', 'NSW');
define('CUSTOM_EMAIL_COUNT', 5);
+define('STUDYGROUP_COUNT', 7);
// Load the include for various constants
module_load_include('inc', 'booking', 'booking.constants');
@@ -319,7 +320,7 @@ function booking_menu() {
if (variable_get('booking_enable_studygroups', 0) == 1)
{
- $items['admin/config/booking/studygroups'] = array(
+ $items['admin/booking/studygroups'] = array(
'title' => 'View Study Groups',
'description' => 'View Study Group memberships',
'page callback' => 'booking_studygroups_view_summary',
@@ -327,16 +328,25 @@ function booking_menu() {
'type' => MENU_NORMAL_ITEM,
);
- $items['admin/config/booking/studygroups/%/view'] = array(
+ $items['admin/booking/studygroups/%/view'] = array(
'title' => 'View Study Group',
'description' => 'View Study Group memberships',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('booking_studygroups_view_form', 4),
+ 'page arguments' => array('booking_studygroups_view_form', 3),
'access arguments' => array('view study groups'),
//'type' => MENU_NORMAL_ITEM,
);
+
+ $items['admin/booking/studygroups/%/view/print'] = array(
+ 'title' => 'Print Study Group',
+ 'description' => 'Print Study Group memberships',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('booking_studygroups_printview_form', 3),
+ 'access arguments' => array('view study groups'),
+ //'type' => MENU_NORMAL_ITEM,
+ );
- $items['admin/config/booking/studygroups/selectleaders'] = array(
+ $items['admin/booking/studygroups/selectleaders'] = array(
'title' => 'Select Study Group Leaders',
'description' => 'Define attendees to lead or help study groups',
'page callback' => 'drupal_get_form',
@@ -345,7 +355,7 @@ function booking_menu() {
'type' => MENU_LOCAL_ACTION,
);
- $items['admin/config/booking/studygroups/calculate'] = array(
+ $items['admin/booking/studygroups/calculate'] = array(
'title' => 'Calculate Study Groups',
'description' => 'Calculate Study Group memberships',
'page callback' => 'drupal_get_form',
@@ -556,6 +566,19 @@ function booking_theme() {
);
}
+/**
+ * Add custom templates to the list of theme hooks
+ * Don't use http://www.metachunk.com/comment/166#comment-166
+ * Use http://www.metachunk.com/blog/adding-module-path-drupal-7-theme-registry
+ */
+
+/*
+function booking_preprocess_page(&$vars) {
+ watchdog('booking', "
Preprocess hook:\n@info
", array('@info' => print_r( $vars, true)));
+ //$vars['theme_hook_suggestions'][] = 'studygroups-print';
+}
+*/
+
/**
* Implementation of hook_mail().
*/
diff --git a/booking.register.inc b/booking.register.inc
index be5c176..5526709 100644
--- a/booking.register.inc
+++ b/booking.register.inc
@@ -1044,7 +1044,7 @@ function booking_load($nodes) {
//$count = db_query("SELECT count(*) as num_groups FROM {booking_studygroup_list} where booking_eventid = :eventid", array(':eventid' => $event->eid))
// ->fetchObject();
- for ($i = 1; $i <= 7; $i++)
+ 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);
@@ -1057,7 +1057,7 @@ function booking_load($nodes) {
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
//now add the study group fields
- for ($i = 1; $i <= 7; $i++)
+ for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
{
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
@@ -1271,7 +1271,7 @@ function _booking_update($node) {
}
}
- //check if someone needs to move from the waiting list to the booked in list
+ //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');
@@ -1279,6 +1279,8 @@ function _booking_update($node) {
//let this person know their request has been processed
_booking_demoted_to_notcoming_email($node->nid);
+ //TODO: Calculate refund
+
//check if there is room on the booked-in list
if (_booking_check_bookings_full() == False)
{
@@ -1303,7 +1305,9 @@ function _booking_update($node) {
{
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);
+ _booking_demoted_to_notcoming_email($node->nid);
+
+ //TODO: Calculate refund
}
//if we're not automatically sending emails on registration
//and someone moved from not-paid to booked-in (ie, manual payment process)
@@ -1566,7 +1570,46 @@ function booking_view($node, $view_mode) {
);
}
- //TODO: Put study group info here too
+ //display study session data if enabled
+ if (variable_get('booking_enable_studygroups', 0) == 1)
+ {
+
+ //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');
+
+ for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
+ {
+ $role = "";
+
+ //calculate the session references
+ $sessionid = "session" . $i;
+ $leaderid = $sessionid . "_leader";
+ $helperid = $sessionid . "_helper";
+ $reserveleaderid = $sessionid . "_reserveleader";
+
+ if ($node->$leaderid == 'Y')
+ $role = "Leader";
+ elseif ($node->$helperid == 'Y')
+ $role = "Helper";
+ elseif ($node->$reserveleaderid == 'Y')
+ $role = "Reserve Leader";
+
+ $group_rows[] = array(t('' . $studygroups[$i]->booking_studygroup_descrip . ' group number'), $node->$sessionid);
+ $group_rows[] = array(t('Role'), $role);
+ }
+
+ $node->content['group-heading'] = array(
+ '#markup' => "Study Groups
",
+ '#weight' => 4,
+ );
+
+ $node->content['group-details'] = array(
+ '#markup' => theme('table', array('header' => $header, 'rows' => $group_rows)),
+ '#weight' => 5,
+ );
+ }
$node->content['details'] = array(
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
diff --git a/booking.reports.inc b/booking.reports.inc
index 2eca91f..7bc8420 100644
--- a/booking.reports.inc
+++ b/booking.reports.inc
@@ -107,6 +107,7 @@ function booking_report_summary() {
t('!fullypaid', array('!fullypaid' => $amount_owing == 0 ? 'Yes' : 'No')),
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
);
+ //add up the total paid
$total_paid += $person->booking_amount_paid;
//booking status
@@ -509,8 +510,7 @@ function booking_csv_report() {
if ($key == 'nid')
{
$output[] = $value;
- //this is really hacky since it does another massive database query for each person
- //$person = node_load($value);
+ //this is really hacky since it does another database query for each person
$output[] = _booking_amount_owing($value, 0, FALSE);
//$output[] = _booking_amount_owing($value);
continue;
@@ -523,53 +523,10 @@ function booking_csv_report() {
else {
$output[] = $field;
}
- }
-
+ }
$row = implode($delimiter, $output) . "\n";
-
- //watchdog('booking', "Report filename: " . $filename . ".");
- /*
-
- //$header = "Barcode,Timestamp,First Name,Last Name,Gender,Date of Birth,Street,Suburb,Postcode,State,Country,Home Phone Number,Mobile Phone Number,Email,Second Email,Ecclesia,Baptised,Married,Partner Name,Room Mate 1,Room Mate 2,Help Areas,Attending Post Conference,Payment Method,Deposit Payment Deadline,Amount Paid,Discount,Status,T-shirt size";
- $header = "First Name,Last Name,Gender,Date of Birth,Married,Partner Name,Email Address,Mobile Phone,Home Phone,Baptised,";
-
- if (variable_get('booking_enable_passport', 1) == 1)
- $header .= "Passport Number,Passport Expiry,Passport Issue Name,Passport Issue Location,";
-
- if (variable_get('booking_enable_tshirts', 0) == 1)
- $header .= "T-Shirt size,";
-
- $header .= "Ecclesia,Street,Suburb,Post Code,State,Country,Emergency Contact Name,Emergency Contact Type,Emergency Contact Phone," .
- "Emergency Contact Phone Alt,Medicare Number,Help Reading,Help Chairing,Help Music,Dietary Requirements,First Aid,Nurse," .
- "Booking Status,Date Paid,Amount Due,Amount Paid";
-
- if (variable_get('booking_enable_skills', 1) == 1)
- $header .= ",Building Skills,Cooking Skills,Child Minding Skills,Other Languages,Mission Experience";
-
- $query = db_query("SELECT * FROM {booking_person} p WHERE p.booking_event_id = :eid",
- array(':eid' => $event->eid));
- $result = $query->fetchAll();
-
- $music_help = empty($r->booking_help_music) ? '' : $r->booking_help_music;
- $row = ucwords($r->booking_firstname) . ',' . ucwords($r->booking_lastname) . ',' . $r->booking_gender . ',' . format_date($r->booking_dob, 'custom', 'd/m/Y') . ',' .
- $r->booking_married . ',' . $r->booking_partner_name . ',' . $r->booking_email . ',"' . $r->booking_mobile . '","' . $r->booking_phone . '",' .
- $r->booking_baptised . ',';
-
- if (variable_get('booking_enable_passport', 1) == 1)
- $row .= $r->booking_passport_num . ',' .
-
- $row .= '"' . $r->booking_ecclesia . '","' . $r->booking_street . '","' . $r->booking_suburb . '",' . $r->booking_postcode . ',' .
- $r->booking_state . ',' . $r->booking_country . ',"' .
- $r->booking_guardian_name . '",' . $r->booking_guardian_type . ',"' . $r->booking_guardian_phone . '","' . $r->booking_guardian_phone_alt . '",' .
- $r->booking_medicare . ',' .
- $r->booking_help_reading . ',' . $r->booking_help_chairing . ',"' . $music_help . '","' .
- $r->booking_dietary . '",' . $r->booking_firstaid . ',' . $r->booking_nurse . ',' .
- _booking_status_generate($r->booking_status) . ',' . format_date(_booking_datepaid_ts($r->nid), 'custom', 'd/m/Y H:i') . ',' .
- $r->booking_total_pay_reqd . ',' . $r->booking_amount_paid . "\n";
-*/
-
@fwrite($handle, $row);
//$index++;
}
diff --git a/booking.studygroups.inc b/booking.studygroups.inc
index 3d15442..f51dc5f 100644
--- a/booking.studygroups.inc
+++ b/booking.studygroups.inc
@@ -426,7 +426,7 @@ function booking_studygroups_calculate() {
//delete from booking_studygroup_mapping;
//alter table booking_studygroup_mapping AUTO_INCREMENT=1;
- //consider using a lock as per https://api.drupal.org/api/drupal/includes!lock.inc/group/lock/7
+ //TODO: consider using a lock as per https://api.drupal.org/api/drupal/includes!lock.inc/group/lock/7
//select all the study groups for this event id
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
@@ -464,6 +464,8 @@ function booking_studygroups_calculate() {
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
+ //TODO: search for entries already in the mapping table that have a booking_status of 3 (not coming) and remove them from the mapping table
+
//iterate over the attendee associative array and add some fields
foreach ($attendees as $person)
{
@@ -749,7 +751,7 @@ function booking_studygroups_view_summary() {
foreach ($result as $group) {
$rows[] = array(
- l(t('!id', array('!id' => $group->sid)), t('admin/config/booking/studygroups/!id/view', array('!id' => $group->sid))),
+ l(t('!id', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view', array('!id' => $group->sid))),
$group->booking_studygroup_descrip,
$group->booking_num_group_sessions,
);
@@ -763,6 +765,112 @@ function booking_studygroups_view_summary() {
}
+
+/**
+ * Function for viewing a printable format of who belongs to which study group
+ */
+function booking_studygroups_printview_form($node, &$form_state, $group_id) {
+ global $event;
+
+ $form = array();
+ $rows = array();
+ $last_session = "";
+
+ //attach the custom css
+ $form['#attached']['css'] = array(
+ drupal_get_path('module', 'booking') . '/booking.css',
+ );
+
+ //verify that $group_id is a number
+ if (! preg_match('/^[0-9]+$/', $group_id)) {
+ drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to view group membership.", 'error', FALSE);
+ drupal_goto('admin/config/booking');
+ return "";
+ }
+
+ //collect information on the study group
+ $group = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid and sid = :sid",
+ array(':eid' => $event->eid, ':sid' => $group_id))
+ ->fetchObject();
+
+ if (! $group)
+ {
+ drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE);
+ drupal_goto('admin/config/booking');
+ return "";
+ }
+
+ $header = array(
+ 'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
+ 'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),
+ 'booking_is_leader' => array('data' => t('Leader?'), 'field' => 'm.booking_is_leader'),
+ 'booking_is_helper' => array('data' => t('Helper?'), 'field' => 'm.booking_is_helper'),
+ 'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
+ );
+
+ $query = db_select('booking_person', 'p');
+ $query->leftJoin('booking_studygroup_mapping', 'm', 'm.booking_node_id = p.nid');
+ $db_and = db_and();
+ $db_and->condition('p.booking_event_id', $event->eid, '=');
+ $db_and->condition('m.booking_studygroup_id', $group_id, '=');
+ $query->condition($db_and);
+ $query->fields('p')->fields('m')->orderBy('p.booking_lastname', 'ASC');
+ $result = $query->execute();
+
+ //watchdog('booking', 'Study groups raw data: @info', array ('@info' => var_export($result, TRUE)));
+
+ foreach($result as $data)
+ {
+ $class = "";
+
+ //apply theme as required
+ if ($data->booking_is_leader == 'Y')
+ $class = "leader-row";
+ elseif ($data->booking_is_helper == 'Y')
+ $class = "helper-row";
+ elseif ($data->booking_is_reserveleader == 'Y')
+ $class = "helper-row";
+ else
+ $class = "normal-row";
+
+ $rows[] = array (
+ 'data' => array(
+ $data->booking_session_id,
+ $data->booking_firstname . " " . $data->booking_lastname,
+ $data->booking_is_leader == 'Y' ? 'Yes' : 'No',
+ $data->booking_is_helper == 'Y' ? 'Yes' : 'No',
+ $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
+ ),
+ 'class' => $class,
+ 'no_striping' => TRUE,
+ );
+ }
+
+ $prefix = t("Study Group !descrip
", array('!descrip' => $group->booking_studygroup_descrip));
+
+/*
+ $form['table'] = array (
+ '#type' => 'tableselect',
+ '#header' => $header,
+ '#options' => $options,
+ //'#attributes' => array('id' => 'sort-table'),
+ );
+*/
+ return array (
+ 'first_para' => array (
+ '#type' => 'markup',
+ '#markup' => $prefix,
+ ),
+ 'table' => array (
+ '#theme' => 'table',
+ '#header' => $header,
+ '#rows' => $rows,
+ '#sticky' => FALSE,
+ )
+ );
+
+}
+
/**
* Function for viewing who belongs to which study group
*/
@@ -780,7 +888,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
//verify that $group_id is a number
if (! preg_match('/^[0-9]+$/', $group_id)) {
- drupal_set_message("Error: Invalid study group ID supplied. Unable to view group membership.", 'error', FALSE);
+ drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to view group membership.", 'error', FALSE);
drupal_goto('admin/config/booking');
return "";
}
diff --git a/booking.travel.inc b/booking.travel.inc
index 65d10b9..3d00278 100644
--- a/booking.travel.inc
+++ b/booking.travel.inc
@@ -265,13 +265,17 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
//only show the room mate field if we're allowed to
if (variable_get('booking_enable_roommate', 0) == 1 || $inserting == FALSE)
{
- $form['requirements']['booking_room_mate1'] = array(
- '#type' => 'textfield',
- '#title' => t('I would like to share a room with'),
- '#maxlength' => 200,
- '#required' => FALSE,
- '#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : $booking_roommate,
- );
+ //married people won't need to select a room mate
+ if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id == 0)
+ {
+ $form['requirements']['booking_room_mate1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('I would like to share a room with'),
+ '#maxlength' => 200,
+ '#required' => FALSE,
+ '#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : $booking_roommate,
+ );
+ }
}
//only show this field if this person isn't married
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id == 0)
@@ -333,6 +337,51 @@ function travel_form_validate($form, &$form_state) {
}
}
+ //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_flightnum_inbound'])) || ($form_state['values']['booking_flightnum_inbound'] == '') )
+ {
+ form_set_error('booking_flightnum_inbound',
+ t('Please enter the flight number associated with your arrival flight.')
+ );
+ }
+
+ if (
+ $form_state['values']['booking_flight_datetime_inbound']['day'] == '' ||
+ $form_state['values']['booking_flight_datetime_inbound']['month'] == '' ||
+ $form_state['values']['booking_flight_datetime_inbound']['year'] == '' ||
+ $form_state['values']['booking_flight_datetime_inbound']['hour'] == '' ||
+ $form_state['values']['booking_flight_datetime_inbound']['minute'] == ''
+ )
+ {
+ form_set_error('booking_flight_datetime_inbound',
+ t('Please enter the arrival time associated with your flight.')
+ );
+ }
+
+ if ( (! isset($form_state['values']['booking_flightnum_outbound'])) || ($form_state['values']['booking_flightnum_outbound'] == '') )
+ {
+ form_set_error('booking_flightnum_outbound',
+ t('Please enter the flight number associated with your departing flight.')
+ );
+ }
+
+ if (
+ $form_state['values']['booking_flight_datetime_outbound']['day'] == '' ||
+ $form_state['values']['booking_flight_datetime_outbound']['month'] == '' ||
+ $form_state['values']['booking_flight_datetime_outbound']['year'] == '' ||
+ $form_state['values']['booking_flight_datetime_outbound']['hour'] == '' ||
+ $form_state['values']['booking_flight_datetime_outbound']['minute'] == ''
+ )
+ {
+ form_set_error('booking_flight_datetime_outbound',
+ t('Please enter the departure time associated with your flight.')
+ );
+ }
+
+ }
+
}
function travel_form_submit($form, &$form_state) {
@@ -387,7 +436,9 @@ function travel_form_submit($form, &$form_state) {
//optional fields
$node->booking_dietary = variable_get('booking_enable_dietary', 0) == 1 ? $values['booking_dietary'] : $person->booking_dietary;
- $node->booking_room_mate1 = variable_get('booking_enable_roommate', 0) == 1 ? $values['booking_room_mate1'] : $person->booking_room_mate1;
+ //room mate field might be enabled but not displayed for a married couple so calculate whether the field is empty or not first
+ $room_mate = empty($values['booking_room_mate1']) ? $person->booking_room_mate1 : $values['booking_room_mate1'];
+ $node->booking_room_mate1 = variable_get('booking_enable_roommate', 0) == 1 ? $room_mate : $person->booking_room_mate1;
//watchdog('booking', "Travel data to save:\n@info
", array('@info' => print_r( $node, true)));