<?php
/**
* @author Bettina Schwarzer, Fritz-Haber-Institut
* @copyright 12/2012
*
* Report Raumverantwortliche
*
*/
error_reporting(E_ALL ^ E_NOTICE);
if (!isset($_GET['s']) || $_GET['s'] != 2 )
{
session_start();
if (! isset($_SESSION["userid"]))
{
include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
login($_SERVER["PHP_SELF"]);
exit;
}
if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("rr",$_SESSION["recht"]) && !in_array("re",$_SESSION["recht"])))
{
header("Location: start.php");
exit;
}
}
include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/>
<link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/>
<title>Report Raumverantwortliche</title>
</head>
<body>
<?php
echo " ";
if (!isset($_GET['s']) || $_GET['s'] != 2 )
{
echo "<div class=\"float-br smaller\" valign='top'>";
echo " user: " . $_SESSION["userid"];
echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
echo "<div class=\"float-r\"><img src=\"/fhiiqm/img/role.png\" border=\"0\" alt=\"Raum\" title=\"Raum\"/></div>\n";
}
$rag = $_POST["rag"]; // Parameter aus Form
$search = $_POST["search"];
if (!$search) $search = $_GET["s"];
$zeil = $rag["z"];
if (!$zeil) $zeil = $_GET["z"];
if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen
$start = $_GET["st"]; // Start bei DS $start+1
if (!$start) $start=0;
if (!is_array($rag))
{
$rag["geb"] = $_GET["g"];
$rag["rtyp"] = $_GET["t"];
$rag["bind"] = $_GET["b"];
$rag["sort1"] = $_GET["s1"];
$rag["sort2"] = $_GET["s2"];
$rag["sort3"] = $_GET["s3"];
}
$_GET["g"] = $rag["geb"];
$_GET["t"] = $rag["rtyp"];
$_GET["b"] = $rag["bind"];
$_GET["s1"] = $rag["sort1"];
$_GET["s2"] = $rag["sort2"];
$_GET["s3"] = $rag["sort3"];
$_GET["z"] = $zeil;
if ($search && $_GET['s'] != 2)
{
echo "<span class='sc'>";
echo "<br /> <a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>« zur Berichtsübersicht</a>";
echo " | <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Räume Verantwortliche\" class=\"sc\">neuer Bericht Räume und Verantwortliche</a>\n";
echo "</span>";
}
echo "<div align='center'>\n";
echo "<p><b>Bericht Räume und Verantwortliche (Labore und Technik)</b></p>\n";
echo "</div>\n";
if (!$search)
{
?>
<div align="center">
<p>Bitte Kriterien für die Suche wählen</p>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_raum" target="_self">
<table width="50%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td>Haus</td>
<td>
<select name="rag[geb]" size="1">
<?php
if ($rag["geb"] == -1) $select = " selected "; else $select = "";
echo "<option $select value=\"-1\"></option>\n";
$sql = "SELECT geb_ID, geb_name FROM Haus ORDER BY 1";
if ($result = $dbc->queryObjectArray($sql))
{
foreach ($result as $row)
{
if ($row->geb_ID == $rag['geb'])
echo "<option selected value=\"$row->geb_ID\">$row->geb_ID - $row->geb_name</option>\n";
else
echo "<option value=\"$row->geb_ID\">$row->geb_ID - $row->geb_name</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Raumtyp</td>
<td><select name="rag[rtyp]">
<?php
if ($rag["rtyp"] == -1) $select = " selected "; else $select = "";
echo "<option $select value=\"-1\"></option>\n";
$sql = "SELECT raumtyp_ID,raumtyp_bez FROM fhiiqm.Raum_Typ WHERE raumtyp_ID IN ('LA','T') ORDER BY 1";
if ($result = $dbc->queryObjectArray($sql))
{
foreach ($result as $row)
{
if ($row->raumtyp_ID == $rag['rtyp'])
echo "<option selected value=\"$row->raumtyp_ID\">$row->raumtyp_ID - $row->raumtyp_bez</option>\n";
else
echo "<option value=\"$row->raumtyp_ID\">$row->raumtyp_ID - $row->raumtyp_bez</option>\n";
}
}
?>
</select></td>
</tr>
<tr>
<td>Verknüpfung</td>
<td>UND
<input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else echo "checked";?>>
ODER
<input type="radio" name="rag[bind]" value="OR" <?php if (isset($rag["bind"]) && $rag["bind"]=="OR") echo "checked"; ?>></td>
</tr>
<tr>
<td>Sortierung nach<br />(in dieser Reihenfolge)</td><td>
<?php
$sort = array("-1"=>"","2"=>"Gebäude","3"=>"Raum-Nr.","5"=>"Raum-Typ");
for ($i=1; $i<4; $i++)
{
echo "$i. <select name='rag[sort$i]'>\n";
foreach ($sort as $key=>$val)
{
$rsort = "sort" . $i;
if ($rag[$rsort] == $val) $select= " selected"; else $select = "";
echo "<option$select value='$key'>$val</option>\n";
}
echo "</select> \n";
}
echo "</td></tr>\n";
$azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows
echo "<tr><td>Zeilen/Seite?</td><td><select name='rag[z]'>\n";
if (!$rag['z']) $rag['z'] = 9999;
foreach ($azeil as $key=>$val)
{
if ($key == $rag['z']) $select = "selected"; else $select = "";
echo "<option $select value='$key'>$val</option>\n";
}
echo "</select></td></tr>\n";
?>
<tr>
<td> </td>
<td><input class="button" type="submit" name="search" value="Bericht erstellen"/></td>
</tr>
</table>
</div>
</form>
<?php
}
else
{
echo "<div align='center'>\n";
if (!$rag["bind"]) $bind = "'AND'"; else $bind = "'$rag[bind]'";
if ($rag["geb"]> -1) $geb = "'$rag[geb]'"; else $geb = "''";
if ($rag["rtyp"]> -1) $rtyp = "'$rag[rtyp]'"; else $rtyp ="''";
if ($rag["sort1"]>0 || $rag["sort2"]>0 || $rag["sort3"]>0)
{
if ($rag["sort1"]>0 ) $so = "$rag[sort1]";
if ($rag["sort2"]>0)
if ($so) $so .= ", $rag[sort2]"; else $so = "$rag[sort2]";
if ($rag["sort3"]>0)
if ($so) $so .= ", $rag[sort3]"; else $so = "$rag[sort3]";
$so = "'$so'";
}
else $so ="''";
$sql = "CALL raum_vma_report($so,$bind,$geb,$rtyp,$start,$zeil,@anz)";
$result = $dbc ->queryObjectArray($sql);
if ($rag["geb"] > -1) $krit = " [Gebäude = '" . $rag["geb"] ."']";
if ($rag["rtyp"] > -1)
{
if ($krit) $bd = " ".$bind; else $bd = "";
$rtn = $dbc -> querySingleItem("SELECT raumtyp_bez FROM Raum_Typ WHERE raumtyp_ID='".$rag["rtyp"]."'");
$krit .= $bd." [Raum-Typ = '$rtn']";
}
if ($krit )echo "Suchergebnis für $krit"; else echo "Suchergebnis\n";
$ianz = $dbc -> querySingleItem("SELECT @anz");
printf ("<p>Anzahl gefundener Räume: %s</p>", $ianz);
if ($result)
{
include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
$bg1 = "#F8F8F8";
$bg2 = "#DEDFE1";
$bg = "#FFFFFF";
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
// Listenkopf
echo "<tr bgcolor='#68ACBF'>";
if ($rag['geb'] == -1) echo "<th>Gebäude</th>";
echo "<th>Raum-Nr.</th>";
echo "<th>Raum-Bezeichnung</th>";
if ($rag['rtyp'] == -1) echo "<th>Raum-Typ</th>";
echo "<th>Fläche(m<sup>2</sup>)</th>";
echo "<th>Verantwortliche</th>";
echo "</tr>\n";
foreach ($result as $row)
{
if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
echo "<tr bgcolor='" . $bg . "'>";
if ($rag['geb'] == -1) echo "<td>$row->geb_ID</td>";
echo "<td>$row->raum_nr</td>";
echo "<td>$row->raum_name</td>";
if ($rag['rtyp'] == -1) echo "<td>$row->raumtyp_ID - $row->raumtyp_bez</td>";
echo "<td class='right'>" . str_replace(".",",",$row->raum_flaeche) . "</td>";
echo "<td>" . str_replace("; ","<br />",$row->vma)."</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "<p></p><table width=60%><tr><td class='right'><a href=\"javascript:window.print()\" class='sc'>
<img src=\"/fhiiqm/img/printer.png\" alt=\"Bericht drucken\" border=\"0\" align=\"right\" title=\"Bericht drucken\"></a></td></tr></table>";
echo "</div>\n";
echo "<br /> ";
if ($search != 2) // Aufruf aus fhiiqm
{
// Parameter aus $_GET fuer weitere Seiten
$_GET["s"] = 1; // bewirkt weitere Suche
foreach ($_GET as $key=>$val)
{
if ($key != "st") $liste .= "&" . $key ."=".$val;
}
// Links auf andere Seiten generieren
liste_links($start,$zeil,$ianz,$liste);
}
}
else
{
echo "<p class='red'> Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
echo "</div>\n";
echo "<br /> ";
}
if ($search != 2)
{
echo "<span class='sc'>";
echo "<br /><br /> <a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>« zur Berichtsübersicht</a>";
echo " | <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Räume Verantwortliche\" class=\"sc\">neuer Bericht Räume und Verantwortliche</a>\n";
echo "</span>";
}
else
echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zurück'; return true;}\">« Zurück</a>";
}
?>
</body>
</html>