From 7e248a8bf3fbe2cbb13db8487cb477e935cc5d55 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:34:28 +1000 Subject: [PATCH 01/42] add travel summary report --- booking.module | 8 ++++ booking.reports.inc | 114 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 97 insertions(+), 25 deletions(-) diff --git a/booking.module b/booking.module index 18e4856..1ad9dd5 100644 --- a/booking.module +++ b/booking.module @@ -324,6 +324,14 @@ function booking_menu() { 'access arguments' => array('access reports'), 'type' => MENU_NORMAL_ITEM, ); + + $items['admin/booking/travel'] = array( + 'title' => 'Travel Summary', + 'description' => "List people's travel details", + 'page callback' => 'booking_report_travel', + 'access arguments' => array('access reports'), + 'type' => MENU_NORMAL_ITEM, + ); $items['admin/booking/manual-email'] = array( 'title' => 'Manually Email People', diff --git a/booking.reports.inc b/booking.reports.inc index c04d1ca..6d82061 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -427,6 +427,84 @@ function booking_report_flight_details() { return $result; } +/** + * List everyone's travel info + */ +function booking_report_travel() { + global $event; + $form = array(); + $prefix = t("

Travel Details

"); + + //define sorting information with the header + //as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7 + $header = array(); + $header[] = array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'); + $header[] = array('data' => t('Name'), 'field' => 'booking_lastname'); + $header[] = array('data' => t('Booking Status'), 'field' => 'booking_status'); + $header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type'); + $header[] = array('data' => t('Catching Train?'), 'field' => 'booking_transport_from_morriset_reqd'); + $header[] = array('data' => t('Inbound Flight Number'), 'field' => 'booking_flightnum_inbound'); + $header[] = array('data' => t('Inbound Flight Time'), 'field' => 'booking_flight_datetime_inbound'); + $header[] = array('data' => t('Outbound Flight Number'), 'field' => 'booking_flightnum_outbound'); + $header[] = array('data' => t('Outbound Flight Time'), 'field' => 'booking_flight_datetime_outbound'); + $header[] = array('data' => t('Accommodation Before?'), 'field' => 'booking_accom_before_reqd'); + $header[] = array('data' => t('Accommodation After?'), 'field' => 'booking_accom_after_reqd'); + + //get travel info from database + $query = db_select('booking_person', 'p'); + $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); + $query->condition('p.booking_eventid', $event->eid, '=') + ->fields('p') + ->fields('t'); + //allow user to sort columns + $table_sort = $query->extend('TableSort')->orderbyHeader($header); + $result = $table_sort->execute(); + + foreach ($result as $person) { + $this_row = array(); + + //define the row for this person + $this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))); + $this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), + t('node/!id', array('!id' => $person->nid)) + ); + $this_row[] = _booking_status_generate($person->booking_status); + + //calculate the travel link + if ($person->tid > 0) { + //$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); + $this_row[] = t('!transport', array('!transport' => $person->booking_transport_type)); + $this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No')); + $this_row[] = t('!inflightnum', array('!transport' => $person->booking_flightnum_inbound)); + $this_row[] = t('!inflighttime', array('!inflighttime' => + $person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i')); + $this_row[] = t('!outflightnum', array('!outflightnum' => $person->booking_flightnum_outbound)); + $this_row[] = t('!outflighttime', array('!outflighttime' => + $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i')); + $this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No')); + $this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No')); + } + + $rows[] = $this_row; + } + + $result = array ( + 'first_para' => array ( + '#type' => 'markup', + '#markup' => $prefix, + ), + 'table' => array ( + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, + '#attributes' => array('id' => 'sort-table'), + //'#sticky' => FALSE, + ) + ); + + return $result; +} + function booking_coming_page() { global $event; @@ -437,21 +515,17 @@ function booking_coming_page() { $rows = array(); //work out whether to include the team colour in this page - if (variable_get('booking_publish_readinggroups', 0) == 1) - { + if (variable_get('booking_publish_readinggroups', 0) == 1) { $header = array('Name', 'Team Colour', 'State'); } - else - { + else { $header = array('Name', 'State'); } //if configuration is set to show on lists even when no payment has been made, then include booking status of 0 (unpaid) or 1 (booked in) //also ensure any committee members always show - if (variable_get('booking_auto_show_on_lists', 1) == 1) - { + if (variable_get('booking_auto_show_on_lists', 1) == 1) { $or = db_or()->condition('p.booking_status', 0)->condition('p.booking_status', 1)>condition('p.booking_committee_member', 'Y'); - $result = db_select('booking_person', 'p') ->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country')) ->condition($or) @@ -461,13 +535,10 @@ function booking_coming_page() { ->orderBy('booking_lastname') ->orderBy('booking_firstname') ->execute(); - } - else - { + else { //payment must be made before someone will show up as booked in, but also include any committee member that might not have paid $or = db_or()->condition('p.booking_status', 1)->condition('p.booking_committee_member', 'Y'); - $result = db_select('booking_person', 'p') ->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country')) ->condition($or) @@ -479,13 +550,11 @@ function booking_coming_page() { ->execute(); } - foreach ($result as $person) - { + foreach ($result as $person) { $state = $person->booking_country === variable_get('booking_default_country') ? $person->booking_state : $person->booking_country; //if we're allowed to publish reading groups, specify them in the array element - if (variable_get('booking_publish_readinggroups', 0) == 1) - { + if (variable_get('booking_publish_readinggroups', 0) == 1) { $rows[] = array( t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), @@ -494,8 +563,7 @@ function booking_coming_page() { ); } //don't publish reading group information - else - { + else { $rows[] = array( t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), @@ -508,15 +576,12 @@ function booking_coming_page() { //output the results //check there were some bookings - if (count($rows) > 0) - { - if (count($rows) >= $booking_limit) - { + if (count($rows) > 0) { + if (count($rows) >= $booking_limit) { //there is a waiting list $output .= token_replace(variable_get('booking_whoscoming_pre_waitlist_text'), booking_define_tokens()); } - else - { + else { //there's no waiting list $output .= token_replace(variable_get('booking_whoscoming_pre_text'), booking_define_tokens()); } @@ -524,8 +589,7 @@ function booking_coming_page() { //theme the table of registrations $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); } - else - { + else { //no bookings $output .= token_replace(variable_get('booking_whoscoming_pre_noregistrations_text'), booking_define_tokens()); } From d44e0d95928c964ddc9be91c20e741290899059e Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:35:48 +1000 Subject: [PATCH 02/42] fix --- booking.reports.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 6d82061..e7a9720 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -477,10 +477,10 @@ function booking_report_travel() { $this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No')); $this_row[] = t('!inflightnum', array('!transport' => $person->booking_flightnum_inbound)); $this_row[] = t('!inflighttime', array('!inflighttime' => - $person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i')); + $person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!outflightnum', array('!outflightnum' => $person->booking_flightnum_outbound)); $this_row[] = t('!outflighttime', array('!outflighttime' => - $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i')); + $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No')); $this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No')); } From 582110a752530a565800c3d5e4e0b3dc67f0b78b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:37:58 +1000 Subject: [PATCH 03/42] rename report --- booking.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.module b/booking.module index 1ad9dd5..a64131a 100644 --- a/booking.module +++ b/booking.module @@ -326,7 +326,7 @@ function booking_menu() { ); $items['admin/booking/travel'] = array( - 'title' => 'Travel Summary', + 'title' => 'Booking Travel Summary', 'description' => "List people's travel details", 'page callback' => 'booking_report_travel', 'access arguments' => array('access reports'), From d88159c25aa2cb20e9d121d510b93da2a41b46b8 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:41:05 +1000 Subject: [PATCH 04/42] remove people no longer coming from travel report --- booking.reports.inc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index e7a9720..e616a29 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -453,9 +453,13 @@ function booking_report_travel() { //get travel info from database $query = db_select('booking_person', 'p'); $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); - $query->condition('p.booking_eventid', $event->eid, '=') - ->fields('p') - ->fields('t'); + //include people either booked in or on the waiting list or hosts, that belong to the current event id + $db_or = db_or(); + $db_or->condition('p.booking_status', 1, '='); + $db_or->condition('p.booking_status', 2, '='); + $db_or->condition('p.booking_status', 5, '='); + $db_and = db_and()->condition($db_or)->condition('p.booking_eventid', $event->eid, '='); + $query->fields('p')->fields('t'); //allow user to sort columns $table_sort = $query->extend('TableSort')->orderbyHeader($header); $result = $table_sort->execute(); @@ -475,7 +479,7 @@ function booking_report_travel() { //$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); $this_row[] = t('!transport', array('!transport' => $person->booking_transport_type)); $this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No')); - $this_row[] = t('!inflightnum', array('!transport' => $person->booking_flightnum_inbound)); + $this_row[] = t('!inflightnum', array('!inflightnum' => $person->booking_flightnum_inbound)); $this_row[] = t('!inflighttime', array('!inflighttime' => $person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!outflightnum', array('!outflightnum' => $person->booking_flightnum_outbound)); From c59f3bda0958ff45ee837c08f13fc792a9a204ce Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:45:19 +1000 Subject: [PATCH 05/42] tweaks to travel report --- booking.reports.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index e616a29..59d0982 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -458,7 +458,8 @@ function booking_report_travel() { $db_or->condition('p.booking_status', 1, '='); $db_or->condition('p.booking_status', 2, '='); $db_or->condition('p.booking_status', 5, '='); - $db_and = db_and()->condition($db_or)->condition('p.booking_eventid', $event->eid, '='); + $db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')->condition($db_or); + $query->condition($db_and); $query->fields('p')->fields('t'); //allow user to sort columns $table_sort = $query->extend('TableSort')->orderbyHeader($header); @@ -475,7 +476,7 @@ function booking_report_travel() { $this_row[] = _booking_status_generate($person->booking_status); //calculate the travel link - if ($person->tid > 0) { + //if ($person->tid > 0) { //$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); $this_row[] = t('!transport', array('!transport' => $person->booking_transport_type)); $this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No')); @@ -487,7 +488,7 @@ function booking_report_travel() { $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No')); $this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No')); - } + //} $rows[] = $this_row; } From 3a0daab0ebc694df255c528e63cc3ffa927a2b82 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:46:47 +1000 Subject: [PATCH 06/42] few more tweaks --- booking.reports.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 59d0982..13ceb4e 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -442,11 +442,11 @@ function booking_report_travel() { $header[] = array('data' => t('Name'), 'field' => 'booking_lastname'); $header[] = array('data' => t('Booking Status'), 'field' => 'booking_status'); $header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type'); - $header[] = array('data' => t('Catching Train?'), 'field' => 'booking_transport_from_morriset_reqd'); - $header[] = array('data' => t('Inbound Flight Number'), 'field' => 'booking_flightnum_inbound'); - $header[] = array('data' => t('Inbound Flight Time'), 'field' => 'booking_flight_datetime_inbound'); - $header[] = array('data' => t('Outbound Flight Number'), 'field' => 'booking_flightnum_outbound'); - $header[] = array('data' => t('Outbound Flight Time'), 'field' => 'booking_flight_datetime_outbound'); + $header[] = array('data' => t('Catching train from airport?'), 'field' => 'booking_transport_from_morriset_reqd'); + $header[] = array('data' => t('Inbound Flight'), 'field' => 'booking_flightnum_inbound'); + $header[] = array('data' => t('Inbound Time'), 'field' => 'booking_flight_datetime_inbound'); + $header[] = array('data' => t('Outbound Flight'), 'field' => 'booking_flightnum_outbound'); + $header[] = array('data' => t('Outbound Time'), 'field' => 'booking_flight_datetime_outbound'); $header[] = array('data' => t('Accommodation Before?'), 'field' => 'booking_accom_before_reqd'); $header[] = array('data' => t('Accommodation After?'), 'field' => 'booking_accom_after_reqd'); From 67dd4d6336dc275c2daff69461bb88ef1995fb53 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:48:58 +1000 Subject: [PATCH 07/42] add link to travel form --- booking.reports.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 13ceb4e..996b5d9 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -438,7 +438,7 @@ function booking_report_travel() { //define sorting information with the header //as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7 $header = array(); - $header[] = array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'); + $header[] = array('data' => t('Edit'), 'field' => 'nid', 'sort' => 'asc'); $header[] = array('data' => t('Name'), 'field' => 'booking_lastname'); $header[] = array('data' => t('Booking Status'), 'field' => 'booking_status'); $header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type'); @@ -469,7 +469,8 @@ function booking_report_travel() { $this_row = array(); //define the row for this person - $this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))); + $this_row[] = $travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); + //$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))); $this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), t('node/!id', array('!id' => $person->nid)) ); From ed160830ffbe0fe8b987085f9ba668fc194d702f Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:54:07 +1000 Subject: [PATCH 08/42] add state to travel summary report --- booking.reports.inc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 996b5d9..4ef5af7 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -440,7 +440,7 @@ function booking_report_travel() { $header = array(); $header[] = array('data' => t('Edit'), 'field' => 'nid', 'sort' => 'asc'); $header[] = array('data' => t('Name'), 'field' => 'booking_lastname'); - $header[] = array('data' => t('Booking Status'), 'field' => 'booking_status'); + $header[] = array('data' => t('State'), 'field' => 'booking_state'); $header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type'); $header[] = array('data' => t('Catching train from airport?'), 'field' => 'booking_transport_from_morriset_reqd'); $header[] = array('data' => t('Inbound Flight'), 'field' => 'booking_flightnum_inbound'); @@ -469,15 +469,16 @@ function booking_report_travel() { $this_row = array(); //define the row for this person - $this_row[] = $travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); + $this_row[] = $travel_link = l(t('Travel'), t('node/!id', array('!id' => $person->tid))); //$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))); $this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), t('node/!id', array('!id' => $person->nid)) ); - $this_row[] = _booking_status_generate($person->booking_status); + $this_row[] = t('!state', array('!state' => $person->booking_state)); + //$this_row[] = _booking_status_generate($person->booking_status); //calculate the travel link - //if ($person->tid > 0) { + if ($person->tid > 0) { //$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid))); $this_row[] = t('!transport', array('!transport' => $person->booking_transport_type)); $this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No')); @@ -489,8 +490,12 @@ function booking_report_travel() { $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No')); $this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No')); - //} - + } + else { + for ($i = 0; $i < 8; $i++) { + $rows[] = "N/A"; + } + } $rows[] = $this_row; } From c8c6f50a0488377dad256e3f4218ea4c4acd7906 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 21:55:30 +1000 Subject: [PATCH 09/42] fix --- booking.reports.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.reports.inc b/booking.reports.inc index 4ef5af7..882dc9f 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -493,7 +493,7 @@ function booking_report_travel() { } else { for ($i = 0; $i < 8; $i++) { - $rows[] = "N/A"; + $this_row[] = "N/A"; } } $rows[] = $this_row; From f09811990dc8ee629b407dbb60c04f1827fad626 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 22:02:15 +1000 Subject: [PATCH 10/42] add css for people flying to study week --- booking.reports.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 882dc9f..e077b01 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -434,6 +434,11 @@ function booking_report_travel() { global $event; $form = array(); $prefix = t("

Travel Details

"); + + //attach css so we can customise colours for some people + $form['#attached']['css'] = array( + drupal_get_path('module', 'booking') . '/booking.css', + ); //define sorting information with the header //as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7 @@ -475,7 +480,9 @@ function booking_report_travel() { t('node/!id', array('!id' => $person->nid)) ); $this_row[] = t('!state', array('!state' => $person->booking_state)); - //$this_row[] = _booking_status_generate($person->booking_status); + //$this_row[] = _booking_status_generate($person->booking_status); + + $class = $data->booking_transport_type == 'Flying' ? "flying-row" : "normal-row"; //calculate the travel link if ($person->tid > 0) { @@ -496,7 +503,7 @@ function booking_report_travel() { $this_row[] = "N/A"; } } - $rows[] = $this_row; + $rows[] = array('data' => $this_row, 'class' => array($class)); } $result = array ( From ad31433dadae4b2f6ac9bb9c6f9adabab73d38e4 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 22:03:00 +1000 Subject: [PATCH 11/42] fix --- booking.reports.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.reports.inc b/booking.reports.inc index e077b01..583f016 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -482,7 +482,7 @@ function booking_report_travel() { $this_row[] = t('!state', array('!state' => $person->booking_state)); //$this_row[] = _booking_status_generate($person->booking_status); - $class = $data->booking_transport_type == 'Flying' ? "flying-row" : "normal-row"; + $class = $person->booking_transport_type == 'Flying' ? "flying-row" : "normal-row"; //calculate the travel link if ($person->tid > 0) { From 49b97729f13893c60b2ca5113d4e0717eaee1843 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 22:04:53 +1000 Subject: [PATCH 12/42] css update --- booking.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/booking.css b/booking.css index 6507348..39d9939 100644 --- a/booking.css +++ b/booking.css @@ -10,6 +10,8 @@ /* tr.normal-row.even {} */ tr.welfare-row.odd {background: #c3e06c;} tr.welfare-row.even {background: #c3e06c;} +tr.flying-row.odd {background: #c3e06c;} +tr.flying-row.even {background: #e5f2c0;} div#booking_email_preselection_suffix_wrapper { margin-bottom: 10px; } \ No newline at end of file From f628e41677221476c6d3e9f82312cd78bed4f8f8 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 22:07:28 +1000 Subject: [PATCH 13/42] attach csv properly --- booking.reports.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index 583f016..1b95e32 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -432,14 +432,9 @@ function booking_report_flight_details() { */ function booking_report_travel() { global $event; - $form = array(); + //$form = array(); $prefix = t("

Travel Details

"); - //attach css so we can customise colours for some people - $form['#attached']['css'] = array( - drupal_get_path('module', 'booking') . '/booking.css', - ); - //define sorting information with the header //as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7 $header = array(); @@ -507,6 +502,9 @@ function booking_report_travel() { } $result = array ( + '#attached' => array ( + 'css' => array(drupal_get_path('module', 'booking') . '/booking.css') + ), 'first_para' => array ( '#type' => 'markup', '#markup' => $prefix, From 91efbb80d67896d429f368bb51bf3d3c1cdd23ab Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 26 Jun 2016 22:14:51 +1000 Subject: [PATCH 14/42] also add highlighting for people that want accommodation --- booking.css | 2 ++ booking.reports.inc | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/booking.css b/booking.css index 39d9939..43ae415 100644 --- a/booking.css +++ b/booking.css @@ -12,6 +12,8 @@ tr.welfare-row.odd {background: #c3e06c;} tr.welfare-row.even {background: #c3e06c;} tr.flying-row.odd {background: #c3e06c;} tr.flying-row.even {background: #e5f2c0;} +tr.accomm-row.odd {background: #ffb380;} +tr.accomm-row.even {background: #ffb380;} div#booking_email_preselection_suffix_wrapper { margin-bottom: 10px; } \ No newline at end of file diff --git a/booking.reports.inc b/booking.reports.inc index 1b95e32..2f8964f 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -492,6 +492,11 @@ function booking_report_travel() { $person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i'))); $this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No')); $this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No')); + + //mark people requiring accommodation in a different colour so they stand out more + if ($person->booking_accom_before_reqd == 1 || $person->booking_accom_after_reqd == 1) { + $class = "accomm-row"; + } } else { for ($i = 0; $i < 8; $i++) { From 4550028fd638253de2c121f4912df8070cfdb3a9 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 10:41:43 +1000 Subject: [PATCH 15/42] re-arrange travel report columns --- booking.admin.inc | 5 ++--- booking.reports.inc | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index aae3fdc..e6b9f59 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -4,8 +4,7 @@ * The administration menu implementations for the booking module configuration pages */ -function booking_admin() -{ +function booking_admin() { $form = array(); //regenerate all our menu hooks when loading this form @@ -564,7 +563,7 @@ $form['management']['booking_import_include_fields_dynamic'] = array( //return system_settings_form($form); //make sure we update our custom sql view every time we change something on the admin page $form = system_settings_form($form); - $form['#submit'][] = '_booking_node_create_mysqlview'; + //$form['#submit'][] = '_booking_node_create_mysqlview'; return $form; } diff --git a/booking.reports.inc b/booking.reports.inc index 2f8964f..a81d25a 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -438,8 +438,8 @@ function booking_report_travel() { //define sorting information with the header //as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7 $header = array(); - $header[] = array('data' => t('Edit'), 'field' => 'nid', 'sort' => 'asc'); $header[] = array('data' => t('Name'), 'field' => 'booking_lastname'); + //$header[] = array('data' => t('Edit'), 'field' => 'nid', 'sort' => 'asc'); $header[] = array('data' => t('State'), 'field' => 'booking_state'); $header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type'); $header[] = array('data' => t('Catching train from airport?'), 'field' => 'booking_transport_from_morriset_reqd'); @@ -469,10 +469,10 @@ function booking_report_travel() { $this_row = array(); //define the row for this person - $this_row[] = $travel_link = l(t('Travel'), t('node/!id', array('!id' => $person->tid))); + //$this_row[] = $travel_link = l(t('Travel'), t('node/!id', array('!id' => $person->tid))); //$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid))); $this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))), - t('node/!id', array('!id' => $person->nid)) + t('node/!id', array('!id' => $person->tid)) ); $this_row[] = t('!state', array('!state' => $person->booking_state)); //$this_row[] = _booking_status_generate($person->booking_status); From 70168189fb3ddee322944492c497d8026bd7577b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 10:44:10 +1000 Subject: [PATCH 16/42] tweak to travel report --- booking.reports.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/booking.reports.inc b/booking.reports.inc index a81d25a..f8443fa 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -499,8 +499,10 @@ function booking_report_travel() { } } else { - for ($i = 0; $i < 8; $i++) { - $this_row[] = "N/A"; + $this_row[] = "N/A"; + //put in empty fields to fill up the table columns + for ($i = 0; $i < 7; $i++) { + $this_row[] = ""; } } $rows[] = array('data' => $this_row, 'class' => array($class)); From 622c84314b7f8736251ae3e32095cf800bc9c5f7 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 10:56:31 +1000 Subject: [PATCH 17/42] tweak debug messages for editing a person's studygroups --- booking.studygroups.inc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/booking.studygroups.inc b/booking.studygroups.inc index b07fddb..f1a64db 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -500,9 +500,10 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) { function booking_studygroups_edit_form_submit($form, &$form_state) { global $event; $counter = 0; - $checkboxes = $form_state['values']['table']; + //$checkboxes = $form_state['values']['table']; $studygroup_ids = $form_state['values']['booking_assign_sessionid']; $values = $form_state['input']; + $update_messages = array(); //check that $values['personid'] is a number if (! preg_match('/^[0-9]+$/', $values['personid'])) { @@ -536,7 +537,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) { } //check to see if we need to remove a study group mapping if (! empty($person_groups[$key]) && $value == 'Remove') { - watchdog('booking', "Removing an existing Study Group session id: @id from group @group.\n
@info
", + $update_messages[] = t("Removing an existing Study Group session id: @id from group @group.\n
@info
", array('@id' => $value, '@group' => $key, '@info' => print_r( $person_groups[$key], true))); $num_deleted = db_delete('booking_studygroup_mapping') @@ -545,7 +546,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) { } //check for an existing study group mapping to change elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id != $value) { - watchdog('booking', "Updating Study Group session from: @key to @value for id @id", + $update_messages[] = t( "Updating Study Group session from: @key to @value for id @id", array('@key' => $person_groups[$key]->booking_session_id, '@value' => $value, '@id' => $nid)); db_update('booking_studygroup_mapping') @@ -567,12 +568,12 @@ function booking_studygroups_edit_form_submit($form, &$form_state) { } //found this entry already, so no change needed elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id == $value) { - watchdog('booking', "Study Group @group session already set to @session.", + $update_messages[] = t("Study Group @group session already set to @session.", array('@group' => $key, '@session' => $value)); } //no previously defined value, so add a new entry to the mapping table else { - watchdog('booking', "Adding Study Group session id: @id for group @group.", array('@id' => $value, '@group' => $key)); + $update_messages[] = t("Adding Study Group session id: @id for group @group.", array('@id' => $value, '@group' => $key)); db_insert('booking_studygroup_mapping') ->fields(array( @@ -593,8 +594,12 @@ function booking_studygroups_edit_form_submit($form, &$form_state) { } } //end new value check } //end valid data check - } //end checkbox loop -} + } //end select dropdown loop + //output messages to watchdog + $final_message = t('Finished processing study groups for person id !id.', array('!id' => $nid)); + drupal_set_message($final_message); + watchdog('booking', "
" . $final_message . "\n" . implode("\n", $update_messages) . "
"); +} //end function /** * Function for calculating who belongs to which study group From 805c639e5d665e71bbcbf564f475c8837b784d25 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 11:34:24 +1000 Subject: [PATCH 18/42] add room description field --- booking.install | 11 ++++ booking.regn_node.inc | 2 +- booking.rooms_admin.inc | 110 ++++++++++++++++++++-------------------- 3 files changed, 66 insertions(+), 57 deletions(-) diff --git a/booking.install b/booking.install index 4e77f9b..ef87142 100644 --- a/booking.install +++ b/booking.install @@ -585,6 +585,16 @@ function booking_update_7237() { _booking_node_create_mysqlview(); } +/** +* Add description field to room definitions +*/ +function booking_update_7237() { + $spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE); + db_add_field('booking_room_definition', 'booking_room_description', $spec); + //update the view to match the new table definition + _booking_node_create_mysqlview(); +} + /** * Implementation of hook_install(). */ @@ -921,6 +931,7 @@ function booking_schema() { 'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), + 'booking_room_description' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE), ), 'primary key' => array('rid'), ); diff --git a/booking.regn_node.inc b/booking.regn_node.inc index f7d39b0..14b71a2 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -762,7 +762,7 @@ function booking_view($node, $view_mode) { } $rows[] = array(t('Linked Partner:'), t($partner_name)); $rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf)); - $rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id); + $rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id == 0 ? 'N/A' : $node->booking_keepseparate_id); $rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone))); $rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile))); $rows[] = array(t('Postal Address:'), t('!street
!suburb !state !code
!country', diff --git a/booking.rooms_admin.inc b/booking.rooms_admin.inc index c7fc96b..428907e 100644 --- a/booking.rooms_admin.inc +++ b/booking.rooms_admin.inc @@ -225,18 +225,20 @@ function booking_rooms_view_definitions() { $definition_query->join('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id'); $definition_query->condition('l.booking_roomlocation_active', 'Y', '=') ->fields('r') - ->fields('l'); + ->fields('l') + ->orderBy('lid')->orderBy('booking_room_number'); $definition_result = $definition_query->execute(); $location_header = array ( - 'booking_roomlocation_descrip' => t('Location Description'), - 'booking_roomlocation_active' => t('Location Active?'), + 'booking_roomlocation_descrip' => t('Location Description'), + 'booking_roomlocation_active' => t('Location Active?'), 'booking_location_edit' => t('Edit Location'), ); $definition_header = array ( - 'booking_room_location_description' => t('Room Location'), - 'booking_room_number' => t('Room Number'), + 'booking_room_location_description' => t('Room Location'), + 'booking_room_number' => t('Room Number'), + 'booking_room_description' => t('Room Description'), 'booking_room_singlebeds' => t('Number Single Beds'), 'booking_room_doublebeds' => t('Number Double Beds'), 'booking_room_queenbeds' => t('Number Queen Beds'), @@ -244,8 +246,7 @@ function booking_rooms_view_definitions() { 'booking_room_edit' => t('Edit Room'), ); - foreach($location_result as $data) - { + foreach($location_result as $data) { $location_rows[] = array ( $data->booking_roomlocation_descrip, $data->booking_roomlocation_active == 'Y' ? 'Yes' : 'No', @@ -253,12 +254,12 @@ function booking_rooms_view_definitions() { ); } - foreach($definition_result as $data) - { + foreach($definition_result as $data) { $definition_rows[] = array ( - //_booking_room_location_lookup($data->booking_room_location_id), + //_booking_room_location_lookup($data->booking_room_location_id), $data->booking_roomlocation_descrip, - $data->booking_room_number, + $data->booking_room_number, + $data->booking_room_description, $data->booking_room_singlebeds, $data->booking_room_doublebeds, $data->booking_room_queenbeds, @@ -309,33 +310,30 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = $query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'"); - foreach($query as $row) - { + foreach($query as $row) { $location_options[$row->lid] = $row->booking_roomlocation_descrip; } - if ($create == true) - { + if ($create == true) { $data = $node; $prefix = t("

Create new room defintion.

"); //watchdog('booking', 'Creating new room definition: @info', array ('@info' => var_export($node, TRUE))); } - else - { + else { //verify that $editid is a number if (! preg_match('/^[0-9]+$/', $room_id)) { drupal_set_message("Error: Invalid room ID supplied. Unable to update room definition.", 'error', FALSE); drupal_goto('admin/config/booking/rooms'); return ""; } - - //$data = $form_state['input']; - $data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id", - array(':id' => $room_id)) - ->fetchObject(); $prefix = t("

Update the room defintions.

"); + + //$data = $form_state['input']; + $data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id", array(':id' => $room_id)) + ->fetchObject(); + //add this to the form in a hidden field so we can update the right price - $form['booking_rid'] = array ( + $form['booking_rid'] = array( '#type' => 'hidden', '#value' => $room_id, ); @@ -343,15 +341,14 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = } //create the options array for bed counts - for ($i = 0; $i <= 15; $i++) + for ($i = 0; $i <= 15; $i++) { $bedcount_options[$i] = $i; + } //define the form for adding to the room definitions - if(!isset($form_state['storage']['confirm'])) { - $form[] = array ( - 'first_heading' => array ( + 'first_heading' => array( '#type' => 'markup', '#markup' => $prefix, ), @@ -363,26 +360,33 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = '#options' => $location_options, '#default_value' => !empty($data->booking_room_location_id) ? $data->booking_room_location_id : '' ); - $form['booking_room_number'] = array ( + $form['booking_room_number'] = array( '#type' => 'textfield', '#title' => t('Specify room number'), '#size' => 5, '#maxlength' => 10, '#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '', ); - $form['booking_room_singlebeds'] = array ( + $form['booking_room_description'] = array( + '#type' => 'textfield', + '#title' => t('Specify room label (not mandatory)'), + '#size' => 50, + '#maxlength' => 100, + '#default_value' => !empty($data->booking_room_description) ? $data->booking_room_description : '', + ); + $form['booking_room_singlebeds'] = array( '#type' => 'select', '#title' => t('Specify number of single beds'), '#options' => $bedcount_options, '#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '', ); - $form['booking_room_doublebeds'] = array ( + $form['booking_room_doublebeds'] = array( '#type' => 'select', '#title' => t('Specify number of double beds'), '#options' => $bedcount_options, '#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '', ); - $form['booking_room_queenbeds'] = array ( + $form['booking_room_queenbeds'] = array( '#type' => 'select', '#title' => t('Specify number of queen beds'), '#options' => $bedcount_options, @@ -394,21 +398,18 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = '#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0, ); - if ($create == true) - { - $form['submit'] = array - ( + if ($create == true) { + $form['submit'] = array( '#type' => 'submit', '#value' => t('Add Room'), ); - } else { - $form['Update'] = array - ( + } + else { + $form['Update'] = array( '#type' => 'submit', '#value' => t('Update Room'), ); - $form['Delete'] = array - ( + $form['Delete'] = array( '#type' => 'submit', '#value' => t('Delete Room'), ); @@ -418,12 +419,10 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = 'form' => $form, ); } - else - { + else { return confirm_form($form, "Are you sure you wish to delete room definition with id " . $room_id . "?", current_path(), NULL, "Delete Room"); } - } /** @@ -437,30 +436,28 @@ function booking_rooms_definition_form_submit($form, &$form_state) { //watchdog('booking', "
Room definition submission:\n@info
", array('@info' => print_r( $form_state, true))); //if we're deleting, add the confirmation to the form if it hasn't been defined yet - if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) - { + if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) { //watchdog('booking', "
Room deletion confirmation being set:\n@info
", array('@info' => print_r( $form_state, true))); $form_state['storage']['confirm'] = TRUE; $form_state['rebuild'] = TRUE; - } - elseif ($form_state['values']['op'] == 'Delete Room') - { + } + elseif ($form_state['values']['op'] == 'Delete Room') { //delete the room watchdog('booking', "Deleting room ID !rid", array('!rid' => $values['booking_rid'])); - + db_delete('booking_room_definition') ->condition('rid', $values['booking_rid']) ->execute(); - + drupal_set_message('Deleted room id ' . $values['booking_rid'] ); $form_state['redirect'] = $redirect_path; } - elseif ($form_state['values']['op'] == 'Update Room') - { + elseif ($form_state['values']['op'] == 'Update Room') { $result = db_update('booking_room_definition') ->fields(array( - 'booking_room_location_id' => $values['booking_room_location_id'], - 'booking_room_number' => $values['booking_room_number'], + 'booking_room_location_id' => $values['booking_room_location_id'], + 'booking_room_number' => $values['booking_room_number'], + 'booking_room_description' => $values['booking_room_description'], 'booking_room_singlebeds' => $values['booking_room_singlebeds'], 'booking_room_doublebeds' => $values['booking_room_doublebeds'], 'booking_room_queenbeds' => $values['booking_room_queenbeds'], @@ -475,8 +472,9 @@ function booking_rooms_definition_form_submit($form, &$form_state) { { db_insert('booking_room_definition') ->fields(array( - 'booking_room_location_id' => $values['booking_room_location_id'], - 'booking_room_number' => $values['booking_room_number'], + 'booking_room_location_id' => $values['booking_room_location_id'], + 'booking_room_number' => $values['booking_room_number'], + 'booking_room_description' => $values['booking_room_description'], 'booking_room_singlebeds' => $values['booking_room_singlebeds'], 'booking_room_doublebeds' => $values['booking_room_doublebeds'], 'booking_room_queenbeds' => $values['booking_room_queenbeds'], From 63226d93f005ef59b6ff0741b3c00da70efee3ea Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 11:34:50 +1000 Subject: [PATCH 19/42] fix USN --- booking.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.install b/booking.install index ef87142..8440949 100644 --- a/booking.install +++ b/booking.install @@ -588,7 +588,7 @@ function booking_update_7237() { /** * Add description field to room definitions */ -function booking_update_7237() { +function booking_update_7238() { $spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE); db_add_field('booking_room_definition', 'booking_room_description', $spec); //update the view to match the new table definition From b3b4fef4d2fba90bbf898c112d8236ecf0115095 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 11:48:33 +1000 Subject: [PATCH 20/42] add room descriptions to view room allocations page --- booking.rooms.inc | 48 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index a742d88..f85a1ae 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -421,10 +421,9 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { } $location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id", - array(':id' => $location_id)) - ->fetchObject(); - - //$prefix = t("

Room Allocations for !room

", array('!room' => _booking_room_location_lookup($location_id))); + array(':id' => $location_id)) + ->fetchObject(); + $prefix = t("

Room Allocations for !room

", array('!room' => $location_description->booking_roomlocation_descrip)); //query for room definitions @@ -444,7 +443,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { array(':eid' => $event->eid))->fetchAllAssoc('nid'); //define the header - $header = array ( + $header = array( 'booking_room_number' => array('data' => t('Room Number')), 'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), @@ -453,27 +452,23 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { 'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')), ); - foreach ($room_query as $data) - { + foreach ($room_query as $data) { //load the existing bed mappings for this room $existing_beds = array(); - for ($i = 1; $i <= 3; $i++) - { - foreach ($room_mapping as $mapping) - { + for ($i = 1; $i <= 3; $i++) { + foreach ($room_mapping as $mapping) { //check that the room id in the mapping table matches the room that we're currently adding to the table //and also the bed type matches the first dimension in the array - if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) - { + if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) { $existing_beds[$i][] = $mapping->booking_nodeid; } } } //create a row that contains just the room location and number - $rows[] = array ( + $rows[] = array( 'data' => array( - $data->booking_room_number, + $data->booking_room_number . " ‐ " . $data->booking_room_description, "", "", "", @@ -484,12 +479,11 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { ); //create an additional row for each single bed - for ($i = 0; $i < $data->booking_room_singlebeds; $i++) - { + for ($i = 0; $i < $data->booking_room_singlebeds; $i++) { //retrieve the default value if one exists $nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0; - $rows[] = array ( + $rows[] = array( 'data' => array( "", _booking_rooms_view_formatperson($attendees, $nid), @@ -504,9 +498,8 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { //create an additional row for each double bed //$j is our counter that increments twice as fast as $i to cater for both beds $j = 0; - for ($i = 0; $i < $data->booking_room_doublebeds; $i++) - { - $rows[] = array ( + for ($i = 0; $i < $data->booking_room_doublebeds; $i++) { + $rows[] = array( 'data' => array( "", "", @@ -521,9 +514,8 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { //create an additional row for each queen bed //$j is our counter that increments twice as fast as $i to cater for both beds $j = 0; - for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) - { - $rows[] = array ( + for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) { + $rows[] = array( 'data' => array( "", "", @@ -539,15 +531,15 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { //watchdog('booking', "
Room assignment report rows:\n@info
", array('@info' => print_r( $rows, true))); - $result = array ( - '#attached' => array ( + $result = array( + '#attached' => array( 'css' => array(drupal_get_path('module', 'booking') . '/booking.css') ), - 'first_para' => array ( + 'first_para' => array( '#type' => 'markup', '#markup' => $prefix, ), - 'table' => array ( + 'table' => array( '#theme' => 'table', '#header' => $header, '#rows' => $rows, From d2dc15451885eaa7a0e178ec9483bcddc427e860 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 11:51:26 +1000 Subject: [PATCH 21/42] add room description to room allocation page --- booking.rooms_allocate.inc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/booking.rooms_allocate.inc b/booking.rooms_allocate.inc index fb3d870..d13a5b1 100644 --- a/booking.rooms_allocate.inc +++ b/booking.rooms_allocate.inc @@ -71,6 +71,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { $header = array ( 'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'), 'booking_room_number' => array('data' => t('Room Number')), + 'booking_room_description' => array('data' => t('Room Label')), 'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), @@ -97,24 +98,21 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { $default_row = array(); $default_row['booking_room_location'] = ""; $default_row['booking_room_number'] = ""; + $default_row['booking_room_description'] = ""; $default_row['booking_room_singlebed'] = ""; $default_row['booking_room_doublebed_p1'] = ""; $default_row['booking_room_doublebed_p2'] = ""; $default_row['booking_room_queenbed_p1'] = ""; $default_row['booking_room_queenbed_p2'] = ""; - foreach ($room_query as $data) - { + foreach ($room_query as $data) { //create an array representing the existing bed mappings for this room $existing_beds = array(); - for ($i = 1; $i <= 3; $i++) - { - foreach ($room_mapping as $mapping) - { + for ($i = 1; $i <= 3; $i++) { + foreach ($room_mapping as $mapping) { //check that the room id in the mapping table matches the room that we're currently adding to the table //and also the bed type matches the first dimension in the array - if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) - { + if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) { $existing_beds[$i][] = $mapping->booking_lastname . ', ' . $mapping->booking_firstname . ' [' . $mapping->booking_nodeid . ']'; } } @@ -125,6 +123,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { //$new_row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id); $new_row['booking_room_location'] = $data->booking_roomlocation_descrip; $new_row['booking_room_number'] = $data->booking_room_number; + $new_row['booking_room_description'] = $data->booking_room_description; $form['rooms']['#rows'][$counter++] = array( 'data' => $new_row, 'id' => array("new-group-row"), From 1aa9f6cfbe9c433cb1e27d087dc9e66be5cdfba4 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 27 Jun 2016 11:53:25 +1000 Subject: [PATCH 22/42] move room label to dedicated column --- booking.rooms.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index f85a1ae..c3eb247 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -445,6 +445,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { //define the header $header = array( 'booking_room_number' => array('data' => t('Room Number')), + 'booking_room_description' => array('data' => t('Room Label')), 'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), @@ -468,7 +469,8 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { //create a row that contains just the room location and number $rows[] = array( 'data' => array( - $data->booking_room_number . " ‐ " . $data->booking_room_description, + $data->booking_room_number, + $data->booking_room_description, "", "", "", @@ -485,6 +487,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $rows[] = array( 'data' => array( + "", "", _booking_rooms_view_formatperson($attendees, $nid), "", @@ -501,6 +504,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { for ($i = 0; $i < $data->booking_room_doublebeds; $i++) { $rows[] = array( 'data' => array( + "", "", "", _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), @@ -520,6 +524,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { "", "", "", + "", "", _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), From d5d45512c6e73aa8fee976d6f365f1119fc62bfa Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 13:12:55 +1000 Subject: [PATCH 23/42] update room number field to be an integer --- booking.helper.inc | 37 +++++++++++++++++++++++++++++++++++++ booking.install | 12 +++++++++++- booking.reports.inc | 3 ++- booking.rooms_admin.inc | 12 ++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/booking.helper.inc b/booking.helper.inc index f8329bc..3634600 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1657,6 +1657,43 @@ function _booking_room_email_summary($node) { return implode("\n", $rows); } +/** + * Helper function to create the mean, median, mode or average of an array + * @see http://www.phpsnips.com/45/Mean,-Median,-Mode,-Range-Of-An-Array + */ +function _booking_mmmr($array, $output = 'mean'){ + if(!is_array($array)) { + return FALSE; + } + else { + switch($output){ + case 'mean': + $count = count($array); + $sum = array_sum($array); + $total = $sum / $count; + break; + case 'median': + rsort($array); + $middle = round(count($array) / 2); + $total = $array[$middle-1]; + break; + case 'mode': + $v = array_count_values($array); + arsort($v); + foreach($v as $k => $v){$total = $k; break;} + break; + case 'range': + sort($array); + $sml = $array[0]; + rsort($array); + $lrg = $array[0]; + $total = $lrg - $sml; + break; + } + return $total; + } +} + /** * @brief Generates a Universally Unique IDentifier, version 4. * diff --git a/booking.install b/booking.install index 8440949..04d8eef 100644 --- a/booking.install +++ b/booking.install @@ -595,6 +595,16 @@ function booking_update_7238() { _booking_node_create_mysqlview(); } +/** +* Change room number field in room definitions to integer +*/ +function booking_update_7239() { + $spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0); + db_change_field('booking_room_definition', 'booking_room_number', 'booking_room_number', $spec); + //update the view to match the new table definition + _booking_node_create_mysqlview(); +} + /** * Implementation of hook_install(). */ @@ -926,7 +936,7 @@ function booking_schema() { 'fields' => array( 'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_room_location_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), - 'booking_room_number' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_room_number' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_singlebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), diff --git a/booking.reports.inc b/booking.reports.inc index f8443fa..565849f 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -279,7 +279,8 @@ function booking_report_summary() { )); $output .= t("

Ages

"); $output .= t("

The combined average age at the start of the week will be !average.
The male average age will be !maleaverage.
The female average age will be !femaleaverage.

", - array('!average' => _booking_avg_age($dob_total, $male_count + $female_count, $event->booking_event_start), '!maleaverage' => _booking_avg_age($male_dob_total, $male_count, $event->booking_event_start), + array('!average' => _booking_avg_age($dob_total, $male_count + $female_count, $event->booking_event_start), + '!maleaverage' => _booking_avg_age($male_dob_total, $male_count, $event->booking_event_start), '!femaleaverage' => _booking_avg_age($female_dob_total, $female_count, $event->booking_event_start) )); $output .= t("

Finances

"); diff --git a/booking.rooms_admin.inc b/booking.rooms_admin.inc index 428907e..725e247 100644 --- a/booking.rooms_admin.inc +++ b/booking.rooms_admin.inc @@ -425,6 +425,18 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id = } } +/** + * Validate the form for adding room definitions + */ +function booking_rooms_definition_form_validate($form, $form_state) { + //make sure room number is numerical + $values = $form_state['input']; + + if (! is_numeric($values['booking_room_number'])) { + form_set_error('booking_room_number', t('Room number must be numeric. If you need to use a more descriptive label, please use the room label field.')); + } +} + /** * Process the form for adding room definitions */ From 69442d30b5433ba39aa7a9d70efd576a4f7200c3 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 13:17:38 +1000 Subject: [PATCH 24/42] add ensuite info to room allocations page --- booking.module | 7 +++---- booking.rooms_allocate.inc | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/booking.module b/booking.module index a64131a..2404fc0 100644 --- a/booking.module +++ b/booking.module @@ -440,11 +440,10 @@ function booking_menu() { } //configure study groups - if (variable_get('booking_enable_studygroups', 0) == 1) - { + if (variable_get('booking_enable_studygroups', 0) == 1) { //the config pages for study groups $items['admin/config/booking/studygroups'] = array( - 'title' => 'Booking Module Study Group Configuration', + 'title' => 'Booking module Study Group configuration', 'description' => 'Define and configure Study Groups for the Booking module', 'page callback' => 'booking_studygroups_admin', 'access arguments' => array('administer site configuration'), @@ -583,7 +582,7 @@ function booking_menu() { //config pages $items['admin/config/booking/rooms'] = array( 'title' => 'Booking module room definitions', - 'description' => 'View and Configure room definitions for the Event Booking module', + 'description' => 'View and configure Room Definitions for the Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_rooms_view_definitions'), 'access arguments' => array('administer site configuration'), diff --git a/booking.rooms_allocate.inc b/booking.rooms_allocate.inc index d13a5b1..1e78923 100644 --- a/booking.rooms_allocate.inc +++ b/booking.rooms_allocate.inc @@ -72,6 +72,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { 'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'), 'booking_room_number' => array('data' => t('Room Number')), 'booking_room_description' => array('data' => t('Room Label')), + 'booking_room_ensuite' => array('data' => t('Ensuite?')), 'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), @@ -99,6 +100,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { $default_row['booking_room_location'] = ""; $default_row['booking_room_number'] = ""; $default_row['booking_room_description'] = ""; + $default_row['booking_room_ensuite'] = ""; $default_row['booking_room_singlebed'] = ""; $default_row['booking_room_doublebed_p1'] = ""; $default_row['booking_room_doublebed_p2'] = ""; @@ -124,6 +126,7 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { $new_row['booking_room_location'] = $data->booking_roomlocation_descrip; $new_row['booking_room_number'] = $data->booking_room_number; $new_row['booking_room_description'] = $data->booking_room_description; + $new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No"; $form['rooms']['#rows'][$counter++] = array( 'data' => $new_row, 'id' => array("new-group-row"), From 06df0a185612ca51d7dd567811dcdb9442938176 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 13:30:16 +1000 Subject: [PATCH 25/42] add ensuite info to booking_rooms_view_form() as well as change to an associative array --- booking.rooms.inc | 62 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index c3eb247..645a65f 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -446,14 +446,36 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $header = array( 'booking_room_number' => array('data' => t('Room Number')), 'booking_room_description' => array('data' => t('Room Label')), + 'booking_room_ensuite' => array('data' => t('Ensuite?')), 'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), 'booking_room_queenbed_p1' => array('data' => t('Queen Bed Person 1')), 'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')), ); + + //define the default fields in a table row + $default_row = array(); + $default_row['booking_room_number'] = ""; + $default_row['booking_room_description'] = ""; + $default_row['booking_room_ensuite'] = ""; + $default_row['booking_room_singlebed'] = ""; + $default_row['booking_room_doublebed_p1'] = ""; + $default_row['booking_room_doublebed_p2'] = ""; + $default_row['booking_room_queenbed_p1'] = ""; + $default_row['booking_room_queenbed_p2'] = ""; foreach ($room_query as $data) { + //create a row that contains just the room location and number and the custom css id for a separating line between the rooms + $new_row = _booking_clone_array($default_row); + $new_row['booking_room_number'] = $data->booking_room_number; + $new_row['booking_room_description'] = $data->booking_room_description; + $new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No"; + $rows[] = array( + 'data' => $new_row, + 'id' => array("new-group-row"), + ); + //load the existing bed mappings for this room $existing_beds = array(); for ($i = 1; $i <= 3; $i++) { @@ -464,13 +486,15 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $existing_beds[$i][] = $mapping->booking_nodeid; } } - } + } //end creating existing room mappings for this room + /* //create a row that contains just the room location and number $rows[] = array( 'data' => array( $data->booking_room_number, $data->booking_room_description, + $data->booking_room_ensuite == 'Y' ? "Yes" : "No", "", "", "", @@ -478,15 +502,22 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { "", ), 'id' => array("new-group-row"), - ); + ); + */ //create an additional row for each single bed for ($i = 0; $i < $data->booking_room_singlebeds; $i++) { //retrieve the default value if one exists $nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0; - + $new_row = _booking_clone_array($default_row); + $new_row['booking_room_singlebed'] = _booking_rooms_view_formatperson($attendees, $nid); + $rows[] = array( + 'data' => $new_row, + ); + /* $rows[] = array( 'data' => array( + "", "", "", _booking_rooms_view_formatperson($attendees, $nid), @@ -495,41 +526,60 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { "", "", ), - ); + ); + */ } //create an additional row for each double bed //$j is our counter that increments twice as fast as $i to cater for both beds $j = 0; for ($i = 0; $i < $data->booking_room_doublebeds; $i++) { + $new_row = _booking_clone_array($default_row); + $new_row['booking_room_doublebed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); + $new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); + $rows[] = array( + 'data' => $new_row, + ); + /* $rows[] = array( 'data' => array( "", "", "", + "", _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), "", "", ), - ); + ); + */ } //create an additional row for each queen bed //$j is our counter that increments twice as fast as $i to cater for both beds $j = 0; for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) { + $new_row = _booking_clone_array($default_row); + $new_row['booking_room_queenbed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); + $new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); + $rows[] = array( + 'data' => $new_row, + ); + /* $rows[] = array( 'data' => array( "", "", "", "", + "", "", _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), ), - ); + ); + */ } } From 3694e37db4b2ce8329e78a95897e41b700488906 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 13:33:33 +1000 Subject: [PATCH 26/42] cleanup --- booking.rooms.inc | 68 +++-------------------------------------------- 1 file changed, 4 insertions(+), 64 deletions(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index 645a65f..14a9fdd 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -487,24 +487,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { } } } //end creating existing room mappings for this room - - /* - //create a row that contains just the room location and number - $rows[] = array( - 'data' => array( - $data->booking_room_number, - $data->booking_room_description, - $data->booking_room_ensuite == 'Y' ? "Yes" : "No", - "", - "", - "", - "", - "", - ), - 'id' => array("new-group-row"), - ); - */ - + //create an additional row for each single bed for ($i = 0; $i < $data->booking_room_singlebeds; $i++) { //retrieve the default value if one exists @@ -514,20 +497,6 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $rows[] = array( 'data' => $new_row, ); - /* - $rows[] = array( - 'data' => array( - "", - "", - "", - _booking_rooms_view_formatperson($attendees, $nid), - "", - "", - "", - "", - ), - ); - */ } //create an additional row for each double bed @@ -539,21 +508,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); $rows[] = array( 'data' => $new_row, - ); - /* - $rows[] = array( - 'data' => array( - "", - "", - "", - "", - _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), - _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), - "", - "", - ), - ); - */ + ); } //create an additional row for each queen bed @@ -565,24 +520,9 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); $rows[] = array( 'data' => $new_row, - ); - /* - $rows[] = array( - 'data' => array( - "", - "", - "", - "", - "", - "", - _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), - _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0), - ), - ); - */ + ); } - - } + } //end room iteration loop //watchdog('booking', "
Room assignment report rows:\n@info
", array('@info' => print_r( $rows, true))); From d6619aa5ee6f7a380a6804edc76a60244723affb Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 13:36:22 +1000 Subject: [PATCH 27/42] update --- booking.rooms.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index 14a9fdd..cf1d3ce 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -411,6 +411,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { global $event; $rows = array(); $form = array(); + $prefix = t("

Room Allocations for !room

", array('!room' => $location_description->booking_roomlocation_descrip)); //verify that $location_id is a number if (! preg_match('/^[0-9]+$/', $location_id)) { @@ -419,15 +420,15 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { drupal_goto('admin/booking/rooms'); return ""; } + + //@todo reduce the number of queries by using some joins $location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id", array(':id' => $location_id)) ->fetchObject(); - $prefix = t("

Room Allocations for !room

", array('!room' => $location_description->booking_roomlocation_descrip)); - //query for room definitions - $room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid", + $room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid ORDER BY booking_room_number", array(':lid' => $location_id)); //query for existing room allocations From ecaa11d70d0ef49bec3fbf8921506b80a373e306 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 17:21:56 +1000 Subject: [PATCH 28/42] bugfix --- booking.rooms.inc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/booking.rooms.inc b/booking.rooms.inc index cf1d3ce..8a38cd8 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -411,7 +411,6 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { global $event; $rows = array(); $form = array(); - $prefix = t("

Room Allocations for !room

", array('!room' => $location_description->booking_roomlocation_descrip)); //verify that $location_id is a number if (! preg_match('/^[0-9]+$/', $location_id)) { @@ -426,11 +425,12 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { $location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id", array(':id' => $location_id)) ->fetchObject(); - + //use the query result to include a human friendly group name + $prefix = t("

Room Allocations for !room

", array('!room' => $location_description->booking_roomlocation_descrip)); //query for room definitions $room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid ORDER BY booking_room_number", array(':lid' => $location_id)); - + //query for existing room allocations $room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid)); @@ -506,7 +506,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { for ($i = 0; $i < $data->booking_room_doublebeds; $i++) { $new_row = _booking_clone_array($default_row); $new_row['booking_room_doublebed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); - $new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); + $new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0); $rows[] = array( 'data' => $new_row, ); @@ -518,7 +518,7 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) { $new_row = _booking_clone_array($default_row); $new_row['booking_room_queenbed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); - $new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); + $new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0); $rows[] = array( 'data' => $new_row, ); @@ -558,8 +558,7 @@ function _booking_rooms_view_formatperson(&$attendees, $nid) { $output = "Empty"; - if ($nid > 0 && !empty($attendees[$nid])) - { + if ($nid > 0 && !empty($attendees[$nid])) { $output = $attendees[$nid]->booking_firstname . " " . $attendees[$nid]->booking_lastname; } From a1c091a03cbe87d7f6af06a740074df27e934b65 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 21:41:59 +1000 Subject: [PATCH 29/42] tweak to text in _booking_leader_helper_email_summary token --- booking.helper.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.helper.inc b/booking.helper.inc index 3634600..59fd200 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1614,7 +1614,7 @@ function _booking_leader_helper_email_summary($node) { $otherperson_phone = $other->booking_mobile; } - $rows[] = t('!role for !descrip (section !id). Your !otherrole is !other. You can contact them on !phone or !email.', + $rows[] = t('!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.', array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip, '!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email, )); From a4da6d2d932e6e530b35d55553bc53433a474073 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 28 Jun 2016 21:48:55 +1000 Subject: [PATCH 30/42] code refactor --- booking.helper.inc | 53 +++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/booking.helper.inc b/booking.helper.inc index 59fd200..96e609d 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1538,58 +1538,35 @@ function _booking_leader_helper_email_summary($node) { $found = FALSE; //display study session data if enabled - if (variable_get('booking_enable_studygroups', 0) == 1) - { + 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 <= variable_get('booking_studygroup_count','0'); $i++) - //for ($i = 1; $i <= count($studygroups); $i++) - foreach ($studygroups as $studygroup) - { + + foreach ($studygroups as $studygroup) { //don't print info about the readings groups - //if ($i == variable_get('booking_readinggroup_id','7')) - // continue; - - //if ($studygroups[$i]->booking_is_readinggroup == 'Y') - // continue; - - if ($studygroup->booking_is_readinggroup == 'Y') + if ($studygroup->booking_is_readinggroup == 'Y') { continue; + } //calculate the session references - //$sessionid = "session" . $i; $sessionid = "session" . $studygroup->sid; $roleid = $sessionid . "_role"; $otherperson_name = "TBA"; $otherperson_email = ""; $otherperson_phone = ""; - //check that this study group session has been defined for this attendee and that they - if (!empty($node->$sessionid) && $node->$roleid > 0) - { - /* - //make sure we only add this prefix text once, as soon as we've found a matching role - if ($found == FALSE) - { - $found = TRUE; - $rows[] = t("You have been assigned to perform the following roles for study groups:"); - } - */ - - //TODO: use a function for this. + //check that this study group session has been defined for this attendee and that they have a role to perform + if (!empty($node->$sessionid) && $node->$roleid > 0) { //if they're a leader or reserver leader, then the matching person is the helper - if ($node->$roleid == 1 || $node->$roleid == 3) - { + if ($node->$roleid == 1 || $node->$roleid == 3) { $role = "Leader"; $otherrole = "Helper"; $otherrole_id = 2; } //otherwise the matching person is the leader - else - { + else { $role = "Helper"; $otherrole = "Leader"; $otherrole_id = 1; @@ -1606,9 +1583,9 @@ function _booking_leader_helper_email_summary($node) { //watchdog('booking', "
Other person for studygroup !group and role !role result:\n@info
", // array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true))); - - foreach ($otherperson as $other) - { + + //create the text for the token + foreach ($otherperson as $other) { $otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname; $otherperson_email = $other->booking_email; $otherperson_phone = $other->booking_mobile; @@ -1618,14 +1595,14 @@ function _booking_leader_helper_email_summary($node) { array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip, '!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email, )); - } } } - foreach ($rows as $key => $value) + //format the output to be used in an email + foreach ($rows as $key => $value) { $rows[$key] = wordwrap($value); - + } return implode("\n", $rows); } From 7934d0718c0749412d942b36132617ffa977517e Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 16:40:05 +1000 Subject: [PATCH 31/42] add reserve helper role to studygroups --- booking.constants.inc | 12 ++++---- booking.studygroup_leaders.inc | 53 +++++++++++++++++++--------------- booking.studygroups.inc | 7 ++--- booking.studygroups_admin.inc | 5 ++-- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/booking.constants.inc b/booking.constants.inc index 6d46a6a..14b3d67 100644 --- a/booking.constants.inc +++ b/booking.constants.inc @@ -108,18 +108,20 @@ function _get_tshirt_options() { * @param $input integer containing role id * @return string for corresponding role */ -function _booking_studygroup_role_lookup($input = NULL) -{ +function _booking_studygroup_role_lookup($input = NULL) { $role = array(); $role[] = t('No Role'); $role[] = t('Leader'); $role[] = t('Helper'); $role[] = t('Reserve Leader'); - - if ($input != NULL) + $role[] = t('Reserve Helper'); + + if ($input != NULL) { return $role[$input]; - else + } + else { return $role; + } } /** diff --git a/booking.studygroup_leaders.inc b/booking.studygroup_leaders.inc index 2c3e915..5fa363a 100644 --- a/booking.studygroup_leaders.inc +++ b/booking.studygroup_leaders.inc @@ -2,11 +2,9 @@ /** * @file - * Functions for calculating leaders and helpers for discussion groups + * Functions for automatically calculating leaders and helpers for discussion groups */ - - /** * Function for calculating and assigning leaders and helpers to active study group sessions */ @@ -66,20 +64,16 @@ function _booking_get_next_studygroup($type, $studygroups) { $count = count($studygroups) - 1; - for ($i = 0; $i < $count; $i++) - { + for ($i = 0; $i < $count; $i++) { $group = $studygroups[$i]; $leader = $group->leader_nid; //watchdog('booking_debug', "
Study Group Element at index $i:\n@info
", array('@info' => print_r( $group, true))); //watchdog('booking_debug', "
Study Group Leader NID at index $i:\n@info
", array('@info' => var_dump($group))); - if ($leader == 0) - { + if ($leader == 0) { return $i; } - } - } /** @@ -101,9 +95,7 @@ function _booking_studygroups_retrieve_eligible_people() { $bookedin_result = $query->execute(); //iterate over the attendee associative array and add some fields - foreach ($bookedin_result as $person) - { - + foreach ($bookedin_result as $person) { $person->processed = 0; $person->leading = array(); $person->helping = array(); @@ -124,9 +116,7 @@ function _booking_studygroups_retrieve_eligible_people() { array(':eid' => $event->eid)); //iterate over the attendee associative array and add some fields - foreach ($result2 as $person) - { - + foreach ($result2 as $person){ $person->processed = 0; $person->leading = array(); $person->helping = array(); @@ -156,11 +146,9 @@ function _booking_studygroups_retrieve_groups() { //assume they all have the same number of sessions //$num_sessions = $studygroup->booking_num_group_sessions; - foreach ($group_mapping as $group) - { + foreach ($group_mapping as $group) { //watchdog('booking_debug', "
Study Group Element:\n@info
", array('@info' => print_r( $group, true))); - for ($i = 1; $i <= 16; $i++) - { + for ($i = 1; $i <= 16; $i++) { $new_group = clone $group; $new_group->session_id = $i; @@ -278,8 +266,8 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) { //create an array representing the existing leaders/helpers for this group $existing_leaders = array(); foreach ($session_members as $person) { - $existing_leaders[$person->booking_session_id][$person->booking_studygroup_role] = $person->booking_lastname - . ', ' . $person->booking_firstname . ' [' . $person->booking_node_id . ']'; + $existing_leaders[$person->booking_session_id][$person->booking_studygroup_role] = + $person->booking_lastname . ', ' . $person->booking_firstname . ' [' . $person->booking_node_id . ']'; } //create the rows for the individual sessions (instances really) of this study group @@ -318,29 +306,47 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) { '#autocomplete_path' => 'booking/studygroups/autocomplete', '#value' => (!empty($existing_leaders[$i][3])) ? $existing_leaders[$i][3] : '', '#attributes' => array('style' => array('width:200px')), - ); + ); + + $reservehelper = array ( + '#id' => 'booking-studygroup-reservehelper-' . $i, + '#type' => 'textfield', + '#title' => 'Name', + '#title_display' => 'invisible', + '#name' => 'booking_studygroup_reservehelper[' . $i . ']', + '#size' => 100, + '#autocomplete_path' => 'booking/studygroups/autocomplete', + '#value' => (!empty($existing_leaders[$i][4])) ? $existing_leaders[$i][4] : '', + '#attributes' => array('style' => array('width:200px')), + ); $form['studygroups'][$i] = array( 'booking-studygroup-leader' => &$leader, 'booking-studygroup-helper' => &$helper, 'booking-studygroup-reserveleader' => &$reserveleader, + 'booking-studygroup-reservehelper' => &$reservehelper, ); $new_row = array(); + //handle readings group differently if ($studygroup->booking_is_readinggroup == 'Y') { $new_row['sid'] = _booking_readinggroup_colour_lookup($i); } + //non readings groups just show the session ID else { $new_row['sid'] = $i; } $new_row['booking_studygroup_leader'] = array('data' => &$leader); $new_row['booking_studygroup_helper'] = array('data' => &$helper); $new_row['booking_studygroup_reserveleader'] = array('data' => &$reserveleader); + $new_row['booking_studygroup_reservehelper'] = array('data' => &$reservehelper); $form['studygroups']['#rows'][$i] = $new_row; - + + //clean up references unset($leader); unset($helper); unset($reserveleader); + unset($reservehelper); } //record whether this was a reading group, so we can update colours if necessary @@ -376,6 +382,7 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) { 'booking_studygroup_leader' => 1, 'booking_studygroup_helper' => 2, 'booking_studygroup_reserveleader' => 3, + 'booking_studygroup_reservehelper' => 4, ); //iterate over the different role types diff --git a/booking.studygroups.inc b/booking.studygroups.inc index f1a64db..5c63184 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -23,6 +23,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) 1 => "leader-row", 2 => "helper-row", 3 => "reserveleader-row", + 4 => "reservehelper-row", ); //verify that $group_id is a number @@ -126,8 +127,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) $assigned_role = $role; $session_id = $group->booking_session_id; //list any role for this current group - if ($role > 0) - { + if ($role > 0) { $text = _booking_studygroup_role_lookup($role); $role_listing .= "" . $text . " group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; $class = $class_array[$role]; @@ -400,8 +400,7 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) { //retrieve the number of study group sessions, assume they all have the same number of sessions $num_sessions = reset($studygroups)->booking_num_group_sessions; //create the array for our html select fields - for ($i = 1; $i <= $num_sessions; $i++) - { + for ($i = 1; $i <= $num_sessions; $i++) { $session_options[$i] = $i; $readinggroup_options[$i] = _booking_readinggroup_colour_lookup($i); } diff --git a/booking.studygroups_admin.inc b/booking.studygroups_admin.inc index e0d9769..b4cd5ca 100644 --- a/booking.studygroups_admin.inc +++ b/booking.studygroups_admin.inc @@ -38,7 +38,6 @@ function booking_studygroups_admin() { $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); return $output; - } /** @@ -175,7 +174,9 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid = } - +/** + * Process addition/update/delete of a studygroup definition + */ function booking_studygroups_define_form_submit($form, &$form_state) { global $event; From af95616e879748d4513ea1a79c4f04a0a2bc409f Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 16:43:32 +1000 Subject: [PATCH 32/42] add missing column heading --- booking.studygroup_leaders.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/booking.studygroup_leaders.inc b/booking.studygroup_leaders.inc index 5fa363a..6194b8f 100644 --- a/booking.studygroup_leaders.inc +++ b/booking.studygroup_leaders.inc @@ -223,7 +223,8 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) { 'sid' => array('data' => t('Study Group Session ID'), 'field' => 'sid'), 'booking_assign_leader' => array('data' => t('Leader')), 'booking_assign_helper' => array('data' => t('Helper')), - 'booking_assign_reserveleader' => array('data' => t('Reserve Leader')), + 'booking_assign_reserveleader' => array('data' => t('Reserve Leader')), + 'booking_assign_reservehelper' => array('data' => t('Reserve Helper')), ); //attach the custom css From 9ceabb97c7128bae336a521b0dc7a7ba14839c84 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 16:45:32 +1000 Subject: [PATCH 33/42] fix missing references to reserve helper --- booking.studygroups.inc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 5c63184..2b6d378 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -1279,6 +1279,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { 1 => "leader-row", 2 => "helper-row", 3 => "reserveleader-row", + 4 => "reservehelper-row", ); //attach the custom css @@ -1348,11 +1349,9 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { $class = $class_array[$data->booking_studygroup_role]; //only add the lines separating groups if we're sorting by the session id - if ($sort['sql'] == "m.booking_session_id") - { + if ($sort['sql'] == "m.booking_session_id") { //Add a different id for first entry of new session, with a border-top to distinguish it - if ($last_session <> $data->booking_session_id) - { + if ($last_session <> $data->booking_session_id) { switch ($data->booking_studygroup_role) { case 1: $class = "leader-new-group-row"; @@ -1363,6 +1362,9 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { case 3: $class = "reserveleader-new-group-row"; break; + case 4: + $class = "reservehelper-new-group-row"; + break; default: $class = "new-group-row"; @@ -1394,14 +1396,6 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { } $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 ( '#attached' => array ( 'css' => array(drupal_get_path('module', 'booking') . '/booking.css') @@ -1416,8 +1410,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { '#rows' => $rows, '#attributes' => array('id' => 'sort-table'), //'#sticky' => FALSE, - ) - //'form' => $form, + ) ); } From 9011220ecc6d4885eedcb166de8fb13898257dec Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 17:52:08 +1000 Subject: [PATCH 34/42] add css for reserve helper --- booking.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/booking.css b/booking.css index 43ae415..fd7d50f 100644 --- a/booking.css +++ b/booking.css @@ -1,10 +1,12 @@ #leader-row {background: #6495ED;} #helper-row {background: #9dd781;} #reserveleader-row {background: #d4dc5c;} +#reservehelper-row {background: #d4dc5c;} #new-group-row {border-top: thick double #ff0000;} #leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;} #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} +#reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} /* test for email page*/ /* tr.normal-row.odd {} */ /* tr.normal-row.even {} */ From 4e4dcf1cc9fc12c1bc93a7596cb0f2cf54a4d4f7 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:05:09 +1000 Subject: [PATCH 35/42] testing change from ID to class for role highlighting --- booking.css | 6 ++++++ booking.studygroups.inc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/booking.css b/booking.css index fd7d50f..383beac 100644 --- a/booking.css +++ b/booking.css @@ -1,12 +1,18 @@ +/* #leader-row {background: #6495ED;} #helper-row {background: #9dd781;} #reserveleader-row {background: #d4dc5c;} #reservehelper-row {background: #d4dc5c;} +*/ #new-group-row {border-top: thick double #ff0000;} #leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;} #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} #reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} +tr[class="leader-row"] {background: #6495ED;} +tr[class="helper-row"] {background: #9dd781;} +tr[class="reserveleader-row"] {background: #d4dc5c;} +tr[class="reservehelper-row"] {background: #d4dc5c;} /* test for email page*/ /* tr.normal-row.odd {} */ /* tr.normal-row.even {} */ diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 2b6d378..8a11d6a 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -1389,7 +1389,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { $data->booking_committee_member == 'Y' ? 'Yes' : 'No', $data->booking_session_manually_allocated == 'Y' ? 'Yes' : 'No', ), - 'id' => array($class), + 'class' => array($class), ); $last_session = $data->booking_session_id; From 4512dd9107570be6716181842aea33bd7b782ebf Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:09:13 +1000 Subject: [PATCH 36/42] css test --- booking.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/booking.css b/booking.css index 383beac..160eedf 100644 --- a/booking.css +++ b/booking.css @@ -9,8 +9,8 @@ #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} #reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} -tr[class="leader-row"] {background: #6495ED;} -tr[class="helper-row"] {background: #9dd781;} +tr[class*="leader-row"] {background: #6495ED;} +tr[class="helper-row*"] {background: #9dd781;} tr[class="reserveleader-row"] {background: #d4dc5c;} tr[class="reservehelper-row"] {background: #d4dc5c;} /* test for email page*/ From 352ef5803392e97d44e6df52a62e7d64924704d6 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:10:57 +1000 Subject: [PATCH 37/42] test --- booking.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking.css b/booking.css index 160eedf..c06fbb1 100644 --- a/booking.css +++ b/booking.css @@ -9,7 +9,7 @@ #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} #reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} -tr[class*="leader-row"] {background: #6495ED;} +tr[class*="leader-row*"] {background: #6495ED;} tr[class="helper-row*"] {background: #9dd781;} tr[class="reserveleader-row"] {background: #d4dc5c;} tr[class="reservehelper-row"] {background: #d4dc5c;} From 7002020efdfd8a513b757714f86f2538e370245b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:13:01 +1000 Subject: [PATCH 38/42] test --- booking.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/booking.css b/booking.css index c06fbb1..836838b 100644 --- a/booking.css +++ b/booking.css @@ -9,10 +9,14 @@ #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} #reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} -tr[class*="leader-row*"] {background: #6495ED;} -tr[class="helper-row*"] {background: #9dd781;} -tr[class="reserveleader-row"] {background: #d4dc5c;} -tr[class="reservehelper-row"] {background: #d4dc5c;} +tr.leader-row.odd {background: #6495ED;} +tr.leader-row.even {background: #6495ED;} +tr.helper-row.odd {background: #9dd781;} +tr.helper-row.even {background: #9dd781;} +tr.reserveleader-row.odd {background: #d4dc5c;} +tr.reserveleader-row.odd {background: #d4dc5c;} +tr.reservehelper-row.odd {background: #d4dc5c;} +tr.reservehelper-row.odd {background: #d4dc5c;} /* test for email page*/ /* tr.normal-row.odd {} */ /* tr.normal-row.even {} */ From 5c8b7d662fa4765fa1e60415c4e6c574578a6a40 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:16:05 +1000 Subject: [PATCH 39/42] undo test --- booking.css | 19 ++++++++++--------- booking.studygroups.inc | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/booking.css b/booking.css index 836838b..9772d25 100644 --- a/booking.css +++ b/booking.css @@ -1,22 +1,23 @@ -/* #leader-row {background: #6495ED;} #helper-row {background: #9dd781;} #reserveleader-row {background: #d4dc5c;} #reservehelper-row {background: #d4dc5c;} +/* +tr.leader-row.odd {background: #6495ED;} +tr.leader-row.even {background: #6495ED;} +tr.helper-row.odd {background: #9dd781;} +tr.helper-row.even {background: #9dd781;} +tr.reserveleader-row.odd {background: #d4dc5c;} +tr.reserveleader-row.even {background: #d4dc5c;} +tr.reservehelper-row.odd {background: #d4dc5c;} +tr.reservehelper-row.even {background: #d4dc5c;} */ #new-group-row {border-top: thick double #ff0000;} #leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;} #helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} #reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} #reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} -tr.leader-row.odd {background: #6495ED;} -tr.leader-row.even {background: #6495ED;} -tr.helper-row.odd {background: #9dd781;} -tr.helper-row.even {background: #9dd781;} -tr.reserveleader-row.odd {background: #d4dc5c;} -tr.reserveleader-row.odd {background: #d4dc5c;} -tr.reservehelper-row.odd {background: #d4dc5c;} -tr.reservehelper-row.odd {background: #d4dc5c;} + /* test for email page*/ /* tr.normal-row.odd {} */ /* tr.normal-row.even {} */ diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 8a11d6a..8327779 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -1374,7 +1374,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { $session = $group->booking_is_readinggroup == 'Y' ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id; - $rows[] = array ( + $rows[] = array( 'data' => array( $session, l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)), @@ -1389,7 +1389,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { $data->booking_committee_member == 'Y' ? 'Yes' : 'No', $data->booking_session_manually_allocated == 'Y' ? 'Yes' : 'No', ), - 'class' => array($class), + 'id' => array($class), ); $last_session = $data->booking_session_id; From a6dc9a61d2d00c3457b6befdc1764095bc17af3b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 29 Jun 2016 19:17:59 +1000 Subject: [PATCH 40/42] change colours --- booking.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/booking.css b/booking.css index 9772d25..48f20e8 100644 --- a/booking.css +++ b/booking.css @@ -12,11 +12,11 @@ tr.reserveleader-row.even {background: #d4dc5c;} tr.reservehelper-row.odd {background: #d4dc5c;} tr.reservehelper-row.even {background: #d4dc5c;} */ -#new-group-row {border-top: thick double #ff0000;} -#leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;} -#helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} -#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} -#reservehelper-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} +#new-group-row {border-top: thick double black;} +#leader-new-group-row {background: #6495ED; border-top: thick double black;} +#helper-new-group-row {background: #9dd781; border-top: thick double black;} +#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double black;} +#reservehelper-new-group-row {background: #d4dc5c; border-top: thick double black;} /* test for email page*/ /* tr.normal-row.odd {} */ From f2c6858634cd52cca9da9024f9d647e66e3f5f4a Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 3 Jul 2016 23:45:09 +1000 Subject: [PATCH 41/42] Make age output optional --- booking.studygroups_report.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/booking.studygroups_report.inc b/booking.studygroups_report.inc index 2411ea1..c1cddd0 100644 --- a/booking.studygroups_report.inc +++ b/booking.studygroups_report.inc @@ -49,8 +49,13 @@ function booking_studygroups_csv_report($group_id) { if (! isset($data[$member->booking_session_id])) { $data[$member->booking_session_id] = array(); } - // lookup the name and role for this entry in the study group session - $text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']'); + // lookup the name and role for this entry in the study group session and optionally include age + if (variable_get('booking_studygroup_csv_ages', 0) == 1) { + $text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']'); + } + else { + $text = array($member->booking_firstname, $member->booking_lastname); + } //add their role if they're leading/helping etc if ($member->booking_studygroup_role > 0) { array_push($text, '(' . _booking_studygroup_role_lookup($member->booking_studygroup_role) . ')'); From e404501cda407741ce84d2dfe673d5a0d7c65c91 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 3 Jul 2016 23:47:03 +1000 Subject: [PATCH 42/42] Add option for including age groups --- booking.admin.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/booking.admin.inc b/booking.admin.inc index e6b9f59..1b8f577 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -238,7 +238,13 @@ function booking_admin() { '#options' => array(0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_friendly_csv_groupnames', 0), ); - + $form['features']['booking_studygroup_csv_ages'] = array( + '#type' => 'radios', + '#title' => t('Include ages in study group CSV export?'), + '#description' => t('Select whether to inclde ages for attendees when exporting study groups to CSV.'), + '#options' => array(0 => t('No'), t('Yes')), + '#default_value' => variable_get('booking_studygroup_csv_ages', 0), + ); $form['misc'] = array( '#type' => 'fieldset', '#title' => 'Configuration Options'