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

@@ -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;
}