diff --git a/admin/judges_teams_timeslots.php b/admin/judges_teams_timeslots.php index 811c6b23..88ed5823 100644 --- a/admin/judges_teams_timeslots.php +++ b/admin/judges_teams_timeslots.php @@ -22,22 +22,64 @@ */ ?> 'Judging Timeslot', + 'divisional1' => 'Divisional Round 1', + 'divisional2' => 'Divisional Round 2', + 'grand' => 'Grand Awards', + 'special' => 'Special Awards' ); + if(array_key_exists('action',$_GET)) + $action = $_GET['action']; + if(array_key_exists('action',$_POST)) + $action = $_POST['action']; + + + if($action == 'delete' && array_key_exists('delete', $_GET)) { + $id = intval($_GET['delete']); + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE id='$id'"); + message_push(happy(i18n("Judging team timeslot successfully removed"))); + } + + if($action == 'empty' && array_key_exists('empty',$_GET)) { + $id = intval($_GET['empty']); + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id'"); + message_push(happy(i18n("Judging team timeslots successfully removed"))); + } + + if($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. + if(count($_POST['teams']) && count($_POST['timeslots'])) { + 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']}')"); + + } + } + message_push(happy(i18n("%1 Timeslots assigned to %2 teams",array(count($_POST['timeslots']),count($_POST['teams']))))); + } else { + message_push(error(i18n("You must select both team(s) and timeslot(s) to assign"))); + } + } + + + + send_header("Judging Teams Timeslots", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Judges' => 'admin/judges.php') ); + ?> - - "; - 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. - if(count($_POST['teams']) && count($_POST['timeslots'])) - { - 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'])))); - } - else - echo error(i18n("You must select both team(s) and timeslot(s) to assign")); - } - echo "
"; echo ""; @@ -134,15 +140,23 @@ function checkinvert(what) echo "".i18n("End Time").""; echo "\n"; - $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date,starttime"); - while($r=mysql_fetch_object($q)) - { + $q=mysql_query("SELECT * FROM judges_timeslots + WHERE year='{$config['FAIRYEAR']}' + AND round_id='0' ORDER BY date,starttime"); + while($r=mysql_fetch_object($q)) { echo ""; - echo "id\" />"; - if($show_date) echo "$r->date"; - echo "".substr($r->starttime,0,-3).""; - echo "".substr($r->endtime,0,-3).""; - echo "\n"; + $span = $show_date ? 4 : 3; + echo "{$r->name} (".$round_str[$r->type].")"; + $qq = mysql_query("SELECT * FROM judges_timeslots + WHERE round_id='{$r->id}' ORDER BY date,starttime"); + while($rr = mysql_fetch_object($qq)) { + echo ""; + echo "id}\" />"; + if($show_date) echo "{$r->date}"; + echo "".substr($rr->starttime,0,-3).""; + echo "".substr($rr->endtime,0,-3).""; + echo "\n"; + } } echo "";