forked from science-ation/science-ation
judging teams management
This commit is contained in:
parent
01a5028c48
commit
ffd0f36e13
@ -32,6 +32,7 @@
|
||||
echo "<hr />";
|
||||
echo "<a href=\"committees.php\">Committee Management</a> <br />";
|
||||
echo "<a href=\"awards.php\">Awards Management</a> <br />";
|
||||
echo "<a href=\"judges.php\">Judges Management</a> <br />";
|
||||
echo "<hr />";
|
||||
echo "<a href=\"communication.php\">Communication (Send Emails)</a> <br />";
|
||||
|
||||
|
37
admin/judges.php
Normal file
37
admin/judges.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?
|
||||
/*
|
||||
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');
|
||||
|
||||
send_header("Administration - Judges");
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "<a href=\"judges_teams.php\">Judging Teams</a><br />";
|
||||
|
||||
send_footer();
|
||||
|
||||
?>
|
251
admin/judges_teams.php
Normal file
251
admin/judges_teams.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?
|
||||
/*
|
||||
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');
|
||||
|
||||
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,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.judges_id.value=judge;
|
||||
document.forms.judges.submit();
|
||||
}
|
||||
|
||||
</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 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo notice(i18n("Creating new team #%1",array($_POST['team_num'])));
|
||||
mysql_query("INSERT INTO judges_teams (num,year) VALUES ('".$_POST['team_num']."','".$config['FAIRYEAR']."')");
|
||||
$team_id=mysql_insert_id();
|
||||
}
|
||||
|
||||
$added=0;
|
||||
|
||||
foreach($_POST['judgelist'] AS $selectedjudge)
|
||||
{
|
||||
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,year) VALUES ('$selectedjudge','$team_id','".$config['FAIRYEAR']."')");
|
||||
$added++;
|
||||
|
||||
}
|
||||
if($added==1) $j=i18n("judge");
|
||||
else $j=i18n("judges");
|
||||
|
||||
echo happy(i18n("%1 %2 added to team #%3",array($added,$j,$_POST['team_num'])));
|
||||
}
|
||||
|
||||
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",array($_POST['team_num'])));
|
||||
|
||||
$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)
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams WHERE year='".$config['FAIRYEAR']."' AND id='".$_POST['team_id']."'");
|
||||
echo notice(i18n("Removed empty team #%1",array($_POST['team_num'])));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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=\"judges_id\">";
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
echo "<th>".i18n("Judges List")."</th>";
|
||||
echo "<th>Judge Teams</th>";
|
||||
echo "</tr>";
|
||||
echo "<tr><td valign=\"top\">";
|
||||
|
||||
|
||||
/*
|
||||
//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";
|
||||
*/
|
||||
$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
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
|
||||
$q=mysql_query($querystr);
|
||||
|
||||
echo mysql_error();
|
||||
echo "<select name=\"judgelist[]\" multiple=\"multiple\" style=\"width: 250px; height: 600px;\">";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<option value=\"$r->id\">$r->firstname $r->lastname</option>\n";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
echo "</td>";
|
||||
echo "<td valign=\"top\">";
|
||||
|
||||
$q=mysql_query("SELECT judges_teams.id,
|
||||
judges_teams.num,
|
||||
judges.id AS judges_id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
|
||||
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
|
||||
num,
|
||||
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;
|
||||
$lastteamid=$r->id;
|
||||
$lastteamnum=$r->num;
|
||||
}
|
||||
$teams[$lastteamid]['members'][]=array("id"=>$r->judges_id,"firstname"=>$r->firstname,"lastname"=>$r->lastname);
|
||||
}
|
||||
//echo nl2br(print_r($teams,true));
|
||||
|
||||
foreach($teams AS $team)
|
||||
{
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td valign=top>";
|
||||
echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><th colspan=\"2\" align=\"left\">Team #".$team['num']."</th></tr>";
|
||||
|
||||
foreach($team['members'] AS $member)
|
||||
{
|
||||
echo "<tr><td>";
|
||||
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".$member['id']."')\" type=\"button\" value=\"<<\">";
|
||||
echo "</td><td>";
|
||||
echo $member['firstname']." ".$member['lastname'];
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
echo "</td></tr></table>";
|
||||
echo "<hr>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($lastteamnum==-1) $newteamid=1;
|
||||
else $newteamid=$lastteamnum+1;
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td valign=top>";
|
||||
echo "<input onclick=\"addbuttonclicked('$newteamid')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><th align=\"left\">New Team #$newteamid</th></tr>";
|
||||
echo "</table>";
|
||||
|
||||
echo "</td></tr></table>";
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
send_footer();
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user