2005-04-19 18:36:03 +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 .
*/
?>
< ?
require ( " ../common.inc.php " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2010-07-13 03:30:17 +00:00
user_auth_required ( 'admin' );
2005-04-19 18:36:03 +00:00
require ( " judges.inc.php " );
2005-05-11 04:13:27 +00:00
require ( " ../projects.inc.php " );
2005-04-19 18:36:03 +00:00
2007-11-18 23:50:23 +00:00
send_header ( " Judging Teams Projects " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Judges' => 'admin/judges.php' )
);
2005-04-19 18:36:03 +00:00
?>
< script language = " javascript " type = " text/javascript " >
2005-04-19 19:22:25 +00:00
function assign ( ts )
2005-04-19 18:36:03 +00:00
{
2005-04-19 19:22:25 +00:00
document . forms . teamsprojects . timeslot . value = ts ;
document . forms . teamsprojects . submit ();
2005-04-19 18:36:03 +00:00
}
2005-05-06 19:14:56 +00:00
function eligibleclick ()
{
if ( document . forms . teamsprojects . showeligible . checked )
{
window . location . href = " judges_teams_projects.php?action=edit&edit= " + document . forms . teamsprojects . edit . value + " &judges_projects_list_eligible=true " ;
}
else
{
window . location . href = " judges_teams_projects.php?action=edit&edit= " + document . forms . teamsprojects . edit . value + " &judges_projects_list_eligible=false " ;
}
}
2005-04-19 18:36:03 +00:00
</ script >
< ?
echo " <br /> " ;
2005-04-19 19:22:25 +00:00
if ( $_GET [ 'action' ]) $action = $_GET [ 'action' ];
else if ( $_POST [ 'action' ]) $action = $_POST [ 'action' ];
if ( $_GET [ 'edit' ]) $edit = $_GET [ 'edit' ];
else if ( $_POST [ 'edit' ]) $edit = $_POST [ 'edit' ];
2005-04-21 17:00:49 +00:00
if ( ! $_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ])
$_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ] = 'unassigned' ;
//now update the judges_teams_list_show viewstate
if ( $_GET [ 'judges_projects_list_show' ])
$_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ] = $_GET [ 'judges_projects_list_show' ];
2005-05-06 19:14:56 +00:00
if ( ! $_SESSION [ 'viewstate' ][ 'judges_projects_list_eligible' ])
$_SESSION [ 'viewstate' ][ 'judges_projects_list_eligible' ] = 'true' ;
//now update the judges_teams_list_show viewstate
if ( $_GET [ 'judges_projects_list_eligible' ])
$_SESSION [ 'viewstate' ][ 'judges_projects_list_eligible' ] = $_GET [ 'judges_projects_list_eligible' ];
2005-04-19 19:22:25 +00:00
2005-04-21 20:29:08 +00:00
if ( $_GET [ 'action' ] == " delete " && $_GET [ 'delete' ] && $_GET [ 'edit' ])
{
mysql_query ( " DELETE FROM judges_teams_timeslots_projects_link WHERE id=' " . $_GET [ 'delete' ] . " ' " );
2005-04-19 19:22:25 +00:00
echo happy ( i18n ( " Judging team project successfully removed " ));
$action = " edit " ;
2005-04-21 20:29:08 +00:00
}
2005-04-19 18:36:03 +00:00
2005-04-21 20:29:08 +00:00
if ( $_POST [ 'action' ] == " assign " && $_POST [ 'edit' ] && $_POST [ 'timeslot' ] && $_POST [ 'project_id' ])
{
2005-04-19 19:22:25 +00:00
mysql_query ( " INSERT INTO judges_teams_timeslots_projects_link (judges_teams_id,judges_timeslots_id,projects_id,year) VALUES (' " . $_POST [ 'edit' ] . " ',' " . $_POST [ 'timeslot' ] . " ',' " . $_POST [ 'project_id' ] . " ',' " . $config [ 'FAIRYEAR' ] . " ') " );
echo happy ( i18n ( " Project assigned to team timeslot " ));
2005-04-21 20:29:08 +00:00
}
2005-04-19 18:36:03 +00:00
2005-04-21 20:29:08 +00:00
$q = mysql_query ( " SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' " );
if ( mysql_num_rows ( $q ) > 1 )
$show_date = true ;
else
$show_date = false ;
2005-04-19 18:36:03 +00:00
2005-04-21 20:29:08 +00:00
if ( ( $action == " edit " || $action == " assign " ) && $edit )
2005-04-19 18:36:03 +00:00
{
2005-04-19 19:22:25 +00:00
echo " <a href= \" judges_teams_projects.php \" >Back to Judging Teams Projects List</a> " ;
echo " <form name= \" teamsprojects \" method= \" post \" action= \" judges_teams_projects.php \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" assign \" > \n " ;
echo " <input type= \" hidden \" name= \" edit \" value= \" $edit\ " > \n " ;
echo " <input type= \" hidden \" name= \" timeslot \" value= \" \" > \n " ;
$team = getJudgingTeam ( $edit );
2005-04-19 18:36:03 +00:00
echo " <b> " . $team [ 'name' ] . " (# " . $team [ 'num' ] . " )</b><br /> " ;
2005-05-06 19:14:56 +00:00
if ( count ( $team [ 'members' ]))
2005-04-19 18:36:03 +00:00
{
2005-05-06 19:14:56 +00:00
$memberlist = " " ;
foreach ( $team [ 'members' ] AS $member )
{
if ( $member [ 'captain' ] == " yes " )
$memberlist .= " <i> " ;
$memberlist .= $member [ 'firstname' ] . " " . $member [ 'lastname' ];
if ( $member [ 'captain' ] == " yes " )
$memberlist .= " </i> " ;
$memberlist .= " , " ;
}
echo " <b> " . i18n ( " Judging Team Members " ) . " : </b> " ;
$memberlist = substr ( $memberlist , 0 , - 2 );
echo " <br /> " ;
2005-04-19 18:36:03 +00:00
}
2005-05-06 19:14:56 +00:00
else
$memberlist = error ( i18n ( " Team has no members assigned to it. <a href= \" judges_teams_members.php \" >Assign Judges Here</a> " ));
2005-04-19 18:36:03 +00:00
echo $memberlist ;
echo " <br /> " ;
echo " <br /> " ;
2005-04-21 17:00:49 +00:00
2005-05-06 20:02:20 +00:00
//we need award_ids for use below to get the eligible projects, so lets build the array here while we're displaying the awards
$award_ids = array ();
2005-05-06 19:14:56 +00:00
if ( count ( $team [ 'awards' ]))
2005-04-19 18:36:03 +00:00
{
2005-05-06 19:14:56 +00:00
$awardlist = " " ;
foreach ( $team [ 'awards' ] AS $award )
{
$awardlist .= $award [ 'name' ];
$awardlist .= " , " ;
2005-05-06 20:02:20 +00:00
$award_ids [] = $award [ 'id' ];
2005-05-06 19:14:56 +00:00
}
echo " <b> " . i18n ( " Judging Team Awards " ) . " : </b> " ;
$awardlist = substr ( $awardlist , 0 , - 2 );
echo " <br /> " ;
2005-04-19 18:36:03 +00:00
}
2005-05-06 19:14:56 +00:00
else
$awardlist = error ( i18n ( " Team has no awards assigned to it. <a href= \" judges_teams.php \" >Assign Awards Here</a> " ));
echo $awardlist ;
2005-04-19 18:36:03 +00:00
//get the timeslots that this team has.
$q = mysql_query ( " SELECT
judges_timeslots . id ,
judges_timeslots . date ,
judges_timeslots . starttime ,
judges_timeslots . endtime
FROM
judges_timeslots ,
judges_teams ,
judges_teams_timeslots_link
WHERE
judges_teams . id = '".$team[' id ']."' AND
judges_teams . id = judges_teams_timeslots_link . judges_teams_id AND
judges_timeslots . id = judges_teams_timeslots_link . judges_timeslots_id
ORDER BY
date , starttime
" );
$numslots = mysql_num_rows ( $q );
2005-05-06 19:14:56 +00:00
if ( $numslots )
{
2005-04-19 18:36:03 +00:00
2005-05-06 19:14:56 +00:00
echo " <br /> " ;
echo " <br /> " ;
if ( $_SESSION [ 'viewstate' ][ 'judges_projects_list_eligible' ] == 'true' )
$ch = " checked= \" checked \" " ;
else
$ch = " " ;
2005-04-19 18:36:03 +00:00
2005-05-12 19:47:08 +00:00
echo " <input $ch onclick= \" eligibleclick() \" type= \" checkbox \" name= \" showeligible \" > " . i18n ( " Only show projects eligible/nominated for awards assigned to this team " );
2005-05-06 19:14:56 +00:00
echo " <table> " ;
echo " </tr> " ;
2005-04-19 18:36:03 +00:00
2005-05-06 19:14:56 +00:00
echo " <tr> " ;
if ( $_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ] == 'all' )
{
echo " <td align=left><a href= \" judges_teams_projects.php?action= $action &edit= $edit &judges_projects_list_show=unassigned \" > " . i18n ( " show unassigned " ) . " </a></td> " ;
echo " <td align=right><b> " . i18n ( " show all " ) . " </b></td> " ;
}
else
{
echo " <td align=left><b> " . i18n ( " show unassigned " ) . " </b></td> " ;
echo " <td align=right><a href= \" judges_teams_projects.php?action= $action &edit= $edit &judges_projects_list_show=all \" > " . i18n ( " show all " ) . " </a></td> " ;
}
echo " <td> </td> " ;
echo " </tr> " ;
echo " <tr><td colspan=2> " ;
if ( $_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ] == 'all' )
{
$querystr = " SELECT
2005-04-19 18:36:03 +00:00
projects . id ,
2005-05-06 19:14:56 +00:00
projects . projectnumber ,
projects . title ,
registrations . status
2005-04-19 18:36:03 +00:00
FROM
projects ,
2005-05-06 19:14:56 +00:00
registrations
2005-04-19 18:36:03 +00:00
WHERE
2009-04-04 04:03:05 +00:00
projectnumber is not null
" . getJudgingEligibilityCode(). " AND
2005-05-06 19:14:56 +00:00
projects . registrations_id = registrations . id AND
projects . year = '".$config[' FAIRYEAR ']."'
2005-04-19 18:36:03 +00:00
ORDER BY
2005-05-06 19:14:56 +00:00
projectnumber " ;
}
else if ( $_SESSION [ 'viewstate' ][ 'judges_projects_list_show' ] == 'unassigned' )
2005-04-19 18:36:03 +00:00
{
2005-05-06 19:14:56 +00:00
$querystr = " SELECT
projects . id ,
projects . projectnumber ,
projects . title ,
registrations . status
FROM
projects
LEFT JOIN judges_teams_timeslots_projects_link ON projects . id = judges_teams_timeslots_projects_link . projects_id ,
registrations
WHERE
2009-04-04 04:03:05 +00:00
projectnumber is not null
" . getJudgingEligibilityCode(). " AND
2005-05-06 19:14:56 +00:00
projects . registrations_id = registrations . id AND
judges_teams_timeslots_projects_link . projects_id IS NULL AND
projects . year = '".$config[' FAIRYEAR ']."'
ORDER BY
projectnumber " ;
2005-04-19 18:36:03 +00:00
}
2005-05-06 19:14:56 +00:00
$pq = mysql_query ( $querystr );
echo mysql_error ();
2005-05-06 20:02:20 +00:00
2005-05-12 19:47:08 +00:00
$eligibleprojects = getProjectsEligibleOrNominatedForAwards ( $award_ids );
// echo nl2br(print_r($eligibleprojects,true));
2005-05-06 20:26:15 +00:00
//the keys are the project numbers, so lets get an array of those too so we can use in_array below
$eligibleprojectsnumbers = array_keys ( $eligibleprojects );
// echo nl2br(print_r($eligibleprojects,true));
2005-04-19 18:36:03 +00:00
2005-05-06 20:26:15 +00:00
$numprojects = 0 ;
2005-05-06 19:14:56 +00:00
echo " <select name= \" project_id \" > " ;
2010-04-06 17:05:59 +00:00
echo " <option value= \" \" > " . i18n ( " Choose Project to Assign to Timeslot " ) . " </option> \n " ;
while ( $pr = mysql_fetch_object ( $pq )) {
if ( $_SESSION [ 'viewstate' ][ 'judges_projects_list_eligible' ] == 'true' ) {
if ( in_array ( $pr -> projectnumber , $eligibleprojectsnumbers )) {
2005-05-06 20:26:15 +00:00
echo " <option value= \" $pr->id\ " > $pr -> projectnumber - $pr -> title </ option > \n " ;
$numprojects ++ ;
}
}
2010-04-06 17:05:59 +00:00
else {
2005-05-06 20:26:15 +00:00
echo " <option value= \" $pr->id\ " > $pr -> projectnumber - $pr -> title </ option > \n " ;
$numprojects ++ ;
}
2005-05-06 19:14:56 +00:00
}
echo " </select> " ;
echo " </td><td> " ;
2010-04-06 17:05:59 +00:00
echo i18n ( " %1 projects listed " , array ( $numprojects ));
2005-04-19 18:36:03 +00:00
echo " </td></tr> " ;
2005-05-06 19:14:56 +00:00
echo " </table> " ;
echo " <br /> " ;
echo " <br /> " ;
2005-04-19 18:36:03 +00:00
2005-05-06 19:14:56 +00:00
echo " <table class= \" summarytable \" > " ;
echo " <tr> " ;
2010-04-06 17:05:59 +00:00
echo " <th> " . i18n ( " Timeslot " ) . " </th> " ;
echo " <th> " . i18n ( " Project " ) . " </th> " ;
2005-05-06 19:14:56 +00:00
echo " </tr> " ;
2010-04-06 17:05:59 +00:00
while ( $r = mysql_fetch_object ( $q )) {
2005-05-06 19:14:56 +00:00
echo " <tr><td> " ;
echo " <nobr> " ;
if ( $show_date )
2010-04-06 17:05:59 +00:00
echo format_date ( $r -> date ) . " " ;
2010-01-19 03:42:25 +00:00
echo format_time ( $r -> starttime );
2005-05-06 19:14:56 +00:00
echo " - " ;
2010-01-19 03:42:25 +00:00
echo format_time ( $r -> endtime );
2005-05-06 19:14:56 +00:00
echo " </nobr> " ;
echo " </td><td> " ;
$projq = mysql_query ( " SELECT
judges_teams_timeslots_projects_link . id AS link_id ,
projects . projectnumber ,
projects . id ,
projects . title
FROM
projects ,
judges_teams_timeslots_projects_link
WHERE
judges_teams_timeslots_projects_link . judges_timeslots_id = '$r->id' AND
judges_teams_timeslots_projects_link . judges_teams_id = '".$team[' id ']."' AND
judges_teams_timeslots_projects_link . projects_id = projects . id AND
judges_teams_timeslots_projects_link . year = '".$config[' FAIRYEAR ']."'
ORDER BY
projectnumber
" );
echo mysql_Error ();
2010-04-06 17:05:59 +00:00
while ( $proj = mysql_fetch_object ( $projq )) {
2005-05-06 19:14:56 +00:00
echo " <a onclick= \" return confirmClick('Are you sure you want to remove this project from this team timeslot?') \" href= \" judges_teams_projects.php?action=delete&delete= " . $proj -> link_id . " &edit= " . $team [ 'id' ] . " \" ><img border=0 src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " $proj->projectnumber - $proj->title <br /> " ;
}
2010-04-06 17:05:59 +00:00
echo " <input name= \" assignbtn[ $r->id ] \" type= \" button \" onclick= \" assign(' $r->id ') \" value= \" " . i18n ( " Assign " ) . " \" > " ;
2005-05-06 19:14:56 +00:00
2007-03-28 22:32:57 +00:00
2005-05-06 19:14:56 +00:00
echo " </td></tr> " ;
}
echo " </table> " ;
}
2010-04-06 17:05:59 +00:00
else {
2005-05-06 19:14:56 +00:00
echo error ( i18n ( " Team has no timeslots assigned to it. <a href= \" judges_teams_timeslots.php \" >Assign Timeslots Here</a> " ));
}
2005-04-19 18:36:03 +00:00
echo " </form> " ;
}
2010-04-06 17:05:59 +00:00
else {
2005-04-19 18:36:03 +00:00
echo " <input type= \" hidden \" name= \" action \" value= \" assign \" > " ;
2009-04-02 16:35:02 +00:00
echo " <table class= \" tableview \" > " ;
2010-03-31 18:44:42 +00:00
echo " <thead><tr> " ;
2005-04-19 18:36:03 +00:00
echo " <th> " . i18n ( " Team " ) . " </th> " ;
echo " <th> " . i18n ( " Timeslots and Projects " ) . " </th> " ;
2010-03-31 18:44:42 +00:00
echo " </tr></thead> " ;
2005-04-19 18:36:03 +00:00
$teams = getJudgingTeams ();
2010-04-06 17:05:59 +00:00
foreach ( $teams AS $team ) {
2005-04-19 18:36:03 +00:00
echo " <tr> " ;
2005-05-11 04:13:27 +00:00
echo " <td width= \" 200 \" > " ;
2005-04-19 18:36:03 +00:00
echo " <b> " . $team [ 'name' ] . " (# " . $team [ 'num' ] . " )</b><br /> " ;
$memberlist = " " ;
2010-01-18 16:24:34 +00:00
if ( count ( $team [ 'members' ])) {
foreach ( $team [ 'members' ] AS $member ) {
2005-12-15 22:28:04 +00:00
echo " " ;
2010-04-06 17:05:59 +00:00
$err = false ;
foreach ( $team [ 'languages_projects' ] AS $projectlang ) {
if ( ! in_array ( $projectlang , $member [ 'languages_array' ])) {
$err = true ;
break ;
}
}
if ( $err ) echo " <span class= \" error \" > " ;
2005-12-15 22:28:04 +00:00
if ( $member [ 'captain' ] == " yes " )
echo " <i> " ;
2009-04-02 16:35:02 +00:00
echo $member [ 'firstname' ] . " " . $member [ 'lastname' ] . " ( " . $member [ 'languages' ] . " )<br /> " ;
2005-12-15 22:28:04 +00:00
if ( $member [ 'captain' ] == " yes " )
echo " </i> " ;
2010-04-06 17:05:59 +00:00
if ( $err ) echo " </span> " ;
2005-12-15 22:28:04 +00:00
}
2005-04-19 18:36:03 +00:00
}
echo " </td> " ;
echo " <td> " ;
//get the timeslots that this team has.
$q = mysql_query ( " SELECT
2005-04-19 19:22:25 +00:00
judges_timeslots . id ,
2005-04-19 18:36:03 +00:00
judges_timeslots . date ,
judges_timeslots . starttime ,
judges_timeslots . endtime
FROM
judges_timeslots ,
judges_teams ,
judges_teams_timeslots_link
WHERE
judges_teams . id = '".$team[' id ']."' AND
judges_teams . id = judges_teams_timeslots_link . judges_teams_id AND
judges_timeslots . id = judges_teams_timeslots_link . judges_timeslots_id
ORDER BY
date , starttime
" );
$numslots = mysql_num_rows ( $q );
2010-04-06 17:05:59 +00:00
echo " <a href= \" judges_teams_projects.php?action=edit&edit= " . $team [ 'id' ] . " \" > " . i18n ( " Edit team project assignments " ) . " </a> " ;
2005-04-19 18:36:03 +00:00
2010-04-06 17:05:59 +00:00
echo " <table class= \" tableview \" style= \" margin-left: 0px; width: 100%; font-size: 1.0em; \" > " ;
2005-04-19 18:36:03 +00:00
2010-04-06 17:05:59 +00:00
while ( $r = mysql_fetch_object ( $q )) {
2007-03-28 22:32:57 +00:00
echo " <tr><td width= \" 100 \" align= \" center \" > " ;
2005-04-19 18:36:03 +00:00
2005-04-19 19:22:25 +00:00
echo " <nobr> " ;
2005-04-19 18:36:03 +00:00
if ( $show_date )
2010-04-06 17:05:59 +00:00
echo format_date ( $r -> date ) . " " ;
2010-01-19 03:42:25 +00:00
echo format_time ( $r -> starttime );
2005-04-19 18:36:03 +00:00
echo " - " ;
2010-01-19 03:42:25 +00:00
echo format_time ( $r -> endtime );
2005-04-19 19:22:25 +00:00
echo " </nobr> " ;
2005-04-19 18:36:03 +00:00
echo " </td><td> " ;
2005-04-19 19:22:25 +00:00
$projq = mysql_query ( " SELECT
projects . projectnumber ,
projects . id ,
2009-04-02 16:35:02 +00:00
projects . title ,
projects . language
2005-04-19 19:22:25 +00:00
FROM
projects ,
judges_teams_timeslots_projects_link
WHERE
judges_teams_timeslots_projects_link . judges_timeslots_id = '$r->id' AND
judges_teams_timeslots_projects_link . judges_teams_id = '".$team[' id ']."' AND
judges_teams_timeslots_projects_link . projects_id = projects . id AND
judges_teams_timeslots_projects_link . year = '".$config[' FAIRYEAR ']."'
ORDER BY
projectnumber
" );
2010-04-06 17:05:59 +00:00
echo mysql_error ();
2009-04-02 16:35:02 +00:00
while ( $proj = mysql_fetch_object ( $projq )) {
2010-04-06 17:05:59 +00:00
if ( ! in_array ( $proj -> language , $team [ 'languages_members' ]))
2009-04-02 16:35:02 +00:00
echo " <span class= \" error \" > " ;
echo " $proj->projectnumber - $proj->title ( $proj->language ) " ;
if ( ! in_array ( $proj -> language , $team [ 'languages' ]))
2010-04-04 15:55:32 +00:00
echo " </span> \n " ;
2009-04-02 16:35:02 +00:00
echo " <br /> " ;
2005-04-19 19:22:25 +00:00
}
2005-04-19 18:36:03 +00:00
echo " </td></tr> " ;
}
echo " </table> " ;
echo " </td> " ;
echo " </tr> " ;
}
2010-04-06 17:05:59 +00:00
echo " </table> " ;
2005-04-19 18:36:03 +00:00
}
send_footer ();
?>