<?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 don't know the right date then use today:
if (!isset($_GET['day']) or !isset($_GET['month']) or !isset($_GET['year'])){
$day = date("d",time());
$month = date("m",time());
$year = date("Y",time());
}
else {
# Make the date valid if day is more then number of days in month:
$day=(int)$_GET['day'];
$month=(int)$_GET['month'];
$year=(int)$_GET['year'];
while (!checkdate($month, $day, $year))
$day--;
}
if (isset($_GET['best'])){
#parse list of all booked entrys and pass them to confirmpopup
#this is better then extracting the entry in confirmpopup.php and destroyin the session there
#because the user may reload confirmpoup.php this way
$confirm="";
foreach($_SESSION['session_booking_ids'] as $val){
$confirm.=$val.":";
}
reset_session();
Header("Location: confirmpopup.php?confirm=".urlencode($confirm));
exit ;
}
if (isset($_GET['abbruch'])){
foreach($_SESSION['session_booking_ids'] as $key=>$val){
if ($_SESSION['session_booking_rid'][$key]> 0){
sql_query("DELETE FROM mrbs_repeat WHERE id=".$_SESSION['session_booking_rid'][$key]);
sql_query("DELETE FROM mrbs_entry WHERE repeat_id="+$_SESSION['session_booking_rid'][$key]);
}
sql_query("DELETE FROM mrbs_entry WHERE id=".$val);
}
reset_session();
Header("Location: week.php");
exit;
}
if (isset($_GET['loeschen'])) {
$nr=(int)$_GET['nr'];
if(isset($_SESSION['session_booking_ids'][$nr])){
if ($_SESSION['session_booking_rid'][$nr]> 0){
sql_query("DELETE FROM mrbs_repeat WHERE id=".$_SESSION['session_booking_rid'][$nr]);
sql_query("DELETE FROM mrbs_entry WHERE repeat_id=".$_SESSION['session_booking_rid'][$nr]);
}
sql_query("DELETE FROM mrbs_entry WHERE id=".$_SESSION['session_booking_ids'][$nr]);
#remove entry from session_booking_ids,$session_booking_rid
$tmp1=array();
$tmp2=array();
foreach($_SESSION['session_booking_ids'] as $key=>$val){
if($key==$nr)
continue;
$tmp1[]=$val;
$tmp2[]=$_SESSION['session_booking_rid'][$key];
}
$_SESSION['session_booking_ids']=$tmp1;
$_SESSION['session_booking_rid']=$tmp2;
}
}
print_header($day, $month, $year, $area);
//form title
$eetitle="";
foreach($titleformat as $val){//titleformat is a config value
$k=$db_entry_fields[$val];
$eetitle.=isset($_SESSION[$k])?$_SESSION[$k]:$val;
}
echo "<br><br><table bgcolor=#000000 cellspacing=0 cellpadding=2 align=center><tr><td>
<table bgcolor=#ffffff width=720 align=center cellspacing=0 cellpadding=0><tr><td bgcolor=#ffffff align=center>
<font color=#cc0000><b>",
_("You're logged in as Mr/Mrs:"),
" $eetitle</b><br><u>",
_("Please don't forget to confirm your order!"),
"</u><hr>";
if (count($_SESSION['session_booking_ids']) <1){
echo "<tr><td><table bgcolor=#ffffff width=720 align=center cellspacing=0 cellpadding=0><tr><td bgcolor=#C0E0FF align=center>";
echo "<h3>",_("You didn't place a reservation."),"</h3></td></tr></table>";
}
foreach($_SESSION['session_booking_ids'] as $key=>$id){
echo "<tr><td><table bgcolor=#ffffff width=720 align=center cellspacing=0 cellpadding=2>";
$res=sql_query("SELECT r.room_name from mrbs_room as r left join mrbs_entry as e on r.id=e.room_id where e.id='$id'");
$zeile=mysql_fetch_row($res);
$room_name=$zeile[0];
echo "<tr><td bgcolor=#C0E0FF><h3>$room_name:</h3></td></tr><tr><td><font color=#009900 size=3><b><br>";
if($_SESSION['session_booking_rid'][$key]==0){
$sql="SELECT start_time,end_time FROM mrbs_entry WHERE id='$id' ORDER BY start_time";
$res=sql_query($sql);
$zeile=mysql_fetch_row($res);
echo "<li>".date("d.m.y, G:i",$zeile[0])," ", _("till"), " ", date("d.m.y, G:i",$zeile[1]);
echo " ";
echo "<a href=\"korb_kompl.php?loeschen=j&nr=$key&year=$year&month=$month&day=$day\">",
_("delete"),
"</a> <a href=edit_entry.php?id=$id>",
_("change"),
"</a>";
}
else{
$sql="SELECT start_time,end_time,id FROM mrbs_entry WHERE repeat_id='".$_SESSION['session_booking_rid'][$key]."' ORDER BY start_time";
$res=sql_query($sql);
$change_id=0;
while($zeile=mysql_fetch_row($res)){
#get first mrbs_entry.id in this series. only this id may be passed to edit_entry.php to change the series
$change_id=$change_id==0?$zeile[2]:$change_id;
echo "<li>", date("d.m.y, G:i",$zeile[0]), " ", _("till"), " ", date("d.m.y, G:i",$zeile[1]);
}
echo " ";
echo "<a href=korb_kompl.php?nr=$key&loeschen=j&year=$year&month=$month&day=$day>",
_("Delete the series"),
"</a> <a href=edit_entry.php?edit_type=series&id=",$change_id,">",
_("Change the series"),
"</a>";
}
echo "<br><br></td></tr></table></tr></td><tr><td>";
}
?>
<tr><td><hr></td></tr></table>
<table bgcolor=#ffffff width=100%><tr><td colspan=2>
<?php
echo "<form method=GET action=\"week.php\">
<input type=hidden name=year value=\"".$year."\">
<input type=hidden name=month value=\"".$month."\">
<input type=hidden name=day value=\"".$day."\">
<input type=hidden name=room value=\"".$_SESSION['session_last_room_id']."\">";
?>
</td></tr>
<tr><td>
<input type=submit value="<?php echo(_("Add another reservation")); ?>"></form>
<form method=GET action=korb_kompl.php>
<input type=hidden name=best value=1>
<br>
<input style=font-weight:bold;color:#ff0000; type=submit value="<?php echo(_("Confirm reservation")); ?>"></form>
</td></tr></table></td></tr></table>
<?php
include("trailer.inc.php");
?>