diff --git a/admin/judges_teams_projects.php b/admin/judges_teams_projects.php index 0602ab8..00d5b16 100644 --- a/admin/judges_teams_projects.php +++ b/admin/judges_teams_projects.php @@ -29,45 +29,13 @@ send_header("Judging Teams Projects"); ?> - - << ".i18n("Back to Administration")."\n"; @@ -75,38 +43,43 @@ function checkinvert(what) echo "
"; echo "
"; - if($_GET['action']=="delete" && $_GET['delete']) + 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($_GET['action']=="delete" && $_GET['delete'] && $_GET['edit']) { - mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='".$_GET['delete']."'"); - echo happy(i18n("Judging team timeslot successfully removed")); + mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE id='".$_GET['delete']."'"); + echo happy(i18n("Judging team project successfully removed")); + $action="edit"; } +/* 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") + if($_POST['action']=="assign" && $_POST['edit'] && $_POST['timeslot'] && $_POST['project_id']) { - //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'])))); + 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")); } - if($_GET['action']=="edit" && $_GET['edit']) + if( ($action=="edit" || $action=="assign" ) && $edit) { - echo "
"; - $team=getJudgingTeam($_GET['edit']); + echo "Back to Judging Teams Projects List"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $team=getJudgingTeam($edit); echo "".$team['name']." (#".$team['num'].")
"; $memberlist="  "; @@ -187,14 +160,17 @@ function checkinvert(what) { echo ""; + echo ""; if($show_date) echo "$r->date "; echo substr($r->starttime,0,-3); echo " - "; echo substr($r->endtime,0,-3); + echo ""; echo ""; $projq=mysql_query("SELECT + judges_teams_timeslots_projects_link.id AS link_id, projects.projectnumber, projects.id, projects.title @@ -213,9 +189,11 @@ function checkinvert(what) echo mysql_Error(); while($proj=mysql_fetch_object($projq)) { + echo "link_id."&edit=".$team['id']."\">"; echo "$proj->projectnumber - $proj->title
"; } + echo "id]\" type=\"button\" onclick=\"assign('$r->id')\" value=\"Assign\">"; echo ""; } @@ -257,7 +235,7 @@ function checkinvert(what) echo ""; //get the timeslots that this team has. $q=mysql_query("SELECT - judges_teams_timeslots_link.id, + judges_timeslots.id, judges_timeslots.date, judges_timeslots.starttime, judges_timeslots.endtime @@ -282,14 +260,37 @@ function checkinvert(what) { echo ""; + echo ""; if($show_date) echo "$r->date "; + echo substr($r->starttime,0,-3); echo " - "; echo substr($r->endtime,0,-3); + echo ""; echo ""; - //FIXME: list the projects :) + $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 "";