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. */ ?> id); // get the minimum and maximum hours from the schedule $starthour = $endhour = null; foreach($eventList as $event){ if($event['date'] == $date){ $sh = $event['hour']; $eh = $sh + ceil($event['duration'] / 60); if($endhour === null || $endhour < $eh) $endhour = $eh; if($starthour === null || $starthour > $sh) $starthour = $sh; } } //do some sanity checks if($starthour<0 || $starthour>24) $starthour=8; if($endhour<$starthour) $endhour=$starthour+10; if($endhour<0 || $endhour>24) $endhour=15; //minute increment $increment=15; 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.")); 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 //they will be moved by javascript after the fact if(is_array($eventList)){ foreach($eventList as $event){ // skip this event if it's not on the day we're looking at if($event['date'] != $date) continue; // some variables for convenience. Used repeatedly $eid = $event['id']; $hour = $event['hour']; $minute = $event['minute']; $location = $event['locations_id']; $duration = $event['duration']; $eventType = $event['eventtype']; $title = $event['title']; $starttime = strtotime($hour . ":" . $minute); $endtime = $starttime + $duration * 60; echo "
"; echo ""; echo $title; echo ""; echo "
"; echo format_time($starttime); echo " to "; echo format_time($endtime); echo "
"; if($eventType == "scienceolympic") { echo i18n("Capacity").": "; $regteams = getNumRegistrations($eid); $maxteams= $event['somaxteams']; echo i18n("%1 of %2", array($regteams, $maxteams)) . "
"; foreach($event['registrations'] as $regr){ echo "
"; echo $regr['name']; echo "
"; } } echo "
"; $js .= "eventdivs[$eid]={hour:$hour,minute:$minute,location:$location,duration:$duration,title:'".rawurlencode($title)."',eventtype:'$eventType'};\n"; } }else{ // it's actually an error message echo $eventList; } echo ""; }else if($_GET['action']=="loadevent") { }else if($_GET['action']=="saveevent") { }else if($_GET['action'] == "saveteamlist"){ // print_r($_POST); // get a list of all students that could be put on this team $query = "SELECT * FROM users" . " JOIN user_roles ON user_roles.users_id = users.id" . " JOIN roles ON roles.id = user_roles.roles_id" . " WHERE schools_id = $schoolid" . " AND conferences_id = {$conference['id']}" . " AND deleted = 'no'" . " AND roles.type = 'student'"; $availList = array(); while($record = mysql_fetch_array($results)){ $availList[$record['accounts_id']] = $record['firstname'] . ' ' . $record['lastname']; } // let's empty the current list of students for this team $results=mysql_query("DELETE FROM schedule_registrations_users_link WHERE users_uid IN (".implode(',', array_keys($availList)).") AND schedule_registrations_id = ".intval($_POST['regId'])); // and now we'll insert only those that were selected $query = "INSERT INTO schedule_registrations_users_link (schedule_registrations_id, users_uid)"; $query .= " VALUES "; $valueSet = array(); for($n = 0; $n < $_POST['numSelected']; $n++){ $valueSet[] = '(' . (int)$_POST['regId'] . ',' . (int)$_POST[$n] .')'; } $query .= implode(',', $valueSet); $results = mysql_query($query); }else if($_GET['action'] == "getteamlist"){ // first we'll get the basic info, and do a quick check that the selected team is in this user's domain if(!array_key_exists('regId', $_POST)){ echo "error\n"; return; } $query = "SELECT sr.*, so_teams.name as name FROM schedule_registrations sr"; $query .= " JOIN so_teams ON so_teams.id = sr.so_teams_id"; $query .= " WHERE sr.id=" . $_POST['regId']; $query .= " AND so_teams.schools_id = " . $schoolid; $results = mysql_query($query); if(!$results){ echo 'team not found'; return; } $record = mysql_fetch_array($results); $teamName = $record['name']; // get a list of all students that could be put on this team $query = "SELECT * FROM users" . " JOIN user_roles ON user_roles.users_id = users.id" . " JOIN roles ON roles.id = user_roles.roles_id" . " WHERE schools_id = $schoolid" . " AND conferences_id = {$conference['id']}" . " AND deleted = 'no'" . " AND roles.type = 'student'"; $results = mysql_query($query); $availList = array(); while($record = mysql_fetch_array($results)){ $availList[$record['accounts_id']] = $record['firstname'] . ' ' . $record['lastname']; } // now find out which of these students are already selected $query = "SELECT * FROM schedule_registrations_users_link srul"; $query .= " WHERE users_uid IN ("; $query .= implode(',', array_keys($availList)) . ')'; $query .= " AND schedule_registrations_id = " . $_POST['regId']; echo "\n[[[ $query ]]]\n"; $results = mysql_query($query); $selectedList = array(); if($results){ while($record = mysql_fetch_array($results)){ $idx = $record['users_uid']; $selectedList[$idx] = $availList[$idx]; unset($availList[$idx]); } } // get the necessary data about the event itself $query = "SELECT sominteamsize, somaxteamsize, title FROM schedule JOIN" . " schedule_registrations sr ON sr.schedule_id = schedule.id WHERE" . " sr.id = " . $_POST['regId']; $results = mysql_fetch_array(mysql_query($query)); $minTeamSize = $results['sominteamsize']; $maxTeamSize = $results['somaxteamsize']; $eventName = $results['title']; // and let's put out the script to pass this data back to the browser echo ''; }else{ send_header("Event Registration", array('School Home' => 'schoolaccess.php'), "events_scheduling" ); echo "
"; ?> date; } if(count($dates)) $editdate=$dates[0]; else list($editdate,$bla)=explode(" ",$config['dates']['fairdate']); echo "
\n"; echo i18n("Schedule date").": "; echo ""; echo "
\n"; ?>