- 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;
switch($report['type']) {
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_volunteers_fields); break;
}
$fieldvar = "report_{$report['type']}s_fields";
$allow_fields = array_keys($$fieldvar);
/* First delete all existing fields */
mysql_query("DELETE FROM reports_items
@ -233,6 +227,7 @@ foreach($stock as $n=>$v) {
$r = mysql_fetch_assoc($q);
$report['name'] = $r['name'];
$report['id'] = $r['id'];
$report['system_report_id'] = $r['system_report_id'];
$report['desc'] = $r['desc'];
$report['creator'] = $r['creator'];
$report['type'] = $r['type'];
@ -245,15 +240,8 @@ foreach($stock as $n=>$v) {
$report['filter'] = array();
$report['loc'] = array();
$allow_fields = array();
switch($report['type']) {
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;
}
$fieldvar = "report_{$report['type']}s_fields";
$allow_fields = array_keys($$fieldvar);
$q = mysql_query("SELECT * FROM reports_items
WHERE reports_id='{$report['id']}'
@ -384,14 +372,8 @@ foreach($stock as $n=>$v) {
global $filter_ops;
//print_r($report);
switch($report['type']) {
case 'student': $fields = $report_students_fields; break;
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;
}
$fieldvar = "report_{$report['type']}s_fields";
$fields = $$fieldvar;
$gen_mode = '';
$fieldname = array();
@ -521,16 +503,8 @@ foreach($stock as $n=>$v) {
$filter_query = " AND ".implode(" AND ", $filter);
}
$q = '';
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;
}
$func = "report_{$report['type']}s_fromwhere";
$q = call_user_func_array($func, array($report, $components));
$q = "SELECT $sel $q $filter_query $group_query ORDER BY $order";

View File

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