- Fix a bug in the student report generation

- Simplify the report generation logic for report types.
This commit is contained in:
dave 2007-11-21 21:55:31 +00:00
parent 311d9475dc
commit ac3e50f94e
2 changed files with 10 additions and 36 deletions

View File

@ -179,14 +179,8 @@ foreach($stock as $n=>$v) {
global $report_volunteers_fields; global $report_volunteers_fields;
switch($report['type']) { $fieldvar = "report_{$report['type']}s_fields";
case 'student': $allow_fields = array_keys($report_students_fields); break; $allow_fields = array_keys($$fieldvar);
case 'judge': $allow_fields = array_keys($report_judges_fields); break;
case 'award': $allow_fields = array_keys($report_awards_fields); break;
case 'committee':$allow_fields = array_keys($report_committees_fields); break;
case 'school': $allow_fields = array_keys($report_schools_fields); break;
case 'volunteer': $allow_fields=array_keys($report_volunteers_fields); break;
}
/* First delete all existing fields */ /* First delete all existing fields */
mysql_query("DELETE FROM reports_items mysql_query("DELETE FROM reports_items
@ -233,6 +227,7 @@ foreach($stock as $n=>$v) {
$r = mysql_fetch_assoc($q); $r = mysql_fetch_assoc($q);
$report['name'] = $r['name']; $report['name'] = $r['name'];
$report['id'] = $r['id']; $report['id'] = $r['id'];
$report['system_report_id'] = $r['system_report_id'];
$report['desc'] = $r['desc']; $report['desc'] = $r['desc'];
$report['creator'] = $r['creator']; $report['creator'] = $r['creator'];
$report['type'] = $r['type']; $report['type'] = $r['type'];
@ -245,15 +240,8 @@ foreach($stock as $n=>$v) {
$report['filter'] = array(); $report['filter'] = array();
$report['loc'] = array(); $report['loc'] = array();
$allow_fields = array(); $fieldvar = "report_{$report['type']}s_fields";
switch($report['type']) { $allow_fields = array_keys($$fieldvar);
case 'student': $allow_fields = array_keys($report_students_fields); break;
case 'judge': $allow_fields = array_keys($report_judges_fields); break;
case 'award': $allow_fields = array_keys($report_awards_fields); break;
case 'committee':$allow_fields = array_keys($report_committees_fields); break;
case 'school': $allow_fields = array_keys($report_schools_fields); break;
case 'volunteer':$allow_fields = array_keys($report_volunteer_fields); break;
}
$q = mysql_query("SELECT * FROM reports_items $q = mysql_query("SELECT * FROM reports_items
WHERE reports_id='{$report['id']}' WHERE reports_id='{$report['id']}'
@ -384,14 +372,8 @@ foreach($stock as $n=>$v) {
global $filter_ops; global $filter_ops;
//print_r($report); //print_r($report);
switch($report['type']) { $fieldvar = "report_{$report['type']}s_fields";
case 'student': $fields = $report_students_fields; break; $fields = $$fieldvar;
case 'judge': $fields = $report_judges_fields; break;
case 'award': $fields = $report_awards_fields; break;
case 'committee': $fields = $report_committees_fields; break;
case 'school': $fields = $report_schools_fields; break;
case 'volunteer': $fields = $report_volunteers_fields; break;
}
$gen_mode = ''; $gen_mode = '';
$fieldname = array(); $fieldname = array();
@ -521,16 +503,8 @@ foreach($stock as $n=>$v) {
$filter_query = " AND ".implode(" AND ", $filter); $filter_query = " AND ".implode(" AND ", $filter);
} }
$func = "report_{$report['type']}s_fromwhere";
$q = ''; $q = call_user_func_array($func, array($report, $components));
switch($report['type']) {
case 'student': $q = report_students_fromwhere($report, $components); break;
case 'judge': $q = report_judges_fromwhere($report, $components); break;
case 'award': $q = report_awards_fromwhere($report, $components); break;
case 'committee': $q = report_committees_fromwhere($report, $components); break;
case 'school': $q = report_schools_fromwhere($report, $components); break;
case 'volunteer': $q = report_volunteers_fromwhere($report, $components); break;
}
$q = "SELECT $sel $q $filter_query $group_query ORDER BY $order"; $q = "SELECT $sel $q $filter_query $group_query ORDER BY $order";

View File

@ -474,7 +474,7 @@ $report_students_fields = array(
$q = " FROM $q = " FROM
schools, projects $awards_join, projectdivisions, schools, projects $awards_join, projectdivisions,
projectcategories, registrations projectcategories, registrations
JOIN students ON students.registrations_id=registrations_id JOIN students ON students.registrations_id=registrations.id
$partner_join $partner_join
$emergencycontact_join $emergencycontact_join
$tour_join $tour_join