From 53ea1fd2fe700ceef6debd56f19c9632c63260cd Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 27 Jun 2014 15:06:19 +1000 Subject: [PATCH] Make it easier to see leaders and helpers in studygroup lists --- booking.css | 6 ++-- booking.helper.inc | 15 +++++++++ booking.module | 6 ++-- booking.studygroups.inc | 71 +++++++++++++++++++---------------------- 4 files changed, 54 insertions(+), 44 deletions(-) diff --git a/booking.css b/booking.css index 3b051f8..3f3f171 100644 --- a/booking.css +++ b/booking.css @@ -1,5 +1,7 @@ #leader-row {background: #6495ED;} -#helper-row {background: #6495ED;} +#helper-row {background: #9dd781;} +#reserveleader-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: #6495ED; border-top: thick double #ff0000;} \ No newline at end of file +#helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} +#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} \ No newline at end of file diff --git a/booking.helper.inc b/booking.helper.inc index 29d924c..fe44c36 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -136,6 +136,21 @@ function _booking_get_waitinglist_top() watchdog('booking', "First person on the waiting list: @info", array('@info' => var_export($person, TRUE))); return $person->nid; } + + //in case there's no people with status waiting list, but there is some with missed payment deadline + $result = db_query('SELECT p.nid, p.booking_firstname, p.booking_lastname, pay.booking_payment_date + FROM {booking_person} p, {booking_payment} pay + WHERE booking_status = 4 and booking_event_id = :eid and p.nid = pay.booking_person_nid + ORDER BY pay.booking_payment_date + LIMIT 1', + array(':eid' => $event->eid)); + + foreach ($result as $person) + { + watchdog('booking', "First person on the missed-payment-deadline list: @info", array('@info' => var_export($person, TRUE))); + return $person->nid; + } + //in case there was no one on the waiting list return -1; } diff --git a/booking.module b/booking.module index 8294993..aedf6f2 100644 --- a/booking.module +++ b/booking.module @@ -380,7 +380,7 @@ function booking_menu() { 'access arguments' => array('edit study groups'), //'type' => MENU_LOCAL_ACTION, ); - + /* $items['admin/booking/studygroups/calculate'] = array( 'title' => 'Calculate Study Groups', 'description' => 'Calculate Study Group memberships', @@ -389,7 +389,7 @@ function booking_menu() { 'access arguments' => array('edit study groups'), 'type' => MENU_LOCAL_ACTION, ); - + */ $items['admin/booking/studygroups/%/update'] = array( 'title' => 'Update Study Groups', 'description' => 'Calculate updated Study Group memberships', @@ -758,7 +758,7 @@ function booking_generate_luckynumbers() { $attendees = $attendee_query->fetchAll(); //assuming there's less than 900 people, generate numbers within that range and shuffle the order - $numbers = range(100,999); + $numbers = range(100,650); shuffle($numbers); foreach ($attendees as $attendee) diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 215ef57..a1bf193 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -51,7 +51,13 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) $group_options = array(); $session_options = array(); - + $class_array = array( + 0 => "normal-row", + 1 => "leader-row", + 2 => "helper-row", + 3 => "reserveleader-row", + ); + //verify that $group_id is a number if (! preg_match('/^[0-9]+$/', $group_id)) { drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to edit group leaders and helpers.", 'error', FALSE); @@ -69,6 +75,10 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) drupal_goto('admin/booking/studygroups'); return ""; } + + $form['#attached']['css'] = array( + drupal_get_path('module', 'booking') . '/booking.css', + ); $prefix = t("

Study Group ‐ !descrip

Allocate a leader/helper session for attendees.

", array('!descrip' => $studygroup->booking_studygroup_descrip)); @@ -129,6 +139,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) $role_listing = ""; $assigned_role = 0; $session_id = 0; + $class = $class_array[0]; //work out what this person is currently leading/helping foreach ($group_mapping as $group) @@ -151,7 +162,8 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) if ($role > 0) { $text = _booking_studygroup_role_lookup($role); - $role_listing .= "" . $text . " group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; + $role_listing .= "" . $text . " group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; + $class = $class_array[$role]; } } @@ -186,7 +198,8 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id) ) ), 'booking_currently_leadhelp' => $role_listing, - 'booking_group_edit' => l(t('Edit'), t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))), + 'booking_group_edit' => l(t('Edit'), t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))), + '#attributes' => array('id' => array($class)) ); } @@ -1614,7 +1627,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { 0 => "normal-row", 1 => "leader-row", 2 => "helper-row", - 3 => "helper-row", + 3 => "reserveleader-row", ); //attach the custom css @@ -1695,48 +1708,28 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) { //only add the lines separating groups if we're sorting by the session id if ($sort['sql'] == "m.booking_session_id") { - /* - if ($data->nid == "924") - { - watchdog('booking', 'Reading group test. Last session: !last. This session: !curr. Class: !class', - array ('!last' => $last_session, '!curr' => $data->booking_session_id, '!class' => $class)); - } - */ //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 ($data->booking_studygroup_role == 1) - { - $class = "leader-new-group-row"; + switch ($data->booking_studygroup_role) { + case 1: + $class = "leader-new-group-row"; + break; + case 2: + $class = "helper-new-group-row"; + break; + case 3: + $class = "reserveleader-new-group-row"; + break; + default: + $class = "new-group-row"; + } - elseif ($data->booking_studygroup_role == 2 || $data->booking_studygroup_role == 3) - { - $class = "helper-new-group-row"; - } - else - { - $class = "new-group-row"; - } - } - } + } //end class calculation $session = $is_reading_group == TRUE ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id; - /* - $options[$data->nid] = array ( - 'booking_session_id' => $session, - 'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)), - t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))), - 'booking_status' => _booking_status_generate($data->booking_status), - 'booking_studygroup_role' => _booking_studygroup_role_lookup($data->booking_studygroup_role), - 'booking_committee' => $data->booking_committee_member == 'Y' ? 'Yes' : 'No', - //'booking_is_leader' => $data->booking_is_leader == 'Y' ? 'Yes' : 'No', - //'booking_is_helper' => $data->booking_is_helper == 'Y' ? 'Yes' : 'No', - //'booking_is_reserveleader' => $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No', - '#attributes' => array('id' => array($class)) - ); - */ - + $rows[] = array ( 'data' => array( $session,