science-ation/admin/schedule.php

161 lines
4.3 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 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.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
if($_GET['date']) {
$date=$_GET['date'];
if(!eregi("[0-9]{4}-[0-9]{2}-[0-9]{2}",$date)) {
echo "Invalid date";
exit;
}
echo "<h3>".i18n("Schedule for %1",array(format_date($date)))."</h3>";
$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 "<a href=\"locations.php\">".i18n("Location Editor")."</a>\n";
exit;
}
echo "<table class=\"schedule\">\n";
echo "<tr>";
echo "<th style=\"width: 50px;\">&nbsp;</th>";
foreach($locations AS $id=>$name) {
echo " <th>$name</th>\n";
}
$starthour="7";
$endhour="22";
$increment=15;
for($h=$starthour;$h<$endhour;$h++) {
for($m=0;$m<60;$m+=$increment) {
echo "<tr>";
echo " <td class=\"scheduletime\">";
if($m==0) {
echo format_time("$h:$m");
}
echo "</td>";
foreach($locations AS $id=>$name) {
echo "<td id=\"{$h}_{$m}_{$id}\" onclick=\"clickTableCell(this)\">";
/*
if($h==8&&$m==0&&$id==3) {
$height=4;
$pxheight=$height*25;
echo "<div class=\"scheduleevent\" style=\"height: {$pxheight}px;\">";
echo "</div>";
}
*/
echo "</td>";
}
echo "</tr>";
}
}
echo "</table>\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 * FROM schedule WHERE conferences_id='{$conference['id']}' AND date='{$date}'");
while($r=mysql_fetch_object($q)) {
echo "<div class=\"scheduleevent\" id=\"event_{$r->hour}_{$r->minute}_{$r->locations_id}\">";
print_r($r);
echo "</div>";
$js.="eventdivs[$x]={hour:$r->hour,minute:$r->minute,location:$r->locations_id,duration:$r->duration};\n";
$x++;
}
echo "<script type=\"text/javascript\">\n";
echo $js;
echo "</script>";
}
else {
send_header("Schedule Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"events_scheduling" );
echo "<br />";
?>
<script type="text/javascript">
$(document).ready(function() {
$(".date").datepicker({ dateFormat: 'yy-mm-dd' });
changeDate();
});
function changeDate() {
$("#schedulediv").load("schedule.php?date="+$("#date").val(),null,function() {
placeEvents();
});
}
function clickTableCell(t) {
var p=$("#"+t.id).offset();
// alert('You clicked in empty cell : '+t.id+' at top:'+position.top+' left:'+position.left);
$("#scheduleeventeditor").css(p);
// $("#scheduleeventeditor").width(150);
// $("#scheduleeventeditor").height(100);
$("#scheduleeventeditor").show();
}
function placeEvents() {
$('.scheduleevent').each(function(idx,item) {
var tablecellid=item.id.substr(6);
var p=$("#"+tablecellid).offset();
$("#"+item.id).css(p);
$("#"+item.id).show();
}
);
}
</script>
<?
if(!$editdate) {
list($editdate,$bla)=explode(" ",$config['dates']['fairdate']);
}
?>
<form method="post">
<?
echo i18n("Schedule date");
?>
<input id="date" class="date" type="text" name="date" value="<?=$editdate?>" size="15" onchange="changeDate()">
</form>
<hr />
<div id="schedulediv">
</div>
<div id="scheduleeventeditor">
</div>
<?
send_footer();
}
?>