From 8d8bcdad942427e71def68d36a61364ea66d0ce0 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 31 Mar 2010 04:07:26 +0000 Subject: [PATCH] Add available in round1,round2 to the judge report --- admin/reports_judges.inc.php | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/admin/reports_judges.inc.php b/admin/reports_judges.inc.php index eb770c3..c599268 100644 --- a/admin/reports_judges.inc.php +++ b/admin/reports_judges.inc.php @@ -201,7 +201,58 @@ function report_judges_team_members(&$report, $field, $text) } } return $ret; +} + + +//$round_special_awards = array(); +$report_judges_rounds = array(); +function report_judges_load_rounds($year) +{ + global $config, $report_judges_rounds; + if(count($report_judges_rounds)) return ; + + $q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `year`='$year'"); + /* Loads judges_timeslots.id, .starttime, .endtime, .date, .name */ + while($r = mysql_fetch_assoc($q)) { + $report_judges_rounds[] = $r; + + if($r['type'] == 'divisional1') $report_judges_rounds['divisional1'] = $r; + if($r['type'] == 'divisional2') $report_judges_rounds['divisional2'] = $r; + } +// if($r['type'] == 'special') $round_special_awards[] = $r; +} + +function report_judges_time_availability(&$report, $field, $text) +{ + global $config, $report_judges_rounds; + $year = $report['year']; + $users_id = $text; + + report_judges_load_rounds($year); + + switch($field) { + case 'available_in_divisional1': + $round = $report_judges_rounds['divisional1']; + break; + case 'available_in_divisional2': + $round = $report_judges_rounds['divisional2']; + break; + default: + echo "Not implemented."; + exit; + } + + $q = mysql_query("SELECT * FROM judges_availability WHERE users_id='$users_id'"); +// echo mysql_error(); + while(($r = mysql_fetch_assoc($q))) { + if($r['start'] <= $round['starttime'] + && $r['end'] >= $round['endtime'] + && $r['date'] == $round['date'] ) { + return 'Yes'; + } + } + return 'No'; } /* Components: languages, teams */ @@ -527,6 +578,20 @@ $report_judges_fields = array( 'exec_function' => 'report_judges_cat_pref', 'components' => array('users_judge')), +/* Time Availability */ + 'available_in_divisional1' => array( + 'name' => 'Time Availability -- Available in Divisional Round 1 ', + 'header' => 'R1', + 'width' => 0.5, + 'exec_function' => 'report_judges_time_availability', + 'table' => 'users.id'), + 'available_in_divisional2' => array( + 'name' => 'Time Availability -- Available in Divisional Round 2 ', + 'header' => 'R2', + 'width' => 0.5, + 'exec_function' => 'report_judges_time_availability', + 'table' => 'users.id'), + /* Others */ 'special_award_only' => array(