4 Nov 2002 10:48
now all changed files for room-dependences
Sven Kuehnel <svenk <at> mpipks-dresden.mpg.de>
2002-11-04 09:48:56 GMT
2002-11-04 09:48:56 GMT
i hope i get an answer of the developer. regards sven
<?php
# $Id: day.php,v 1.2 2002/10/29 08:43:22 mrbs Exp $
include "config.inc";
include "functions.inc";
include "$dbsys.inc";
include "mincals.inc";
#If we dont know the right date then make it up
if (!isset($day) or !isset($month) or !isset($year))
{
$day = date("d");
$month = date("m");
$year = date("Y");
} else {
# Make the date valid if day is more then number of days in month
while (!checkdate($month, $day, $year))
$day--;
}
if (empty($area))
$area = get_default_area();
# print the page header
print_header($day, $month, $year, $area);
# Define the start and end of the day.
$am7=mktime($morningstarts,0,0,$month,$day,$year);
$pm7=mktime($eveningends,$eveningends_minutes,0,$month,$day,$year);
if ( $pview != 1 ) {
echo "<table><tr><td width=\"100%\">";
#Show all avaliable areas
echo "<u>$vocab[areas]</u><br>";
# need to show either a select box or a normal html list,
# depending on the settings in config.inc
if ($area_list_format == "select") {
echo make_area_select_html('day.php', $area, $year, $month, $day); # from functions.inc
} else {
# show the standard html list
$sql = "SELECT id, area_name FROM mrbs_area ORDER BY area_name";
$res = sql_query($sql);
if ($res) for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
echo "<a href=\"day.php?year=$year&month=$month&day=$day&area=$row[0]\">";
if ($row[0] == $area)
echo "<font color=\"red\">" . htmlspecialchars($row[1]) . "</font></a><br>\n";
else echo htmlspecialchars($row[1]) . "</a><br>\n";
}
}
#Draw the three month calendars
minicals($year, $month, $day, $area);
echo "</tr></table>";
}
#y? are year, month and day of yesterday
#t? are year, month and day of tomorrow
$i= mktime(0,0,0,$month,$day-1,$year);
$yy = date("Y",$i);
$ym = date("m",$i);
$yd = date("d",$i);
$i= mktime(0,0,0,$month,$day+1,$year);
$ty = date("Y",$i);
$tm = date("m",$i);
$td = date("d",$i);
#Show description
if ($pview !=1) {
echo "<table border=0>
<tr><td>$vocab[descr1]</td><td class=J>$vocab[descrcolor]</td>
<td>$vocab[descr2]</td></tr></table>
";
}
#Show current date
echo "<h2 align=center>" . strftime("%A %d %B %Y", $am7) . "</h2>\n";
if ( $pview != 1 ) {
#Show Go to day before and after links
echo "<table width=\"100%\"><tr><td><a
href=\"day.php?year=$yy&month=$ym&day=$yd&area=$area\"><< $vocab[daybefore]</a></td>
<td align=center><a href=\"day.php?area=$area\">$vocab[gototoday]</a></td>
<td align=right><a href=\"day.php?year=$ty&month=$tm&day=$td&area=$area\">$vocab[dayafter] >></a></td></tr></table>";
}
#We want to build an array containing all the data we want to show
#and then spit it out.
#Get all appointments for today in the area that we care about
#Note: The predicate clause 'start_time <= ...' is an equivalent but simpler
#form of the original which had 3 BETWEEN parts. It selects all entries which
#occur on or cross the current day.
$sql = "SELECT mrbs_room.id, start_time, end_time, name, mrbs_entry.id, type, depend
FROM mrbs_entry, mrbs_room
WHERE mrbs_entry.room_id = mrbs_room.id
AND area_id = $area
AND start_time <= $pm7 AND end_time > $am7";
$res = sql_query($sql);
if (! $res) fatal_error(0, sql_error());
for ($i = 0; ($row = sql_row($res, $i)); $i++) {
# Each row weve got here is an appointment.
#row[0] = Room ID
#row[1] = start time
#row[2] = end time
#row[3] = short description
#row[4] = id of this booking
#row[5] = type (internal/external)
#row[6] = depend flag
# $today is a map of the screen that will be displayed
# It looks like:
# $today[Room ID][Time][id]
# [color]
# [data]
# Fill in the map for this meeting. Start at the meeting start time,
# or the day start time, whichever is later. End one slot before the
# meeting end time (since the next slot is for meetings which start then),
# or at the last slot in the day, whichever is earlier.
# Note: int casts on database rows for max may be needed for PHP3.
# Adjust the starting and ending times so that bookings which don't
# start or end at a recognized time still appear.
$start_t = max(round_t_down($row[1], $resolution, $am7), $am7);
$end_t = min(round_t_up($row[2], $resolution, $am7) - $resolution, $pm7);
for ($t = $start_t; $t <= $end_t; $t += $resolution)
{
$today[$row[0]][$t]["id"] = $row[4];
if ($row[6] == 0)
{
$today[$row[0]][$t]["color"] = $row[5];
$today[$row[0]][$t]["data"] = "";
}
else
{
$today[$row[0]][$t]["color"] = "J";
}
}
# Show the name of the booker in the first segment that the booking
# happens in, or at the start of the day if it started before today.
if ($row[1] < $am7)
$today[$row[0]][$am7]["data"] = $row[3];
else
$today[$row[0]][$start_t]["data"] = $row[3];
}
# We need to know what all the rooms area called, so we can show them all
# pull the data from the db and store it. Convienently we can print the room
# headings and capacities at the same time
$sql = "SELECT room_name, capacity, id FROM mrbs_room WHERE area_id=$area ORDER BY 1";
$res = sql_query($sql);
# It might be that there are no rooms defined for this area.
# If there are none then show an error and dont bother doing anything
# else
if (! $res) fatal_error(0, sql_error());
if (sql_count($res) == 0)
{
echo "<h1>$vocab[no_rooms_for_area]</h1>";
sql_free($res);
}
else
{
#This is where we start displaying stuff
echo "<table cellspacing=0 border=1 width=\"100%\">";
echo "<tr><th width=\"1%\">$vocab[time]</th>";
$room_column_width = (int)(95 / sql_count($res));
for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
echo "<th width=\"$room_column_width%\">" . htmlspecialchars($row[0])
. "($row[1])</th>";
$rooms[] = $row[2];
}
echo "</tr>\n";
# URL for highlighting a time. Don't use REQUEST_URI or you will get
# the timetohighlight parameter duplicated each time you click.
$hilite_url="day.php?year=$year&month=$month&day=$day&area=$area&timetohighlight";
# This is the main bit of the display
# We loop through unixtime and then the rooms we just got
for ($t = $am7; $t <= $pm7; $t += $resolution)
{
# Show the time linked to the URL for highlighting that time
echo "<tr>";
tdcell("red");
echo "<a href=\"$hilite_url=$t\">" . date("H:i",$t) . "</a></td>";
# Loop through the list of rooms we have for this area
while (list($key, $room) = each($rooms))
{
if(isset($today[$room][$t]["id"]))
{
$id = $today[$room][$t]["id"];
$color = $today[$room][$t]["color"];
$descr = htmlspecialchars($today[$room][$t]["data"]);
}
else
unset($id);
# $c is the colour of the cell that the browser sees. White normally,
# red if were hightlighting that line and a nice attractive green if the room is booked.
# We tell if its booked by $id having something in it
if (isset($id))
$c = $color;
elseif (isset($timetohighlight) && ($t == $timetohighlight))
$c = "red";
else
$c = "white";
tdcell($c);
$sql = "SELECT depend FROM mrbs_entry WHERE id=$id";
$res = sql_query($sql);
$depend = mysql_fetch_row($res);
// echo " dep=$depend[0] / ";
// echo " des=$descr<br>";
# If the room isn't booked then allow it to be booked
if(!isset($id))
{
$hour = date("H",$t);
$minute = date("i",$t);
echo "<center>";
if ( $pview != 1 ) {
echo "<a
href=\"edit_entry.php?area=$area&room=$room&hour=$hour&minute=$minute&year=$year&month=$month&day=$day\"><img
src=new.gif width=10 height=10 border=0></a>";
} else echo ' ';
echo "</center>";
}
elseif ($descr != "" && $depend[0] == 0)
{
#if it is booked then show
echo " <a href=\"view_entry.php?id=$id&area=$area&day=$day&month=$month&year=$year\">$descr</a>";
}
else
echo " ";
echo "</td>\n";
}
echo "</tr>\n";
reset($rooms);
}
echo "</table>";
if ( $pview != 1 ) show_colour_key();
}
include "trailer.inc";
?>
<?php
# $Id: del_entry.php,v 1.2 2002/10/29 08:43:23 mrbs Exp $
include "config.inc";
include "functions.inc";
include "$dbsys.inc";
include "mrbs_auth.inc";
include "mrbs_sql.inc";
if(getAuthorised(getUserName(), getUserPassword(), 1) && ($info = mrbsGetEntryInfo($id)))
{
$day = strftime("%d", $info["start_time"]);
$month = strftime("%m", $info["start_time"]);
$year = strftime("%Y", $info["start_time"]);
$area = mrbsGetRoomArea($info["room_id"]);
$depend = mrbsDependIdList($id);
for($d = 0; $d < count($depend); $d++)
{
$id = $depend[$d];
sql_begin();
$result = mrbsDelEntry(getUserName(), $id, $series, 1);
sql_commit();
}
if ($result)
{
Header("Location: day.php?day=$day&month=$month&year=$year&area=$area");
exit();
}
}
// If you got this far then we got an access denied.
showAccessDenied($day, $month, $year, $area);
?>
<?php
# $Id: edit_entry.php,v 1.2 2002/10/29 08:43:23 mrbs Exp $
include "config.inc";
include "functions.inc";
include "$dbsys.inc";
include "mrbs_auth.inc";
#If we dont know the right date then make it up
if(!isset($day) or !isset($month) or !isset($year))
{
$day = date("d");
$month = date("m");
$year = date("Y");
}
if(empty($area))
$area = get_default_area();
if(!isset($edit_type))
$edit_type = "";
if(!getAuthorised(getUserName(), getUserPassword(), 1))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
# This page will either add or modify a booking
# We need to know:
# Name of booker
# Description of meeting
# Date (option select box for day, month, year)
# Time
# Duration
# Internal/External
# Firstly we need to know if this is a new booking or modifying an old one
# and if it's a modification we need to get all the old data from the db.
# If we had $id passed in then it's a modification.
if (isset($id))
{
$sql = "select name, create_by, description, start_time, end_time - start_time,
type, room_id, entry_type, repeat_id from mrbs_entry where id=$id";
$res = sql_query($sql);
if (! $res) fatal_error(1, sql_error());
if (sql_count($res) != 1) fatal_error(1, "Entry ID $id not found");
$row = sql_row($res, 0);
sql_free($res);
# Note: Removed stripslashes() calls from name and description. Previous
# versions of MRBS mistakenly had the backslash-escapes in the actual database
# records because of an extra addslashes going on. Fix your database and
# leave this code alone, please.
$name = $row[0];
$create_by = $row[1];
$description = $row[2];
$start_day = strftime('%d', $row[3]);
$start_month = strftime('%m', $row[3]);
$start_year = strftime('%Y', $row[3]);
$start_hour = strftime('%H', $row[3]);
$start_min = strftime('%M', $row[3]);
$duration = $row[4];
$type = $row[5];
$room_id = $row[6];
$entry_type = $row[7];
$rep_id = $row[8];
if($entry_type >= 1)
{
$sql = "SELECT rep_type, start_time, end_date, rep_opt, rep_num_weeks
FROM mrbs_repeat WHERE id=$rep_id";
$res = sql_query($sql);
if (! $res) fatal_error(1, sql_error());
if (sql_count($res) != 1) fatal_error(1, "Repeat ID $rep_id not found");
$row = sql_row($res, 0);
sql_free($res);
$rep_type = $row[0];
if($edit_type == "series")
{
$start_day = (int)strftime('%d', $row[1]);
$start_month = (int)strftime('%m', $row[1]);
$start_year = (int)strftime('%Y', $row[1]);
$rep_end_day = (int)strftime('%d', $row[2]);
$rep_end_month = (int)strftime('%m', $row[2]);
$rep_end_year = (int)strftime('%Y', $row[2]);
switch($rep_type)
{
case 2:
case 6:
$rep_day[0] = $row[3][0] != "0";
$rep_day[1] = $row[3][1] != "0";
$rep_day[2] = $row[3][2] != "0";
$rep_day[3] = $row[3][3] != "0";
$rep_day[4] = $row[3][4] != "0";
$rep_day[5] = $row[3][5] != "0";
$rep_day[6] = $row[3][6] != "0";
if ($rep_type == 6)
{
$rep_num_weeks = $row[4];
}
break;
default:
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
}
else
{
$rep_type = $row[0];
$rep_end_date = strftime('%A %d %B %Y',$row[2]);
$rep_opt = $row[3];
}
}
}
else
{
# It is a new booking. The data comes from whichever button the user clicked
$edit_type = "series";
$name = "";
$room_dep = 0;
$create_by = getUserName();
$description = "";
$start_day = $day;
$start_month = $month;
$start_year = $year;
$start_hour = $hour;
$start_min = $minute;
$duration = 60 * 60;
$type = "I";
$room_id = $room;
$id = 0;
$rep_id = 0;
$rep_type = 0;
$rep_end_day = $day;
$rep_end_month = $month;
$rep_end_year = $year;
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
toTimeString($duration, $dur_units);
#now that we know all the data to fill the form with we start drawing it
if(!getWritable($create_by, getUserName()))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
print_header($day, $month, $year, $area);
?>
<SCRIPT LANGUAGE="JavaScript">
// do a little form verifying
function validate_and_submit ()
{
if(document.forms["main"].name.value == "")
{
alert ( "You have not entered a\nBrief Description." );
return false;
}
h = parseInt(document.forms["main"].hour.value);
m = parseInt(document.forms["main"].minute.value);
if(h > 23 || m > 59)
{
alert("You have not entered a\nvalid time of day.");
return false;
}
i1 = parseInt(document.forms["main"].id.value);
i2 = parseInt(document.forms["main"].rep_id.value);
n = parseInt(document.forms["main"].rep_num_weeks.value);
if ((!i1 || (i1 && i2)) && document.forms["main"].rep_type &&
document.forms["main"].rep_type[6].checked && (!n || n < 2))
{
alert("You have not entered a\nuseful n-weekly value.");
return false;
}
// would be nice to also check date to not allow Feb 31, etc...
document.forms["main"].submit();
return true;
}
</SCRIPT>
<h2><?php echo isset($id) ? $vocab["editentry"] : $vocab["addentry"]; ?></H2>
<FORM NAME="main" ACTION="edit_entry_handler.php" METHOD="GET">
<TABLE BORDER=0>
<TR><TD CLASS=CR><B><?php echo $vocab["namebooker"]?></B></TD>
<TD CLASS=CL><INPUT NAME="name" SIZE=40 VALUE="<?php echo htmlentities($name) ?>"></TD></TR>
<TR><TD CLASS=TR><B><?php echo $vocab["fulldescription"]?></B></TD>
<TD CLASS=TL><TEXTAREA NAME="description" ROWS=8 COLS=40 WRAP="virtual"><?php echo htmlentities (
$description ); ?></TEXTAREA></TD></TR>
<TR><TD CLASS=CR><B><?php echo $vocab["date"]?></B></TD>
<TD CLASS=CL>
<?php genDateSelector("", $start_day, $start_month, $start_year) ?>
</TD>
</TR>
<TR><TD CLASS=CR><B><?php echo $vocab["time"]?></B></TD>
<TD CLASS=CL><INPUT NAME="hour" SIZE=2 VALUE="<?php echo $start_hour;?>" MAXLENGTH=2>:<INPUT
NAME="minute" SIZE=2 VALUE="<?php echo $start_min;?>" MAXLENGTH=2>
</TD></TR>
<TR><TD CLASS=CR><B><?php echo $vocab["duration"];?></B></TD>
<TD CLASS=CL><INPUT NAME="duration" SIZE=7 VALUE="<?php echo $duration;?>">
<SELECT NAME="dur_units">
<?php
$units = array("minutes", "hours", "days", "weeks");
while (list(,$unit) = each($units))
{
echo "<OPTION VALUE=$unit";
if ($dur_units == $vocab[$unit]) echo " SELECTED";
echo ">$vocab[$unit]";
}
?>
</SELECT>
<INPUT NAME="all_day" TYPE="checkbox" VALUE="yes"> <?php echo $vocab["all_day"]; ?>
</TD></TR>
<tr><td class=CR><b><?php echo $vocab["rooms"] ?></b></td>
<td class=CL valign=top><table><tr><td><select name="rooms[]" multiple>
<?php
$sql = "SELECT id, room_name FROM mrbs_room WHERE area_id=$area ORDER BY room_name";
$res = sql_query($sql);
if ($res) for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
$selected = "";
if ($row[0] == $room_id) {
$selected = "SELECTED";
}
echo "<option $selected value=\"".$row[0]."\">".$row[1];
}
?>
</select></td><td><?php echo $vocab["ctrl_click"] ?></td></tr></table>
</td></tr>
<TR><TD CLASS=CR><B><?php echo $vocab["type"]?></B></TD>
<TD CLASS=CL><SELECT NAME="type">
<?php
for ($c = "A"; $c <= "J"; $c++)
{
if (!empty($typel[$c]))
echo "<OPTION VALUE=$c" . ($type == $c ? " SELECTED" : "") . ">$typel[$c]\n";
}
?></SELECT></TD></TR>
<?php if($edit_type == "series") { ?>
<TR>
<TD CLASS=CR><B><?php echo $vocab["rep_type"]?></B></TD>
<TD CLASS=CL>
<?php
for($i = 0; isset($vocab["rep_type_$i"]); $i++)
{
echo "<INPUT NAME=\"rep_type\" TYPE=\"RADIO\" VALUE=\"" . $i . "\"";
if($i == $rep_type)
echo " CHECKED";
echo ">" . $vocab["rep_type_$i"] . "\n";
}
?>
</TD>
</TR>
<TR>
<TD CLASS=CR><B><?php echo $vocab["rep_end_date"]?></B></TD>
<TD CLASS=CL><?php genDateSelector("rep_end_", $rep_end_day, $rep_end_month, $rep_end_year) ?></TD>
</TR>
<TR>
<TD CLASS=CR><B><?php echo $vocab["rep_rep_day"]?></B> <?php echo $vocab["rep_for_weekly"]?></TD>
<TD CLASS=CL>
<?php
# Display day name checkboxes according to language and preferred weekday start.
for ($i = 0; $i < 7; $i++)
{
$wday = ($i + $weekstarts) % 7;
echo "<INPUT NAME=\"rep_day[$wday]\" TYPE=CHECKBOX";
if ($rep_day[$wday]) echo " CHECKED";
echo ">" . day_name($wday) . "\n";
}
?>
</TD>
</TR>
<?php
}
else
{
$key = "rep_type_" . (isset($rep_type) ? $rep_type : "0");
echo "<tr><td class=\"CR\"><b>$vocab[rep_type]</b></td><td class=\"CL\">$vocab[$key]</td></tr>\n";
if(isset($rep_type) && ($rep_type != 0))
{
$opt = "";
if ($rep_type == 2)
{
# Display day names according to language and preferred weekday start.
for ($i = 0; $i < 7; $i++)
{
$wday = ($i + $weekstarts) % 7;
if ($rep_opt[$wday]) $opt .= day_name($wday) . " ";
}
}
if($opt)
echo "<tr><td class=\"CR\"><b>$vocab[rep_rep_day]</b></td><td class=\"CL\">$opt</td></tr>\n";
echo "<tr><td class=\"CR\"><b>$vocab[rep_end_date]</b></td><td class=\"CL\">$rep_end_date</td></tr>\n";
}
}
?>
<TR>
<TD CLASS=CR><B><?php echo $vocab["rep_num_weeks"]?></B> <?php echo $vocab["rep_for_nweekly"]?></TD>
<TD CLASS=CL><INPUT TYPE=TEXT NAME="rep_num_weeks" VALUE="<?php echo $rep_num_weeks?>">
</TR>
<TR>
<TD colspan=2 align=center>
<SCRIPT LANGUAGE="JavaScript">
document.writeln ( '<INPUT TYPE="button" VALUE="<?php echo $vocab["save"]?>"
ONCLICK="validate_and_submit()">' );
</SCRIPT>
<NOSCRIPT>
<INPUT TYPE="submit" VALUE="<?php echo $vocab["save"]?>">
</NOSCRIPT>
</TD></TR>
</TABLE>
<INPUT TYPE=HIDDEN NAME="returl" VALUE="<?php echo $HTTP_REFERER?>">
<INPUT TYPE=HIDDEN NAME="room_id" VALUE="<?php echo $room_id?>">
<INPUT TYPE=HIDDEN NAME="create_by" VALUE="<?php echo $create_by?>">
<INPUT TYPE=HIDDEN NAME="rep_id" VALUE="<?php echo $rep_id?>">
<INPUT TYPE=HIDDEN NAME="edit_type" VALUE="<?php echo $edit_type?>">
<INPUT TYPE=HIDDEN NAME="room_dep" VALUE="<?php echo $room_dep?>">
<?php if(isset($id)) echo "<INPUT TYPE=HIDDEN NAME=\"id\" VALUE=\"$id\">\n"; ?>
</FORM>
<?php include "trailer.inc" ?>
<?php
// $Id: edit_entry_handler.php,v 1.2 2002/10/29 08:43:23 mrbs Exp $
include "config.inc";
include "functions.inc";
include "$dbsys.inc";
include "mrbs_auth.inc";
include "mrbs_sql.inc";
#If we dont know the right date then make it up
if(!isset($day) or !isset($month) or !isset($year))
{
$day = date("d");
$month = date("m");
$year = date("Y");
}
if(empty($area))
$area = get_default_area();
if(!getAuthorised(getUserName(), getUserPassword(), 1))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
if(!getWritable($create_by, getUserName()))
{
showAccessDenied($day, $month, $year, $area);
exit;
}
// Units start in seconds
$units = 1.0;
switch($dur_units)
{
case "years":
$units *= 52;
case "weeks":
$units *= 7;
case "days":
$units *= 24;
case "hours":
$units *= 60;
case "minutes":
$units *= 60;
case "seconds":
break;
}
// Units are now in "$dur_units" numbers of seconds
if(isset($all_day) && ($all_day == "yes"))
{
$starttime = mktime(0, 0, 0, $month, $day , $year);
$endtime = mktime(0, 0, 0, $month, $day+1, $year);
}
else
{
$starttime = mktime($hour, $minute, 0, $month, $day, $year);
$endtime = mktime($hour, $minute, 0, $month, $day, $year) + ($units * $duration);
# Round up the duration to the next whole resolution unit.
# If they asked for 0 minutes, push that up to 1 resolution unit.
$diff = $endtime - $starttime;
if (($tmp = $diff % $resolution) != 0 || $diff == 0)
$endtime += $resolution - $tmp;
}
if(isset($rep_type) && isset($rep_end_month) && isset($rep_end_day) && isset($rep_end_year))
{
// Get the repeat entry settings
$rep_enddate = mktime($hour, $minute, 0, $rep_end_month, $rep_end_day, $rep_end_year);
}
else
$rep_type = 0;
if(!isset($rep_day))
$rep_day = "";
# For weekly repeat(2), build string of weekdays to repeat on:
$rep_opt = "";
if (($rep_type == 2) || ($rep_type == 6))
for ($i = 0; $i < 7; $i++) $rep_opt .= empty($rep_day[$i]) ? "0" : "1";
# Expand a series into a list of start times:
if ($rep_type != 0)
$reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0,
$rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id))
{
$ignore_id = $id;
$repeat_id = sql_query1("SELECT repeat_id FROM mrbs_entry WHERE id=$id");
if ($repeat_id < 0)
$repeat_id = 0;
}
else
$ignore_id = 0;
# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock('mrbs_entry'))
fatal_error(1, "Failed to acquire exclusive database access");
# Check for any schedule conflicts in each room we're going to try and book in
$err = "";
foreach ( $rooms as $room_id ) {
if ($rep_type != 0 && !empty($reps))
{
if(count($reps) < $max_rep_entrys)
{
$diff = $endtime - $starttime;
for($i = 0; $i < count($reps); $i++)
{
$tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id);
if(!empty($tmp))
$err = $err . $tmp;
}
}
else
{
$err .= $vocab["too_may_entrys"] . "<P>";
$hide_title = 1;
}
}
else
$err .= mrbsCheckFree($room_id, $starttime, $endtime-1, $ignore_id, 0);
} # end foreach rooms
if(empty($err))
{
$depend = mrbsGetDependList($room_id);
for($i = 0; $i <= count($depend); $i++)
{
if ($i == 0)
{
$room_dep = 0;
}
else
{
$room_dep = 1;
}
foreach ( $rooms as $room_id ) {
if($edit_type == "series")
{
$room_id = $depend[$i];
mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt,
$room_id, $create_by, $name, $type, $description, $rep_num_weeks);
}
else
{
$room_id = $depend[$i];
# Mark changed entry in a series with entry_type 2:
if ($repeat_id > 0)
$entry_type = 2;
else
$entry_type = 0;
# Create the entry:
mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id, $room_id,
$create_by, $name, $type, $description, $room_dep);
}
} # end foreach $rooms
}
# Delete the original entry
if(isset($id))
$depid = mrbsDependIdList($id);
for($d = 0; $d <= count($depid); $d++)
{
$id = $depid[$d];
mrbsDelEntry(getUserName(), $id, ($edit_type == "series"), 1);
}
sql_mutex_unlock('mrbs_entry');
$area = mrbsGetRoomArea($room_id);
# Now its all done go back to the day view
Header("Location: day.php?year=$year&month=$month&day=$day&area=$area");
exit;
}
# The room was not free.
sql_mutex_unlock('mrbs_entry');
if(strlen($err))
{
print_header($day, $month, $year, $area);
echo "<H2>" . $vocab["sched_conflict"] . "</H2>";
if(!isset($hide_title))
{
echo $vocab["conflict"];
echo "<UL>";
}
echo $err;
if(!isset($hide_title))
echo "</UL>";
}
echo "<a href=\"$returl\">$vocab[returncal]</a><p>";
include "trailer.inc"; ?>
<?php
# $Id: lang.de,v 1.2 2002/10/29 08:43:24 mrbs Exp $
# This file contains PHP code that specifies language specific strings
# The default strings come from lang.en, and anything in a locale
# specific file will overwrite the default. This is a German file.
#
# Translations provided by: Michael Redinger
#
# This file is PHP code. Treat it as such.
# The charset to use in "Content-type" header
$vocab["charset"] = "iso-8859-1";
# Used in style.inc
$vocab["mrbs"] = "Raumbuchungssystem MRBS";
# Used in functions.inc
$vocab["report"] = "Bericht";
$vocab["admin"] = "Admin";
$vocab["help"] = "Hilfe";
$vocab["search"] = "Suche:";
# Used in day.php
$vocab["bookingsfor"] = "Einträge für";
$vocab["bookingsforpost"] = "";
$vocab["areas"] = "Bereiche";
$vocab["daybefore"] = "gehe zum vorherigen Tag";
$vocab["dayafter"] = "gehe zum nächsten Tag";
$vocab["gototoday"] = "gehe zum heutigen Tag";
$vocab["goto"] = "Start";
$vocab["descr1"] = "Die ";
$vocab["descr2"] = " Felder, sind in Abhänigkeit von anderen Räumen gebucht";
$vocab["descrcolor"] = "grauen";
# Used in trailer.inc
$vocab["viewday"] = "Zeige Tag";
$vocab["viewweek"] = "Zeige Woche";
$vocab["viewmonth"] = "Zeige Monat";
$vocab["ppreview"] = "Druckansicht";
# Used in edit_entry.php
$vocab["addentry"] = "Eintrag hinzufügen";
$vocab["editentry"] = "Eintrag ändern";
$vocab["editseries"] = "Alle Einträge ändern";
$vocab["namebooker"] = "Eintrag von";
$vocab["fulldescription"] = "Volständige Beschreibung:<br> (Anzahl der
Teilnehmer,<br> Intern/Extern etc)";
$vocab["date"] = "Tag:";
$vocab["start_date"] = "Anfangsdatum:";
$vocab["end_date"] = "Enddatum:";
$vocab["time"] = "Zeit:";
$vocab["duration"] = "Dauer:";
$vocab["seconds"] = "Sekunden";
$vocab["minutes"] = "Minuten";
$vocab["hours"] = "Stunden";
$vocab["days"] = "Tage";
$vocab["weeks"] = "Wochen";
$vocab["years"] = "Jahre";
$vocab["all_day"] = "Ganztägig";
$vocab["type"] = "Art:";
$vocab["internal"] = "Intern";
$vocab["external"] = "Extern";
$vocab["save"] = "Speichern";
$vocab["rep_type"] = "Art der Wiederholung:";
$vocab["rep_type_0"] = "Keine";
$vocab["rep_type_1"] = "täglich";
$vocab["rep_type_2"] = "wöchentlich";
$vocab["rep_type_3"] = "monatlich";
$vocab["rep_type_4"] = "jährlich";
$vocab["rep_type_5"] = "monatlich, entsprechender Tag";
$vocab["rep_type_6"] = "n-Weekly";
$vocab["rep_end_date"] = "Ende der Wiederholung:";
$vocab["rep_rep_day"] = "Tag der Wiederholung:";
$vocab["rep_for_weekly"] = "(für wöchentlich)";
$vocab["rep_freq"] = "Häufigkeit:";
$vocab["rep_num_weeks"] = "Number of weeks";
$vocab["rep_for_nweekly"] = "(for n-weekly)";
$vocab["ctrl_click"] = "Use Control-Click to select more than one room";
# Used in view_entry.php
$vocab["description"] = "Beschreibung:";
$vocab["room"] = "Raum:";
$vocab["createdby"] = "Erstellt von:";
$vocab["lastupdate"] = "Letzte Änderung:";
$vocab["deleteentry"] = "Eintrag löschen";
$vocab["deleteseries"] = "Alle Einträge löschen";
$vocab["confirmdel"] = "Sind Sie sicher,\\ndass Sie diesen Eintrag\\nlöschen wollen?\\n\\n";
$vocab["returnprev"] = "Zurück zur vorigen Seite";
# Used in edit_entry_handler.php
$vocab["error"] = "Fehler";
$vocab["sched_conflict"] = "Konflikt in der Planung";
$vocab["conflict"] = "Der neue Eintrag hat einen Konflikt mit folgenden Einträgen:";
$vocab["too_may_entrys"] = "Die gewählten Optionen würden zu viele Einträge erzeugen.<BR>Ändern
Sie bitte die Optionen!";
$vocab["returncal"] = "Zurück zur Kalenderansicht";
# Authentication stuff
$vocab["accessdenied"] = "Zugang verweigert";
$vocab["norights"] = "Sie haben keine Berechtigung, diesen Eintrag zu ändern";
# Used in search.php
$vocab["invalid_search"] = "Leerer oder ungültiger Suchbegriff.";
$vocab["search_results"] = "Suchergebnis für:";
$vocab["nothing_found"] = "Keine passenden Suchergebnisse gefunden.";
$vocab["records"] = "Ergebnisse ";
$vocab["through"] = " bis ";
$vocab["of"] = " von ";
$vocab["previous"] = "Vorige";
$vocab["next"] = "Nächste";
$vocab["entry"] = "Eintrag";
$vocab["view"] = "Öffnen";
$vocab["advanced_search"] = "Advanced search";
$vocab["search_button"] = "Suche";
$vocab["search_for"] = "Search For";
$vocab["from"] = "From";
# Used in report.php
$vocab["report_on"] = "Bericht über Termine:";
$vocab["report_start"] = "Bericht Beginn:";
$vocab["report_end"] = "Bericht Ende:";
$vocab["match_area"] = "Suche Bereich:";
$vocab["match_room"] = "Suche Raum:";
$vocab["match_entry"] = "Suche Kurzbeschreibung:";
$vocab["match_descr"] = "Suche Beschreibung:";
$vocab["include"] = "Generiere:";
$vocab["report_only"] = "nur Bericht";
$vocab["summary_only"] = "nur Zusammenfassung";
$vocab["report_and_summary"] = "Bericht und Zusammenfassung";
$vocab["summarize_by"] = "Zusammenfassung nach:";
$vocab["sum_by_descrip"] = "Kurzbeschreibung";
$vocab["sum_by_creator"] = "Ersteller";
$vocab["entry_found"] = "Eintrag gefunden";
$vocab["entries_found"] = "Einträge gefunden";
$vocab["summary_header"] = "Stundenzusammenfassung der Einträge";
$vocab["total"] = "Gesamt";
$vocab["submitquery"] = "Bericht erstellen";
# Used in week.php
$vocab["weekbefore"] = "gehe zur vorigen Woche";
$vocab["weekafter"] = "gehe zur nächsten Woche";
$vocab["gotothisweek"] = "gehe zu dieser Woche";
# Used in month.php
$vocab["monthbefore"] = "gehe zum vorigen Monat";
$vocab["monthafter"] = "gehe zum nächsten Monat";
$vocab["gotothismonth"] = "gehe zu diesen Monat";
# Used in {day week month}.php
$vocab["no_rooms_for_area"] = "Der Bereich enthält keinen Raum";
# Used in admin.php
$vocab["edit"] = "Bearbeiten";
$vocab["delete"] = "Löschen";
$vocab["rooms"] = "Räume";
$vocab["in"] = "in";
$vocab["noareas"] = "Keine Bereiche";
$vocab["addarea"] = "Bereich hinzufügen";
$vocab["name"] = "Name";
$vocab["noarea"] = "Kein Bereich ausgewählt";
$vocab["browserlang"] = "Die Spracheinstellung Ihres Browsers ist";
$vocab["postbrowserlang"] = ".";
$vocab["addroom"] = "Raum hinzufügen";
$vocab["capacity"] = "Kapazität";
$vocab["norooms"] = "Keine Räume vorhanden.";
# Used in edit_area_room.php
$vocab["editarea"] = "Bereich bearbeiten";
$vocab["change"] = "Ändern";
$vocab["backadmin"] = "Zurück zu Admin";
$vocab["editroomarea"] = "Raum- oder Bereichsbeschreibung bearbeiten";
$vocab["editroom"] = "Raum bearbeiten";
# Used in del.php
$vocab["deletefollowing"] = "Dadurch werden die folgenden Einträge gelöscht";
$vocab["sure"] = "Sind Sie sicher?";
$vocab["YES"] = "JA";
$vocab["NO"] = "NEIN";
?>
<?php
# $Id: lang.en,v 1.2 2002/10/29 08:43:24 mrbs Exp $
# This file contains PHP code that specifies language specific strings
# The default strings come from lang.en, and anything in a locale
# specific file will overwrite the default. This is a US/UK English file.
#
#
#
# This file is PHP code. Treat it as such.
# The charset to use in "Content-type" header
$vocab["charset"] = "iso-8859-1";
# Used in style.inc
$vocab["mrbs"] = "Meeting Room Booking System";
# Used in functions.inc
$vocab["report"] = "Report";
$vocab["admin"] = "Admin";
$vocab["help"] = "Help";
$vocab["search"] = "Search:";
# Used in day.php
$vocab["bookingsfor"] = "Bookings for";
$vocab["bookingsforpost"] = ""; # Goes after the date
$vocab["areas"] = "Areas";
$vocab["daybefore"] = "Go To Day Before";
$vocab["dayafter"] = "Go To Day After";
$vocab["gototoday"] = "Go To Today";
$vocab["goto"] = "goto";
$vocab["descr1"] = "The fields with the ";
$vocab["descr2"] = " mark are booked in dependence of another room.";
$vocab["descrcolor"] = "grey";
# Used in trailer.inc
$vocab["viewday"] = "View Day";
$vocab["viewweek"] = "View Week";
$vocab["viewmonth"] = "View Month";
$vocab["ppreview"] = "Print Preview";
# Used in edit_entry.php
$vocab["addentry"] = "Add Entry";
$vocab["editentry"] = "Edit Entry";
$vocab["editseries"] = "Edit Series";
$vocab["namebooker"] = "Brief Description:";
$vocab["fulldescription"] = "Full Description:<br> (Number of
people,<br> Internal/External etc)";
$vocab["date"] = "Date:";
$vocab["start_date"] = "Start Time:";
$vocab["end_date"] = "End Time:";
$vocab["time"] = "Time:";
$vocab["duration"] = "Duration:";
$vocab["seconds"] = "seconds";
$vocab["minutes"] = "minutes";
$vocab["hours"] = "hours";
$vocab["days"] = "days";
$vocab["weeks"] = "weeks";
$vocab["years"] = "years";
$vocab["all_day"] = "All day";
$vocab["type"] = "Type:";
$vocab["internal"] = "Internal";
$vocab["external"] = "External";
$vocab["save"] = "Save";
$vocab["rep_type"] = "Repeat Type:";
$vocab["rep_type_0"] = "None";
$vocab["rep_type_1"] = "Daily";
$vocab["rep_type_2"] = "Weekly";
$vocab["rep_type_3"] = "Monthly";
$vocab["rep_type_4"] = "Yearly";
$vocab["rep_type_5"] = "Monthly, corresponding day";
$vocab["rep_type_6"] = "n-Weekly";
$vocab["rep_end_date"] = "Repeat End Date:";
$vocab["rep_rep_day"] = "Repeat Day:";
$vocab["rep_for_weekly"] = "(for (n-)weekly)";
$vocab["rep_freq"] = "Frequency:";
$vocab["rep_num_weeks"] = "Number of weeks";
$vocab["rep_for_nweekly"] = "(for n-weekly)";
$vocab["ctrl_click"] = "Use Control-Click to select more than one room";
# Used in view_entry.php
$vocab["description"] = "Description:";
$vocab["room"] = "Room:";
$vocab["createdby"] = "Created By:";
$vocab["lastupdate"] = "Last Updated:";
$vocab["deleteentry"] = "Delete Entry";
$vocab["deleteseries"] = "Delete Series";
$vocab["confirmdel"] = "Are you sure\\nyou want to\\ndelete this entry?\\n\\n";
$vocab["returnprev"] = "Return to previous page";
# Used in edit_entry_handler.php
$vocab["error"] = "Error";
$vocab["sched_conflict"] = "Scheduling Conflict";
$vocab["conflict"] = "The new booking will conflict with the following entry(s):";
$vocab["too_may_entrys"] = "The selected options will create too many entries.<BR>Please use
different options!";
$vocab["returncal"] = "Return to calendar view";
# Authentication stuff
$vocab["accessdenied"] = "Access Denied";
$vocab["norights"] = "You do not have access rights to modify this item.";
# Used in search.php
$vocab["invalid_search"] = "Empty or invalid search string.";
$vocab["search_results"] = "Search Results for:";
$vocab["nothing_found"] = "No matching entries found.";
$vocab["records"] = "Records ";
$vocab["through"] = " through ";
$vocab["of"] = " of ";
$vocab["previous"] = "Previous";
$vocab["next"] = "Next";
$vocab["entry"] = "Entry";
$vocab["view"] = "View";
$vocab["advanced_search"] = "Advanced search";
$vocab["search_button"] = "Search";
$vocab["search_for"] = "Search For";
$vocab["from"] = "From";
# Used in report.php
$vocab["report_on"] = "Report on Meetings:";
$vocab["report_start"] = "Report start date:";
$vocab["report_end"] = "Report end date:";
$vocab["match_area"] = "Match area:";
$vocab["match_room"] = "Match room:";
$vocab["match_entry"] = "Match brief description:";
$vocab["match_descr"] = "Match full description:";
$vocab["include"] = "Include:";
$vocab["report_only"] = "Report only";
$vocab["summary_only"] = "Summary only";
$vocab["report_and_summary"] = "Report and Summary";
$vocab["summarize_by"] = "Summarize by:";
$vocab["sum_by_descrip"] = "Brief description";
$vocab["sum_by_creator"] = "Creator";
$vocab["entry_found"] = "entry found";
$vocab["entries_found"] = "entries found";
$vocab["summary_header"] = "Summary of (Entries) Hours";
$vocab["total"] = "Total";
$vocab["submitquery"] = "Run Report";
# Used in week.php
$vocab["weekbefore"] = "Go To Week Before";
$vocab["weekafter"] = "Go To Week After";
$vocab["gotothisweek"] = "Go To This Week";
# Used in month.php
$vocab["monthbefore"] = "Go To Month Before";
$vocab["monthafter"] = "Go To Month After";
$vocab["gotothismonth"] = "Go To This Month";
# Used in {day week month}.php
$vocab["no_rooms_for_area"] = "No rooms defined for this area";
# Used in admin.php
$vocab["edit"] = "Edit";
$vocab["delete"] = "Delete";
$vocab["rooms"] = "Rooms";
$vocab["in"] = "in";
$vocab["noareas"] = "No Areas";
$vocab["addarea"] = "Add Area";
$vocab["name"] = "Name";
$vocab["noarea"] = "No area selected";
$vocab["browserlang"] = "Your browser is set to use";
$vocab["postbrowserlang"] = "language.";
$vocab["addroom"] = "Add Room";
$vocab["capacity"] = "Capacity";
$vocab["norooms"] = "No rooms.";
# Used in edit_area_room.php
$vocab["editarea"] = "Edit Area";
$vocab["change"] = "Change";
$vocab["backadmin"] = "Back to Admin";
$vocab["editroomarea"] = "Edit Area or Room Description";
$vocab["editroom"] = "Edit Room";
# Used in del.php
$vocab["deletefollowing"] = "This will delete the following bookings";
$vocab["sure"] = "Are you sure?";
$vocab["YES"] = "YES";
$vocab["NO"] = "NO";
?>
<?php
// $Id: mrbs_sql.inc,v 1.2 2002/10/29 08:43:24 mrbs Exp $
/** mrbsCheckFree()
*
* Check to see if the time period specified is free
*
* $room_id - Which room are we checking
* $starttime - The start of period
* $endtime - The end of the period
* $ignore - An entry ID to ignore, 0 to ignore no entries
* $repignore - A repeat ID to ignore everything in the series, 0 to ignore no series
*
* Returns:
* nothing - The area is free
* something - An error occured, the return value is human readable
*/
function mrbsCheckFree($room_id, $starttime, $endtime, $ignore, $repignore)
{
$depend = mrbsGetDependList($room_id);
for($d = 0; $d <= count($depend); $d++)
{
global $vocab;
# Select any meetings which overlap ($starttime,$endtime) for this room:
$sql = "SELECT id, name, start_time FROM mrbs_entry WHERE
start_time < $endtime AND end_time > $starttime
AND room_id = $room_id";
if ($ignore > 0)
$sql .= " AND id <> $ignore";
if ($repignore > 0)
$sql .= " AND repeat_id <> $repignore";
$sql .= " ORDER BY start_time";
$res = sql_query($sql);
if(! $res)
return sql_error();
if (sql_count($res) == 0)
{
sql_free($res);
return "";
}
# Get the room's area ID for linking to day, week, and month views:
$area = mrbsGetRoomArea($room_id);
}
# Build a string listing all the conflicts:
$err = "";
for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
$starts = getdate($row[2]);
$param_ym = "area=$area&year=$starts[year]&month=$starts[mon]";
$param_ymd = $param_ym . "&day=$starts[mday]";
$err .= "<LI><A HREF=\"view_entry.php?id=$row[0]\">$row[1]</A>"
. " ( " . strftime('%A %d %B %Y %T', $row[2]) . ") "
. "(<A HREF=\"day.php?$param_ymd\">$vocab[viewday]</a>"
. " | <A HREF=\"week.php?room=$room_id&$param_ymd\">$vocab[viewweek]</a>"
. " | <A HREF=\"month.php?room=$room_id&$param_ym\">$vocab[viewmonth]</a>)";
}
return $err;
}
/** mrbsDelEntry()
*
* Delete an entry, or optionally all entrys.
*
* $user - Who's making the request
* $id - The entry to delete
* $series - If set, delete the series, except user modified entrys
* $all - If set, include user modified entrys in the series delete
*
* Returns:
* 0 - An error occured
* non-zero - The entry was deleted
*/
function mrbsDelEntry($user, $id, $series, $all)
{
$repeat_id = sql_query1("SELECT repeat_id FROM mrbs_entry WHERE id=$id");
if ($repeat_id < 0)
return 0;
$sql = "SELECT create_by, id, entry_type FROM mrbs_entry WHERE ";
if($series)
$sql .= "repeat_id=$repeat_id";
else
$sql .= "id=$id";
$res = sql_query($sql);
$removed = 0;
for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
if(!getWritable($row[0], $user))
continue;
if($series && $row[2] == 2 && !$all)
continue;
if (sql_command("DELETE FROM mrbs_entry WHERE id=" . $row[1]) > 0)
$removed++;
}
if ($repeat_id > 0 &&
sql_query1("SELECT count(*) FROM mrbs_entry WHERE repeat_id=$repeat_id") == 0)
sql_command("DELETE FROM mrbs_repeat WHERE id=$repeat_id");
return $removed > 0;
}
/** mrbsCreateSingleEntry()
*
* Create a single (non-repeating) entry in the database
*
* $starttime - Start time of entry
* $endtime - End time of entry
* $entry_type - Entry type
* $repeat_id - Repeat ID
* $room_id - Room ID
* $owner - Owner
* $name - Name
* $type - Type (Internal/External)
* $description - Description
*
* Returns:
* 0 - An error occured while inserting the entry
* non-zero - The entry's ID
*/
function mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id, $room_id,
$owner, $name, $type, $description, $room_dep)
{
$name = slashes($name);
$description = slashes($description);
$sql = "INSERT INTO mrbs_entry ( start_time, end_time, entry_type, repeat_id, room_id,
create_by, name, type, description, depend)
VALUES ($starttime, $endtime, $entry_type, $repeat_id, $room_id,
'$owner', '$name', '$type', '$description', $room_dep)";
if (sql_command($sql) < 0) return 0;
return sql_insert_id("mrbs_entry", "id");
}
/** mrbsCreateRepeatEntry()
*
* Creates a repeat entry in the data base
*
* $starttime - Start time of entry
* $endtime - End time of entry
* $rep_type - The repeat type
* $rep_enddate - When the repeating ends
* $rep_opt - Any options associated with the entry
* $room_id - Room ID
* $owner - Owner
* $name - Name
* $type - Type (Internal/External)
* $description - Description
*
* Returns:
* 0 - An error occured while inserting the entry
* non-zero - The entry's ID
*/
function mrbsCreateRepeatEntry($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt,
$room_id, $owner, $name, $type, $description, $rep_num_weeks)
{
$name = slashes($name);
$description = slashes($description);
$sql = "INSERT INTO mrbs_repeat ( start_time, end_time, rep_type, end_date, rep_opt,
room_id, create_by, type, name, description, rep_num_weeks)
VALUES ($starttime, $endtime, $rep_type, $rep_enddate, '$rep_opt',
$room_id, '$owner', '$type', '$name', '$description', '$rep_num_weeks')";
if (sql_command($sql) < 0) return 0;
return sql_insert_id("mrbs_repeat", "id");
}
/** same_day_next_month
* Return the number of days to step forward for a "monthly repeat,
* corresponding day" series - same week number and day of week next month.
* This function always returns either 28 or 35.
* For dates after the 28th day of a month, the results are undefined.
*/
function same_day_next_month($time)
{
$days_in_month = date("t", $time);
$day = date("d", $time);
$weeknumber = (int)(($day - 1) / 7) + 1;
if ($day + 7 * (5 - $weeknumber) <= $days_in_month) return 35;
else return 28;
}
/** mrbsGetRepeatEntryList
*
* Returns a list of the repeating entrys
*
* $time - The start time
* $enddate - When the repeat ends
* $rep_type - What type of repeat is it
* $rep_opt - The repeat entrys
* $max_ittr - After going through this many entrys assume an error has occured
*
* Returns:
* empty - The entry does not repeat
* an array - This is a list of start times of each of the repeat entrys
*/
function mrbsGetRepeatEntryList($time, $enddate, $rep_type, $rep_opt, $max_ittr, $rep_num_weeks)
{
$sec = date("s", $time);
$min = date("i", $time);
$hour = date("G", $time);
$day = date("d", $time);
$month = date("m", $time);
$year = date("Y", $time);
$entrys = "";
for($i = 0; $i < $max_ittr; $i++)
{
$time = mktime($hour, $min, $sec, $month, $day, $year);
if ($time > $enddate)
break;
$entrys[$i] = $time;
switch($rep_type)
{
// Daily repeat
case 1:
$day += 1;
break;
// Weekly repeat
case 2:
$j = $cur_day = date("w", $entrys[$i]);
// Skip over days of the week which are not enabled:
while (($j = ($j + 1) % 7) != $cur_day && !$rep_opt[$j])
$day += 1;
$day += 1;
break;
// Monthly repeat
case 3:
$month += 1;
break;
// Yearly repeat
case 4:
$year += 1;
break;
// Monthly repeat on same week number and day of week
case 5:
$day += same_day_next_month($time);
break;
// n Weekly repeat
case 6:
$j = $cur_day = date("w", $entrys[$i]);
// Skip over days of the week which are not enabled:
while (($j = ($j + 1) % (7*$rep_num_weeks)) != $cur_day && !$rep_opt[$j])
{
$day += 1;
}
$day += 1;
break;
// Unknown repeat option
default:
return;
}
}
return $entrys;
}
/** mrbsCreateRepeatingEntrys()
*
* Creates a repeat entry in the data base + all the repeating entrys
*
* $starttime - Start time of entry
* $endtime - End time of entry
* $rep_type - The repeat type
* $rep_enddate - When the repeating ends
* $rep_opt - Any options associated with the entry
* $room_id - Room ID
* $owner - Owner
* $name - Name
* $type - Type (Internal/External)
* $description - Description
*
* Returns:
* 0 - An error occured while inserting the entry
* non-zero - The entry's ID
*/
function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt,
$room_id, $owner,
$name, $type, $description, $rep_num_weeks)
{
global $max_rep_entrys;
global $room_dep;
$reps = mrbsGetRepeatEntryList($starttime, $rep_enddate, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
if(count($reps) > $max_rep_entrys)
return 0;
if(empty($reps))
{
mrbsCreateSingleEntry($starttime, $endtime, 0, 0, $room_id, $owner, $name, $type, $description, $room_dep);
return;
}
$ent = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id,
$owner, $name,
$type, $description, $rep_num_weeks);
if($ent)
{
$diff = $endtime - $starttime;
for($i = 0; $i < count($reps); $i++)
mrbsCreateSingleEntry($reps[$i], $reps[$i] + $diff, 1, $ent,
$room_id, $owner, $name, $type, $description, $room_dep);
}
return $ent;
}
/* mrbsGetEntryInfo()
*
* Get the booking's entrys
*
* $id = The ID for which to get the info for.
*
* Returns:
* nothing = The ID does not exist
* array = The bookings info
*/
function mrbsGetEntryInfo($id)
{
$sql = "SELECT start_time, end_time, entry_type, repeat_id, room_id,
timestamp, create_by, name, type, description
FROM mrbs_entry WHERE (ID = $id)";
$res = sql_query($sql);
if (! $res) return;
$ret = "";
if(sql_count($res) > 0)
{
$row = sql_row($res, 0);
$ret["start_time"] = $row[0];
$ret["end_time"] = $row[1];
$ret["entry_type"] = $row[2];
$ret["repeat_id"] = $row[3];
$ret["room_id"] = $row[4];
$ret["timestamp"] = $row[5];
$ret["create_by"] = $row[6];
$ret["name"] = $row[7];
$ret["type"] = $row[8];
$ret["description"] = $row[9];
}
sql_free($res);
return $ret;
}
function mrbsGetRoomArea($id)
{
$sql = "SELECT area_id FROM mrbs_room WHERE (id = $id)";
$id = sql_query1($sql);
if ($id <= 0) return 0;
return $id;
}
##################denpendence##############
#gibt raum_id zurueck, die abhaenig von anderen raeumen ist,
#wenn nicht, dann nichts
function mrbsNumDepRoom($room_id)
{
$sql = "SELECT room_id FROM mrbs_depend";
$res = mysql_query($sql);
for ($d = 0; $row = mysql_fetch_row($res); $d++)
{
$num[$d] = $row[0];
}
$num = array_unique($num);
while($room_id != $num[0])
{
array_shift($num);
if (count($num) == 0)
break;
}
$num= current($num);
return $num;
}
#gibt entweder die raum_id wieder oder mit abhaenigenen raeumen
#inc. sich selbst in $row[0]
function mrbsGetDependList($room_id)
{
if ($room_id != (mrbsNumDepRoom($room_id)))
{
return $room_id;
}
else
{
$sql = "SELECT depend FROM mrbs_depend WHERE (room_id = $room_id)";
$res = mysql_query($sql);
for ($count = 1; $row = mysql_fetch_row ($res); ++$count)
{
$ent[$count] = $row[0];
}
array_unshift($ent,$room_id);
return $ent;
}
}
# gibt array mit abhaengigen id's zurueck inc. sich selbst
function mrbsDependIdList($id)
{
$sql = "SELECT start_time, end_time, name FROM mrbs_entry WHERE (id=$id)";
$res = mysql_query($sql);
$row=mysql_fetch_row($res);
$start_time=$row[0];
$end_time=$row[1];
$name=$row[2];
$sql = "SELECT id FROM mrbs_entry WHERE start_time=$start_time AND end_time=$end_time AND name='$name'";
$res = mysql_query($sql);
for ($d = 0; $row = mysql_fetch_row ($res); $d++)
{
$dep[$d] = $row[0];
}
return $dep;
}
######################################################
function mrbsGetRoomName($id)
{
$sql = "SELECT room_name FROM mrbs_room WHERE (id = $id)";
$res = mysql_query($sql);
if(mysql_num_rows($res) > 0)
{
$row = mysql_fetch_row($res);
return $row[0];
}
return 0;
}
?>
# Add an extra column to the mrbs_entry table for depend ALTER TABLE mrbs_entry ADD COLUMN depend int(11) NOT NULL; #Add a new tabel mrbs_depend for the dependence matrix CREATE TABLE mrbs_depend ( room_id int DEFAULT '1' NOT NULL, depend int DEFAULT '0' NOT NULL );
RSS Feed