Factor getJudgesTeams into a function since we seem to need to use it all over the place :)

This commit is contained in:
james 2005-04-18 17:56:46 +00:00
parent 9b385a10fd
commit 57ed732bd0
5 changed files with 61 additions and 134 deletions

51
admin/judges.inc.php Normal file
View File

@ -0,0 +1,51 @@
<?
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
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$lastteamid=-1;
$lastteamnum=-1;
echo mysql_error();
$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;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
return $teams;
}
?>

View File

@ -32,6 +32,7 @@
echo "<br />"; echo "<br />";
echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />"; echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />";
echo "<a href=\"judges_timeslots.php\">".i18n("Manage Judging Timeslots")."</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 />"; echo "<a href=\"judges_teams_projects.php\">".i18n("Assign Projects to Teams")."</a><br />";
send_footer(); send_footer();

View File

@ -24,6 +24,7 @@
<? <?
require("../common.inc.php"); require("../common.inc.php");
auth_required('admin'); auth_required('admin');
include "judges.inc.php";
send_header("Administration - Judging Teams"); send_header("Administration - Judging Teams");
?> ?>
@ -321,53 +322,11 @@ function switchjudgeinfo()
echo "</td>"; echo "</td>";
echo "<td valign=\"top\">"; echo "<td valign=\"top\">";
$q=mysql_query("SELECT judges_teams.id, $teams=getJudgingTeams();
judges_teams.num,
judges_teams.name,
judges.id AS judges_id,
judges.firstname,
judges.lastname,
judges_teams_link.captain
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$lastteamid=-1; //grab an array of all the current team numbers
$lastteamnum=-1; foreach($teams AS $team)
echo mysql_error(); $teamnumers[$team['num']]=1;
$teams=array();
while($r=mysql_fetch_object($q))
{
$teamnumbers[$r->num]=1;
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;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
//echo nl2br(print_r($teams,true));
//start at 1, and find the next available team number //start at 1, and find the next available team number
$newteamnum=1; $newteamnum=1;

View File

@ -26,6 +26,7 @@
auth_required('admin'); auth_required('admin');
require("../lpdf.php"); require("../lpdf.php");
require("../lcsv.php"); require("../lcsv.php");
require("judges.inc.php");
$type=$_GET['type']; $type=$_GET['type'];
@ -45,50 +46,7 @@
$rep=new lcsv(i18n("Judging Teams")); $rep=new lcsv(i18n("Judging Teams"));
} }
$q=mysql_query("SELECT judges_teams.id, $teams=getJudgingTeams();
judges_teams.num,
judges_teams.name,
judges.id AS judges_id,
judges.firstname,
judges.lastname,
judges_teams_link.captain
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$lastteamid=-1;
$lastteamnum=-1;
echo mysql_error();
$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;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
$table=array(); $table=array();

View File

@ -26,6 +26,7 @@
auth_required('admin'); auth_required('admin');
require("../lpdf.php"); require("../lpdf.php");
require("../lcsv.php"); require("../lcsv.php");
require("judges.inc.php");
$type=$_GET['type']; $type=$_GET['type'];
@ -45,50 +46,7 @@
$rep=new lcsv(i18n("Judging Teams View")); $rep=new lcsv(i18n("Judging Teams View"));
} }
$q=mysql_query("SELECT judges_teams.id, $teams=getJudgingTeams();
judges_teams.num,
judges_teams.name,
judges.id AS judges_id,
judges.firstname,
judges.lastname,
judges_teams_link.captain
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$lastteamid=-1;
$lastteamnum=-1;
echo mysql_error();
$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;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
foreach($teams AS $team) foreach($teams AS $team)
{ {