Move some common schedule functions out

Properly show current capacity in schedule view
This commit is contained in:
james 2010-06-15 21:52:03 +00:00
parent e5d9460d73
commit a4ea7f6b1e
3 changed files with 48 additions and 23 deletions

44
schedule.inc.php Normal file
View File

@ -0,0 +1,44 @@
<?
/*
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.
*/
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;
}
?>

View File

@ -23,6 +23,7 @@
?>
<?
require("common.inc.php");
require_once("schedule.inc.php");
if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
// we're logged in, make sure the school is good
@ -112,9 +113,7 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
if($r->eventtype=="scienceolympic") {
echo "<br />";
echo i18n("Capacity").": ";
//FIXME: get # actually registered
$regteams=0;
$regteams=getNumRegistrations($r->id);
$maxteams=$r->somaxteams;
echo i18n("%1 of %2",array($regteams,$maxteams));
@ -154,6 +153,7 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
buttons: {
"<?=i18n('Close')?>": function() {
$(this).dialog("close");
changeDate();
}
}
});

View File

@ -23,26 +23,7 @@
?>
<?
require("common.inc.php");
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;
}
require_once("schedule.inc.php");
if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
// we're logged in, make sure the school is good