science-ation/schedule.inc.php

89 lines
2.9 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2010 Youth Science Ontario <info@youthscienceontario.ca>
Copyright (C) 2010 James Grant <james@lightbox.org>
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.
*/
$ROWHEIGHT=20;
$BORDERSIZE=2;
function getTeamEventStatus($teamid,$scheduleid) {
global $conference;
$q=mysql_query("SELECT * FROM schedule_registrations WHERE so_teams_id='$teamid' AND schedule_id='$scheduleid' AND conferences_id='{$conference['id']}'");
//we use registered/notregistered insetad of true/false becuase we might haevf other statuses down the line, like "waitinglist"
if(mysql_num_rows($q)) {
return "registered";
}
else
return "notregistered";
}
function getNumRegistrations($scheduleid) {
global $conference;
$q=mysql_query("SELECT COUNT(*) AS num FROM schedule_registrations WHERE schedule_id='$scheduleid' AND conferences_id='{$conference['id']}'");
$r=mysql_fetch_object($q);
return $r->num;
}
function getEventList($conferencesId, $school_id){
global $conference;
$events = array();
$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']}'");
$err = mysql_error();
if($err != "") return($err);
while($event = mysql_fetch_assoc($q)) {
if($event['eventtype'] == "scienceolympic") {
$regteams = getNumRegistrations($event['id']);
$maxteams = $event['somaxteams'];
$regq = mysql_query("SELECT so_teams.name, schedule_registrations.id
FROM schedule_registrations
JOIN so_teams ON so_teams_id=so_teams.id
WHERE schedule_registrations.conferences_id='{$conferencesId}'
AND so_teams.schools_id=$school_id
AND schedule_registrations.schedule_id='{$event['id']}'");
$err = mysql_error();
if($err != "") break;
$event['registrations'] = array();
while($regr = mysql_fetch_assoc($regq)) {
$event['registrations'][] = $regr;
}
}
$events[] = $event;
}
if($err != "") return($err);
return $events;
}
function getLocationList($conferencesId){
global $conference;
$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;
}
return $locations;
}
?>