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. */ ?> 'Judging Timeslot', 'divisional1' => 'Divisional Round 1', 'divisional2' => 'Divisional Round 2', 'grand' => 'Grand Awards', 'special' => 'Special Awards' ); if(array_key_exists('action',$_POST)) $action = $_POST['action']; else if(array_key_exists('action',$_GET)) $action = $_GET['action']; else $action = ''; if(array_key_exists('round_id',$_POST)) $round_id = intval($_POST['round_id']); else if(array_key_exists('round_id',$_GET)) $round_id = intval($_GET['round_id']); else $round_id = 0; if(array_key_exists('timeslot_id',$_POST)) $timeslot_id = intval($_POST['timeslot_id']); else if(array_key_exists('timeslot_id',$_GET)) $timeslot_id = intval($_GET['timeslot_id']); else $timeslot_id = 0; if($action == 'saveround') { $save = true; /* Sanity check all the values */ $y = intval($_POST['date_year']); $m = intval($_POST['date_month']); $d = intval($_POST['date_day']); if($y && $m && $d) $date = "$y-$m-$d"; else { $save = false; message_push(error(i18n("Date is required"))); } if(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute', $_POST)) { $starttime = sprintf("%02d:%02d:00", intval($_POST['starttime_hour']), intval($_POST['starttime_minute'])); } else { $save = false; message_push( error(i18n("Start Time is required"))); } if(array_key_exists('endtime_hour', $_POST) && array_key_exists('endtime_minute', $_POST)) { $endtime = sprintf("%02d:%02d:00", intval($_POST['endtime_hour']), intval($_POST['endtime_minute'])); } else { $save = false; message_push( error(i18n("End Time is required"))); } $type = $_POST['type']; if(!array_key_exists($type, $round_str)) { $save = false; message_push(error(i18n('Invalid type specified'))); } $name = mysql_escape_string(stripslashes($_POST['name'])); if($save == true) { if($round_id == 0) { /* New entry */ mysql_query("INSERT INTO judges_timeslots (round_id,conferences_id) VALUES('0','{$conference['id']}')"); $round_id = mysql_insert_id(); } mysql_query("UPDATE judges_timeslots SET `date`='$date', starttime='$starttime', endtime='$endtime', `name`='$name', `type`='$type' WHERE id='$round_id'"); echo mysql_error(); message_push(happy(i18n("Round successfully saved"))); $action = ''; } } if($action == 'deleteround') { mysql_query("DELETE FROM judges_timeslots WHERE id='$round_id'"); /* Also delete all timeslots */ mysql_query("DELETE FROM judges_timeslots WHERE round_id='$round_id'"); message_push(happy(i18n("Round successfully removed"))); $action = ''; } if($action == 'deletetimeslot') { mysql_query("DELETE FROM judges_timeslots WHERE id='$timeslot_id'"); message_push(happy(i18n("Timeslot successfully removed"))); $action = ''; } if($action == 'savetimeslot') { $save = true; $q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'"); $round_data = mysql_fetch_assoc($q); $date = $round_data['date']; if(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute', $_POST)) { $starttime = sprintf("%02d:%02d:00", intval($_POST['starttime_hour']), intval($_POST['starttime_minute'])); } else { $save = false; message_push( error(i18n("Start Time is required"))); } if(array_key_exists('endtime_hour', $_POST) && array_key_exists('endtime_minute', $_POST)) { $endtime = sprintf("%02d:%02d:00", intval($_POST['endtime_hour']), intval($_POST['endtime_minute'])); } else { $save = false; message_push( error(i18n("End Time is required"))); } if($save == true) { if($timeslot_id == 0) { /* New entry */ mysql_query("INSERT INTO judges_timeslots (round_id,date,type,conferences_id) VALUES('$round_id', '$date','timeslot','{$conference['id']}')"); $timeslot_id = mysql_insert_id(); } mysql_query("UPDATE judges_timeslots SET starttime='$starttime', endtime='$endtime' WHERE id='$timeslot_id'"); echo mysql_error(); message_push(happy(i18n("Timeslot successfully saved"))); $action = ''; } } if($action=='savemultiple') { $save = true; $addnum = intval($_POST['addnum']); $duration = intval($_POST['duration'] ); $break = intval($_POST['break']); if(array_key_exists('starttime_hour', $_POST) && array_key_exists('starttime_minute',$_POST) && $addnum && $duration) { $q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'"); $round_data = mysql_fetch_assoc($q); $date = $round_data['date']; $hr=intval($_POST['starttime_hour']); $min=intval($_POST['starttime_minute']); $tt=$duration+$break; for($x=0;$x<$addnum;$x++) { $q=mysql_query("SELECT DATE_ADD('$date $hr:$min:00', INTERVAL $duration MINUTE) AS endtime, DATE_ADD('$date $hr:$min:00', INTERVAL $tt MINUTE) AS startnext "); echo mysql_error(); $r=mysql_fetch_object($q); list($ed,$et)=explode(" ",$r->endtime); list($nd,$nt)=explode(" ",$r->startnext); $starttime = sprintf("%02d:%02d:00", $hr, $min); mysql_query("INSERT INTO judges_timeslots (date,type,round_id,starttime,endtime,conferences_id) VALUES ( '$date','timeslot','{$round_data['id']}', '$starttime', '$et', '{$conference['id']}')"); echo mysql_error(); $date=$nd; list($s_h,$s_m,$s_s)=explode(":",$nt); list($e_h,$e_m,$e_s)=explode(":",$et); message_push(happy(i18n("Adding timeslot: %1",array("$date $hr:$min - $e_h:$e_m")))); $hr=$s_h; $min=$s_m; } $action = ''; } else { message_push(error(i18n("All fields are required to add multiple timeslots"))); } } if($action == '') { send_header("Judging Rounds and Timeslots", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Judges' => 'admin/judges.php')); } else { send_header("Judging Rounds and Timeslots", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', 'Judges' => 'admin/judges.php', 'Judging Rounds and Timeslots' => 'admin/judges_timeslots.php')); } echo "
"; if($action == 'addround' || $action == 'editround') { echo "
"; echo "\n"; echo "\n"; if($action == 'addround') { echo "

Add New Judging Round

"; $r = array(); $r['date'] = $config['dates']['fairdate']; } else { echo "

Edit Judging Round

"; $q=mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'"); if(mysql_num_rows($q) != 1) { echo "UNKNOWN ROUND $round_id"; exit; } $r = mysql_fetch_assoc($q); } echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".i18n('Round Type').":"; echo ""; echo "
".i18n("Name").":"; echo "
".i18n("Date").":"; emit_date_selector("date",$r['date']); echo "
".i18n("Start Time").":"; emit_time_selector("starttime",$r['starttime']); echo "
".i18n("End Time").":"; emit_time_selector("endtime",$r['endtime']); echo "
"; echo ""; echo "
"; } if($action == 'addtimeslot' || $action == 'edittimeslot') { echo "
"; echo "\n"; echo "\n"; echo "\n"; $q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'"); $round_data = mysql_fetch_assoc($q); if($action == 'addtimeslot') { echo "

Add New Judging Timeslot

"; $r = array(); $r['date'] = $round_data['date']; } else { echo "

Edit Judging Timeslot

"; $q=mysql_query("SELECT * FROM judges_timeslots WHERE id='$timeslot_id'"); if(mysql_num_rows($q) != 1) { echo "UNKNOWN ROUND $round_id"; exit; } $r = mysql_fetch_assoc($q); } echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".i18n('Round Type').":{$round_str[$round_data['type']]}
".i18n("Name").":{$round_data['name']}
".i18n("Start Time").":"; emit_time_selector("starttime",$r['starttime']); echo "
".i18n("End Time").":"; emit_time_selector("endtime",$r['endtime']); echo "
"; echo ""; echo "
"; } if($action == 'addmultiple') { echo "

Add Multiple New Judging Timeslots

"; echo "
"; echo "\n"; echo "\n"; echo "\n"; $q = mysql_query("SELECT * FROM judges_timeslots WHERE id='$round_id'"); $round_data = mysql_fetch_assoc($q); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".i18n('Round Type').":{$round_str[$round_data['type']]}
".i18n("Name").":{$round_data['name']}
".i18n("Add").""; echo " "; echo i18n("new timeslots"); echo "
".i18n("Starting timeslots at").""; emit_time_selector("starttime"); echo "
".i18n("With a duration of").""; echo " "; echo i18n("minutes")."
".i18n("And a break of").""; echo " "; echo i18n("minutes")."
"; echo ""; echo "
"; echo "
"; } if($action == '') { echo "".i18n("Add new round")."
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $q=mysql_query("SELECT * FROM judges_timeslots WHERE conferences_id='{$conference['id']}' AND `type`!='timeslot' ORDER BY date,starttime"); while($r=mysql_fetch_object($q)) { echo ""; $qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r->id}' ORDER BY `date`,`starttime`"); $c = mysql_num_rows($qq) +1; echo ""; echo ""; echo ""; echo ""; echo " \n"; echo ""; while($rr = mysql_fetch_object($qq)) { echo ""; // echo ""; echo ""; echo ""; echo ""; echo " \n"; echo ""; } } echo "
".i18n("Date")."".i18n("Start Time")."".i18n("End Time")."".i18n("Judging Round")."".i18n("Actions")."
".format_date($r->date)."".format_time($r->starttime)."
"; echo "
".format_time($r->endtime)."{$r->name} (".i18n($round_str[$r->type]).")"; echo "id}\">"; echo " "; echo "id}\">"; echo "id}\">(new) "; echo "id}\">(multiple)
"; echo "
".format_time($rr->starttime)."".format_time($rr->endtime)."".i18n($round_str[$rr->type]).""; echo "id}×lot_id={$rr->id}\">"; echo " "; echo "id}\">"; echo "
"; } send_footer(); ?>