implement earlyaccess code summary
This commit is contained in:
@@ -5,40 +5,63 @@
|
||||
* 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();
|
||||
$attributes = array('style' => 'max-width:60%', 'id' => 'sort-table');
|
||||
$prefix = t("<h2>Early Access Codes</h2>");
|
||||
|
||||
//get study groups
|
||||
$query = db_select('booking_studygroup_list', 's')
|
||||
->fields('s')
|
||||
->condition('s.booking_eventid', $event->eid, '=');
|
||||
$result = $query->execute();
|
||||
$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'),
|
||||
);
|
||||
|
||||
foreach ($result as $group) {
|
||||
//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(
|
||||
$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))),
|
||||
'data' => array(
|
||||
$data->booking_regn_earlyaccess_code,
|
||||
$data->booking_regn_earlyaccess_code_avail == 'Y' ? 'Yes' : 'No',
|
||||
$data->booking_firstname,
|
||||
$data->booking_lastname,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Study Groups</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
//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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user