Implement start hour and end hour for schedule view

Implement event duration height calculations
This commit is contained in:
james 2010-06-11 15:55:16 +00:00
parent 44fd9bea1f
commit 80fc39bf7f

View File

@ -25,8 +25,24 @@
require("../common.inc.php"); require("../common.inc.php");
require_once("../user.inc.php"); require_once("../user.inc.php");
user_auth_required('committee', 'admin'); user_auth_required('committee', 'admin');
if($_GET['date']) {
$date=$_GET['date']; $ROWHEIGHT=20;
$BORDERSIZE=2;
if($_POST['date']) {
$date=$_POST['date'];
$starthour=$_POST['starthour'];
$endhour=$_POST['endhour'];
//do some sanity checks
if($starthour<0 || $starthour>24) $starthour=7;
if($endhour<$starthour)
$endhour=$starthour+10;
if($endhour<0 || $endhour>24) $endhour=17;
//minute increment
$increment=15;
if(!eregi("[0-9]{4}-[0-9]{2}-[0-9]{2}",$date)) { if(!eregi("[0-9]{4}-[0-9]{2}-[0-9]{2}",$date)) {
echo "Invalid date"; echo "Invalid date";
exit; exit;
@ -48,9 +64,6 @@
foreach($locations AS $id=>$name) { foreach($locations AS $id=>$name) {
echo " <th>$name</th>\n"; echo " <th>$name</th>\n";
} }
$starthour="7";
$endhour="22";
$increment=15;
for($h=$starthour;$h<$endhour;$h++) { for($h=$starthour;$h<$endhour;$h++) {
for($m=0;$m<60;$m+=$increment) { for($m=0;$m<60;$m+=$increment) {
echo "<tr>"; echo "<tr>";
@ -83,10 +96,10 @@
//they will be moved by javascript after the fact //they will be moved by javascript after the fact
$q=mysql_query("SELECT * FROM schedule WHERE conferences_id='{$conference['id']}' AND date='{$date}'"); $q=mysql_query("SELECT * FROM schedule WHERE conferences_id='{$conference['id']}' AND date='{$date}'");
while($r=mysql_fetch_object($q)) { while($r=mysql_fetch_object($q)) {
echo "<div class=\"scheduleevent\" id=\"event_{$r->hour}_{$r->minute}_{$r->locations_id}\">"; echo "<div class=\"scheduleevent\" id=\"event_{$r->id}\">";
print_r($r); print_r($r);
echo "</div>"; echo "</div>";
$js.="eventdivs[$x]={hour:$r->hour,minute:$r->minute,location:$r->locations_id,duration:$r->duration};\n"; $js.="eventdivs[$r->id]={hour:$r->hour,minute:$r->minute,location:$r->locations_id,duration:$r->duration};\n";
$x++; $x++;
} }
echo "<script type=\"text/javascript\">\n"; echo "<script type=\"text/javascript\">\n";
@ -108,7 +121,7 @@
}); });
function changeDate() { function changeDate() {
$("#schedulediv").load("schedule.php?date="+$("#date").val(),null,function() { $("#schedulediv").load("schedule.php",{date:$("#date").val(),starthour:$("#starthour").val(),endhour:$("#endhour").val()},function() {
placeEvents(); placeEvents();
}); });
} }
@ -126,11 +139,17 @@
function placeEvents() { function placeEvents() {
$('.scheduleevent').each(function(idx,item) { $('.scheduleevent').each(function(idx,item) {
var tablecellid=item.id.substr(6); var eventid=item.id.substr(6);
var eventobj=eventdivs[eventid];
var tablecellid=eventobj.hour+'_'+eventobj.minute+'_'+eventobj.location;
var eheight=((eventobj.duration/15)*<?=$ROWHEIGHT?>)-<? echo $BORDERSIZE*2; ?>;
var p=$("#"+tablecellid).offset(); var p=$("#"+tablecellid).offset();
$("#"+item.id).css(p); $("#"+item.id).css(p);
$("#"+item.id).show(); $("#"+item.id).show();
$("#"+item.id).height(eheight);
} }
); );
} }
@ -142,10 +161,13 @@
} }
?> ?>
<form method="post"> <form method="post">
<? <? echo i18n("Schedule date"); ?>
echo i18n("Schedule date");
?>
<input id="date" class="date" type="text" name="date" value="<?=$editdate?>" size="15" onchange="changeDate()"> <input id="date" class="date" type="text" name="date" value="<?=$editdate?>" size="15" onchange="changeDate()">
<? echo i18n("Start hour")." ";
emit_hour_selector("starthour",7,"onchange=\"changeDate()\"");
echo i18n("End hour")." ";
emit_hour_selector("endhour",17,"onchange=\"changeDate()\"");
?>
</form> </form>
<hr /> <hr />
<div id="schedulediv"> <div id="schedulediv">