<?php
/*
* ARBS - Advanced Resource Booking System
* Copyright (C) 2005-2007 ITMC der TU Dortmund
* Based on MRBS by Daniel Gardner <http://mrbs.sourceforge.net/>
*
* 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; either version 2
* of the License, or (at your option) any later version.
*
* 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; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
include_once("glob_inc.inc.php");
#If we dont know the right date then make it up
if(!isset($_GET['area'])){
$area=get_default_area();
}
else{
$area=(int)$_GET['area'];//the area from mrbs_area
}
$id=(int)$_GET['id'];
$view=substr(strip_tags($_GET['view']),0,12);//for security reasons strip to 12 chars
#If we dont know the right date then make it up
if (!isset($_GET['day']) or !isset($_GET['month']) or !isset($_GET['year'])){
$day = date("d");
$month = date("m");
$year = date("Y");
}
else {
$day=(int)$_GET['day'];
$month=(int)$_GET['month'];
$year=(int)$_GET['year'];
# Make the date valid if day is more then number of days in month
while (!checkdate($month, $day, $year))
$day--;
}
print_header($day, $month, $year, $area);
if(isset($_GET['repeat_id'])){
$repeat_id=(int)$_GET['repeat_id'];
$sql= "SELECT mrbs_entry.id FROM `mrbs_entry` WHERE repeat_id='".$repeat_id."'";
$res = sql_query($sql);
if (! $res) fatal_error(0, sql_error()." ".$sql);
$row = sql_row($res,0);
$id=$row[0];
}
$sql="SELECT r.room_name," . sql_syntax_timestamp_to_unix("e.timestamp") . ",
(e.end_time - e.start_time),
e.start_time,
e.end_time,
e.create_by,
e.repeat_id,
e.type,
r.id,
".sql_syntax_timestamp_to_unix("e.created");
foreach($dbfield_structure as $key=>$val){
foreach($val as $v2){
$sql.=",e.".$v2[0];
}
}
$sql.=" FROM mrbs_entry as e left join mrbs_room as r on e.room_id=r.id WHERE e.id='$id'";
$res = sql_query($sql);
if (! $res)
fatal_error(0, sql_error());
if(sql_count($res) < 1)
fatal_error(0, sprintf(_("Invalid entry id. ($d)"), $id));
$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.
$create_by = htmlspecialchars($row[5]);
$room_name = htmlspecialchars($row[0]);
$updated = strftime('%X - %A %d %B %Y', $row[1]);
$duration = $row[2];
$start_date = strftime('%X - %A %d %B %Y', $row[3]);
$end_date = strftime('%X - %A %d %B %Y', $row[4]);
$repeat_id=$row[6];
$rep_type = 0;
$type=$row[7];
$room_id=$row[8];
$created= strftime('%X - %A %d %B %Y', $row[9]);;
if($repeat_id != 0){
$res = sql_query("SELECT rep_type, end_date, rep_opt, rep_num_weeks
FROM mrbs_repeat WHERE id=$repeat_id");
if (! $res)
fatal_error(0, sql_error());
if (sql_count($res) == 1){
$reprow = sql_row($res, 0);
$rep_type = $reprow[0];
$rep_end_date = strftime('%A %d %B %Y',$reprow[1]);
$rep_opt = $reprow[2];
$rep_num_weeks = $reprow[3];
}
sql_free($res);
}
toTimeString($duration, $dur_units);
$repeat_key = "rep_type_" . $rep_type;
# Now that we know all the data we start drawing it
?>
<table border=0>
<?php
#show all data from dbfield_structure
@$showHidden=getAuthorised(getUserName(), getUserPassword(), 1);
$n=10;//the offset in the mysql result set from where the userfields beginn
foreach($dbfield_structure as $key=>$val){
echo "<tr><td colspan=2><b><u>",($key==""?" ":$lang[$key]),"</u></b></td></tr>\n";
foreach($val as $rows){
$v=nl2br(htmlspecialchars($row[$n]));
echo "<tr><td><b>",$lang[$rows[3]],"</b></td><td>",((!$rows[5]||$showHidden)?$v:$lang["entryhidden"]),"</td></tr>\n";
$n++;
}
echo "<tr><td> </td><td> </td></tr>\n";
}
?>
<tr><td colspan=2><b><u><?php echo(_("Event data")); ?></u></b></td></tr>
<?php
#show the booking type only if there are more then one possible types
if(count($typel)>1){
echo "<tr><td><b>",_("Type"),"</b></td><td>",(empty($typel[$type])? "?$type?" : $typel[$type]),"</td></tr>";
}
?>
<tr>
<td><b><?php echo(_("Room")); ?></b></td>
<td><?php echo($room_name); ?></td>
</tr>
<tr>
<td><b><?php echo(_("Duration")); ?></b></td>
<td><?php echo $duration . " " . $dur_units ?></td>
</tr>
<tr>
<td><b><?php echo(_("Type of repetition")); ?></b></td>
<td><?php
switch($rep_type) {
case 0: echo(_("once")); break;
case 1: echo(_("daily repeating")); break;
case 2: echo(_("weekly repeating")); break;
case 3: echo(_("weekly while in the term")); break;
}
?></td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td><b><?php echo(_("Start date")); ?></b></td>
<td><?php echo(parseDate($start_date)); ?></td>
</tr>
<tr>
<td><b><?php echo(_("End date")); ?></b></td>
<td><?php echo(parseDate($end_date)); ?></td>
</tr>
<tr><td> </td><td> </td></tr>
<tr>
<td><b><?php echo(_("Created by")); ?></b></td>
<td>
<?php
if (strlen($create_by)==0) {
echo(_("Customer"));
}
else{
echo $create_by;
}
?>
</td>
</tr>
<tr>
<td><b><?php echo(_("Created on")); ?></b></td>
<td><?php echo(parseDate($created)); ?></td>
</tr>
<tr>
<td><b><?php echo(_("Last change")); ?></b></td>
<td><?php echo(parseDate($updated)); ?></td>
</tr>
<?php
if($rep_type != 0){
$opt = "";
if (($rep_type == 2) || ($rep_type == 6)){
# Display day names according to language and preferred weekday start.
for ($i = 0; $i < 7; $i++){
$daynum = ($i + $weekstarts) % 7;
if ($rep_opt[$daynum])
$opt .= parseDate(day_name($daynum)) . " ";
}
}
if ($rep_type == 6){
echo "<tr><td><b>", _("Number of weeks"), " ", _("(n-times per week)"), "</b></td><td>$rep_num_weeks</td></tr>\n";
}
if($opt)
echo "<tr><td><b>", _("Day of repetition"), "</b></td><td>$opt</td></tr>\n";
echo "<tr><td><b>", _("Last day of repetition:"), "</b></td><td>".parseDate($rep_end_date)."</td></tr>\n";
}
echo "</table><br><p>";
echo "<table border=0>";
if($entryPrintEnabled)
echo "<tr><td><img height=30 src=img/leihschein.jpg border=0></td><td><a href=\"print_single.php?view=week&id=" . $id. "&day=$day&month=$month&year=$year\">", _("Print view of booker's ticket"), "</a></td></tr>";
echo "<tr><td><img height=20 src=img/b_report.gif></td><td><a href=view_entry.php?view=$view&id=$id&pview=1>", _("Print view of this page"), "</a></td></tr>";
?>
<tr><td><img src=img/edit.gif border=0></td><td><a href="edit_entry.php?view=<?php echo($view)?>&id=<?php echo $id ?>"><?php echo(_("Change entry")); ?></a>
<?php
if($repeat_id)
echo " - <a href=\"edit_entry.php?view=$view&id=$id&edit_type=series&day=$day&month=$month&year=$year\">" . _("Change all entries") . "</a>";
?>
</td></tr>
<tr><td><img src=img/delete.jpg border=0></td><td>
<A HREF="del_entry.php?view=<?php echo($view); ?>&room=<?php echo($room_id); ?>&id=<?php echo($id); ?>&series=0&day=<?php echo($day); ?>&month=<?php echo($month); ?>&year=<?php echo($year); ?>" onClick="return confirm('<?php echo(_("Are you sure to delete this entry?")); ?>');"><?php echo(_("Delete entry")); ?></A>
<?php
if($repeat_id)
echo " - <A HREF=\"del_entry.php?view=$view&room=$room_id&id=$id&series=1&day=$day&month=$month&year=$year\" onClick=\"return confirm('", _(_("Are you sure to delete this entry?")), "');\">", _("Delete all entries"), "</A>";
?>
</td></tr>
<tr><td> </td><td>
<a href="<?php echo($_SERVER['HTTP_REFERER']); ?>"><?php echo(_("Back to previous page")); ?></a>
<?php // activate trailer -> remove html after this lines
//include("trailer.inc.php");
?>
</td></tr>
</table>
</body></html>