diff --git a/booking.earlyaccess_admin.inc b/booking.earlyaccess_admin.inc index 73ff92b..f4428cc 100644 --- a/booking.earlyaccess_admin.inc +++ b/booking.earlyaccess_admin.inc @@ -5,41 +5,64 @@ * Admin pages for managing early access codes */ +// @todo - list all early access codes for the current event, whether they're available, and who used them if not + /** * Function to summarise information about early access codes */ function booking_earlyaccess_admin() { - - // @todo - list all early access codes for the current event, whether they're available, and who used them if not - global $event; $output = ""; - $header = array('Study Group', 'Session Count', 'Reading Group?', 'Edit Definition'); $rows = array(); - $attributes = array('style' => 'max-width:60%'); - //$attributes = array(); - - //get study groups - $query = db_select('booking_studygroup_list', 's') - ->fields('s') - ->condition('s.booking_eventid', $event->eid, '='); - $result = $query->execute(); - - foreach ($result as $group) { - $rows[] = array( - $group->booking_studygroup_descrip, - $group->booking_num_group_sessions, - $group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No', - l(t('Edit Group Definition', array('!id' => $group->sid)), t('admin/config/booking/studygroups/!id/edit', array('!id' => $group->sid))), - ); - } + $attributes = array('style' => 'max-width:60%', 'id' => 'sort-table'); + $prefix = t("

Early Access Codes

"); - //output everything - $output .= t("

!event Study Groups

", array('!event' => $event->booking_eventname)); - $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); + $header = array( + 'booking_regn_earlyaccess_code' => array('data' => t('Code'), 'field' => 'c.booking_regn_earlyaccess_code', 'sort' => 'asc'), + 'booking_regn_earlyaccess_code_avail' => array('data' => t('Available?'), 'field' => 'c.booking_regn_earlyaccess_code_avail'), + 'booking_firstname' => array('data' => t('First Name'), 'field' => 'p.booking_firstname'), + 'booking_lastname' => array('data' => t('Last Name'), 'field' => 'p.booking_lastname'), + ); - return $output; + //get a list of all the early access codes for this event + $codelist_query = db_select('booking_regn_earlyaccess_codes', 'c'); + $codelist_query->leftJoin('booking_person', 'p', 'c.cid = p.booking_earlyaccess_code_id'); + $codelist_query->condition('c.booking_eventid', $event->eid, '=') + ->fields('c') + ->fields('p') + ->orderBy('cid'); + $result = $codelist_query->execute(); + + //add results to array + foreach($result as $data) { + $rows[] = array( + 'data' => array( + $data->booking_regn_earlyaccess_code, + $data->booking_regn_earlyaccess_code_avail == 'Y' ? 'Yes' : 'No', + $data->booking_firstname, + $data->booking_lastname, + ), + ); + } + + //theme output + $output = array ( + 'first_para' => array ( + '#type' => 'markup', + '#markup' => $prefix, + ), + 'table' => array ( + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, + '#attributes' => $attributes, + //'#sticky' => FALSE, + ) + ); + + //return markup array + return $output; } /**