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. */ ?> 24) $starthour=8; if($endhour<$starthour) $endhour=$starthour+10; if($endhour<0 || $endhour>24) $endhour=15; //minute increment $increment=15; if(!eregi("[0-9]{4}-[0-9]{2}-[0-9]{2}",$date)) { echo "Invalid date"; exit; } echo "

".i18n("Schedule for %1",array(format_date($date)))."

"; $q=mysql_query("SELECT * FROM locations WHERE conferences_id='{$conference['id']}' ORDER BY name"); while($r=mysql_fetch_object($q)) { $locations[$r->id]=$r->name; } if(!count($locations)) { echo error(i18n("There are no locations defined. Please set up your locations first")); echo "".i18n("Location Editor")."\n"; exit; } echo "\n"; echo ""; echo ""; foreach($locations AS $id=>$name) { echo " \n"; } for($h=$starthour;$h<$endhour;$h++) { for($m=0;$m<60;$m+=$increment) { echo ""; echo " "; foreach($locations AS $id=>$name) { echo ""; } echo ""; } } echo "
 $name
"; if($m==0) { echo format_time("$h:$m"); } echo ""; echo "
\n"; $js="var eventdivs=new Array();\n"; //now make all our DIV's for the events that are scheduled in the database $x=0; //they will be moved by javascript after the fact $q=mysql_query("SELECT schedule.*, events.name, events.eventtype FROM schedule JOIN events ON schedule.events_id=events.id WHERE schedule.conferences_id='{$conference['id']}' AND date='{$date}'"); echo mysql_error(); while($r=mysql_fetch_object($q)) { echo "
eventtype}\" id=\"event_{$r->id}\" onclick=\"editEvent($r->id)\">"; echo "
id)\">
\n"; echo ""; echo $r->title; echo ""; echo "
"; $starttime=strtotime($r->hour.":".$r->minute); $endtime=$starttime+$r->duration*60; echo format_time($starttime); echo " to "; echo format_time($endtime); if($r->eventtype=="scienceolympic") { echo "
"; echo i18n("Teams")." : "; //FIXME: get # actually registered $regteams=0; $maxteams=$r->somaxteams; echo i18n("%1 of %2",array($regteams,$maxteams)); } echo "
"; $js.="eventdivs[$r->id]={hour:$r->hour,minute:$r->minute,location:$r->locations_id,duration:$r->duration};\n"; $x++; } echo ""; } else if($_GET['action']=="loadevent") { $id=intval($_GET['id']); $q=mysql_query("SELECT schedule.*, events.name, events.eventtype FROM schedule, events WHERE schedule.id='$id' AND schedule.conferences_id='{$conference['id']}' AND schedule.events_id=events.id"); echo mysql_error(); if($r=mysql_fetch_array($q)) { $r['idtype']=$r['events_id'].":".$r['eventtype']; echo json_encode($r); } else echo json_encode(array("id"=>0)); exit; } else if($_GET['action']=="saveevent") { $id=intval($_POST['id']); if(!$id) { mysql_query("INSERT INTO schedule (conferences_id) VALUES ('{$conference['id']}')"); $id=mysql_insert_id(); } list($event_id,$event_type)=explode(":",$_POST['event_id']); if($event_id>0) { mysql_query("UPDATE schedule SET title='".mysql_real_escape_string($_POST['title'])."', date='".mysql_real_escape_string($_POST['date'])."', hour='".mysql_real_escape_string($_POST['hour'])."', minute='".mysql_real_escape_string($_POST['minute'])."', duration='".mysql_real_escape_string($_POST['duration'])."', events_id='$event_id', locations_id='".mysql_real_escape_string($_POST['location_id'])."', somaxteams='".mysql_real_escape_string($_POST['somaxteams'])."' WHERE id='$id' AND conferences_id='{$conference['id']}'"); echo mysql_error(); happy_("Event successfully saved"); } else { error_("Error saving event - You must select an event"); } exit; } else if($_GET['action']=="deleteevent") { //FIXME: dont let it delete an event that is already in use! //FIXME: and if we do, delete everything that its been linked to! $id=intval($_POST['id']); mysql_query("DELETE FROM schedule WHERE conferences_id='{$conference['id']}' AND id='{$id}'"); exit; } else { send_header("Schedule Management", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php'), "events_scheduling" ); echo "
"; ?>