--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/abt_raum_rt_report.php Thu Jul 12 13:29:11 2012 +0200
@@ -0,0 +1,356 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 06/2012
+ *
+ * Report Raeume, Raumtyp, Abteilung (Raum-Arb.-Gruppen)
+ * $_GET['s']=2 - Aufruf aus adm-fhi-Seite ohne Anmeldung
+ *
+ */
+
+ 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 Abteilung - Raum, Raumtyp</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["abt"] = $_GET["a"];
+ $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["a"] = $rag["abt"];
+ $_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=\"Raum-Typ\" class=\"sc\">neuer Abteilung - Raum, Raumtyp Bericht</a>\n";
+ echo "</span>";
+ }
+ echo "<div align='center'>\n";
+ echo "<p><b>Bericht Abteilung - Raum, Raumtyp</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>Abteilung</td>
+ <td>
+ <select name="rag[abt]" size="1">
+ <?php
+ if ($rag["abt"] == -1) $select = " selected "; else $select = "";
+ echo "<option $select value=\"-1\"></option>\n";
+ $sql = "SELECT abt_ID, abt_name, abt_long FROM Abteilung ORDER BY 1";
+ if ($result = $dbc->queryObjectArray($sql))
+ {
+ foreach ($result as $row)
+ {
+ if ($row->abt_ID == $rag['abt'])
+ echo "<option selected value=\"$row->abt_ID\">$row->abt_name - $row->abt_long</option>\n";
+ else
+ echo "<option value=\"$row->abt_ID\">$row->abt_name - $row->abt_long</option>\n";
+ }
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <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 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"=>"","1"=>"Gebäude","2"=>"Raum-Nr.","3"=>"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] == $i) $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";
+
+ $sql = "SELECT geb_ID,raum_nr,raum_name,r.raumtyp_ID,raumtyp_bez,rag_bez,abt_name,ra.rag_ID,ra.abt_ID
+ FROM RaumArb_Gruppe ra
+ LEFT OUTER JOIN Abteilung a ON ra.abt_ID=a.abt_ID
+ LEFT OUTER JOIN Raum_RaumArbGruppe rr ON ra.rag_ID=rr.rag_ID
+ LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+ LEFT OUTER JOIN Raum_Typ t ON r.raumtyp_ID=t.raumtyp_ID";
+
+ $lim = " LIMIT $start,$zeil";
+
+ if (!$rag["bind"]) $bind = " AND "; else $bind = $rag["bind"];
+
+ if ($rag["geb"]> -1) $where = " geb_ID = '$rag[geb]' ";
+ if ($rag["abt"]> -1)
+ if ($where) $where .= "$bind ra.abt_ID = '$rag[abt]' "; else $where = " ra.abt_ID = '$rag[abt]' ";
+ if ($rag["rtyp"]> -1)
+ if ($where) $where .= "$bind r.raumtyp_ID = '$rag[rtyp]' "; else $where = " r.raumtyp_ID = '$rag[rtyp]' ";
+ if ($where) $where = " WHERE $where";
+
+ if ($rag["sort1"]>0 || $rag["sort2"]>0 || $rag["sort3"]>0)
+ {
+ if ($rag["sort1"]>0) $ord = $rag["sort1"];
+ if ($rag["sort2"]>0) $ord .= ",".$rag["sort2"];
+ if ($rag["sort3"]>0) $ord .= ",".$rag["sort3"];
+ }
+
+ $sql .= $where;
+// $ianz = $dbc -> numrows($sql);
+ if ($ord) $ord = " ORDER BY 8, ".$ord; else $ord = " ORDER BY 8 ";
+ $sql .= $ord . $lim;
+// echo "sql = $sql<br />\n";
+ $result = $dbc ->queryObjectArray($sql);
+
+ if ($rag["abt"] > -1)
+ {
+ $abtn = $dbc -> querySingleItem("SELECT abt_name FROM Abteilung WHERE abt_ID=".$rag["abt"]);
+ $krit = " [Abteilung = '$abtn']";
+ }
+ if ($rag["geb"] > -1)
+ {
+ if ($krit) $bd = " ".$bind; else $bd = "";
+ $krit .= $bd." [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 COUNT(*)
+ FROM RaumArb_Gruppe ra
+ LEFT OUTER JOIN Abteilung a ON ra.abt_ID=a.abt_ID
+ LEFT OUTER JOIN Raum_RaumArbGruppe rr ON ra.rag_ID=rr.rag_ID
+ LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+ LEFT OUTER JOIN Raum_Typ t ON r.raumtyp_ID=t.raumtyp_ID $where");
+ 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['abt'] || $rag['abt'] == -1) echo "<th>Abteilung</th>";
+ echo "<th>Arbeitsgruppe</th>";
+ if (!$rag['geb'] || $rag['geb'] == -1) echo "<th>Gebäude</th>";
+ echo "<th>Raum-Nr.</th>";
+ echo "<th>Raum-Bezeichnung</th>";
+ if (!$rag['rtyp'] || $rag['rtyp'] == -1) echo "<th>Raum-Typ</th>";
+ echo "</tr>\n";
+
+ foreach ($result as $row)
+ {
+ if ($row->rag_ID != $rid)
+ {
+ if ($rid) echo "</td></tr>\n";
+ if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+ echo "<tr bgcolor='" . $bg . "'>";
+ if (!$rag['abt'] || $rag['abt'] == -1) echo "<td>$row->abt_name";
+ echo "<td>$row->rag_bez";
+ if (!$rag['geb'] || $rag['geb'] == -1) echo "<td>$row->geb_ID</td>";
+ echo "<td>$row->raum_nr</td>";
+ echo "<td>$row->raum_name</td>";
+ if (!$rag['rtyp'] || $rag['rtyp'] == -1) echo "<td>$row->raumtyp_ID - $row->raumtyp_bez</td></tr>\n";
+ }
+ else
+ {
+ echo "<tr bgcolor='" . $bg . "'>";
+ if (!$rag['abt'] || $rag['abt'] == -1) echo "<td> </td><td> </td>"; else echo "<td> </td>";
+ if (!$rag['geb'] || $rag['geb'] == -1) echo "<td>$row->geb_ID</td>";
+ echo "<td>$row->raum_nr</td>";
+ echo "<td>$row->raum_name</td>";
+ if (!$rag['rtyp'] || $rag['rtyp'] == -1) echo "<td>$row->raumtyp_ID - $row->raumtyp_bez</td></tr>\n";
+ }
+ $rid = $row->rag_ID;
+ }
+ 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=\"Raum-Typ\" class=\"sc\">neuer Abteilung - Raum, Raumtyp Bericht</a>\n";
+ echo "</span>";
+ }
+ else
+ echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zurück'; return true;}\">« Zurück</a>";
+ }
+
+?>
+
+</body>
+</html>
\ No newline at end of file