From 6c61595cb9d080ce51aaddae8c7659ba290575d2 Mon Sep 17 00:00:00 2001
From: dave <dave>
Date: Thu, 20 Dec 2007 09:43:22 +0000
Subject: [PATCH] - Add an option to print ALL student names for a project
 (will work for more   than 2 students).

---
 admin/reports.inc.php          | 5 ++++-
 admin/reports_students.inc.php | 7 +++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/admin/reports.inc.php b/admin/reports.inc.php
index 664df570..49d2527e 100644
--- a/admin/reports.inc.php
+++ b/admin/reports.inc.php
@@ -528,6 +528,7 @@ foreach($report_stock as $n=>$v) {
 	$sel = array();
 	$x=0;
 	$group_by = array();
+	$post_group_by = array();
 	$components = array();
 	$order = array();
 
@@ -539,8 +540,9 @@ foreach($report_stock as $n=>$v) {
 		$table['dataalign'][] = 'left';
 		$sel[] = "{$fields[$f]['table']} AS C$x";
 		$fieldname[$f] = "C$x";
+		/* We want to add these to group by, but AFTER all the other group bys */
 		if(is_array($fields[$f]['group_by']))
-			$group_by = array_merge($group_by, $fields[$f]['group_by']);
+			$post_group_by = array_merge($group_by, $fields[$f]['group_by']);
 
 		if(is_array($fields[$f]['components'])) {
 			$components = array_merge($components, 
@@ -607,6 +609,7 @@ foreach($report_stock as $n=>$v) {
 		$report['year'] = $config['FAIRYEAR'];
 	}
 	
+	$group_by = array_merge($group_by, $post_group_by);
 	$group_query = "";
 	if(count($group_by)) {
 		$group_query = "GROUP BY ".implode(",", $group_by);
diff --git a/admin/reports_students.inc.php b/admin/reports_students.inc.php
index 365544f2..03312bf9 100644
--- a/admin/reports_students.inc.php
+++ b/admin/reports_students.inc.php
@@ -69,6 +69,13 @@ $report_students_fields = array(
 		'table_sort' => 'students.lastname',
 		'components' => array('partner') ),
 
+	'allnames' =>  array(
+		'name' => "Student -- All Student Names (REQUIRES MYSQL 5.0) ",
+		'header' => 'Student(s)',
+		'width' => 3.0,
+		'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')",
+		'group_by' => array('students.registrations_id')),
+
 	'email' => array(
 		'name' => 'Student -- Email',
 		'header' => 'Email',