diff --git a/admin/judges_timeslots.php b/admin/judges_timeslots.php index 8ba7bd8..2d5bbd4 100644 --- a/admin/judges_timeslots.php +++ b/admin/judges_timeslots.php @@ -63,6 +63,8 @@ echo error(i18n("End Time is required")); } + $allowdivisional=$_POST['allowdivisional']; + if(!$allowdivisional) $allowdivisional="no"; if(!$err) { @@ -73,12 +75,53 @@ } if($_POST['action']=="edit") { - mysql_query("UPDATE judges_timeslots SET `date`='$date', starttime='$starttime', endtime='$endtime' WHERE id='".$_POST['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']) @@ -89,7 +132,75 @@ } - if($_GET['action']=="add" || $_GET['action']=="edit") + if($_GET['action']=="addmultiple") + { + + echo "