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. */ ?> 'committee_main.php', 'Administration' => 'admin/index.php', 'Judges' => 'admin/judges.php') ); echo "
"; if($_POST['action']=="add" || $_POST['action']=="edit") { $err=0; if($_POST['date_year'] && $_POST['date_month'] && $_POST['date_day']) { $date=$_POST['date_year'] ."-". $_POST['date_month'] ."-". $_POST['date_day']; } else { $err=1; echo error(i18n("Date is required")); } if($_POST['starttime_hour'] && $_POST['starttime_minute']) { $starttime=$_POST['starttime_hour'] .":". $_POST['starttime_minute'].":00"; } else { $err=1; echo error(i18n("Start Time is required")); } if($_POST['endtime_hour'] && $_POST['endtime_minute']) { $endtime=$_POST['endtime_hour'] .":". $_POST['endtime_minute'].":00"; } else { $err=1; echo error(i18n("End Time is required")); } $allowdivisional=$_POST['allowdivisional']; if(!$allowdivisional) $allowdivisional="no"; if(!$err) { if($_POST['action']=="add") { mysql_query("INSERT INTO judges_timeslots (date,starttime,endtime,year) VALUES ('$date','$starttime','$endtime','".$config['FAIRYEAR']."')"); echo happy(i18n("New timeslot successfully added")); } if($_POST['action']=="edit") { mysql_query("UPDATE judges_timeslots SET `date`='$date', starttime='$starttime', endtime='$endtime', allowdivisional='$allowdivisional' WHERE id='".$_POST['edit']."'"); echo mysql_error(); echo happy(i18n("Timeslot successfully saved")); } } } else if($_POST['action']=="addmultiple") { if($_POST['addnum'] && $_POST['date_day'] && $_POST['date_month'] && $_POST['date_year'] && $_POST['starttime_hour'] && $_POST['starttime_minute'] && $_POST['duration'] && $_POST['break']) { $date=$_POST['date_year']."-".$_POST['date_month']."-".$_POST['date_day']; $hr=$_POST['starttime_hour']; $min=$_POST['starttime_minute']; $dur=$_POST['duration']; $brk=$_POST['break']; $tt=$dur+$brk; if($_POST['allowdivisional']=="yes") $ad="yes"; else $ad="no"; for($x=0;$x<$_POST['addnum'];$x++) { $q=mysql_query("SELECT DATE_ADD('$date $hr:$min:00', INTERVAL $dur 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)=split(" ",$r->endtime); list($nd,$nt)=split(" ",$r->startnext); mysql_query("INSERT INTO judges_timeslots (date,starttime,endtime,allowdivisional,year) VALUES ( '$date', '$hr:$min:00', '$et', '$ad', '".$config['FAIRYEAR']."')"); echo mysql_Error(); $date=$nd; list($s_h,$s_m,$s_s)=split(":",$nt); list($e_h,$e_m,$e_s)=split(":",$et); echo happy(i18n("Adding timeslot: %1",array($date." ".$hr.":".$min." - ".$e_h.":".$e_m))); $hr=$s_h; $min=$s_m; } } else echo error(i18n("All fields are required to add multiple timeslots")); } //FIXME: only delete if the timeslot is not in use!!! if($_GET['action']=="delete" && $_GET['delete']) { mysql_query("DELETE FROM judges_timeslots WHERE id='".$_GET['delete']."'"); echo happy(i18n("Timeslot successfully removed")); } if($_GET['action']=="addmultiple") { echo "

Add Multiple New Judging Timeslots

"; echo "<< ".i18n("Back to Judging Timeslots")."\n"; $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date DESC LIMIT 1"); if(mysql_num_rows($q)) { $r=mysql_fetch_object($q); $date=$r->date; } else { $date=$config['dates']['fairdate']; } echo "
"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo i18n("Add"); echo ""; echo ""; echo ""; echo i18n("new timeslots"); echo "
"; echo i18n("On date"); echo ""; emit_date_selector("date",$date); echo "
"; echo i18n("Starting timeslots at"); echo ""; emit_time_selector("starttime"); echo "
"; echo i18n("With a duration of"); echo ""; echo ""; echo ""; echo i18n("minutes"); echo "
"; echo i18n("And a break of"); echo ""; echo ""; echo ""; echo i18n("minutes"); echo "
"; if($allowdivisional=="yes") $ch="checked=\"checked\""; else $ch=""; echo ""; echo ""; echo i18n("Allow this timeslot to be used by the automatic judges scheduler for divisional awards"); echo "
"; echo ""; echo "
"; echo "
"; $showlist=false; } else if($_GET['action']=="add" || $_GET['action']=="edit") { echo "
"; echo "\n"; if($_GET['action']=="add") { echo "

Add New Judging Timeslot

"; $buttontext=i18n("Add Timeslot"); //get a default date, either the date from a different timeslot, or the date of the fair, whichever. $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date DESC LIMIT 1"); if(mysql_num_rows($q)) { $r=mysql_fetch_object($q); $date=$r->date; } else { $date=$config['dates']['fairdate']; } $starttime=""; $endtime=""; $allowdivisional="yes"; } else if($_GET['action']=="edit") { echo "\n"; echo "

Edit Judging Timeslot

"; $buttontext=i18n("Save Timeslot"); $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' AND id='".$_GET['edit']."'"); $r=mysql_fetch_object($q); $date=$r->date; $starttime=$r->starttime; $endtime=$r->endtime; $allowdivisional=$r->allowdivisional; } echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".i18n("Date").":"; emit_date_selector("date",$date); echo "
".i18n("Start Time").":"; emit_time_selector("starttime",$starttime); echo "
".i18n("End Time").":"; emit_time_selector("endtime",$endtime); echo "
"; if($allowdivisional=="yes") $ch="checked=\"checked\""; else $ch=""; echo ""; echo ""; echo i18n("Allow this timeslot to be used by the automatic judges scheduler for divisional awards"); echo "
"; echo ""; echo "
"; } else { echo "".i18n("Add new judging timeslot")."
"; echo "".i18n("Add multiple new judging timeslots")."
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' ORDER BY date,starttime"); while($r=mysql_fetch_object($q)) { echo ""; // echo ""; echo ""; echo ""; echo ""; echo ""; echo " \n"; echo ""; } echo "
".i18n("Date")."".i18n("Start Time")."".i18n("End Time")."".i18n("Div OK?")."".i18n("Actions")."
$r->id$r->date".substr($r->starttime,0,-3)."".substr($r->endtime,0,-3)."$r->allowdivisional"; echo "id\">"; echo " "; echo "id\">"; echo "
"; } send_footer(); ?>