diff --git a/admin/reports.inc.php b/admin/reports.inc.php index 4f882e20..e3a83c05 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -652,8 +652,7 @@ foreach($report_stock as $n=>$v) { $group_change = false; /* See if any of the "group" fields have changed */ foreach($report['group'] as $x=>$g) { - $f = $g['field']; - $c = $fieldname[$f]; + $c = $fieldname[$g['field']]; if($last_group_data[$c] != $i[$c]) $group_change = true; $last_group_data[$c] = $i[$c]; @@ -697,7 +696,7 @@ foreach($report_stock as $n=>$v) { if(is_array($fields[$f]['value_map'])) { $v = $fields[$f]['value_map'][$i["C$o"]]; } else if(is_callable($fields[$f]['exec_function'])) { - $v = call_user_func_array($fields[$f]['exec_function'], array($i["C$o"])); + $v = call_user_func_array($fields[$f]['exec_function'], array($report, $i["C$o"])); // } else if(isset($fields[$f]['exec_code'])) { // Somethign like this, how do we pass $i["C$o"] in? // $v = exec($fields[$f]['exec_code']); diff --git a/admin/reports_students.inc.php b/admin/reports_students.inc.php index 636c35eb..d46b9abd 100644 --- a/admin/reports_students.inc.php +++ b/admin/reports_students.inc.php @@ -21,11 +21,20 @@ Boston, MA 02111-1307, USA. */ -function report_students_i18n_fr($text) +function report_students_i18n_fr(&$report, $text) { return i18n($text, array(), array(), 'fr'); } +function reports_students_numstudents(&$report, $text) +{ + $year = $report['year']; + $q = mysql_query("SELECT students.id FROM students + WHERE students.registrations_id='$text' + AND students.year='$year'"); + return mysql_num_rows($q); +} + $report_students_fields = array( 'pn' => array( 'name' => 'Project Number', @@ -190,9 +199,8 @@ $report_students_fields = array( 'name' => 'Project -- Number of Students', 'header' => 'Stu.', 'width' => 0.5, - 'table' => 'COUNT(numstudents.id)', - 'components' => array('numstudents'), - 'group_by' => array('numstudents.id') ), + 'table' => 'students.registrations_id', + 'exec_function' => 'reports_students_numstudents'), 'address' => array( 'name' => 'Student Address -- Street Address', @@ -524,13 +532,6 @@ $report_students_fields = array( AND award_types.year='$year' "; } - if(in_array('numstudents', $components)) { - /* This requires some extra gymnastics and will duplicate - * students/projects if they have won multiple awards */ - $numstudents_join = "LEFT JOIN students AS numstudents ON students.registrations_id=numstudents.registrations_id"; - $numstudents_where = " AND numstudents.year='$year'"; - } - if(in_array('awards_nominations', $components)) { $awards_join = "LEFT JOIN project_specialawards_link ON(projects.id=project_specialawards_link.projects_id), @@ -574,7 +575,6 @@ $report_students_fields = array( $tour_join $awards_join $partner_join - $numstudents_join WHERE students.year='$year' AND projects.year='$year' @@ -584,7 +584,6 @@ $report_students_fields = array( AND (registrations.status='complete' OR registrations.status='paymentpending') $awards_where $tour_where - $numstudents_where "; return $q;