Location: PHPKode > projects > ARBS > arbs-1.5.1.78/roomlist.php
<?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.
 */


//room has been registred before if it was set in _GET
if (isset($room) && !isset($_GET['category'])){	
        $category = sql_query1("select CID from mrbs_multicat where RID=$room LIMIT 0,1");
}
elseif (isset($_GET['category'])){
		$category=(int)$_GET['category'];
        if (!isset($room))
                $room = sql_query1("select min(RID) from mrbs_multicat where CID=$category AND extra=0 LIMIT 0,1");
}
else{
        $category = get_default_category($area);
        if (!isset($_GET['room']))
	        $room = sql_query1("select min(id) from mrbs_room where area_id=$area");
        if ($category ==0){
                $category_found = false;
        }
        else{
                $category_found = true;
        }
}

if ( $pview != 1 ) {
        # Table with areas, rooms, minicals.
        echo "<table height=140><tr>";
        $this_area_name = "";
        $this_room_name = "";
	$infolink="";
        # Show all areas
        echo "<td width=\"200\"><u>" . _("Areas") . "</u><br>";
}

$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++){
                if ( $pview != 1 )
                        echo "<a href=\"week.php?year=$year&month=$month&day=$day&area=$row[0]\">";
                if ($row[0] == $area){
                        $this_area_name = htmlspecialchars($row[1]);
                        if ( $pview != 1 )
                                echo "<font color=\"red\">$this_area_name</font></a><br>\n";
                }
                else if ( $pview != 1 )
                        echo htmlspecialchars($row[1]) . "</a><br>\n";
        }
}

echo "<br>";
print_company_image();
echo "<br><br>",$startpage;

?>
<br><br>
<?php
if ( $pview != 1) {
        echo "</td>\n";
# Show all categories in the current area
}
$cID=0;
$sql = "select id, name from mrbs_category where area_id=$area order by name";
$res = sql_query($sql);
if ($res&&$pview!=1){
        for ($i = 0; ($row = sql_row($res, $i)); $i++){
                $ol_text="";
                $subres=sql_query("SELECT m.rid, r.room_name FROM mrbs_room AS r LEFT JOIN mrbs_multicat AS m ON r.id=m.RID WHERE m.CID='$row[0]' AND hidden='false' ORDER BY m.uorder");
                while($zeile=mysql_fetch_row($subres)){
                        $ol_text.="<a href=week.php?year=$year&month=$month&day=$day&area=$area&category=$row[0]&room=$zeile[0]>".$zeile[1]."</a><br>";
                }
                if ($i==0)
                        echo "<td width=\"200\"><u>$lang[category]</u><br>";
                // Wenn $ol_text leer ist, hat diese Kategorie keinerlei Räume (zumindest keine sichtbaren).
                // Also zeigen wir sie auch gar nicht erst an ;-)
                if ($ol_text!="") {
                        if ($row[0] == $category && $category_found!=true){
                                $cID=$row[0];
                                $this_cat_name = htmlspecialchars($row[1]);
                                        echo "<a href=\"pre.php?year=$year&month=$month&day=$day&area=$area&category=$row[0]\"><font color=\"red\">$this_cat_name</font></a>";
                        }
                        else{
                                #get sub-items of this category for overlib view
                                
                                echo "<a onmouseover=\"return overlib('",addslashes($ol_text),"',STICKY, MOUSEOFF);\" onmouseout=\"return nd();\" href=\"pre.php?year=$year&month=$month&day=$day&area=$area&category=$row[0]\">",htmlspecialchars($row[1]),"</a>";			
                        }
                        echo "<br/>\n";
		}
        }
}
# Show all rooms in the current area, store capacity and comment of each room in array $room_capacity,$room_comment
#$room_capacity[$room_id]=capacity
#$room_comment[$room_id]=comment
$room_capacity=array();
$room_comment=array();
if ($i == 0 || $category_found==false){
        if ($i==0)
                $sql = "SELECT id, room_name,capacity,comment,infourl FROM mrbs_room WHERE area_id=$area AND hidden='false' ORDER BY room_name";
        else
                $sql = "SELECT r.id, r.room_name,r.capacity,r.comment,r.infourl FROM mrbs_room AS r LEFT JOIN mrbs_multicat AS m ON r.id=m.RID WHERE m.CID='$category' AND hidden='false' ORDER BY m.uorder";
        $i=0;
        $res = sql_query($sql);
        if ($res){
		echo "<td width=\"200\"><u>", _("Device"), "</u><br>";
                for ($i = 0; ($row = sql_row($res, $i)); $i++){
			if($room==-1)
				$room=$row[0];
			$room_capacity[$row[0]]=$row[2];
                        $room_comment[$row[0]]=$row[3];
                        if ($pview!=1 && $i>0&&$i%6==0)
                                echo "</td><td width=200><br>";
                        if ( $pview != 1 )
                                echo "<a href=\"week.php?year=$year&month=$month&day=$day&area=$area&category=$category&room=$row[0]\">";
                        if ($row[0] == $room){
                                $this_room_name = htmlspecialchars($row[1]);
				$infolink=$row[4];
                                if ( $pview != 1 )
                                        echo "<font color=\"red\">$this_room_name</font></a><br>\n";
                        }
                        else if ( $pview != 1 )
                                echo htmlspecialchars($row[1]) . "</a><br>\n";
                }
        }
}
if ( $pview != 1 ) {
        echo "</td>\n";

        echo "</tr></table>\n";

        # Don't continue if this area has no rooms:
        if ($category_found == true && (!isset($room) || $room<=0)){
                echo "<h1>", _("Please select a category"), "</h1>";
                include("trailer.inc.php");
                exit;
        }
        if ($room <= 0){
                echo "<h1>", _("This area / category doesn't have a room"), "</h1>";
                include("trailer.inc.php");
                exit;
        }
}
?>
Return current item: ARBS