From 57ec92392a6e57ec3025c026af53ee613439f214 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 19 Apr 2005 18:36:03 +0000 Subject: [PATCH] Add judges team timeslots assignments (finished) Add judges team projects assignments (in progress) --- admin/judges.inc.php | 55 ++++++ admin/judges_teams_projects.php | 308 +++++++++++++++++++++++++++++++ admin/judges_teams_timeslots.php | 225 ++++++++++++++++++++++ 3 files changed, 588 insertions(+) create mode 100644 admin/judges_teams_projects.php create mode 100644 admin/judges_teams_timeslots.php diff --git a/admin/judges.inc.php b/admin/judges.inc.php index f375ab7..6eee61a 100644 --- a/admin/judges.inc.php +++ b/admin/judges.inc.php @@ -1,6 +1,8 @@ id; + $team['num']=$r->num; + $team['name']=$r->name; + $first=false; + } + + $team['members'][]=array( + "id"=>$r->judges_id, + "firstname"=>$r->firstname, + "lastname"=>$r->lastname, + "captain"=>$r->captain + ); + } + return $team; + +} + ?> diff --git a/admin/judges_teams_projects.php b/admin/judges_teams_projects.php new file mode 100644 index 0000000..0602ab8 --- /dev/null +++ b/admin/judges_teams_projects.php @@ -0,0 +1,308 @@ + + Copyright (C) 2005 James Grant + + 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. +*/ +?> + + + + + + << ".i18n("Back to Administration")."\n"; + echo "<< ".i18n("Back to Judges")."\n"; + echo "
"; + echo "
"; + + if($_GET['action']=="delete" && $_GET['delete']) + { + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='".$_GET['delete']."'"); + echo happy(i18n("Judging team timeslot successfully removed")); + } + + if($_GET['action']=="empty" && $_GET['empty']) + { + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['empty']."'"); + echo happy(i18n("Judging team timeslots successfully removed")); + } + + if($_POST['action']=="assign") + { + //the db handles the uniqueness (to ensure the same timeslot isnt assigned to the same team more than once) + //so all we'll do here is just mass insert without regards for whats already there. + foreach($_POST['teams'] AS $tm) + { + foreach($_POST['timeslots'] AS $ts) + { + mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year) VALUES ('$tm','$ts','".$config['FAIRYEAR']."')"); + + } + } + echo happy(i18n("%1 Timeslots assigned to %2 teams",array(count($_POST['timeslots']),count($_POST['teams'])))); + } + + + if($_GET['action']=="edit" && $_GET['edit']) + { + echo "
"; + $team=getJudgingTeam($_GET['edit']); + + echo "".$team['name']." (#".$team['num'].")
"; + $memberlist="  "; + foreach($team['members'] AS $member) + { + if($member['captain']=="yes") + $memberlist.=""; + $memberlist.=$member['firstname']." ".$member['lastname']; + if($member['captain']=="yes") + $memberlist.=""; + $memberlist.=", "; + } + $memberlist=substr($memberlist,0,-2); + echo $memberlist; + echo "
"; + + + $q=mysql_query("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 + "); + echo mysql_error(); + $numprojects=mysql_num_rows($q); + echo "
"; + echo ""; + echo "$numprojects projects listed"; + + + //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 "
"; + echo "
"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + + while($r=mysql_fetch_object($q)) + { + echo ""; + } + echo "
TimeslotProject
"; + + if($show_date) + echo "$r->date "; + echo substr($r->starttime,0,-3); + echo " - "; + echo substr($r->endtime,0,-3); + echo ""; + + $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
"; + + } + + echo "
"; + + + + + echo "
"; + } + else + { + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $teams=getJudgingTeams(); + foreach($teams AS $team) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
".i18n("Team")."".i18n("Timeslots and Projects")."
"; + echo "".$team['name']." (#".$team['num'].")
"; + $memberlist=""; + foreach($team['members'] AS $member) + { + echo "  "; + if($member['captain']=="yes") + echo ""; + echo $member['firstname']." ".$member['lastname']."
"; + if($member['captain']=="yes") + echo "
"; + + } + echo "
"; + //get the timeslots that this team has. + $q=mysql_query("SELECT + judges_teams_timeslots_link.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 "Edit team project assignments"; + + echo ""; + + while($r=mysql_fetch_object($q)) + { + echo ""; + } + echo "
"; + + if($show_date) + echo "$r->date "; + echo substr($r->starttime,0,-3); + echo " - "; + echo substr($r->endtime,0,-3); + echo ""; + + //FIXME: list the projects :) + + + echo "
"; + + echo "
"; + + } + + send_footer(); +?> diff --git a/admin/judges_teams_timeslots.php b/admin/judges_teams_timeslots.php new file mode 100644 index 0000000..9a70003 --- /dev/null +++ b/admin/judges_teams_timeslots.php @@ -0,0 +1,225 @@ + + Copyright (C) 2005 James Grant + + 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. +*/ +?> + + + + + + << ".i18n("Back to Administration")."\n"; + echo "<< ".i18n("Back to Judges")."\n"; + echo "
"; + echo "
"; + + if($_GET['action']=="delete" && $_GET['delete']) + { + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='".$_GET['delete']."'"); + echo happy(i18n("Judging team timeslot successfully removed")); + } + + if($_GET['action']=="empty" && $_GET['empty']) + { + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['empty']."'"); + echo happy(i18n("Judging team timeslots successfully removed")); + } + + if($_POST['action']=="assign") + { + //the db handles the uniqueness (to ensure the same timeslot isnt assigned to the same team more than once) + //so all we'll do here is just mass insert without regards for whats already there. + foreach($_POST['teams'] AS $tm) + { + foreach($_POST['timeslots'] AS $ts) + { + mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year) VALUES ('$tm','$ts','".$config['FAIRYEAR']."')"); + + } + } + echo happy(i18n("%1 Timeslots assigned to %2 teams",array(count($_POST['timeslots']),count($_POST['teams'])))); + } + + echo "
"; + echo ""; + + echo "Choose timeslots to assign:
"; + echo "select all"; + echo " | "; + echo "select none"; + echo " | "; + echo "invert selection"; + + + $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; + + echo ""; + echo ""; + echo ""; + if($show_date) echo ""; + echo ""; + echo ""; + echo "\n"; + + $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date,starttime"); + while($r=mysql_fetch_object($q)) + { + echo ""; + echo ""; + if($show_date) echo ""; + echo ""; + echo ""; + echo "\n"; + } + echo "
 ".i18n("Date")."".i18n("Start Time")."".i18n("End Time")."
id\" />$r->date".substr($r->starttime,0,-3)."".substr($r->endtime,0,-3)."
"; + + echo "
"; + echo "
"; + echo "Choose teams to assign the above selected timeslots to:"; + echo "
"; + + echo "select all"; + echo " | "; + echo "select none"; + echo " | "; + echo "invert selection"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $teams=getJudgingTeams(); + foreach($teams AS $team) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo "
 ".i18n("Team")."".i18n("Timeslots")."
"; + echo "".$team['name']." (#".$team['num'].")
"; + $memberlist=""; + foreach($team['members'] AS $member) + { + echo "  "; + if($member['captain']=="yes") + echo ""; + echo $member['firstname']." ".$member['lastname']."
"; + if($member['captain']=="yes") + echo "
"; + + } + echo "
"; + //get the timeslots that this team has. + $q=mysql_query("SELECT + judges_teams_timeslots_link.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); + + while($r=mysql_fetch_object($q)) + { + if($show_date) + echo "$r->date "; + echo substr($r->starttime,0,-3); + echo " - "; + echo substr($r->endtime,0,-3); + echo "  id\">"; + echo "
"; + } + if($numslots) + echo "  remove all"; + + echo "
"; + + echo "
"; + echo "
"; + echo ""; + echo "
"; + + + send_footer(); +?>