2009-09-09 00:26:12 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
2010-08-19 22:56:35 +00:00
require_once ( 'common.inc.php' );
require_once ( 'user.inc.php' );
require_once ( 'judge.inc.php' );
require_once ( " questions.inc.php " );
require_once ( 'user_edit.inc.php' );
/* Ensure they're logged in as a judge or admin */
user_auth_required ( array (), array ( 'judge' , 'admin' ));
$edit_id = isset ( $_GET [ 'users_id' ]) ? intval ( $_GET [ 'users_id' ]) : $_SESSION [ 'users_id' ];
if ( $edit_id != $_SESSION [ 'users_id' ])
user_auth_required ( 'admin' );
else
user_auth_required ();
2009-09-09 00:26:12 +00:00
2010-08-19 22:56:35 +00:00
$u = user_load ( $edit_id );
2009-09-26 19:22:30 +00:00
2010-08-31 07:23:49 +00:00
/* Load the judging rounds */
$times = array ();
$q = mysql_query ( " SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND year=' { $config [ 'FAIRYEAR' ] } ' ORDER BY starttime,type " );
$x = 0 ;
while ( $r = mysql_fetch_object ( $q )) {
$found = false ;
foreach ( $times as $xx => $t ) {
if ( $t [ 'date' ] == $r -> date && $t [ 'starttime' ] == $r -> starttime && $t [ 'endtime' ] == $r -> endtime ) {
$times [ $xx ][ 'name' ] .= " , { $r -> name } " ;
$found = true ;
break ;
}
}
if ( ! $found ) {
$times [ $x ] = array ( 'date' => $r -> date ,
'starttime' => $r -> starttime ,
'endtime' => $r -> endtime ,
'name' => $r -> name );
$x ++ ;
}
}
2009-09-26 19:22:30 +00:00
switch ( $_GET [ 'action' ]) {
case 'save' :
2009-09-09 00:26:12 +00:00
if ( ! is_array ( $_POST [ 'languages' ])) $_POST [ 'languages' ] = array ();
$u [ 'languages' ] = array ();
foreach ( $_POST [ 'languages' ] AS $val )
$u [ 'languages' ][] = $val ;
$u [ 'special_award_only' ] = ( $_POST [ 'special_award_only' ] == 'yes' ) ? 'yes' : 'no' ;
$u [ 'willing_chair' ] = ( $_POST [ 'willing_chair' ] == 'yes' ) ? 'yes' : 'no' ;
$u [ 'years_school' ] = intval ( $_POST [ 'years_school' ]);
$u [ 'years_regional' ] = intval ( $_POST [ 'years_regional' ]);
$u [ 'years_national' ] = intval ( $_POST [ 'years_national' ]);
$u [ 'highest_psd' ] = stripslashes ( $_POST [ 'highest_psd' ]);
user_save ( $u );
2010-08-19 22:56:35 +00:00
questions_save_answers ( " judgereg " , $u [ 'id' ], $_POST [ 'questions' ]);
2010-08-31 07:23:49 +00:00
mysql_query ( " DELETE FROM judges_availability WHERE users_id=' { $u [ 'id' ] } ' " );
if ( is_array ( $_POST [ 'time' ]) ) {
foreach ( $_POST [ 'time' ] as $x ) {
if ( trim ( $times [ $x ][ 'starttime' ]) == '' ) continue ;
mysql_query ( " INSERT INTO judges_availability (users_id, `date`,`start`,`end`)
VALUES ( '{$u[' id ']}' ,
'{$times[$x][' date ']}' ,
'{$times[$x][' starttime ']}' , '{$times[$x][' endtime ']}' ) " );
}
}
2009-09-26 19:22:30 +00:00
happy_ ( " Preferences successfully saved " );
2009-11-26 19:09:37 +00:00
2010-08-19 22:56:35 +00:00
$u = user_load ( $u [ 'id' ]);
2009-11-26 19:09:37 +00:00
$newstatus = judge_status_other ( $u );
2010-08-19 22:56:35 +00:00
?>
< script type = " text/javascript " >
user_update_tab_status ( 'judge' , '<?=$newstatus?>' );
</ script >
< ?
2009-09-26 19:22:30 +00:00
exit ;
}
2009-09-09 00:26:12 +00:00
2010-08-31 07:23:49 +00:00
$fields = array ( 'languages[]' , 'years_school' , 'years_regional' , 'years_national' , 'willing_chair' , 'highest_psd' , 'time[]' );
2010-08-19 22:56:35 +00:00
$required = array ( 'languages[]' );
2010-08-31 07:23:49 +00:00
if ( count ( $times ) > 1 ) $required [] = 'time[]' ;
2009-09-26 19:22:30 +00:00
?>
2010-08-19 22:56:35 +00:00
< h4 >< ? = i18n ( " Judge Information " ) ?> - <span class="status_judge"></span></h4>
2010-08-24 00:04:57 +00:00
< br />
2010-08-19 22:56:35 +00:00
< form class = " editor " id = " judgeother_form " >
< table width = " 90% " >
< tr >< td style = " text-align: left " colspan = " 2 " >< b >< ? = i18n ( 'Judging Language(s)' ) ?> </b><hr /></td></tr>
< tr >< ? = user_edit_item ( $u , 'Languages' , 'languages[]' , 'languages' ) ?> </tr>
2009-09-09 00:26:12 +00:00
2010-08-19 22:56:35 +00:00
< tr >< td style = " text-align: left " colspan = " 2 " >< br />< b >< ? = i18n ( 'Judging Experience' ) ?> </b><hr />
< i >< ? = i18n ( 'Please specify the number of years you\'ve judged at the following levels. This helps balance the experience on judging teams.' ) ?> </i>
</ td ></ tr >
< tr >< ? = user_edit_item ( $u , 'Judge at a School/District Fair' , 'years_school' , 'textbox' , 5 ) ?> </tr>
< tr >< ? = user_edit_item ( $u , 'Judge at a Regional Fair' , 'years_regional' , 'textbox' , 5 ) ?> </tr>
< tr >< ? = user_edit_item ( $u , 'Judge at a National Fair' , 'years_national' , 'textbox' , 5 ) ?> </tr>
2010-08-31 07:23:49 +00:00
< ? if ( count ( $times ) > 1 ) { ?>
< tr >< td style = " text-align: left " colspan = " 2 " >< br />< b >< ? = i18n ( 'Time Availability' ) ?> </b><hr />
< i >< ? = i18n ( 'Please specify the time(s) you are available to judge. You will be scheduled to judge in ALL (not just one) judging timeslot.' ) ?> </i>
</ td ></ tr >
< ?
/* Get all their available times */
$q = mysql_query ( " SELECT * FROM judges_availability WHERE users_id= \" { $u [ 'id' ] } \" ORDER BY `start` " );
$sel = array ();
while ( $r = mysql_fetch_object ( $q )) {
foreach ( $times as $x => $t ) {
if ( $r -> start == $t [ 'starttime' ] && $r -> end == $t [ 'endtime' ] && $r -> date == $t [ 'date' ])
$sel [] = $x ;
}
}
$items = array ();
foreach ( $times as $x => $t ) {
$st = substr ( $t [ 'starttime' ], 0 , 5 );
$end = substr ( $t [ 'endtime' ], 0 , 5 );
$items [ $x ] = " { $t [ 'name' ] } ( { $times [ $x ][ 'date' ] } $st - $end ) " ;
}
echo '<tr>' ;
user_edit_item ( $u , 'Time Availability' , 'time[]' , 'checklist' , $items , $sel );
echo '</tr>' ;
}
?>
2010-08-19 22:56:35 +00:00
< tr >< td style = " text-align: left " colspan = " 2 " >< br />< b >< ? = i18n ( 'Judging Questions' ) ?> </b><hr /></td></tr>
< tr >< ? = user_edit_item ( $u , 'I am willing to be the lead for my judging team' , 'willing_chair' , 'yesno' ) ?> </tr>
< tr >< ? = user_edit_item ( $u , 'Highest post-secondary degree' , 'highest_psd' , 'textbox' ) ?> </tr>
2009-09-09 00:26:12 +00:00
2009-11-26 19:09:37 +00:00
< ?
2010-08-19 22:56:35 +00:00
questions_print_answer_editor ( 'judgereg' , $u , 'questions' );
2009-11-26 19:09:37 +00:00
?>
2010-08-19 22:56:35 +00:00
</ table >
< br />
< button >< ? = i18n ( " Save Information " ) ?> </button>
</ form >
< script type = " text/javascript " >
function judgeother_save ()
2009-09-09 00:26:12 +00:00
{
2010-08-19 22:56:35 +00:00
$ ( " #debug " ) . load ( " <?= $config['SFIABDIRECTORY'] ?>/judge_other.php?action=save&users_id=<?= $u['id'] ?> " , $ ( " #judgeother_form " ) . serializeArray ());
return false ;
2009-09-09 00:26:12 +00:00
}
2010-08-19 22:56:35 +00:00
$ ( document ) . ready ( function () {
$ ( " #judgeother_form " ) . validate ({
errorPlacement : function ( error , element ) {
if ( element . attr ( 'type' ) == 'checkbox' ) {
error . insertAfter ( element . parent ( " span " ) );
} else {
error . insertAfter ( element );
}
},
rules : {
" languages[] " : { required : true },
2010-08-31 07:23:49 +00:00
" time[] " : { required : < ? = in_array ( 'time[]' , $required ) ? 'true' : 'false' ?> },
2010-08-19 22:56:35 +00:00
years_school : { min : 0 , max : 100 },
years_regional : { min : 0 , max : 100 },
years_national : { min : 0 , max : 100 }
},
messages : {
" languages[] " : { required : " <?=i18n('Please select the language(s) you can judge in')?> " },
2010-08-31 07:23:49 +00:00
" time[] " : { required : " <?=i18n('Please select the time(s) you are available for judging')?> " },
2010-08-19 22:56:35 +00:00
years_school : {
min : " <?=i18n('Please enter a valid number')?> " ,
max : " <?=i18n('Please enter a valid number')?> " ,
},
years_regional : {
min : " <?=i18n('Please enter a valid number')?> " ,
max : " <?=i18n('Please enter a valid number')?> " ,
},
years_national : {
min : " <?=i18n('Please enter a valid number')?> " ,
max : " <?=i18n('Please enter a valid number')?> " ,
}
},
submitHandler : function () {
judgeother_save ();
return false ;
},
cancelHandler : function () {
judgeother_save ();
return false ;
}
});
user_update_tab_status ( 'judge' );
2010-08-24 00:04:53 +00:00
2010-08-24 00:04:56 +00:00
// $("#judgeother_form").valid();
2010-08-19 22:56:35 +00:00
});
</ script >
2009-09-09 00:26:12 +00:00
2009-09-26 19:22:30 +00:00
< ?
2010-08-19 22:56:35 +00:00
/*
2009-09-09 00:26:12 +00:00
if ( $config [ 'judges_specialaward_only_enable' ] == 'yes' ) {
2010-08-19 22:56:35 +00:00
2009-09-26 19:22:30 +00:00
< tr >< td colspan = " 2 " >< hr /></ td ></ tr >
2009-12-14 20:25:38 +00:00
< tr >< td >< ? = i18n ( " I am a judge for a specific special award " ) ?> :</td>
< td >< table >< tr >< td >
2010-08-19 22:56:35 +00:00
2009-09-09 00:26:12 +00:00
$ch = ( $u [ 'special_award_only' ] == 'yes' ) ? 'checked="checked"' : '' ;
2009-09-26 19:22:30 +00:00
echo " <input $ch type= \" checkbox \" name= \" special_award_only \" value= \" yes \" /> " ;
2009-12-14 20:25:38 +00:00
echo " </td><td> " ;
echo i18n ( " Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page. " );
2010-08-19 22:56:35 +00:00
2009-12-14 20:25:38 +00:00
</ td ></ tr ></ table >
2009-09-26 19:22:30 +00:00
</ td ></ tr >
2009-09-09 00:26:12 +00:00
2010-08-19 22:56:35 +00:00
}
*/
2009-09-09 00:26:12 +00:00
?>