new report for leaders/helpers

This commit is contained in:
Nathan Coad
2016-06-08 12:03:41 +10:00
parent 4d06713fea
commit e3030316d6
2 changed files with 77 additions and 17 deletions

View File

@@ -292,7 +292,21 @@ function booking_menu() {
'page arguments' => array(3), //include the temporary id
'access arguments' => array('access booking form'),
'type' => MENU_SUGGESTED_ITEM,
);
);
$items['coming'] = array(
'title' => "Who's Coming?",
'page callback' => 'booking_coming_page',
'access arguments' => array("access coming list"),
'type' => MENU_NORMAL_ITEM,
);
$items['waitinglist'] = array(
'title' => "Who's on the waiting list?",
'page callback' => 'booking_waitinglist_page',
'access arguments' => array("access waiting list"),
'type' => MENU_NORMAL_ITEM,
);
//Various reports
$items['admin/booking/summary'] = array(
@@ -347,21 +361,6 @@ function booking_menu() {
'access arguments' => array('import bookings'),
'type' => MENU_NORMAL_ITEM,
);
$items['coming'] = array(
'title' => "Who's Coming?",
'page callback' => 'booking_coming_page',
'access arguments' => array("access coming list"),
'type' => MENU_NORMAL_ITEM,
);
$items['waitinglist'] = array(
'title' => "Who's on the waiting list?",
'page callback' => 'booking_waitinglist_page',
'access arguments' => array("access waiting list"),
'type' => MENU_NORMAL_ITEM,
);
//show flight info report only if we have passport info enabled
if (variable_get('booking_enable_passport', 0) == 1)
@@ -478,7 +477,17 @@ function booking_menu() {
'page callback' => 'booking_studygroups_view_summary',
'access arguments' => array("view study groups"),
'type' => MENU_NORMAL_ITEM,
);
);
//@todo a nice report with everyone's studygroup membership
$items['admin/booking/studygroups/report/leadershelpers'] = array(
'title' => 'View Studygroup Leaders and Helpers',
'description' => 'View Studygroup Leaders and Helpers',
'page callback' => 'booking_studygroups_leadhelp_view_summary',
'access arguments' => array("view study groups"),
'type' => MENU_LOCAL_ACTION,
);
$items['admin/booking/studygroups/calculateleaders'] = array(
'title' => 'Calculate Study Group Leaders',

View File

@@ -99,4 +99,55 @@ function booking_studygroups_csv_report($group_id) {
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
print $csv;
exit(0);
}
/**
* Function to generate table listing all males and groups they're leading/helping
*/
function booking_studygroups_leadhelp_view_summary() {
global $event;
$output = "";
$header = array('First Name', 'Last Name');
$rows = array();
$attributes = array('style' => 'max-width:60%');
//select entries from the study groups mapping table
$query = db_select('booking_studygroup_mapping', 'm');
$query->join('booking_studygroup_list', 's', 's.sid = m.booking_studygroup_id');
$query->condition('m.booking_eventid', $event->eid, '=');
$query->fields('m')->fields('s', array('booking_studygroup_descrip'));
$group_mapping = $query->execute()->fetchAllAssoc('sid');
foreach ($group_mapping as $group) {
$header[] = $group->booking_studygroup_descrip;
}
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_gender = 'M' ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
foreach ($person_query as $person) {
//add the name to an array for this line
$newline = array($person->booking_firstname, $person->booking_lastname);
//go through each of the studygroups and check if the person belongs to the group
foreach ($group_mapping as $group) {
$role = $group->booking_studygroup_role;
if ($group->booking_node_id == $data->nid && $role > 0) {
$text = _booking_studygroup_role_lookup($role);
$newline[] .= "<b>" . $text . "</b> for session #" . $group->booking_session_id;
}
else {
$newline[] = "";
}
}
//add the line to the array of rows
$rows[] = $newline;
}
//output everything
$output .= t("<h3>!event Study Group Leaders and Helpers</h3>", array('!event' => $event->booking_eventname));
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
return $output;
}