science-ation/admin/judges_teams_projects.php

357 lines
9.9 KiB
PHP
Raw Normal View History

<?
/*
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');
require("judges.inc.php");
send_header("Judging Teams Projects");
?>
<script language="javascript" type="text/javascript">
2005-04-19 19:22:25 +00:00
function assign(ts)
{
2005-04-19 19:22:25 +00:00
document.forms.teamsprojects.timeslot.value=ts;
document.forms.teamsprojects.submit();
}
</script>
<?
echo "<a href=\"index.php\">&lt;&lt; ".i18n("Back to Administration")."</a>\n";
echo "<a href=\"judges.php\">&lt;&lt; ".i18n("Back to Judges")."</a>\n";
echo "<br />";
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'];
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-04-19 19:22:25 +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";
}
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"));
}
$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;
if( ($action=="edit" || $action=="assign" ) && $edit)
{
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);
echo "<b>".$team['name']." (#".$team['num'].")</b><br />";
$memberlist="&nbsp;&nbsp;";
foreach($team['members'] AS $member)
{
if($member['captain']=="yes")
$memberlist.="<i>";
$memberlist.=$member['firstname']." ".$member['lastname'];
if($member['captain']=="yes")
$memberlist.="</i>";
$memberlist.=", ";
}
$memberlist=substr($memberlist,0,-2);
echo $memberlist;
echo "<br />";
if($_SESSION['viewstate']['judges_projects_list_show']=='all')
{
$querystr="SELECT
projects.id,
projects.projectnumber,
projects.title,
registrations.status
FROM
projects,
registrations
WHERE
projectnumber is not null AND
registrations.status='complete' AND
projects.registrations_id=registrations.id AND
projects.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber";
}
else
{
$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
projectnumber is not null AND
registrations.status='complete' AND
projects.registrations_id=registrations.id AND
judges_teams_timeslots_projects_link.projects_id IS NULL AND
projects.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber";
}
$q=mysql_query($querystr);
echo mysql_error();
$numprojects=mysql_num_rows($q);
echo "<br />";
echo "<table>";
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>&nbsp;</td>";
echo "</tr>";
echo "<tr><td colspan=2>";
echo "<select name=\"project_id\">";
echo "<option value=\"\">Choose Project to Assign to Timeslot</option>\n";
while($r=mysql_fetch_object($q))
{
echo "<option value=\"$r->id\">$r->projectnumber - $r->title</option>\n";
}
echo "</select>";
echo "</td><td>";
echo "$numprojects projects listed";
echo "</td></tr>";
echo "</table>";
//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);
echo "<br />";
echo "<br />";
echo "<table class=\"summarytable\">";
echo "<tr>";
echo "<th>Timeslot</th>";
echo "<th>Project</th>";
echo "</tr>";
while($r=mysql_fetch_object($q))
{
echo "<tr><td>";
2005-04-19 19:22:25 +00:00
echo "<nobr>";
if($show_date)
echo "$r->date ";
echo substr($r->starttime,0,-3);
echo " - ";
echo substr($r->endtime,0,-3);
2005-04-19 19:22:25 +00:00
echo "</nobr>";
echo "</td><td>";
$projq=mysql_query("SELECT
2005-04-19 19:22:25 +00:00
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();
while($proj=mysql_fetch_object($projq))
{
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 />";
}
2005-04-19 19:22:25 +00:00
echo "<input name=\"assignbtn[$r->id]\" type=\"button\" onclick=\"assign('$r->id')\" value=\"Assign\">";
echo "</td></tr>";
}
echo "</table>";
echo "</form>";
}
else
{
echo "<input type=\"hidden\" name=\"action\" value=\"assign\">";
echo "<table class=\"summarytable\">";
echo "<tr>";
echo "<th>".i18n("Team")."</th>";
echo "<th>".i18n("Timeslots and Projects")."</th>";
echo "</tr>";
$teams=getJudgingTeams();
foreach($teams AS $team)
{
echo "<tr>";
echo "<td>";
echo "<b>".$team['name']." (#".$team['num'].")</b><br />";
$memberlist="";
foreach($team['members'] AS $member)
{
echo "&nbsp;&nbsp;";
if($member['captain']=="yes")
echo "<i>";
echo $member['firstname']." ".$member['lastname']."<br />";
if($member['captain']=="yes")
echo "</i>";
}
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,
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);
echo "<a href=\"judges_teams_projects.php?action=edit&edit=".$team['id']."\">Edit team project assignments</a>";
echo "<table class=summarytable style=\"margin-left: 0px; width: 100%;\">";
while($r=mysql_fetch_object($q))
{
echo "<tr><td>";
2005-04-19 19:22:25 +00:00
echo "<nobr>";
if($show_date)
echo "$r->date ";
2005-04-19 19:22:25 +00:00
echo substr($r->starttime,0,-3);
echo " - ";
echo substr($r->endtime,0,-3);
2005-04-19 19:22:25 +00:00
echo "</nobr>";
echo "</td><td>";
2005-04-19 19:22:25 +00:00
$projq=mysql_query("SELECT
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();
while($proj=mysql_fetch_object($projq))
{
echo "$proj->projectnumber - $proj->title <br />";
}
echo "</td></tr>";
}
echo "</table>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
send_footer();
?>