forked from science-ation/science-ation
Whew! Add a new interface to link judging teams with the awards that they are
judging for. Can now auto-create judging teams based on awards list (one team per award). db bumped to v6 moved judges_teams to judges_teams_members judges_teams is now the new interface
This commit is contained in:
parent
c171fe752d
commit
a947ff8e85
@ -5,26 +5,14 @@ function getJudgingTeams()
|
||||
|
||||
$q=mysql_query("SELECT judges_teams.id,
|
||||
judges_teams.num,
|
||||
judges_teams.name,
|
||||
judges.id AS judges_id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.captain
|
||||
|
||||
judges_teams.name
|
||||
FROM
|
||||
judges,
|
||||
judges_teams,
|
||||
judges_teams_link
|
||||
judges_teams
|
||||
WHERE
|
||||
judges_teams.year='".$config['FAIRYEAR']."' AND
|
||||
judges_teams_link.judges_id=judges.id AND
|
||||
judges_teams_link.judges_teams_id=judges_teams.id
|
||||
judges_teams.year='".$config['FAIRYEAR']."'
|
||||
ORDER BY
|
||||
name,
|
||||
num,
|
||||
captain DESC,
|
||||
lastname,
|
||||
firstname");
|
||||
num,name
|
||||
");
|
||||
|
||||
$lastteamid=-1;
|
||||
$lastteamnum=-1;
|
||||
@ -32,20 +20,67 @@ function getJudgingTeams()
|
||||
$teams=array();
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($r->id!=$lastteamid)
|
||||
$teams[$r->id]['id']=$r->id;
|
||||
$teams[$r->id]['num']=$r->num;
|
||||
$teams[$r->id]['name']=$r->name;
|
||||
$lastteamid=$r->id;
|
||||
$lastteamnum=$r->num;
|
||||
|
||||
//get the members for this team
|
||||
$mq=mysql_query("SELECT
|
||||
judges.id AS judges_id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.captain
|
||||
|
||||
FROM
|
||||
judges,
|
||||
judges_teams_link
|
||||
WHERE
|
||||
judges_teams_link.judges_id=judges.id AND
|
||||
judges_teams_link.judges_teams_id='$r->id'
|
||||
ORDER BY
|
||||
captain DESC,
|
||||
lastname,
|
||||
firstname");
|
||||
echo mysql_error();
|
||||
|
||||
|
||||
while($mr=mysql_fetch_object($mq))
|
||||
{
|
||||
$teams[$r->id]['id']=$r->id;
|
||||
$teams[$r->id]['num']=$r->num;
|
||||
$teams[$r->id]['name']=$r->name;
|
||||
$lastteamid=$r->id;
|
||||
$lastteamnum=$r->num;
|
||||
$teams[$lastteamid]['members'][]=array(
|
||||
"id"=>$mr->judges_id,
|
||||
"firstname"=>$mr->firstname,
|
||||
"lastname"=>$mr->lastname,
|
||||
"captain"=>$mr->captain
|
||||
);
|
||||
}
|
||||
$teams[$lastteamid]['members'][]=array(
|
||||
"id"=>$r->judges_id,
|
||||
"firstname"=>$r->firstname,
|
||||
"lastname"=>$r->lastname,
|
||||
"captain"=>$r->captain
|
||||
|
||||
//get the awards for this team
|
||||
$aq=mysql_query("SELECT award_awards.id,
|
||||
award_awards.name,
|
||||
award_awards.award_types_id,
|
||||
award_types.type AS award_type
|
||||
FROM
|
||||
award_awards,
|
||||
judges_teams_awards_link,
|
||||
award_types
|
||||
WHERE
|
||||
judges_teams_awards_link.award_awards_id=award_awards.id
|
||||
AND judges_teams_awards_link.judges_teams_id='$r->id'
|
||||
AND award_awards.award_types_id=award_types.id
|
||||
ORDER BY
|
||||
name
|
||||
");
|
||||
while($ar=mysql_fetch_object($aq))
|
||||
{
|
||||
$teams[$r->id]['awards'][]=array(
|
||||
"id"=>$ar->id,
|
||||
"name"=>$ar->name,
|
||||
"award_types_id"=>$ar->award_types_id,
|
||||
"award_type"=>$ar->award_type
|
||||
);
|
||||
}
|
||||
}
|
||||
return $teams;
|
||||
}
|
||||
@ -56,49 +91,87 @@ function getJudgingTeam($teamid)
|
||||
|
||||
$q=mysql_query("SELECT judges_teams.id,
|
||||
judges_teams.num,
|
||||
judges_teams.name,
|
||||
judges.id AS judges_id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.captain
|
||||
judges_teams.name
|
||||
|
||||
FROM
|
||||
judges,
|
||||
judges_teams,
|
||||
judges_teams_link
|
||||
judges_teams
|
||||
WHERE
|
||||
judges_teams.year='".$config['FAIRYEAR']."' AND
|
||||
judges_teams_link.judges_id=judges.id AND
|
||||
judges_teams_link.judges_teams_id=judges_teams.id AND
|
||||
judges_teams.id='$teamid'
|
||||
ORDER BY
|
||||
name,
|
||||
num,
|
||||
captain DESC,
|
||||
lastname,
|
||||
firstname");
|
||||
name
|
||||
");
|
||||
|
||||
$team=array();
|
||||
|
||||
$first=true;
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
//this only gets done the first time
|
||||
if($first)
|
||||
$team['id']=$r->id;
|
||||
$team['num']=$r->num;
|
||||
$team['name']=$r->name;
|
||||
|
||||
//get the members for this team
|
||||
$mq=mysql_query("SELECT
|
||||
judges.id AS judges_id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.captain
|
||||
|
||||
FROM
|
||||
judges,
|
||||
judges_teams_link
|
||||
WHERE
|
||||
judges_teams_link.judges_id=judges.id AND
|
||||
judges_teams_link.judges_teams_id='$r->id'
|
||||
ORDER BY
|
||||
captain DESC,
|
||||
lastname,
|
||||
firstname");
|
||||
echo mysql_error();
|
||||
|
||||
|
||||
while($mr=mysql_fetch_object($mq))
|
||||
{
|
||||
$team['id']=$r->id;
|
||||
$team['num']=$r->num;
|
||||
$team['name']=$r->name;
|
||||
$first=false;
|
||||
$team['members'][]=array(
|
||||
"id"=>$mr->judges_id,
|
||||
"firstname"=>$mr->firstname,
|
||||
"lastname"=>$mr->lastname,
|
||||
"captain"=>$mr->captain
|
||||
);
|
||||
}
|
||||
|
||||
$team['members'][]=array(
|
||||
"id"=>$r->judges_id,
|
||||
"firstname"=>$r->firstname,
|
||||
"lastname"=>$r->lastname,
|
||||
"captain"=>$r->captain
|
||||
|
||||
//get the awards for this team
|
||||
$aq=mysql_query("SELECT award_awards.id,
|
||||
award_awards.name,
|
||||
award_awards.award_types_id,
|
||||
award_types.type AS award_type
|
||||
FROM
|
||||
award_awards,
|
||||
judges_teams_awards_link,
|
||||
award_types
|
||||
WHERE
|
||||
judges_teams_awards_link.award_awards_id=award_awards.id
|
||||
AND judges_teams_awards_link.judges_teams_id='$r->id'
|
||||
AND award_awards.award_types_id=award_types.id
|
||||
ORDER BY
|
||||
name
|
||||
");
|
||||
while($ar=mysql_fetch_object($aq))
|
||||
{
|
||||
$team['awards'][]=array(
|
||||
"id"=>$ar->id,
|
||||
"name"=>$ar->name,
|
||||
"award_types_id"=>$ar->award_types_id,
|
||||
"award_type"=>$ar->award_type
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $team;
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />";
|
||||
echo "<a href=\"judges_teams_members.php\">".i18n("Manage Judging Team Members")."</a><br />";
|
||||
echo "<a href=\"judges_timeslots.php\">".i18n("Manage Judging Timeslots")."</a><br />";
|
||||
echo "<a href=\"judges_teams_timeslots.php\">".i18n("Assign Timeslots to Judging Teams")."</a><br />";
|
||||
echo "<a href=\"judges_teams_projects.php\">".i18n("Assign Projects to Teams")."</a><br />";
|
||||
|
@ -26,60 +26,15 @@
|
||||
auth_required('admin');
|
||||
include "judges.inc.php";
|
||||
|
||||
send_header("Administration - Judging Teams");
|
||||
send_header("Administration - Manage Judging Teams");
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
function addbuttonclicked(team)
|
||||
function addclicked()
|
||||
{
|
||||
document.forms.judges.action.value="add";
|
||||
document.forms.judges.team_num.value=team;
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
function delbuttonclicked(team_id,team_num,team_name,judge)
|
||||
{
|
||||
document.forms.judges.action.value="del";
|
||||
document.forms.judges.team_id.value=team_id;
|
||||
document.forms.judges.team_num.value=team_num;
|
||||
document.forms.judges.team_name.value=team_name;
|
||||
document.forms.judges.judges_id.value=judge;
|
||||
document.forms.judges.action.value="assign";
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
|
||||
function saveteamnamesbuttonclicked()
|
||||
{
|
||||
document.forms.judges.action.value="saveteamnames";
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
|
||||
function openjudgeinfo(id)
|
||||
{
|
||||
if(id)
|
||||
currentid=id;
|
||||
else
|
||||
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
|
||||
|
||||
window.open("judges_info.php?id="+currentid,"JudgeInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500");
|
||||
return false;
|
||||
|
||||
}
|
||||
function switchjudgeinfo()
|
||||
{
|
||||
if(document.forms.judges["judgelist[]"].selectedIndex != -1)
|
||||
{
|
||||
currentname=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].text;
|
||||
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
|
||||
|
||||
document.forms.judges.judgeinfobutton.disabled=false;
|
||||
document.forms.judges.judgeinfobutton.value=currentname;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
document.forms.judges.judgeinfobutton.disabled=true;
|
||||
document.forms.judges.judgeinfobutton.value="<? echo i18n("Judge Info")?>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -87,320 +42,273 @@ function switchjudgeinfo()
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
echo "<a href=\"judges.php\"><< ".i18n("Back to Judges")."</a>\n";
|
||||
|
||||
if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0)
|
||||
if($_GET['edit']) $edit=$_GET['edit'];
|
||||
if($_POST['edit']) $edit=$_POST['edit'];
|
||||
if($_GET['action']) $action=$_GET['action'];
|
||||
if($_POST['action']) $action=$_POST['action'];
|
||||
|
||||
if($action=="delete" && $_GET['delete'])
|
||||
{
|
||||
//first check if this team exists.
|
||||
$q=mysql_query("SELECT id,name FROM judges_teams WHERE num='".$_POST['team_num']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$r=mysql_fetch_object($q);
|
||||
$team_id=$r->id;
|
||||
$team_name=$r->name;
|
||||
$captain='no';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo notice(i18n("Creating new team #%1 with name '%2'",array($_POST['team_num'],$_POST['new_team_name'])));
|
||||
mysql_query("INSERT INTO judges_teams (num,name,year) VALUES ('".$_POST['team_num']."','".$_POST['new_team_name']."','".$config['FAIRYEAR']."')");
|
||||
$team_id=mysql_insert_id();
|
||||
$team_name=$_POST['new_team_name'];
|
||||
$captain='yes';
|
||||
}
|
||||
|
||||
$added=0;
|
||||
|
||||
foreach($_POST['judgelist'] AS $selectedjudge)
|
||||
{
|
||||
//before we insert them, we need to make sure they dont already belong to this team. We can not have the same judge assigned to the same team multiple times.
|
||||
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='$selectedjudge' AND judges_teams_id='$team_id'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo notice(i18n("Judge (%1) already belongs to judging team: %2",array($selectedjudge,$team_name)));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//lets make the first one we add a captain, the rest, non-captains :)
|
||||
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
|
||||
$added++;
|
||||
}
|
||||
//if this is alreayd no, then who cares, but if its the first one that is going into the new team, then
|
||||
//captain will be yes, and we only want the first one assigned to a new team to be the captain
|
||||
//sno now we can set this back to no
|
||||
$captain='no';
|
||||
|
||||
}
|
||||
if($added==1) $j=i18n("judge");
|
||||
else $j=i18n("judges");
|
||||
|
||||
echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$team_name)));
|
||||
//ALSO DELETE: team members, timeslots, projects, awards
|
||||
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
|
||||
echo happy(i18n("Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team"));
|
||||
}
|
||||
|
||||
if($_POST['action']=="del" && $_POST['team_num'] && $_POST['team_id'] && $_POST['judges_id'])
|
||||
if(($action=="save" || $action=="assign") && $edit)
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_POST['judges_id']."' AND judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
echo happy(i18n("Removed judge from team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
|
||||
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q)==0)
|
||||
//if we're updating or assigning, it doesnt matter, lets do the same thing (save record, add award
|
||||
//but when we're done, if we're "assign" then go back to edit that team
|
||||
//if we're save, then go back to the team list
|
||||
$err=false;
|
||||
$q=mysql_query("UPDATE judges_teams SET num='".$_POST['team_num']."', name='".mysql_escape_string(stripslashes($_POST['team_name']))."' WHERE id='$edit'");
|
||||
if(mysql_error())
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams WHERE year='".$config['FAIRYEAR']."' AND id='".$_POST['team_id']."'");
|
||||
echo notice(i18n("Removed empty team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
|
||||
$err=true;
|
||||
echo error(mysql_error());
|
||||
}
|
||||
|
||||
if($_POST['award'])
|
||||
{
|
||||
//link up the award
|
||||
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('".$_POST['award']."','$edit','".$config['FAIRYEAR']."')");
|
||||
echo happy(i18n("Award assigned to team"));
|
||||
}
|
||||
|
||||
if($action=="assign")
|
||||
$action="edit";
|
||||
else if($action=="save")
|
||||
{
|
||||
if($err)
|
||||
$action="edit";
|
||||
else
|
||||
{
|
||||
echo happy(i18n("Team successfully saved"));
|
||||
unset($action);
|
||||
unset($edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($action=="unassign")
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND year='".$config['FAIRYEAR']."'");
|
||||
echo happy(i18n("Award unassigned from judge team"));
|
||||
//keep editing the same team
|
||||
$action="edit";
|
||||
}
|
||||
|
||||
if($action=="createall")
|
||||
{
|
||||
//first make sure we're really empty (dont want people hitting refresh and adding all the teams twice
|
||||
$q=mysql_query("SELECT COUNT(*) AS c FROM judges_teams WHERE year='".$config['FAIRYEAR']."'");
|
||||
$r=mysql_fetch_object($q);
|
||||
if($r->c)
|
||||
{
|
||||
echo error(i18n("Cannot 'Create All' teams when any teams currently exist. Try deleting all existing teams first."));
|
||||
}
|
||||
else
|
||||
{
|
||||
//make sure the team still has a captain!
|
||||
//FIXME: this might best come from the "i am willing to be a team captain" question under the judges profile
|
||||
$gotcaptain=false;
|
||||
$first=true;
|
||||
//grab all the awards
|
||||
$q=mysql_query("SELECT award_awards.*, award_types.type AS award_type, award_types.order AS award_types_order FROM award_awards,award_types WHERE award_awards.award_types_id=award_types.id AND award_awards.year='".$config['FAIRYEAR']."' ORDER BY award_types_order, name");
|
||||
$num=1;
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$firstjudge=$r->judges_id;
|
||||
$first=false;
|
||||
}
|
||||
|
||||
if($r->captain=="yes")
|
||||
{
|
||||
$gotcaptain=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$gotcaptain)
|
||||
{
|
||||
//make the first judge the captain
|
||||
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_POST['team_id']."' AND judges_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
|
||||
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
|
||||
$name=mysql_escape_string("($r->award_type) $r->name");
|
||||
mysql_query("INSERT INTO judges_teams(num,name,year) VALUES ('$num','$name','".$config['FAIRYEAR']."')");
|
||||
$team_id=mysql_insert_id();
|
||||
//now link the new team to the award
|
||||
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','".$config['FAIRYEAR']."')");
|
||||
echo happy(i18n("Created team #%1: %2",array($num,$name)));
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_POST['action']=="saveteamnames")
|
||||
if($action=="add" && $_GET['num'])
|
||||
{
|
||||
if(count($_POST['team_names']))
|
||||
mysql_query("INSERT INTO judges_teams(num,year) VALUES ('".$_GET['num']."','".$config['FAIRYEAR']."')");
|
||||
echo mysql_error();
|
||||
$edit=mysql_insert_id();
|
||||
$action="edit";
|
||||
}
|
||||
|
||||
if($action=="edit" && $edit)
|
||||
{
|
||||
echo "<a href=\"judges_teams.php\"><< ".i18n("Back to Judging Teams")."</a>\n";
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
$team=getJudgingTeam($edit);
|
||||
|
||||
if(!$_SESSION['viewstate']['judges_teams_awards_show'])
|
||||
$_SESSION['viewstate']['judges_teams_awards_show']='unassigned';
|
||||
//now update the judges_teams_awards_show viewstate
|
||||
if($_GET['judges_teams_awards_show'])
|
||||
$_SESSION['viewstate']['judges_teams_awards_show']=$_GET['judges_teams_awards_show'];
|
||||
|
||||
echo "<form name=\"judges\" method=\"post\" action=\"judges_teams.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\">";
|
||||
echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\">";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td>".i18n("Team Number").":</td><td><input type=\"text\" size=\"4\" name=\"team_num\" value=\"".$team['num']."\"></td></tr>";
|
||||
echo "<tr><td>".i18n("Team Name").":</td><td><input type=\"text\" size=\"40\" name=\"team_name\" value=\"".$team['name']."\"></td></tr>";
|
||||
echo "<tr><td>".i18n("Awards").":</td><td>";
|
||||
|
||||
foreach($team['awards'] AS $award)
|
||||
{
|
||||
foreach($_POST['team_names'] AS $team_id=>$team_name)
|
||||
{
|
||||
mysql_query("UPDATE judges_teams SET name='".mysql_escape_string(stripslashes($team_name))."' WHERE id='$team_id'");
|
||||
}
|
||||
echo happy(i18n("Team names successfully saved"));
|
||||
echo "<a onclick=\"return confirmClick('Are you sure you want to unassign this award from this team?')\" href=\"judges_teams.php?action=unassign&unassign=".$award['id']."&edit=".$team['id']."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
echo " (".$award['award_type'].") ".$award['name']." <br />";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($_GET['action']=="addcaptain")
|
||||
{
|
||||
|
||||
//teams can have as many captains as they want, so just add it.
|
||||
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
|
||||
echo happy(i18n("Team captain assigned"));
|
||||
}
|
||||
|
||||
if($_GET['action']=="removecaptain")
|
||||
{
|
||||
//teams must always have at least one captain, so if we only have one, and we are trying to remove it, dont let them!
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE captain='yes' AND judges_teams_id='".$_GET['team_id']."'");
|
||||
if(mysql_num_rows($q)<2)
|
||||
echo "<table><tr>";
|
||||
if($_SESSION['viewstate']['judges_teams_awards_show']=='all')
|
||||
{
|
||||
echo error(i18n("A judge team must always have at least one captain"));
|
||||
echo "<td align=left><a href=\"judges_teams.php?action=edit&edit=$edit&judges_teams_awards_show=unassigned\">".i18n("show unassigned")."</a></td>";
|
||||
echo "<td align=right><b>".i18n("show all")."</b></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
|
||||
echo happy(i18n("Team captain removed"));
|
||||
echo "<td align=left><b>".i18n("show unassigned")."</b></td>";
|
||||
echo "<td align=right><a href=\"judges_teams.php?action=edit&edit=$edit&judges_teams_awards_show=all\">".i18n("show all")."</a></td>";
|
||||
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
|
||||
if(!$_SESSION['viewstate']['judges_teams_list_show'])
|
||||
$_SESSION['viewstate']['judges_teams_list_show']='unassigned';
|
||||
//now update the judges_teams_list_show viewstate
|
||||
if($_GET['judges_teams_list_show'])
|
||||
$_SESSION['viewstate']['judges_teams_list_show']=$_GET['judges_teams_list_show'];
|
||||
|
||||
echo "<form name=\"judges\" method=\"post\" action=\"judges_teams.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\">";
|
||||
echo "<input type=\"hidden\" name=\"team_id\">";
|
||||
echo "<input type=\"hidden\" name=\"team_num\">";
|
||||
echo "<input type=\"hidden\" name=\"team_name\">";
|
||||
echo "<input type=\"hidden\" name=\"judges_id\">";
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
echo "<th>".i18n("Judges List");
|
||||
echo "<br />";
|
||||
echo "<input disabled=\"true\" name=\"judgeinfobutton\" id=\"judgeinfobutton\" onclick=\"openjudgeinfo()\" type=\"button\" value=\"".i18n("Judge Info")."\">";
|
||||
echo "</th>";
|
||||
echo "<th>".i18n("Judge Teams")."</th>";
|
||||
echo "</tr>";
|
||||
echo "<tr><td valign=\"top\">";
|
||||
echo "<table width=\"100%\"><tr>";
|
||||
if($_SESSION['viewstate']['judges_teams_list_show']=='all')
|
||||
{
|
||||
echo "<td align=left><a href=\"judges_teams.php?judges_teams_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.php?judges_teams_list_show=all\">".i18n("show all")."</a></td>";
|
||||
|
||||
}
|
||||
echo "</tr></table>";
|
||||
|
||||
|
||||
/*
|
||||
//mysql 4.0 does not support subqueries - it is supported as of mysql 4.1
|
||||
//this means we cant use NOT IN (SELECT..) so, we will have to workaround this
|
||||
//at least for now.
|
||||
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
FROM
|
||||
judges,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges.id NOT IN (SELECT judges_id AS id FROM judges_teams_link WHERE judges_teams_link.year='".$config['FAIRYEAR']."')
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
*/
|
||||
if($_SESSION['viewstate']['judges_teams_list_show']=='all')
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
FROM
|
||||
judges,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.judges_id
|
||||
FROM
|
||||
judges
|
||||
LEFT JOIN judges_teams_link ON judges.id = judges_teams_link.judges_id,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges_teams_link.judges_id IS NULL AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
|
||||
$q=mysql_query($querystr);
|
||||
|
||||
echo mysql_error();
|
||||
echo "<select name=\"judgelist[]\" onchange=\"switchjudgeinfo()\" multiple=\"multiple\" style=\"width: 250px; height: 600px;\">";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($r->firstname && $r->lastname)
|
||||
echo "<option value=\"$r->id\">$r->firstname $r->lastname</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
echo "</td>";
|
||||
echo "<td valign=\"top\">";
|
||||
|
||||
$teams=getJudgingTeams();
|
||||
|
||||
//grab an array of all the current team numbers
|
||||
foreach($teams AS $team)
|
||||
$teamnumers[$team['num']]=1;
|
||||
|
||||
//start at 1, and find the next available team number
|
||||
$newteamnum=1;
|
||||
while($teamnumbers[$newteamnum]==1)
|
||||
{
|
||||
$newteamnum++;
|
||||
}
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td valign=top>";
|
||||
echo "<input onclick=\"addbuttonclicked('$newteamnum')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><th align=\"left\">New #$newteamnum: <input type=\"text\" name=\"new_team_name\" value=\"Team #$newteamnum\" /></th></tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "</td></tr></table>";
|
||||
|
||||
|
||||
|
||||
foreach($teams AS $team)
|
||||
{
|
||||
echo "<hr>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td valign=top>";
|
||||
echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": ";
|
||||
echo "<input type=\"text\" name=\"team_names[".$team['id']."]\" value=\"".$team['name']."\" size=\"10\">";
|
||||
echo "</th></tr>\n";
|
||||
|
||||
foreach($team['members'] AS $member)
|
||||
if($_SESSION['viewstate']['judges_teams_awards_show']=='all')
|
||||
{
|
||||
echo "<tr><td>";
|
||||
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".htmlspecialchars($team['name'])."','".$member['id']."')\" type=\"button\" value=\"<<\">";
|
||||
echo "</td><td>";
|
||||
if($member['captain']=="yes")
|
||||
{
|
||||
echo "<a title=\"Captain - Click to remove captain status\" href=\"judges_teams.php?action=removecaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
|
||||
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark.".$config['icon_extension']."\">";
|
||||
echo "</a> ";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<a title=\"Non-Captain - Click to make a team captain\" href=\"judges_teams.php?action=addcaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
|
||||
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark_disabled.".$config['icon_extension']."\">";
|
||||
echo "</a> ";
|
||||
|
||||
}
|
||||
echo "<a href=\"\" onclick=\"return openjudgeinfo(".$member['id'].");\">";
|
||||
echo $member['firstname']." ".$member['lastname'];
|
||||
echo "</a>";
|
||||
echo "</td></tr>";
|
||||
$querystr="SELECT
|
||||
award_awards.id,
|
||||
award_awards.name,
|
||||
award_types.type AS award_type,
|
||||
award_types.order AS award_type_order
|
||||
FROM
|
||||
award_awards,
|
||||
award_types
|
||||
WHERE
|
||||
award_awards.year='".$config['FAIRYEAR']."'
|
||||
AND award_types.id=award_awards.award_types_id
|
||||
ORDER BY
|
||||
award_type_order,
|
||||
name
|
||||
";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystr="SELECT
|
||||
award_awards.id,
|
||||
award_awards.name,
|
||||
award_types.type AS award_type,
|
||||
award_types.order AS award_type_order
|
||||
FROM
|
||||
award_awards,
|
||||
award_types
|
||||
LEFT JOIN judges_teams_awards_link ON award_awards.id = judges_teams_awards_link.award_awards_id
|
||||
WHERE
|
||||
award_awards.year='".$config['FAIRYEAR']."' AND
|
||||
judges_teams_awards_link.award_awards_id IS NULL
|
||||
AND award_types.id=award_awards.award_types_id
|
||||
ORDER BY
|
||||
award_type_order,
|
||||
name";
|
||||
}
|
||||
|
||||
echo "<tr><td colspan=2>";
|
||||
$q=mysql_query($querystr);
|
||||
|
||||
echo mysql_error();
|
||||
echo "<select name=\"award\">";
|
||||
echo "<option value=\"\">".i18n("Choose award to assign to team")."</option>\n";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<option value=\"$r->id\">($r->award_type) $r->name</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
echo "<input type=\"button\" value=\"Add\" onclick=\"addclicked()\">";
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "</td></tr></table>";
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "<input type=submit value=\"".i18n("Save Changes")."\">";
|
||||
echo "</form>";
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
echo "<br />";
|
||||
echo "<input type=\"button\" onclick=\"saveteamnamesbuttonclicked()\" type=\"button\" value=\"Save Team Names\" />";
|
||||
$teams=getJudgingTeams();
|
||||
|
||||
if(!count($teams))
|
||||
{
|
||||
echo "<a href=\"judges_teams.php?action=createall\">".i18n("Automatically create one new team for every award")."</a><br />";
|
||||
echo "<a href=\"judges_teams.php?action=add&num=1\">".i18n("Manually add individual team")."</a><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
//grab an array of all the current team numbers
|
||||
foreach($teams AS $team)
|
||||
$teamnumbers[$team['num']]=1;
|
||||
|
||||
//start at 1, and find the next available team number
|
||||
$newteamnum=1;
|
||||
while($teamnumbers[$newteamnum]==1)
|
||||
{
|
||||
$newteamnum++;
|
||||
}
|
||||
|
||||
|
||||
echo "<a href=\"judges_teams.php?action=add&num=$newteamnum\">Add individual team</a><br />";
|
||||
echo "<table class=\"summarytable\">\n";
|
||||
echo "<tr><th>Num</th>";
|
||||
echo "<th>Team Name</th>";
|
||||
echo "<th>Award(s)</th>";
|
||||
echo "<th>Actions</th>";
|
||||
echo "</tr>";
|
||||
foreach($teams AS $team)
|
||||
{
|
||||
echo "<tr><td>#".$team['num']."</td><td>";
|
||||
echo $team['name'];
|
||||
echo "</td>";
|
||||
|
||||
echo "<td>";
|
||||
if(count($team['awards']))
|
||||
{
|
||||
foreach($team['awards'] AS $award)
|
||||
{
|
||||
echo $award['name']." <br />";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo error(i18n("No award assigned to team"),"inline");
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo " <td align=\"center\">";
|
||||
echo "<a href=\"judges_teams.php?action=edit&edit=".$team['id']."\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
|
||||
echo " ";
|
||||
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this team?')\" href=\"judges_teams.php?action=delete&delete=".$team['id']."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
echo "<br />";
|
||||
}
|
||||
}
|
||||
send_footer();
|
||||
|
||||
|
||||
|
369
admin/judges_teams_members.php
Normal file
369
admin/judges_teams_members.php
Normal file
@ -0,0 +1,369 @@
|
||||
<?
|
||||
/*
|
||||
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");
|
||||
auth_required('admin');
|
||||
include "judges.inc.php";
|
||||
|
||||
send_header("Administration - Judging Teams");
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
function addbuttonclicked(team)
|
||||
{
|
||||
document.forms.judges.action.value="add";
|
||||
document.forms.judges.team_num.value=team;
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
function delbuttonclicked(team_id,team_num,team_name,judge)
|
||||
{
|
||||
document.forms.judges.action.value="del";
|
||||
document.forms.judges.team_id.value=team_id;
|
||||
document.forms.judges.team_num.value=team_num;
|
||||
document.forms.judges.team_name.value=team_name;
|
||||
document.forms.judges.judges_id.value=judge;
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
|
||||
function openjudgeinfo(id)
|
||||
{
|
||||
if(id)
|
||||
currentid=id;
|
||||
else
|
||||
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
|
||||
|
||||
window.open("judges_info.php?id="+currentid,"JudgeInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500");
|
||||
return false;
|
||||
|
||||
}
|
||||
function switchjudgeinfo()
|
||||
{
|
||||
if(document.forms.judges["judgelist[]"].selectedIndex != -1)
|
||||
{
|
||||
currentname=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].text;
|
||||
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
|
||||
|
||||
document.forms.judges.judgeinfobutton.disabled=false;
|
||||
document.forms.judges.judgeinfobutton.value=currentname;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
document.forms.judges.judgeinfobutton.disabled=true;
|
||||
document.forms.judges.judgeinfobutton.value="<? echo i18n("Judge Info")?>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
echo "<a href=\"judges.php\"><< ".i18n("Back to Judges")."</a>\n";
|
||||
|
||||
if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0)
|
||||
{
|
||||
//first check if this team exists.
|
||||
$q=mysql_query("SELECT id,name FROM judges_teams WHERE num='".$_POST['team_num']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$r=mysql_fetch_object($q);
|
||||
$team_id=$r->id;
|
||||
$team_name=$r->name;
|
||||
|
||||
//if the team is empty, we'll add the first person as the captain
|
||||
$team=getJudgingTeam($team_id);
|
||||
if(count($team['members']))
|
||||
$captain='no';
|
||||
else
|
||||
$captain='yes';
|
||||
}
|
||||
$added=0;
|
||||
|
||||
foreach($_POST['judgelist'] AS $selectedjudge)
|
||||
{
|
||||
//before we insert them, we need to make sure they dont already belong to this team. We can not have the same judge assigned to the same team multiple times.
|
||||
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='$selectedjudge' AND judges_teams_id='$team_id'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo notice(i18n("Judge (%1) already belongs to judging team: %2",array($selectedjudge,$team_name)));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//lets make the first one we add a captain, the rest, non-captains :)
|
||||
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
|
||||
$added++;
|
||||
}
|
||||
//if this is alreayd no, then who cares, but if its the first one that is going into the new team, then
|
||||
//captain will be yes, and we only want the first one assigned to a new team to be the captain
|
||||
//sno now we can set this back to no
|
||||
$captain='no';
|
||||
|
||||
}
|
||||
if($added==1) $j=i18n("judge");
|
||||
else $j=i18n("judges");
|
||||
|
||||
echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$team_name)));
|
||||
}
|
||||
|
||||
if($_POST['action']=="del" && $_POST['team_num'] && $_POST['team_id'] && $_POST['judges_id'])
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_POST['judges_id']."' AND judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
echo happy(i18n("Removed judge from team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
|
||||
|
||||
//if there is still members left in the team, make sure we have a captain still
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
//make sure the team still has a captain!
|
||||
//FIXME: this might best come from the "i am willing to be a team captain" question under the judges profile
|
||||
$gotcaptain=false;
|
||||
$first=true;
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$firstjudge=$r->judges_id;
|
||||
$first=false;
|
||||
}
|
||||
|
||||
if($r->captain=="yes")
|
||||
{
|
||||
$gotcaptain=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$gotcaptain)
|
||||
{
|
||||
//make the first judge the captain
|
||||
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_POST['team_id']."' AND judges_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
|
||||
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_POST['action']=="saveteamnames")
|
||||
{
|
||||
if(count($_POST['team_names']))
|
||||
{
|
||||
foreach($_POST['team_names'] AS $team_id=>$team_name)
|
||||
{
|
||||
mysql_query("UPDATE judges_teams SET name='".mysql_escape_string(stripslashes($team_name))."' WHERE id='$team_id'");
|
||||
}
|
||||
echo happy(i18n("Team names successfully saved"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($_GET['action']=="addcaptain")
|
||||
{
|
||||
|
||||
//teams can have as many captains as they want, so just add it.
|
||||
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
|
||||
echo happy(i18n("Team captain assigned"));
|
||||
}
|
||||
|
||||
if($_GET['action']=="removecaptain")
|
||||
{
|
||||
//teams must always have at least one captain, so if we only have one, and we are trying to remove it, dont let them!
|
||||
$q=mysql_query("SELECT * FROM judges_teams_link WHERE captain='yes' AND judges_teams_id='".$_GET['team_id']."'");
|
||||
if(mysql_num_rows($q)<2)
|
||||
{
|
||||
echo error(i18n("A judge team must always have at least one captain"));
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
|
||||
echo happy(i18n("Team captain removed"));
|
||||
}
|
||||
}
|
||||
|
||||
if(!$_SESSION['viewstate']['judges_teams_list_show'])
|
||||
$_SESSION['viewstate']['judges_teams_list_show']='unassigned';
|
||||
//now update the judges_teams_list_show viewstate
|
||||
if($_GET['judges_teams_list_show'])
|
||||
$_SESSION['viewstate']['judges_teams_list_show']=$_GET['judges_teams_list_show'];
|
||||
|
||||
echo "<form name=\"judges\" method=\"post\" action=\"judges_teams_members.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\">";
|
||||
echo "<input type=\"hidden\" name=\"team_id\">";
|
||||
echo "<input type=\"hidden\" name=\"team_num\">";
|
||||
echo "<input type=\"hidden\" name=\"team_name\">";
|
||||
echo "<input type=\"hidden\" name=\"judges_id\">";
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
echo "<th>".i18n("Judges List");
|
||||
echo "<br />";
|
||||
echo "<input disabled=\"true\" name=\"judgeinfobutton\" id=\"judgeinfobutton\" onclick=\"openjudgeinfo()\" type=\"button\" value=\"".i18n("Judge Info")."\">";
|
||||
echo "</th>";
|
||||
echo "<th>".i18n("Judge Teams")."</th>";
|
||||
echo "</tr>";
|
||||
echo "<tr><td valign=\"top\">";
|
||||
echo "<table width=\"100%\"><tr>";
|
||||
if($_SESSION['viewstate']['judges_teams_list_show']=='all')
|
||||
{
|
||||
echo "<td align=left><a href=\"judges_teams_members.php?judges_teams_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_members.php?judges_teams_list_show=all\">".i18n("show all")."</a></td>";
|
||||
|
||||
}
|
||||
echo "</tr></table>";
|
||||
|
||||
|
||||
/*
|
||||
//mysql 4.0 does not support subqueries - it is supported as of mysql 4.1
|
||||
//this means we cant use NOT IN (SELECT..) so, we will have to workaround this
|
||||
//at least for now.
|
||||
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
FROM
|
||||
judges,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges.id NOT IN (SELECT judges_id AS id FROM judges_teams_link WHERE judges_teams_link.year='".$config['FAIRYEAR']."')
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
*/
|
||||
if($_SESSION['viewstate']['judges_teams_list_show']=='all')
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
FROM
|
||||
judges,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.judges_id
|
||||
FROM
|
||||
judges
|
||||
LEFT JOIN judges_teams_link ON judges.id = judges_teams_link.judges_id,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges_teams_link.judges_id IS NULL AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
|
||||
$q=mysql_query($querystr);
|
||||
|
||||
echo mysql_error();
|
||||
echo "<select name=\"judgelist[]\" onchange=\"switchjudgeinfo()\" multiple=\"multiple\" style=\"width: 250px; height: 600px;\">";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($r->firstname && $r->lastname)
|
||||
echo "<option value=\"$r->id\">$r->firstname $r->lastname</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
echo "</td>";
|
||||
echo "<td valign=\"top\">";
|
||||
|
||||
$teams=getJudgingTeams();
|
||||
|
||||
foreach($teams AS $team)
|
||||
{
|
||||
echo "<hr>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td valign=top>";
|
||||
echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": ";
|
||||
echo $team['name'];
|
||||
echo "</th></tr>\n";
|
||||
|
||||
foreach($team['members'] AS $member)
|
||||
{
|
||||
echo "<tr><td>";
|
||||
// echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams.php?action=unassign&unassign=".$award['id']."&edit=".$team['id']."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
|
||||
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".htmlspecialchars($team['name'])."','".$member['id']."')\" type=\"button\" value=\"<<\">";
|
||||
echo "</td><td width=\"100%\">";
|
||||
if($member['captain']=="yes")
|
||||
{
|
||||
echo "<a title=\"Captain - Click to remove captain status\" href=\"judges_teams_members.php?action=removecaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
|
||||
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark.".$config['icon_extension']."\">";
|
||||
echo "</a> ";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<a title=\"Non-Captain - Click to make a team captain\" href=\"judges_teams_members.php?action=addcaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
|
||||
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark_disabled.".$config['icon_extension']."\">";
|
||||
echo "</a> ";
|
||||
|
||||
}
|
||||
echo "<a href=\"\" onclick=\"return openjudgeinfo(".$member['id'].");\">";
|
||||
echo $member['firstname']." ".$member['lastname'];
|
||||
echo "</a>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
|
||||
echo "<br />";
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
send_footer();
|
||||
|
||||
|
||||
|
||||
?>
|
@ -182,20 +182,29 @@ function i18n($str,$args=array())
|
||||
}
|
||||
}
|
||||
|
||||
function error($str)
|
||||
function error($str,$type="normal")
|
||||
{
|
||||
return "<div class=\"error\">$str</div><br />";
|
||||
if($type=="normal")
|
||||
return "<div class=\"error\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
return "<span class=\"error\">$str</span><br />";
|
||||
|
||||
}
|
||||
|
||||
function notice($str)
|
||||
function notice($str,$type="normal")
|
||||
{
|
||||
return "<div class=\"notice\">$str</div><br />";
|
||||
if($type=="normal")
|
||||
return "<div class=\"notice\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
return "<span class=\"notice\">$str</span><br />";
|
||||
}
|
||||
|
||||
function happy($str)
|
||||
function happy($str,$type="normal")
|
||||
{
|
||||
return "<div class=\"happy\">$str</div><br />";
|
||||
if($type=="normal")
|
||||
return "<div class=\"happy\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
return "<span class=\"happy\">$str</span><br />";
|
||||
}
|
||||
|
||||
$HEADER_SENT=false;
|
||||
|
@ -1 +1 @@
|
||||
5
|
||||
6
|
||||
|
9
db/db.update.6.sql
Normal file
9
db/db.update.6.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE `judges_teams_awards_link` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
|
||||
`award_awards_id` INT UNSIGNED NOT NULL ,
|
||||
`judges_teams_id` INT UNSIGNED NOT NULL ,
|
||||
`year` INT NOT NULL ,
|
||||
PRIMARY KEY ( `id` )
|
||||
);
|
||||
ALTER TABLE judges_teams_awards_link ADD UNIQUE (award_awards_id,judges_teams_id,year);
|
||||
ALTER TABLE `judges_teams` CHANGE `name` `name` VARCHAR( 255 ) NOT NULL;
|
Loading…
Reference in New Issue
Block a user