implement earlyaccess code summary

This commit is contained in:
2017-06-29 14:23:18 +10:00
parent 5f9465dd59
commit 241f1e02e2

View File

@@ -5,41 +5,64 @@
* Admin pages for managing early access codes * 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 to summarise information about early access codes
*/ */
function booking_earlyaccess_admin() { 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; global $event;
$output = ""; $output = "";
$header = array('Study Group', 'Session Count', 'Reading Group?', 'Edit Definition');
$rows = array(); $rows = array();
$attributes = array('style' => 'max-width:60%'); $attributes = array('style' => 'max-width:60%', 'id' => 'sort-table');
//$attributes = array(); $prefix = t("<h2>Early Access Codes</h2>");
//get study groups $header = array(
$query = db_select('booking_studygroup_list', 's') 'booking_regn_earlyaccess_code' => array('data' => t('Code'), 'field' => 'c.booking_regn_earlyaccess_code', 'sort' => 'asc'),
->fields('s') 'booking_regn_earlyaccess_code_avail' => array('data' => t('Available?'), 'field' => 'c.booking_regn_earlyaccess_code_avail'),
->condition('s.booking_eventid', $event->eid, '='); 'booking_firstname' => array('data' => t('First Name'), 'field' => 'p.booking_firstname'),
$result = $query->execute(); 'booking_lastname' => array('data' => t('Last Name'), 'field' => 'p.booking_lastname'),
);
foreach ($result as $group) { //get a list of all the early access codes for this event
$rows[] = array( $codelist_query = db_select('booking_regn_earlyaccess_codes', 'c');
$group->booking_studygroup_descrip, $codelist_query->leftJoin('booking_person', 'p', 'c.cid = p.booking_earlyaccess_code_id');
$group->booking_num_group_sessions, $codelist_query->condition('c.booking_eventid', $event->eid, '=')
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No', ->fields('c')
l(t('Edit Group Definition', array('!id' => $group->sid)), t('admin/config/booking/studygroups/!id/edit', array('!id' => $group->sid))), ->fields('p')
); ->orderBy('cid');
} $result = $codelist_query->execute();
//output everything //add results to array
$output .= t("<h3>!event Study Groups</h3>", array('!event' => $event->booking_eventname)); foreach($result as $data) {
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); $rows[] = array(
'data' => array(
$data->booking_regn_earlyaccess_code,
$data->booking_regn_earlyaccess_code_avail == 'Y' ? 'Yes' : 'No',
$data->booking_firstname,
$data->booking_lastname,
),
);
}
return $output; //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;
} }
/** /**