+ MA-Telefon-Liste, Edit MA, Telefon
authorBettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Fri, 21 Dec 2012 15:31:50 +0100
changeset 33 f1a8785434e4
parent 32 c2d325791e24
child 34 fc60ef80a7ad
+ MA-Telefon-Liste, Edit MA, Telefon + Report dezentrale Anlagen + Report MA - Beziehungen
fhiiqm/alpruef_flist.php
fhiiqm/alrisk_flist.php
fhiiqm/alvtr_flist.php
fhiiqm/anlage_flist.php
fhiiqm/ap_gefahr_flist.php
fhiiqm/as_report.php
fhiiqm/css/db.css
fhiiqm/deprecated/ap_massn_ed.php
fhiiqm/deprecated/ap_massn_flist.php
fhiiqm/deprecated/as_massn_ed.php
fhiiqm/deprecated/as_massn_flist.php
fhiiqm/deprecated/info_ins.php
fhiiqm/deprecated/info_upd.php
fhiiqm/deprecated/vertrag_flist2.php
fhiiqm/form/ma_ed_form.inc.php
fhiiqm/form/produkt_form.inc.php
fhiiqm/form/raumarbgr_form.inc.php
fhiiqm/img/fhilogotransp.gif
fhiiqm/img/fhilogotransp.png
fhiiqm/img/user.png
fhiiqm/inc/ma_tel_dat_show.inc.php
fhiiqm/inc/menu.inc.php
fhiiqm/inc/pdf_ma_tel.inc.php
fhiiqm/inc/produkt_dat_show.inc.php
fhiiqm/info_report.php
fhiiqm/laser_flist.php
fhiiqm/laser_log_flist_ed.php
fhiiqm/ma_fkt_ed.php
fhiiqm/ma_fkt_flist.php
fhiiqm/ma_tel_ed.php
fhiiqm/ma_tel_flist.php
fhiiqm/ma_tel_pdf.php
fhiiqm/partner_flist.php
fhiiqm/produkt_ins.php
fhiiqm/produkt_upd.php
fhiiqm/prozess_flist.php
fhiiqm/raum_aptyp_ed.php
fhiiqm/raum_aptyp_flist.php
fhiiqm/raum_flist.php
fhiiqm/raum_flist_ed.php
fhiiqm/raum_report.php
fhiiqm/raum_upd.php
fhiiqm/raum_vma_ed.php
fhiiqm/raum_vma_flist.php
fhiiqm/raumarbgr_ed.php
fhiiqm/raumarbgr_flist.php
fhiiqm/recht_list.php
fhiiqm/report/fkt_ma_report.php
fhiiqm/report/info_report_gvp.php
fhiiqm/report/ma_relation_report.php
fhiiqm/report/rag_gefahr_massn_report.php
fhiiqm/report/rag_raum_rt_ma_report.php
fhiiqm/report/raum_dez_anl_report.php
fhiiqm/report/raum_ohne_rag_report.php
fhiiqm/report/raum_vma_report.php
fhiiqm/start.php
fhiiqm/tel_ed.php
fhiiqm/tel_flist.php
fhiiqm/test/fpdf_create.php
fhiiqm/test/ma_tel_flist_mysql.php
fhiiqm/test/ma_tel_pdf_mysql.php
fhiiqm/tool/fpdf.php
fhiiqm/vertrag_flist1.php
fhiiqm/vertrag_flist12.php
--- a/fhiiqm/alpruef_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/alpruef_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
--- a/fhiiqm/alrisk_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/alrisk_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
--- a/fhiiqm/alvtr_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/alvtr_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
--- a/fhiiqm/anlage_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/anlage_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
--- a/fhiiqm/ap_gefahr_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/ap_gefahr_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -66,10 +66,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 1;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 1;
+    if (!isset($dir) || !$dir)  $dir = "";
 
 
     $sql = "SELECT t.arbplatz_typ, a.gefahr_ID, arbplatz_typ_bez, gefahr_bez 
--- a/fhiiqm/as_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/as_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -80,6 +80,13 @@
         </tr>
         <tr>
             <td class="bigger">
+                <a href="/fhiiqm/report/rag_raum_rt_ma_report.php" title="Abteilung-Raum-Raumtyp">(2a) Arbeitsgruppe - Raum+Raumtyp - Mitarbeiter</a>
+                <br />&nbsp;&nbsp;&nbsp;Auswahl: Abteilung, Raumtyp 
+                <br />&nbsp;&nbsp;&nbsp;Ansicht:  Arbeitsgruppe, Abteilung, Raum+Raumtyp, Mitarbeiter 
+            </td>
+        </tr>
+        <tr>
+            <td class="bigger">
                 <a href="/fhiiqm/report/abt_ag_aptyp_report.php" title="Abteilung-AG-APTyp">(3) Abteilung - Arbeitsgruppe - Arbeitsplatztyp</a>
                 <br />&nbsp;&nbsp;&nbsp;Auswahl: Abteilung
                 <br />&nbsp;&nbsp;&nbsp;Ansicht: Abteilung, Arbeitsgruppe, Arbeitsplatztyp (ohne Redundanzen)
--- a/fhiiqm/css/db.css	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/css/db.css	Fri Dec 21 15:31:50 2012 +0100
@@ -119,7 +119,7 @@
     font-size: 11px;
     color: #000000;
     text-decoration: none;
-    background-color: #ffffff}
+    background-color: #FFFFFF}
 
 input.read
 {   font-family: Verdana, Arial, Helvetica, sans-serif;
@@ -164,6 +164,10 @@
 {
     vertical-align: bottom;
 }
+.valignm
+{
+    vertical-align: middle;
+}
 .valignt
 {
     vertical-align: top;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/ap_massn_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,195 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 06/2012
+ * 
+ * INSERT/UPDATE Arbeitsplatz - Massnahmen
+ * 
+ */
+
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login($_SERVER["PHP_SELF"]);
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+
+    $sub = $_POST["eintragen"];
+    $ap  = $_POST["ap"];
+    $ok  = $_POST["ok"];
+    $apid = $_GET["i"]; // arbeitsplatz_ID
+    
+
+
+?>
+<!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>Arbeitsplatztyp - AS Ma&szlig;nahmen</title>
+
+    <script type="text/javascript">
+    <!--
+    var counter = 0;
+    var limit = 99;
+    var arr = new Array();
+    function addInput(divId){
+         if (counter == limit)  {
+              alert("Das Limit von " + counter + " zusätzlichen inputs ist erreicht");
+         }
+         else {
+              var newdiv = document.createElement('div');
+              var count;
+              var opt="<option value='-1'></option>";
+              for (var key in arr)  
+              {
+                opt = opt.concat("<option value='",key,"'>",arr[key],"</option>\n" );
+              }
+              opt += "</select>\n";
+              newdiv.innerHTML += "<select name='ap[asm][]'>"+opt;
+              document.getElementById(divId).appendChild(newdiv);
+              counter++;
+         }
+    }
+    function delInput(divId){
+            var kn = document.getElementById(divId); 
+            while (kn.childNodes.length>0 && kn.lastChild.nodeName != "SELECT" && kn.lastChild.nodeName != "A")
+            {
+//                alert ("vor "+kn.lastChild.nodeName+", nodetyp = "+ kn.lastChild.nodeType);
+                var knc = kn.lastChild;
+                    document.getElementById(divId).removeChild(knc);
+            }
+            if (kn.lastChild.nodeName == "SELECT") document.getElementById(divId).removeChild(kn.lastChild);
+    }
+    //-->
+    </script>
+
+</head>
+
+<body>
+
+<?php
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"Arbeitsplatztyp - Massnahmen bearbeiten\" title=\"Arbeitsplatztyp - Massnahme bearbeiten\"/></div>\n";
+
+    if ($apid) $text = "editieren"; else $text = "erfassen";
+    echo "<div align=\"center\">";
+    echo "<h3>Arbeitsplatztyp - Arbeitssicherheit Ma&szlig;nahmen $text</h3>";
+    echo "</div>\n";
+    if (!$sub || !isset($ap) || !$ok) 
+    {
+        if ($apid && !$sub && !isset($ap))
+        {
+            $sql = "SELECT asm_ID, arbplatz_typ FROM AS_Massnahme_Arbplatz WHERE arbplatz_typ = '" . $apid . "'";
+            if ($res = $dbc -> queryObjectArray($sql))
+            {
+                foreach ($res as $row)
+                {
+                    $ap["aptyp"] = $row->arbplatz_typ;
+                    $ap["asm"][]  = $row->asm_ID;   
+                }
+            }
+            else $ap["aptyp"] = $apid;
+        }
+        include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/form/ap_massn_form.inc.php");
+        
+	  	if ($sub)
+        {
+            $frage = "Alle Angaben ok?";
+			echo "<tr>
+			  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
+			        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
+			        if ($ok)  echo "checked=\"checked\""; 
+			echo " /></td>\n</tr>\n";
+        }
+        if (!is_null($_SESSION["recht"]) && in_array("ase",$_SESSION["recht"]))
+        {
+            echo "
+           	<tr><td>&nbsp;</td>\n
+            	<td><input  class=\"button\" type=\"submit\" name=\"eintragen\" value=\"  eintragen  \" />";
+           	echo "</td></tr>\n";
+        }
+        echo "</table>\n";
+        echo "</div>\n";
+    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ap_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Massnahmenen-Liste\">&laquo; zur Arbeitsplatztyp-Massnahmenen-Liste</a></p>\n"; 
+    echo "</form>\n";
+    }
+    else
+    {
+        echo "<div align='center'>\n";
+
+        if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+        
+        $stmt = $dbc -> stmtinit();
+        if (is_object($stmt))
+        {
+            $retd = 1;
+            if ($apid && is_array($ap['asm']))
+            {   //UPDATE
+                // Loeschen alte Arbeitsplatztypen
+                $retd = $dbc -> execute("DELETE FROM AS_Massnahme_Arbplatz WHERE arbplatz_typ = '". $ap["aptyp"] ."'");
+            }
+            
+            if ($retd && is_array($ap['asm']))
+            {
+                $rett = 1;
+                $stmt -> prepare("INSERT INTO AS_Massnahme_Arbplatz (asm_ID,arbplatz_typ) VALUES(?,?)");
+                for ($k=0; $k<count($ap["asm"]); $k++)
+                {
+                    if ($ap["asm"][$k] && $ap["asm"][$k] != -1) 
+                    {
+                        $stmt -> bind_param('is',$ap["asm"][$k], $ap["aptyp"]);
+                        $rett = $stmt -> execute();
+                        if (!$rett) $rett = false;
+                    }
+                }
+                if (!$rett) echo "error INSERT Massnahme: $stmt->error<br />\n";
+                
+            }
+        }
+            if ($rett)
+            {
+                echo "<p class='green'><b>AS Ma&szlig;nahmenen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden erfolgreich gespeichert.</b></p>\n";
+                echo "<table>\n";
+                if (is_array($ap["asm"]))
+                {
+                    echo "<tr><td>AS Ma&szlig;nahmen: </td>";
+                    foreach ($ap["asm"] as $gf)
+                    { 
+                        $sql = "SELECT asm_bez FROM AS_Massnahme WHERE asm_ID=$gf";
+                        $asmbez = $dbc -> querySingleItem($sql);
+                        if ($next) $next ="<tr><td>&nbsp;</td>"; else $next =" ";
+                        if ($gf && $gf != -1) echo "$next<td>$asmbez</td></tr>\n";
+                    }
+                }
+                echo "</table>\n";
+            }   
+            else
+                echo "<p class='red'><b>AS Ma&szlig;nahmen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden nicht oder nur teilweise gespeichert</b></p>\n";
+        
+        echo "</div>";
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ap_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Ma&szlig;nahmen-Liste\">&laquo; zur Arbeitsplatztyp-Ma&szlig;nahmen-Liste</a></p>\n"; 
+    }
+?>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/ap_massn_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,187 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 05/2012
+ * 
+ * Liste Arbeitsplatztyp - AS Massnahme 
+ * Tabelle 'AS_Massnahme_Arbplatz' wird nicht mehr genutzt (19.06.2012, bs)
+ * 
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    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("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+
+?>
+<!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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+   	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
+
+    <link type="text/css" href="/fhiiqm/css/jquery/ui-lightness-1.8.21/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
+    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-1.7.2.min.js"></script>
+    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-ui-1.8.21.custom.min.js"></script>
+
+	<title>Arbplatztyp-AS-Ma&szlig;nahme-Liste</title>
+</head>
+
+<body onload="document.ffilter.filter.focus();">
+
+    <script>
+      $(document).ready(function() {
+        $("#dialog").dialog({
+            	bgiframe: true,
+            	autoOpen: false,
+            	height: 300,
+                width: 400,
+                resizable: true,
+            	modal: true
+                });
+        $('#open0').click(function() {
+    	       $('#dialog').dialog("open");
+                });
+        $('#open1').click(function() {
+    	       $('#dialog').dialog("open");
+                });
+        });
+    </script>
+    
+<?php
+    include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	$dbc = new dbconnection();
+
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"Arbeitsplatztypen-AS Massnahmen\" title=\"Arbeitsplatztypen-AS Massnahmen\"/></div>\n";
+    
+    // Felder, nach denen gefiltert werden kann
+    $fields = array(2=>"Gefärdungs-Nr.");
+
+	$sort   = $_GET["s"];   // Sortierung nach Spalte
+    if (!isset($sort) && !$sort) $sort = $_POST["s"];      
+
+    $dir    = $_GET["d"];   // Sortierrichtung
+    if (!isset($dir) && !$dir) $dir = $_POST["d"];
+
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
+
+    $filter = $_POST["filter"];
+    if (!isset($filter) && !$filter) $filter = $_GET["b"];   
+
+    $subf   = $_POST["subf"]; // submit
+    
+    if (!isset($fnum) && !$fnum) $fnum = 1;
+    if (!isset($filter) && !$filter) $filter = "";
+    if (!isset($sort) && !$sort) $sort = 1;
+    if (!isset($dir) && !$dir)  $dir = "";
+
+
+    $sql = "SELECT ma.arbplatz_typ,arbplatz_typ_bez, ma.asm_ID, m.asm_bez, asm_bem 
+            FROM fhiiqm.AS_Massnahme_Arbplatz ma 
+            LEFT OUTER JOIN Arbplatz_Typ t ON ma.arbplatz_typ=t.arbplatz_typ
+            LEFT OUTER JOIN AS_Massnahme m ON ma.asm_ID=m.asm_ID ";
+    if ($fnum == 4 & $filter > " ")
+        $sql .= " WHERE asm_bez LIKE '%$filter%' ";
+    $sql .= " ORDER BY $sort $dir";
+    
+    $result = $dbc ->queryObjectArray($sql);
+    
+    echo "<div align='center'>\n";
+    echo "<p><b>Liste Arbeitsplatztypen - Ma&szlig;nahmen</b></p>\n";
+        
+    if ($result)
+    {
+		$bg1 = "#F8F8F8";
+		$bg2 = "#DEDFE1";
+		$bg = "#FFFFFF";
+     
+        echo "<table border='0' cellspacing='0'>\n";
+        echo "<tr><td class='bigger'>Mittels '<img src='/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />' 
+            können Sie nach jeder Spalte auf- bzw. absteigend sortieren</td></tr>
+            <td class='bigger'>'<img src='/fhiiqm/img/filter.gif' border='0' width='14' hight='11' />' erm&ouml;glicht das Filtern nach Ma&szlig;nahmen</td></tr>\n
+                <tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten Arbeitsplatztyp - Ma&szlig;nahmen</td></tr>\n
+                <tr><td class='bigger'>&nbsp;</td></tr>";
+        echo "</table>\n";
+        if (isset($fnum) && $fnum>1 && !$filter && !$subf)
+        {
+            // Formular anzeigen fuer Filterbegriff
+            $text = $fields[$fnum];
+            echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
+            echo "<input type='hidden' name='f' value='$fnum'>";
+            echo "<table width=\"30%\" border=\"0\">\n";
+            echo "<tr><td>filtern nach $text: </td>";
+            echo "<td><input id='filter' name='filter' type=\"text\" size=\"30\" maxlength=\"30\" value=\"$filter\"/></td>";
+            echo "<td><input class=\"button\" type=\"submit\" value=\"finden\" name=\"subf\" title=\"subf\" /></td></tr></table>\n";
+            echo "</form>\n";
+            echo "<p>&nbsp;&nbsp;&nbsp;</p>\n";
+        }
+        echo "<table border='0'>\n";
+        // Listenkopf generieren
+        echo "<tr bgcolor='#68ACBF'>";
+        tab_column(1,"Arbeitsplatz-Typ",$sort,$dir,0,$fnum,$filter,0,9999);
+        tab_column(4,"Ma&szlig;nahmen",$sort,$dir,4,$fnum,$filter,0,9999);
+        echo "<th>Bemerkung</th>";
+        echo "<th>&nbsp;</th></tr>";
+   
+        $vt = "?"; $i=0;
+        if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+        
+        foreach ($result as $row)
+        {
+            if ($row->arbplatz_typ != $vt)
+            {    
+                if ($vt != "?")
+                { 
+                    echo "</td><td><a href='/fhiiqm/ap_massn_ed.php?i=$vt'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+                    if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                }
+                echo "<tr bgcolor='" . $bg . "'>";
+                echo "<td>$row->arbplatz_typ - $row->arbplatz_typ_bez</td>";
+            }
+            else echo "<tr bgcolor='" . $bg . "'><td>&nbsp;</td>";
+                
+            echo "<td>$row->asm_bez</td>";
+            if (strlen($row->asm_bem) > 100) 
+            {   
+                $plus = "<a href='#' id='open$i'>...(weiter)</a>";
+                $bem[$i] = $row->asm_bem;
+                $i++;
+            }
+            else $plus = "";    
+            echo "<td>". nl2br(substr($row->asm_bem,0,100)). $plus;  
+            $vt = $row->arbplatz_typ;
+        }
+        echo "</td><td><a href='/fhiiqm/ap_massn_ed.php?i=$vt'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+        echo "</table>\n</div>\n";
+    }
+    else
+    {
+            echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider nichts gefunden f&uuml;r ". $fields["$fnum"] . " wie '$filter'!</p><br /></div>";
+            echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Massnahmengen Arbeitsplatztyp\" class=\"sc\">Liste AS-Ma&szlig;nahmen Arbeitsplatztyp</a></p>\n";
+    }
+                echo "<div id='dialog' title='Erl&auml;uterung Ma&szlig;nahme' style='display:none'>";
+                echo nl2br($bem[$i]);
+                echo "</div>";
+?>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/as_massn_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,155 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 06/2012
+ * 
+ * INSERT/UPDATE AS-Massnahme
+ * 
+ */
+
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login($_SERVER["PHP_SELF"]);
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+
+    $sub = $_POST["eintragen"];
+    $del    = $_POST["del"];
+    $asm  = $_POST["asm"];
+	$ok		= $_POST["ok"];
+    if (!$asm['okn']) $ok=false;
+    $asmid = $_GET["i"]; // asm_ID
+    
+
+
+?>
+<!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>AS-Massnahme</title>
+</head>
+
+<body>
+
+<?php
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"AS-Massnahme bearbeiten\" title=\"AS-Massnahme bearbeiten\"/></div>\n";
+
+    if ($ragid) $text = "editieren"; else $text = "erfassen";
+    echo "<div align=\"center\">";
+    echo "<h3>Arbeitssicherheit-Massnahme $text</h3>";
+    echo "</div>\n";
+    if ((!$sub && !$del) || !isset($asm) || !$ok) 
+    {
+        if ($asmid && !$sub && !isset($asm))
+        {
+            $sql = "SELECT asm_bez, asm_bem FROM AS_Massnahme WHERE asm_ID=$asmid";
+            $res = $dbc -> queryObjectArray($sql);
+            foreach ($res as $row)
+            {
+                $asm["bez"] = $row->asm_bez;
+                $asm["bem"] = $row->asm_bem;
+            }
+        }
+        include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/form/as_massn_form.inc.php");
+        
+        if ($sub || $del)
+		{
+		  	if ($sub)
+                $frage = "Alle Angaben ok?";
+            elseif ($del)
+                $frage = "AS Massnahme wirklich l&ouml;schen?";
+			echo "<tr>
+			  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
+			        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
+			        if ($ok)  echo "checked=\"checked\""; 
+			echo " /></td>\n</tr>\n"; 
+		}
+        if (!is_null($_SESSION["recht"]) && in_array("ase",$_SESSION["recht"]))
+        {
+            echo "
+           	<tr><td>&nbsp;</td>\n
+            	<td><input  class=\"button\" type=\"submit\" name=\"eintragen\" value=\"  eintragen  \" />";
+            if ($asmid)
+            {
+                echo "&nbsp;&nbsp;&nbsp;<input class=\"buttonr\" type=\"submit\" value=\"l&ouml;schen\" name=\"del\" title=\"delete\" />";
+            }
+           	echo "</td></tr>\n";
+        }
+        echo "</table>\n";
+        echo "</div>\n";
+    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"as_massn_flist.php\" target=\"_self\" title=\"AS-Massnahmen-Liste\">&laquo; zur AS-Massnahmen-Liste</a></p>\n"; 
+    echo "</form>\n";
+    }
+    else
+    {
+        echo "<div align='center'>\n";
+
+        if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+        if ($del)
+        {
+            $sql = "DELETE FROM AS_Massnahme WHERE asm_ID = $asmid";
+            $retmd = $dbc -> execute($sql);
+            if ($retmd)
+            {
+                echo "<p class='green'><b>DELETE: Daten  zu '".$asm["bez"]."' wurden erfolgreich gel&ouml;scht.</b></p>\n";
+            }                
+            else
+            {
+                echo "<p class='red'><b>DELETE: Daten  zu '".$asm["bez"]."' konnten nicht gel&ouml;scht werden!</b></p>\n";
+                echo "sql = $sql<br />";
+                echo "error DELETE: " . $dbc->error . "<br />";
+            }
+        }
+        else
+        {
+            $stmt = $dbc -> stmtinit();
+            if (is_object($stmt))
+            {
+                $retm=1;
+                if ($asmid && is_array($asm)) // UPDATE
+                {
+                    $stmt -> prepare("UPDATE AS_Massnahme SET asm_bez=?, asm_bem=?");
+                    $stmt -> bind_param('ss',$asm['bez'], substr($asm["bem"],0,2000));
+                    $retm = $stmt -> execute();
+                    if (!$retm) echo "error UPDATE AS-Massnahme: $stmt->error<br />\n";
+                }
+                else //INSERT    
+                {
+                    $stmt -> prepare("INSERT INTO AS_Massnahme (asm_bez, asm_bem) VALUES(?,?)");
+                    $stmt -> bind_param('ss',$asm['bez'], substr($asm["bem"],0,2000));
+                    $retm = $stmt -> execute();
+                    if (!$retm) echo "error INSERT AS-Massnahme: $stmt->error<br />\n";
+                }
+            }
+            if ($retm)
+                echo "<p class='green'><b>AS-Massnahme '".$asm["bez"]."' wurde erfolgreich gespeichert.</b></p>\n";
+            else
+                 echo "<p class='red'><b>AS-Massnahme '".$asm["bez"]."' konnte nicht gespeichert werden.</b></p>\n";
+        }     
+        echo "</div>\n";
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"".$_SERVER['PHP_SELF']."\" target=\"_self\" title=\"AS-Massnahmen\"> weitere AS-Massnahmen erfassen</a></p>\n"; 
+   }
+?>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/as_massn_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,141 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 06/2012
+ * 
+ * Liste Arbeitssicherheit - Massnahmen
+ * 
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login($_SERVER["PHP_SELF"]);
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+    
+    include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+	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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+   	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
+
+	<title>Arbeitssicherheit-Ma&szlig;nahmen-Liste</title>
+</head>
+
+<body onload="document.ffilter.filter.focus();">
+    
+<?php
+
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"AS Massnahmen\" title=\"AS Massnahmen\"/></div>\n";
+    
+    // Felder, nach denen gefiltert werden kann
+    $fields = array(2=>"Ma&szlig;nahme-Bezeichnung");
+
+	$sort   = $_GET["s"];   // Sortierung nach Spalte
+    if (!isset($sort) && !$sort) $sort = $_POST["s"];      
+
+    $dir    = $_GET["d"];   // Sortierrichtung
+    if (!isset($dir) && !$dir) $dir = $_POST["d"];
+
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
+
+    $filter = $_POST["filter"];
+    if (!isset($filter) && !$filter) $filter = $_GET["b"];   
+
+    $subf   = $_POST["subf"]; // submit
+    
+    if (!isset($fnum) && !$fnum) $fnum = 1;
+    if (!isset($filter) && !$filter) $filter = "";
+    if (!isset($sort) && !$sort) $sort = 1;
+    if (!isset($dir) && !$dir)  $dir = "";
+
+    if ($fnum == 2 && $filter>" ") $where = " WHERE asm_bez LIKE '%" . $filter ."%'"; else $where = "";
+    $sql = "SELECT asm_ID,asm_bez,asm_bem FROM fhiiqm.AS_Massnahme $where ";
+    $sql .= " ORDER BY $sort $dir";
+
+    $result = $dbc ->queryObjectArray($sql);
+
+    echo "<div align='center'>\n";
+    echo "<p><b>Liste Arbeitssicherheit - Ma&szlig;nahmen</b></p>\n";
+    
+    if ($result)
+    {
+		$bg1 = "#F8F8F8";
+		$bg2 = "#DEDFE1";
+		$bg  = "#FFFFFF";
+     
+        echo "<table border='0' cellspacing='0'>\n";
+        echo "<tr><td class='bigger'>Mittels '<img src='/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />' 
+            können Sie nach Ma&szlig;nahmen auf- bzw. absteigend sortieren</td></tr>
+                <tr><td class='bigger'>'<img src='/fhiiqm/img/filter.gif' border='0' width='14' hight='11' />' erm&ouml;glicht das Filtern nach Ma&szlig;nahmen</td></tr>\n
+                <tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten Ma&szlig;nahme</td></tr>\n
+                <tr><td class='bigger'>&nbsp;</td></tr>";
+        echo "</table>\n";
+
+        if (isset($fnum) && $fnum>1 && !$filter && !$subf)
+        {
+            // Formular anzeigen fuer Filterbegriff
+            $text = $fields[$fnum];
+            echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
+            echo "<input type='hidden' name='f' value='$fnum'>";
+            echo "<table width=\"30%\" border=\"0\">\n";
+            echo "<tr><td>filtern nach $text: </td>";
+            echo "<td><input id='filter' name='filter' type=\"text\" size=\"30\" maxlength=\"30\" value=\"$filter\"/></td>";
+            echo "<td><input class=\"button\" type=\"submit\" value=\"finden\" name=\"subf\" title=\"subf\" /></td></tr></table>\n";
+            echo "</form>\n";
+            echo "<p>&nbsp;&nbsp;&nbsp;</p>\n";
+        }
+        
+        echo "<table border='0'>\n";
+        if ($fnum == 2) $filt = "filter_activ"; else $filt = "filter"; 
+        echo "<tr bgcolor='#68ACBF'>";
+//        <th>Massnahme&nbsp;&nbsp;&nbsp;<a href='".$_SERVER['PHP_SELF']."?f=2'><img src='/fhiiqm/img/$filt.gif' border='0' width='14' hight='11' alt='Filter Massnahme' title='Filter Massnahme'></a></th>";
+        tab_column(2,"Ma&szlig;nahme",$sort,$dir,2,$fnum,$filter,0,9999);
+        echo "<th>Bemerkung</th>";
+        echo "<th>&nbsp;</th></tr>";
+        
+        if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+        foreach ($result as $row)
+        {
+                echo "<tr bgcolor='" . $bg . "'>";
+                echo "<td>$row->asm_bez</td>";
+                echo "<td>".nl2br($row->asm_bem) ."</td>";  
+                echo "</td><td><a href='/fhiiqm/as_massn_ed.php?i=$row->asm_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>
+                    </tr>\n";
+        }
+        echo "</table>\n";
+        echo "</div>\n";
+    }
+    else
+    {
+            echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider nichts gefunden f&uuml;r ". $fields["$fnum"] . " wie '$filter'!</p><br /></div>";
+            echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"AS Massnahme\" class=\"sc\">Liste AS Ma&szlig;nahmen</a></p>\n";
+    }
+    echo "&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/as_massn_ed.php\" target=\"_self\" title=\"AS Ma&szlig;nahme erfassen\" class=\"sc\">weitere AS Ma&szlig;nahme erfassen</a></p>\n";
+?>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/info_ins.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,185 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 08/2011
+ *
+ * INSERT Informationen   
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login($_SERVER["PHP_SELF"]);
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+    
+?>
+<!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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+   	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
+
+	<title>Eingabe Informationen</title>
+</head>
+
+<body>
+
+<?php
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/document_image_ver.png\" border=\"0\" alt=\"Informationen eingeben\" title=\"Informationen eingeben\"/></div>\n";
+
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	//$dbc = new dbconnection();
+    
+	$ok		= $_POST["ok"];
+    $inf    = $_POST["inf"];
+   	$submit	= $_POST["ins"];
+    if (!$inf["okn"]) $ok = false;
+    if (!$ok || !$submit)
+    {
+        include($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/form/info_form.inc.php");
+        if ($submit)
+		{
+            echo            
+            "<tr>
+        		<td>Upload Infodokument </td>
+        		<td><input type=\"file\" name=\"ifile\" size=\"50\" maxlength=\"50\" value=\"" .
+            $_FILES["ifile"]["name"] . "\"/></td>
+            </tr>";
+    
+		  	$frage = "Alle Angaben ok?<br>
+              erst wenn Haken gesetzt, Upload-File w&auml;hlen!";
+			echo "<tr>
+			  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
+			        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
+			        if ($ok)  echo "checked"; 
+			echo "></td>\n</tr>\n"; 
+		}
+		
+		echo "<tr>\n";
+		echo "
+		  <td>&nbsp;</td>
+		  <td><input class=\"button\" type=\"submit\" value=\"eingeben\" name=\"ins\" title=\"insert\" /></td>\n";
+		echo "</tr>\n";
+        echo "</table>\n";
+        echo "</div>\n";
+        echo "</form>\n";	
+
+    }
+    else
+    {
+        echo "<div align='center'>\n";
+        //daten speichern
+        $inf["iname"] = substr($inf["iname"],0,300);
+        $inf["ilong"] = substr($inf["ilong"],0,8000);
+        if ($inf["ityp"] == -1) $inf["ityp"] = null;
+        
+        if ($inf["ijahr"] && $inf["imon"] && $inf["itag"])
+        {
+            $idat = $inf["ijahr"]."-".$inf["imon"]."-".$inf["itag"];
+            // Datum valid?
+            if (!$idat = new DateTime_s($idat)) $idat = null;
+        }    
+        else
+            $idat = null;
+        if ($inf["bjahr"] && $inf["bmon"] && $inf["btag"])
+        {
+            $bdat = $inf["bjahr"]."-".$inf["bmon"]."-".$inf["btag"];
+            if (!$bdat = new DateTime_s($bdat)) $bdat = null;
+        }    
+        else
+            $bdat = null;
+        if ($inf["ejahr"] && $inf["emon"] && $inf["etag"])
+        {
+            $edat = $inf["ejahr"]."-".$inf["emon"]."-".$inf["etag"];
+            if (!$edat = new DateTime_s($edat)) $edat = null;
+        }    
+        else
+            $edat = null;
+
+        if ($inf["pers"] == -1) $inf["pers"] = null;
+        if ($inf["prid"] <1 ) $inf["prid"] = null;
+        if ($inf["infrel"] == -1) $inf["infrel"] = null;
+        if ($inf["lang"] == -1) $inf["lang"] = null;
+        //echo "datcreate: $idat, datevalidfrom: $bdat, datevalidto: $edat, author: " . $inf["pers"] . "<br />\n";        
+
+        if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+        $stmt = $dbc -> stmtinit();
+        if (is_object($stmt))
+        {
+            $stmt -> prepare ("INSERT INTO Info (info_name_s,info_name_l,info_date,info_valid_from,info_valid_to,
+                        infotyp_ID,persknr,lang,info_rel_ID) VALUES (?,?,?,?,?,?,?,?,?)");
+            $stmt -> bind_param('sssssiisi', $inf["iname"],$inf["ilong"],$idat,$bdat,$edat,$inf["ityp"],$inf["pers"],$inf["lang"],$inf["infrel"]);
+            $result = $stmt -> execute();      
+        }
+        if ($dbc->error) echo "error: " . $dbc->error . "<br><br>\n";
+        if ($result)
+        { // INSERT o.k.
+          // info_ID ermitteln
+            $infid = $dbc -> insertId();
+            
+            // n:m Tabellen INSERT
+            include ("inc/info_tab_ins.inc.php");
+
+            // upload File
+            if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] )
+            {
+                include ("inc/file_upload.inc.php");
+                $fname = gen_filename($inf['ifname'],"ifile",$infid);
+                $retf   = upload("ifile", $fname, $infid, "infos");              // Datei prüfen und in Dokumentenverzeichnis verschieben
+                
+                if ($retf)
+                {   // upload o.k.
+                    //UPDATE des Filenamens
+                    $sql = "UPDATE Info SET info_file = '" . $infid . "_" . $fname ."' WHERE info_ID=$infid";
+                    $retv=$dbc->execute($sql);
+                    if (!$retv) 
+                        echo $dbc -> error . "<br>\n";
+                }
+               
+            }
+            else 
+            {
+                $retf=1; //kein Infodoc hochgeladen
+            }
+            if ($result && $retf && $reta && $retp) // INSERT Raum
+            {
+                //Eingabe Daten, Upload File erfolgreich 
+                    echo "<p class='green'><b>Infodaten zu ID '$infid' wurden erfolgreich gespeichert.</b></p>\n";
+                    echo "<br /><br />\n";
+
+                // Anzeigen gespeicherte Raumdaten
+                if ($fname)
+                    $ifile = $infid . "_" . $fname;
+                else
+                    $ifile = $inf['ifname'];
+                include ("inc/info_dat_show.inc.php");
+            }            
+        }
+        $dbc -> close();
+        echo "</div>\n";
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"info_flist.php\" target=\"_self\" title=\"Infoliste\">Zur Infolisteliste</a></p>\n";    
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"info_ins.php\" target=\"_self\" title=\"Information erfassen\">Weitere Information erfassen</a></p>\n";    
+    }
+
+
+?>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/info_upd.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,268 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 08/2011
+ *
+ * INSERT Informationen   
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login($_SERVER["PHP_SELF"]);
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ir",$_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+    
+?>
+<!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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+   	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
+
+	<title>Eingabe Informationen</title>
+</head>
+
+<body>
+
+<?php
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\"><img src=\"img/document_image_ver.png\" border=\"0\" alt=\"Infodaten &auml;ndern\" title=\"Infodaten &auml;ndern\"/></div>\n";
+
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+    include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+	$dbc = new dbconnection();
+    
+    $infid    = $_GET["uid"];
+    if (!$inf) $inf=1;
+	$upd	= $_POST["upd"];
+    $del    = $_POST["del"];
+	$inf    = $_POST["inf"];
+    $ok		= $_POST["ok"];
+    if (!$inf["okn"]) $ok = false;
+
+    if (!$ok && ((!$upd && !$del) || $upd || $del))
+    {
+        if (!$upd && !$del)
+        {
+            $sql = "SELECT info_ID,info_name_s,info_name_l,info_date,info_valid_from,info_valid_to,infotyp_ID,
+                    persknr,lang,info_file,info_rel_ID,info_freigabe FROM fhiiqm.Info WHERE info_ID = $infid";
+            if ($result = $dbc -> queryObjectArray($sql))
+            {
+                foreach ($result as $row)
+                {
+                    $inf["infid"]   = $infid;
+                    $inf["iname"]   = $row->info_name_s;
+                    $inf["ilong"]   = $row->info_name_l;
+                    $inf["ityp"]   = $row->infotyp_ID;
+                    $inf["ijahr"]   = substr($row->info_date,0,4);  
+                    $inf["imon"]    = substr($row->info_date,5,2);  
+                    $inf["itag"]    = substr($row->info_date,8,2);  
+                    $inf["bjahr"]   = substr($row->info_valid_from,0,4);  
+                    $inf["bmon"]    = substr($row->info_valid_from,5,2);  
+                    $inf["btag"]    = substr($row->info_valid_from,8,2);  
+                    $inf["ejahr"]   = substr($row->info_valid_to,0,4);  
+                    $inf["emon"]    = substr($row->info_valid_to,5,2);  
+                    $inf["etag"]    = substr($row->info_valid_to,8,2);
+                    $inf["pers"]    = $row->persknr;
+                    $inf["infrel"]  = $row->info_rel_ID;
+                    $inf["ifname"]   = $row->info_file;
+                    $inf["lang"]    = $row->lang;     
+                }
+            }
+            // Produkt
+            $sql = "SELECT produkt_ID FROM Info_Produkt WHERE info_ID = $infid";
+            if ($result = $dbc -> queryObjectArray($sql))
+            {
+                foreach ($result as $row)
+                {
+                    $inf['prid'][] = $row->produkt_ID;
+                }
+            }
+            // Adressat
+            $sql = "SELECT info_adr_ID FROM Info_Adressat WHERE info_id = $infid";
+            if ($result = $dbc->queryObjectArray($sql))
+            {
+                foreach ($result as $row)
+                $inf["adr"][] = $row->info_adr_ID;
+            }
+                
+        }
+        include_once("form/info_form.inc.php");
+        
+        if ($upd)
+		{
+            echo            
+            "<tr>
+        		<td>Upload Infodokument </td>
+        		<td><input type=\"file\" name=\"ifile\" size=\"50\" maxlength=\"50\" value=\"" .
+            $_FILES["ifile"]["name"] . "\"/></td>
+            </tr>";
+    
+		}
+	  	if ($upd || $del)
+        {
+            if ($upd)
+              $frage = "Alle Angaben ok?<br>
+              erst wenn Haken gesetzt, Upload-File w&auml;hlen!";
+            elseif ($del)
+                $frage = "Information wirklich l&ouml;schen?";
+    		echo "<tr>
+    		  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
+    		        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
+    		        if ($ok)  echo "checked"; 
+    		echo "></td>\n</tr>\n"; 
+        }
+		
+        if (!is_null($_SESSION["recht"]) && in_array("ie",$_SESSION["recht"]))
+        {
+    		echo "<tr>\n";
+    		echo "
+    		  <td>&nbsp;</td>
+    		  <td><input class=\"button\" type=\"submit\" value=\"&auml;ndern\" name=\"upd\" title=\"update\" />
+    		  &nbsp;&nbsp;&nbsp;<input class=\"button\" type=\"submit\" value=\"l&ouml;schen\" name=\"del\" title=\"delete\" /></td>\n";
+    		echo "</tr>\n";
+        }
+        echo "</table>\n";
+        echo "</div>\n";
+        if (!is_null($_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"]))
+            echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"info_flist.php\" target=\"_self\" title=\"Infoliste\">&laquo; zur Infoliste</a></p>\n";    
+        echo "</form>\n";	
+
+        
+    }
+    elseif ($ok && $upd)
+    {
+        echo "<div align='center'>\n";
+        //daten speichern
+        $inf["iname"] = substr($inf["iname"],0,300);
+        $inf["ilong"] = substr($inf["ilong"],0,8000);
+        if ($inf["ityp"] == -1) $inf["ityp"] = null;
+        
+        //Datumswerte validieren
+        $idat = date_obj($inf["ijahr"], $inf["imon"], $inf["itag"]);
+        $bdat = date_obj($inf["bjahr"], $inf["bmon"], $inf["btag"]);
+        $edat = date_obj($inf["ejahr"], $inf["emon"], $inf["etag"]);
+
+        if ($inf["pers"] == -1) $inf["pers"] = null;
+        if ($inf["infrel"] == -1) $inf["infrel"] = null;
+        if ($inf["lang"] == -1) $inf["lang"] = null;
+        //echo "datcreate: $idat, datevalidfrom: $bdat, datevalidto: $edat, author: " . $inf["pers"] . "<br />\n";        
+
+        if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+        $stmt = $dbc -> stmtinit();
+        if (is_object($stmt))
+        {
+            $stmt -> prepare("UPDATE fhiiqm.Info SET
+                        info_name_s = ?, 
+                        info_name_l = ?, 
+                        info_date = ?, 
+                        info_valid_from = ?, 
+                        info_valid_to = ?, 
+                        infotyp_ID = ?, 
+                        persknr = ?, 
+                        lang = ?, 
+                        info_rel_ID = ? WHERE info_ID = $infid");
+            $stmt -> bind_param('sssssiisi',$inf["iname"],$inf["ilong"],$idat,$bdat,$edat,$inf["ityp"],$inf["pers"],$inf["lang"],$inf["infrel"]);
+            $result = $stmt -> execute();
+//            print_r($stmt);
+        }
+        if ($dbc->error) echo "error: " . $dbc->error . "<br><br>\n";
+        if ($result)
+        { // UPDATE o.k.
+            
+            // n:m Tabellen INSERT
+            include ("inc/info_tab_ins.inc.php");
+
+            // upload File
+                // echo "upload-error: " . $_FILES["ifile"]["error"] .  "<br />\n";
+            if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] )
+            {
+//                echo "file hochgeladen: " . $_FILES["ifile"]["name"] ."<br />\n";
+                include ("inc/file_upload.inc.php");
+                $fname = gen_filename($inf['ifname'],"ifile",$infid);
+                $retdf  = mod_file("/var/www/fhiiqm/infos",$infid,"","del");  // Loeschen alte Datei
+                $retf   = upload("ifile", $fname, $infid, "infos");              // Datei prüfen und in Dokumentenverzeichnis verschieben
+                
+                if ($retf)
+                {   // upload o.k.
+                    //UPDATE des Filenamens
+                    $sql = "UPDATE Info SET info_file = '" . $infid . "_" . $fname ."' WHERE info_ID=$infid";
+                    $retv=$dbc->execute($sql);
+                    if (!$retv) 
+                        echo $dbc -> error . "<br>\n";
+                }
+               
+            }
+            else 
+            {
+                $retf=1; //kein Infodoc hochgeladen
+            }
+            if ($result && $retf && $reta && $retp) // INSERT Raum
+            {
+                //Eingabe Daten, Upload File erfolgreich 
+                    echo "<p class='green'><b>Infodaten zu ID '$infid' wurden erfolgreich gespeichert.</b></p>\n";
+                    echo "<br /><br />\n";
+
+                // Anzeigen gespeicherte Raumdaten
+                if ($fname)
+                    $ifile = $infid . "_" . $fname;
+                else
+                    $ifile = $inf['ifname'];
+                include ("inc/info_dat_show.inc.php");
+            }
+        }                      
+    }
+    elseif ($ok & $del)
+    {
+       // DELETE aus Tab Info und abhaengigen Tabellen
+        echo "<div align='center'>\n";
+
+        $idat = date_obj($inf["ijahr"], $inf["imon"], $inf["itag"]);
+        $bdat = date_obj($inf["bjahr"], $inf["bmon"], $inf["btag"]);
+        $edat = date_obj($inf["ejahr"], $inf["emon"], $inf["etag"]);
+        
+        $sql = "DELETE FROM Info WHERE info_ID = $infid";
+        $retid = $dbc -> execute($sql);
+        if ($retid)
+        {
+            include ("inc/file_upload.inc.php");
+            $retdf  = mod_file("/var/www/fhiiqm/infos",$infid,"","del");  // Loeschen Dokument
+            if ($retdf) echo "<p class='green'><b>Infodokument zu ID '$infid' wurde gel&ouml;scht.</b></p>\n";
+            echo "<p class='green'><b>Infodaten zu ID '$infid' wurden gel&ouml;scht.</b></p>\n";
+            echo "<br /><br />\n";
+
+            // Anzeigen geloeschter Vertragsdaten
+            if ($fname)
+                $ifile = $infid . "_" . $fname;
+            else
+                $ifile = $inf['ifname'];
+            include ("inc/info_dat_show.inc.php");
+        }
+         
+    }
+    if ($ok && ($upd || $del))
+    {
+        echo "</div><br /><br />\n";
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"info_flist.php\" target=\"_self\" title=\"Infoliste\">Zur&uuml;ck zur Infoliste</a></p>\n";    
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"info_ins.php\" target=\"_self\" title=\"Info erfassen\">Weitere Info erfassen</a></p>\n";    
+    }
+
+?>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/deprecated/vertrag_flist2.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,195 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 7/2011
+ * 
+ * Liste Vertragsdaten mit Sortierung
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    session_start();
+    if (! isset($_SESSION["userid"]))
+    { 
+        include_once ("inc/func_lib.inc.php");	
+        login("vertrag_flist2.php");
+        exit;
+    }
+    
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("vr",$_SESSION["recht"]) && !in_array("ve",$_SESSION["recht"])))
+    {
+        header("Location: start.php");
+        exit;
+    }    
+    
+?>
+    
+<!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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen "/> 
+   	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print" /> 
+
+	<title>Liste Vertragsdaten, Teil 2</title>
+</head>
+
+<body>
+
+<?php
+    echo "&nbsp;";  
+    echo "<div class=\"float-br smaller\" valign='top'>";
+    echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+    echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+    echo "<div class=\"float-r\">&nbsp;&nbsp;&nbsp;<img src=\"img/document_mark_as_final.png\" border=\"0\" alt=\"Vertr&auml;ge\" title=\"Vertr&auml;ge\"/></div>\n";
+
+    $zeil = $_GET["z"];
+    if (!$zeil) $zeil = 25; // Anzahl der gezeigten Zeilen
+    $start = $_GET["st"];   // Start bei DS $start+1
+    if (!$start) $start=0;
+    
+    // Felder, nach denen gefiltert werden kann
+    $fields = array(2=>"Bezeichnung",4=>"Bearbeiter",6=>"Vertragstyp",7=>"Produkt",8=>"Partner");
+
+	$sort   = $_GET["s"];
+    $dir    = $_GET["d"];
+    if (!isset($sort) && !$sort) $sort = 2;
+    if (!isset($dir) && !$dir)  $dir = "";
+
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $filter = $_GET["b"];
+    if (!isset($fnum) && !$fnum) $fnum = 0;
+    
+    // Recht Produktgruppe beruecksichtigen
+    if (is_array($_SESSION["prodg"]))
+    {
+            foreach ($_SESSION["prodg"] as $val)
+                $listg .= "," .$val;
+            $listg = substr($listg,1);
+    }
+    else $listg = "";
+
+    include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+    include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+	$dbc = new dbconnection();
+
+    $sql = "CALL fhiiqm.vertrag_flist2(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "', '" . $listg . "',$start,$zeil, @anz, @ganz)";
+    // Parameter: Nr. Sortfelf, Sortierrichtung, Nr. Filterfeld, Filterbegriff, Start bei DS $start+1, Anzahl DS/Seite, Anzahl gefundener Vertraege, Anzahl DS gesamt
+    // liefert Felder: contract_ID,cname,clong,bearb,doc,typ,prod,cbegin,cend,kmon,partfirmar,kyear,kosten,bem
+    $result = $dbc -> queryObjectArray($sql);
+    if ($result)
+    {
+		$bg1 = "#F8F8F8";
+		$bg2 = "#DEDFE1";
+		$bg = "#FFFFFF";
+        
+        $heute = new DateTime();
+        
+        $vanz = $dbc -> querySingleItem("SELECT @anz");
+        $ganz = $dbc -> querySingleItem("SELECT @ganz");
+        
+        echo "<div align='center'>\n";
+        echo "<p><b>Vertr&auml;ge Teil 2</b></p>\n";
+        echo "<table border='0' cellspacing='0'>\n";
+        echo "<tr><td class='bigger'>Mittels '<img src='img/auf.gif' border='0' width='9' hight='9'>' / '<img src='img/ab.gif' border='0' width='9' hight='9'>' 
+            können Sie Spalten auf- bzw. absteigend sortieren</td></tr>
+            <tr><td class='bigger'>Klick auf '<img src='img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten der Vertragsdaten</td></tr>\n";
+        echo "</table>\n";
+        printf ("<p>Anzahl Vertr&auml;ge: %s </p>", $vanz);
+        echo "<table width='99%'>\n";
+
+        if ($filter>'!') echo "<tr><td class='bigger' colspan=7>Filter: ". $fields["$fnum"] . " wie '$filter'</td><tr>\n";
+
+        echo "<tr bgcolor='#68ACBF'>";
+        tab_column(2,"Bezeichnung",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        tab_column(8,"Beginn",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        tab_column(9,"Ende",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        tab_column(10,"Verl&auml;ng.",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        tab_column(11,"K&uuml;nd.frist (mon)",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+//        tab_column(12,"Partner",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        echo "<th>Kosten/Jahr(&euro;)</th>";
+        echo "<th>Bemerkung</th>";
+        echo "<th>E-Mail</th>";
+
+        echo "<th>&nbsp;</th></tr>\n";
+        $cid=0;
+        foreach ($result as $row)
+        {
+            if ($row->contract_ID != $cid && $cid != 0)
+            {   // nicht beim 1. Datensatz
+                echo "</td>";
+                echo "<td width='27%'>$bem</td>";    
+                echo "<td>$mail</td>";
+                echo "<td><a href='vertrag_upd.php?uid=$cid'><img src=\"img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+            }
+            if ($row->contract_ID != $cid)
+            {   // Anzeigen der nur einmal relevanten Daten
+    			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                if ($row->cend)
+                {
+                    $ce = new DateTime($row->cend);
+                    if ((!$row->cautoend || is_null($row->cautoend)) && $heute > $ce) $class="class='red'"; else $class="";
+                }
+                else $class="";
+                echo "<tr bgcolor='" . $bg . "'><td $class><b>$row->cname</b></td>";    
+    //            echo "<td>$row->contract_s</td>";    
+                if ($row->cbegin)
+                {
+                    $cb = new DateTime($row->cbegin);    
+                    echo "<td>" . $cb->format('d.m.Y')."</td>";
+                }
+                else  echo "<td>&nbsp;</td>";       
+                if ($row->cend)
+                    echo "<td>" . $ce->format('d.m.Y')."</td>";    
+                else  echo "<td>&nbsp;</td>";       
+                if ($row->cautoend) echo "<td>automatisch</td>"; else echo "<td>&nbsp;</td>"; 
+                echo "<td class='center'>$row->kmon</td>";    
+//                echo "<td>$row->partfirma</td>";
+                echo "<td>"; 
+                $bem = nl2br($row->bem);
+                if ($row->email) $mail= "ja"; else $mail= "&nbsp;";   
+            }
+            // Anzeigen Kosten pro Jahr -> 1 Zeile des Resultsets (Kosten fast rechtsbuendig!))
+            if ($row->kosten)
+            { 
+                if ($row->contract_ID == $cid) echo "<br />";
+                echo "$row->kyear:&nbsp;&nbsp;&nbsp;" . str_replace(" ","&nbsp;",sprintf("%' 10s",number_format($row->kosten,2,",","."))) . "";
+            }    
+            $cid = $row->contract_ID;    
+       }
+        echo "</td>";
+        echo "<td>$bem</td>";    
+        echo "<td>$mail</td>";
+        echo "<td><a href='vertrag_upd.php?uid=$cid'><img src=\"img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+        echo "</table></div>\n";
+        echo "<br />&nbsp;&nbsp;&nbsp;";
+        
+        // Sortierung und Filter aus $_GET fuer weitere Seiten
+        foreach ($_GET as $key=>$val)
+        {
+            if ($key != "st") $liste .= "&" . $key ."=".$val;
+        }    
+        // Sortierung und Filter aus $_POST fuer weitere Seiten
+        if ($subf)
+        foreach ($_POST as $key=>$val)
+        {
+            if ($key != "st" && $key != "subf" && $key != "filter") $liste .= "&" . $key ."=".$val;
+            if ($key == "filter") $liste .= "&b=" . $val;
+        }    
+        
+        // Links auf andere Seiten generieren
+        liste_links($start,$zeil,$ganz,$liste);
+    }
+    else
+    {
+        print_r ($dbc -> error);
+    }
+    $dbc -> close();
+    if (!is_null($_SESSION["recht"]) && in_array("ve",$_SESSION["recht"]))
+        echo "<p>&nbsp;&nbsp;&nbsp;<a href=\"vertrag_ins.php\" class=\"sc\" target=\"_self\" title=\"Vertrag erfassen\">Weiteren Vertrag erfassen</a></p>\n";    
+
+?>
+</body>
+</html>
\ No newline at end of file
--- a/fhiiqm/form/ma_ed_form.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/form/ma_ed_form.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -19,9 +19,17 @@
 <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_ma">
 <div align="center"> 
 <table width="60%" border="0" cellspacing="3" cellpadding="3">
+    <tr>
+        <td>
+            <u>Mitarbeiter</u> FHI?
+        </td>
+        <td><input name="ma[fhi]" type="checkbox" value="1" <?php if ($ma['fhi']) echo "checked=\"checked\""; ?> onchange="this.form.submit();" />
+        </td>    
+    </tr>        
 	<tr>
-	   <td>Name *</td>
-	   <td><input name="ma[name]" type="text" size="30" maxlength="30" value="<?php echo $ma['name']; ?>" />
+        <?php if (!$ma["fhi"]) echo "<td>Bezeichnung 1 *</td>\n";
+	           else echo "<td>Name *</td>\n"; ?>
+	   <td><input name="ma[name]" type="text" size="30" maxlength="50" value="<?php echo $ma['name']; ?>" />
         <?php
 			     if (isset($ma['name']) && $ma['name']<'!')
 				{
@@ -32,8 +40,9 @@
         </td>
     </tr>
 	<tr>
-	   <td>Vorname</td>
-	   <td><input name="ma[vname]" type="text" size="30" maxlength="30" value="<?php echo $ma['vname']; ?>" />
+        <?php if (!$ma["fhi"]) echo "<td>Bezeichnung 2 </td>\n";
+	           else echo "<td>Vorname </td>\n"; ?>
+	   <td><input name="ma[vname]" type="text" size="30" maxlength="50" value="<?php echo $ma['vname']; ?>" />
         <?php
 		/*	     if (isset($ma['vname']) && $ma['vname']<'!')
 				{
@@ -43,10 +52,12 @@
         ?>
         </td>
     </tr>
+    <?php if ($ma["fhi"]) {   ?>   
 	<tr>
 	   <td>Titel</td>
 	   <td><input name="ma[titel]" type="text" size="30" maxlength="30" value="<?php echo $ma['titel']; ?>" /></td>
     </tr>
+    <?php } ?>
     <tr><td>Ort</td>
         <td valign="top">Haus&nbsp;
              <select name="ma[geb]" onchange="this.form.submit();">
@@ -87,6 +98,30 @@
         </td>
     </tr>
     <tr>
+        <td>Arbeitsgruppe</td>
+        <td><select name="ma[rag]">
+            <?php 
+                if ($ma['rag'] == -1) $select = " selected "; else $select = "";
+                echo "<option $select value=\"-1\"></option>\n";
+                $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
+                        ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,rag_ID";
+                if ($result = $dbc->queryObjectArray($sql))
+                {
+                    foreach ($result as $row)
+                    {
+                        if ($row->rag_ID == $ma['rag'])
+                        {
+    					   echo "<option selected value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
+                        }  
+    				    else
+    					   echo "<option value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
+                    }
+            }
+            ?>
+            </select>
+        </td>
+    </tr>
+    <tr>
         <td>Telefon</td>
         <td><div id="addtel">
         <select name="ma[tel][]" size="1">
@@ -156,10 +191,12 @@
         </div>
         </td>   
     </tr>
+    <?php if ($ma["fhi"]) {   ?>   
 	<tr>
 	   <td>E-Mail</td>
 	   <td><input name="ma[email]" type="text" size="30" maxlength="100" value="<?php echo $ma['email']; ?>" /></td>
     </tr>
+    <?php } ?>
     <tr><td>Abteilung *</td>
         <td valign="top">
              <select name="ma[abt]">
@@ -177,7 +214,6 @@
             }
             ?>
             </select>
-            &nbsp;&nbsp;&nbsp;Mitarbeiter FHI?&nbsp;&nbsp;&nbsp;<input name="ma[fhi]" type="checkbox" value="1" <?php if ($ma['fhi']) echo "checked"; ?> />
             <input type="hidden" name="okn" value="<?php echo $okn; ?>" />
         </td>   
     </tr>
--- a/fhiiqm/form/produkt_form.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/form/produkt_form.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -85,18 +85,18 @@
             <?php 
                 if ($prod['ag'] == -1) $select = " selected "; else $select = "";
                 echo "<option $select value=\"-1\"></option>\n";
-                $sql = "SELECT ag_ID, ag_name, abt_name FROM Arbeitsgruppe g INNER JOIN Abteilung a 
-                        ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,ag_ID";
+                $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
+                        ON g.abt_ID = a.abt_ID ORDER BY g.abt_ID,rag_ID";
                 if ($result = $dbc->queryObjectArray($sql))
                 {
                     foreach ($result as $row)
                     {
-                        if ($row->ag_ID == $prod['ag'])
+                        if ($row->rag_ID == $prod['ag'])
                         {
-    					   echo "<option selected value=\"$row->ag_ID\">$row->abt_name: $row->ag_name</option>\n";
+    					   echo "<option selected value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
                         }  
     				    else
-    					   echo "<option value=\"$row->ag_ID\">$row->abt_name: $row->ag_name</option>\n";
+    					   echo "<option value=\"$row->rag_ID\">$row->abt_name: $row->rag_bez</option>\n";
                     }
             }
             ?>
--- a/fhiiqm/form/raumarbgr_form.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/form/raumarbgr_form.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -108,7 +108,7 @@
                 $select = ( "-1"==$rag['ma'][0] ) ? ' selected' : null;
                 echo "<option $select value=\"-1\"></option>\n";
                 $sql = "SELECT persknr, CONCAT (nachname, ', ',vorname, ', ' , IFNULL(abt_name,''),' (',CASE aktiv WHEN 1 THEN 'aktiv' ELSE 'inaktiv' END, ')') AS ma
-                 FROM fhiiqm.Mitarbeiter m LEFT OUTER JOIN fhiiqm.Abteilung a ON m.abt_tel=a.abt_ID ORDER BY 2";
+                 FROM fhiiqm.Mitarbeiter m LEFT OUTER JOIN fhiiqm.Abteilung a ON m.abt_tel=a.abt_ID WHERE aktiv < 2 ORDER BY 2";
                 if ($result = $dbc->queryObjectArray($sql))
                 {
                     foreach ($result as $row)
Binary file fhiiqm/img/fhilogotransp.gif has changed
Binary file fhiiqm/img/fhilogotransp.png has changed
Binary file fhiiqm/img/user.png has changed
--- a/fhiiqm/inc/ma_tel_dat_show.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/inc/ma_tel_dat_show.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -20,6 +20,14 @@
             }
             else
                 echo "<tr><td>Abteilung: </td><td>&nbst;</td></tr>\n";
+            // Arbeitsgruppe
+            if ($ma['rag'])
+            {
+                $sql = "SELECT rag_bez FROM RaumArb_Gruppe
+                            WHERE rag_ID = '" . $ma["rag"] ."' ";
+                if ($ragb = $dbc->querySingleItem($sql))
+                    echo "<tr><td>AG: </td><td>" . $ragb . "</td></tr>\n";
+            }
             $i=0;
             foreach ($ma['tel'] as $tel)
             {
--- a/fhiiqm/inc/menu.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/inc/menu.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -162,13 +162,8 @@
                 echo "   </ul>\n
                     </li>\n";
           }      
-                    
-          echo "<li>Stammdaten\n
+          echo "<li>R&auml;ume\n
             	   <ul>\n";
-          if (in_array("pr",$_SESSION["recht"]) || in_array("pe",$_SESSION["recht"]))
-            		echo "<li><a href=\"/fhiiqm/prod_hier.php\" target=\"_blank\" title=\"Produkthierarchie\">Produkthierarchie</a></li>\n";
-          if (in_array("pe",$_SESSION["recht"]))
-            		echo "<li><a href=\"/fhiiqm/produkt_ins.php\" target=\"_blank\" title=\"Produkt erfassen\">Produkt erfassen</a></li>\n";
           if (in_array("rr",$_SESSION["recht"]) || in_array("re",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/raum_flist.php\" target=\"_blank\" title=\"Raumliste\">R&auml;ume sortieren, filtern, bearbeiten</a></li>\n";
           if (in_array("re",$_SESSION["recht"]))
@@ -178,6 +173,17 @@
                 }
           if (in_array("ddr",$_SESSION["recht"]) || in_array("dde",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/raum_vma_flist.php\" target=\"_blank\" title=\"Raumliste\">Raumverantwortliche sortieren, filtern, bearbeiten</a></li>\n";
+          if (in_array("rr",$_SESSION["recht"]) || in_array("re",$_SESSION["recht"]))
+                    echo "<li><a href=\"/fhiiqm/raum_report.php\" target=\"_blank\" title=\"Report R&auml;ume\">Berichte R&auml;ume</a></li>\n";
+    	  echo "   </ul>\n
+                </li>\n";
+                    
+          echo "<li>Stammdaten\n
+            	   <ul>\n";
+          if (in_array("pr",$_SESSION["recht"]) || in_array("pe",$_SESSION["recht"]))
+            		echo "<li><a href=\"/fhiiqm/prod_hier.php\" target=\"_blank\" title=\"Produkthierarchie\">Produkthierarchie</a></li>\n";
+          if (in_array("pe",$_SESSION["recht"]))
+            		echo "<li><a href=\"/fhiiqm/produkt_ins.php\" target=\"_blank\" title=\"Produkt erfassen\">Produkt erfassen</a></li>\n";
           if (in_array("rtr",$_SESSION["recht"]) || in_array("rte",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/recht_list.php\" target=\"_blank\" title=\"Nutzerliste\">Nutzer - Rechte bearbeiten</a></li>\n";
           if (in_array("rte",$_SESSION["recht"]))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/inc/pdf_ma_tel.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,277 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * Klasse PDF zur Telefonliste
+ */
+
+    include ($_SERVER['DOCUMENT_ROOT']."/fhiiqm/tool/fpdf.php");
+    class PDF extends FPDF
+    {
+        //Author Patrick Benny: Fit text to cell 
+        //*********************************************************************
+        //Cell with horizontal scaling if text is too wide
+        function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true)
+        {
+            //Get string width
+            $str_width=$this->GetStringWidth($txt);
+            // Division by 0 avoid, 21.11.2012, bs
+            if ($str_width == 0) $str_width = 0.1;
+    
+            //Calculate ratio to fit cell
+            if($w==0)
+                $w = $this->w-$this->rMargin-$this->x;
+            $ratio = ($w-$this->cMargin*2)/$str_width;
+    
+            $fit = ($ratio < 1 || ($ratio > 1 && $force));
+            if ($fit)
+            {
+                if ($scale)
+                {
+                    //Calculate horizontal scaling
+                    $horiz_scale=$ratio*100.0;
+                    //Set horizontal scaling
+                    $this->_out(sprintf('BT %.2F Tz ET',$horiz_scale));
+                }
+                else
+                {
+                    //Calculate character spacing in points
+                    $char_space=($w-$this->cMargin*2-$str_width)/max($this->MBGetStringLength($txt)-1,1)*$this->k;
+                    //Set character spacing
+                    $this->_out(sprintf('BT %.2F Tc ET',$char_space));
+                }
+                //Override user alignment (since text will fill up cell)
+                $align='';
+            }
+    
+            //Pass on to Cell method
+            $this->Cell($w,$h,$txt,$border,$ln,$align,$fill,$link);
+    
+            //Reset character spacing/horizontal scaling
+            if ($fit)
+                $this->_out('BT '.($scale ? '100 Tz' : '0 Tc').' ET');
+        }
+    
+        //Cell with horizontal scaling only if necessary
+        function CellFitScale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,false);
+        }
+    
+        //Cell with horizontal scaling always
+        function CellFitScaleForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,true);
+        }
+    
+        //Cell with character spacing only if necessary
+        function CellFitSpace($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,false);
+        }
+    
+        //Cell with character spacing always
+        function CellFitSpaceForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            //Same as calling CellFit directly
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,true);
+        }
+    
+        //Patch to also work with CJK double-byte text
+        function MBGetStringLength($s)
+        {
+            if($this->CurrentFont['type']=='Type0')
+            {
+                $len = 0;
+                $nbbytes = strlen($s);
+                for ($i = 0; $i < $nbbytes; $i++)
+                {
+                    if (ord($s[$i])<128)
+                        $len++;
+                    else
+                    {
+                        $len++;
+                        $i++;
+                    }
+                }
+                return $len;
+            }
+            else
+                return strlen($s);
+        }
+        //*********************************************************************
+        
+        //Kopfzeile
+        function Header()
+        {
+            global $header;
+            //$this->Cell(20);
+            //Titel
+            //Arial fett 15
+            $this->SetFont('Arial','BI',11);
+            $this->Cell(55,10,'Fritz-Haber-Institut',0,0,'L');
+            $this->SetFont('Arial','B',11);
+            $this->Cell(40,10,'Telefonverzeichnis',0,0,'L');
+            $this->SetTextColor(255,0,0);
+            $this->Cell(0,10,'(intern)',0,0,'L');
+            //Logo
+            $this->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/fhilogotransp.png",170,8,25);
+            //Zeilenumbruch
+            $this->Ln(20);
+            //Colors, line width and bold font
+            $this->SetFont('helvetica','',8);
+            $this->SetFillColor(104,172,191);
+            $this->SetTextColor(0,0,102);
+            $this->SetDrawColor(255,255,255);
+            $this->SetLineWidth(.0);
+            $this->SetFont('','B');
+            //Tabellen-Header immer im Kopf
+            $w=array(55,40,30,15,40);
+            for($i=0;$i<count($header);$i++)
+                $this->Cell($w[$i],5,$header[$i],1,0,'L',1);
+            $this->Ln();
+        }
+        
+        //Fusszeile
+        function Footer()
+        {
+            //Position 1,5 cm von unten
+            $this->SetY(-15);
+            //Arial kursiv 8
+            $this->SetFont('Arial','I',8);
+            //Datum der Liste
+            $heute = new DateTime();
+            $this->Cell(0,10,$heute->format('d.m.Y H:i:s'),0,0,'L');
+            //Seitenzahl
+            $this->Cell(0,10,'Seite '.$this->PageNo().'/{nb}',0,0,'R');
+        }
+        //Colored table
+        function FancyTable($header,$data)
+        {
+
+            //Colors, line width and bold font
+            $this->SetFillColor(104,172,191);
+            $this->SetTextColor(0,0,102);
+            $this->SetDrawColor(255,255,255);
+            $this->SetLineWidth(.0);
+            $this->SetFont('','B');
+
+            //Header notwendig fuer Tabelle, Hoehe = 0!
+            $w=array(55,40,30,15,40); // Breite der Zellen
+            for($i=0;$i<count($header);$i++)
+                $this->Cell($w[$i],0,'',1,0,'L',1);
+            $this->Ln();
+            //Color and font restoration
+//            $this->SetFillColor(222,222,222);
+            $this->SetFillColor(238,238,238);
+            $this->SetTextColor(0);
+            $this->SetFont('');
+            //Data
+            $fill=0;
+            $fill = !$fill;
+            foreach($data as $row)
+            {
+    			if ($row->persknr != $vpnr)
+                {
+                    $fill=!$fill;
+                    if (substr($row->name,0,1) != $vfirst) $this->Ln(5); //$this->AddPage();
+                    $titel = ($row->titel)? ", $row->titel" : "" ;
+                    $vname = ($row->vorname)? ", $row->vorname" : "";
+                    $name = $row->name . $titel . $vname;
+                    $this->CellFitScale($w[0],4.5,$name,0,0,'L',$fill);
+                    $this->CellFitScale($w[1],4.5,$row->abt_name,'LR',0,'L',$fill);
+                    if ($row->telefon_typ == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row->public) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row->telefon_nr.$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row->geb_ID . " " . $row->raum_nr,'LR',0,'L',$fill);
+                    $this->CellFitScale($w[4],4.5,$row->email,'LR',0,'L',$fill);
+                    $this->Ln();
+                }
+                else
+                {
+                    $this->Cell($w[0],4.5,'','LR',0,'L',$fill);
+                    if ($vabt != $row->abt_name) $abt = $row->abt_name;
+                    else $abt = '';    
+                    $this->CellFitScale($w[1],4.5,$abt,'LR',0,'L',$fill);
+                    if ($row->telefon_typ == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row->public) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row->telefon_nr.$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row->geb_ID . " " . $row->raum_nr,'LR',0,'L',$fill);
+                    $this->Cell($w[4],4.5,'','LR',0,'L',$fill);
+                    $this->Ln();
+                    
+                }
+                $vpnr = $row->persknr;
+                $vabt = $row->abt_name;
+                $vfirst = substr($row->name,0,1);
+            }
+        }
+        function FancyTableOldMySQL($header,$data)
+        {
+
+            //Colors, line width and bold font
+            $this->SetFillColor(104,172,191);
+            $this->SetTextColor(0,0,102);
+            $this->SetDrawColor(255,255,255);
+            $this->SetLineWidth(.0);
+            $this->SetFont('','B');
+
+            //Header notwendig fuer Tabelle, Hoehe = 0!
+            $w=array(55,40,30,15,40);
+            for($i=0;$i<count($header);$i++)
+                $this->Cell($w[$i],0,'',1,0,'L',1);
+            $this->Ln();
+            //Color and font restoration
+//            $this->SetFillColor(222,222,222);
+            $this->SetFillColor(238,238,238);
+            $this->SetTextColor(0);
+            $this->SetFont('');
+            //Data
+            $fill=0;
+            $fill = !$fill;
+            while ($row = mysql_fetch_assoc($data)) 
+            {
+    			if ($row["persknr"] != $vpnr)
+                {
+                    $fill=!$fill;
+                    $titel = ($row["titel"])? ", ".$row["titel"]  : "" ;
+                    $vname = ($row["vorname"])? ",". $row["vorname"] : "";
+                    $name = $row["name"] . $titel . $vname;
+                    $this->CellFitScale($w[0],4.5,$name,0,0,'L',$fill);
+                    $this->CellFitScale($w[1],4.5,$row["abt_name"],'LR',0,'L',$fill);
+                    if ($row["telefon_typ"] == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row["public"]) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row["telefon_nr"].$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row["geb_ID"] . " " . $row["raum_nr"],'LR',0,'L',$fill);
+                    $this->CellFitScale($w[4],4.5,$row["email"],'LR',0,'L',$fill);
+                    $this->Ln();
+                }
+                else
+                {
+                    $newline = 0;
+                    $this->Cell($w[0],4.5,'','LR',0,'L',$fill);
+                    if ($vabt != $row["abt_name"]) $abt = $row["abt_name"];
+                    else $abt = '';    
+                    $this->CellFitScale($w[1],4.5,$abt,'LR',0,'L',$fill);
+                    if ($row["telefon_typ"] == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row["public"]) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row["telefon_nr"].$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row["geb_ID"] . " " . $row["raum_nr"],'LR',0,'L',$fill);
+                    $this->Cell($w[4],4.5,'','LR',0,'L',$fill);
+                    $this->Ln();
+                    
+                }
+                $vpnr = $row["persknr"];
+                $vabt = $row["abt_name"];
+            }
+        }
+    }
+
+
+?>
\ No newline at end of file
--- a/fhiiqm/inc/produkt_dat_show.inc.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/inc/produkt_dat_show.inc.php	Fri Dec 21 15:31:50 2012 +0100
@@ -22,13 +22,13 @@
             }
             echo "<tr><td>Produkt-Hierarchie: </td><td>" . $phier . "<td></td></tr>\n";
             // Arbeitsgruppe
-            $sql = "SELECT ag_ID, ag_name, abt_name FROM Arbeitsgruppe g INNER JOIN Abteilung a 
+            $sql = "SELECT rag_ID, rag_bez, abt_name FROM RaumArb_Gruppe g INNER JOIN Abteilung a 
                         ON g.abt_ID = a.abt_ID
-                        WHERE ag_ID = '" . $prod["ag"] ."' ";
+                        WHERE rag_ID = '" . $prod["ag"] ."' ";
             if ($result = $dbc->queryObjectArray($sql))
             {
                 foreach ($result as $row)
-                echo "<tr><td>zugeordnet zu AG: </td><td>" . $row->ag_name . "</td></tr>\n";
+                echo "<tr><td>zugeordnet zu AG: </td><td>" . $row->rag_bez . "</td></tr>\n";
             }
             // Wichtigkeit
             $sql = "SELECT imp_ID, imp_name_s FROM Wichtigkeit WHERE imp_ID = " . $prod["imp"];
--- a/fhiiqm/info_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/info_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -71,6 +71,13 @@
                 <br />&nbsp;&nbsp;&nbsp;Ansicht: Kennzeichen, Infotitel, Zuordnung zu Info, Kurzinfo, Produkt, Infotyp, (Adressat,) (Ort,) Status
             </td>
         </tr>
+        <tr>
+            <td class="bigger">
+                <a href="/fhiiqm/report/ma_relation_report.php" title="MA - Bez&uuml;ge">Mitarbeiter - Beziehungen</a>
+                <br />&nbsp;&nbsp;&nbsp;Auswahl: Status, Mitarbeiter, Abteilung(, Datum ab)
+                <br />&nbsp;&nbsp;&nbsp;Mitarbeiter und ihre Zuordnungen
+            </td>
+        </tr>
     </table>
     </div>    
 
--- a/fhiiqm/laser_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/laser_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -71,10 +71,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
     
--- a/fhiiqm/laser_log_flist_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/laser_log_flist_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -106,10 +106,10 @@
 
     $subf   = $_POST["subf"]; // submit Filter
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
 
     echo "&nbsp;";  
--- a/fhiiqm/ma_fkt_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/ma_fkt_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -30,12 +30,23 @@
     if (!$fkt["pid"]) $fkt["pid"] = $_GET["p"];
 //    if (!$fkt["fid"]) $fkt["fid"] = $_GET["f"];
     $mfid = $_GET[i];
+
+    $zeil = $_GET["z"];
+    if (!$zeil) $zeil = 25; // Anzahl der gezeigten Zeilen
+    $start = $_GET["st"];   // Start bei DS $start+1
+    if (!$start) $start=0;
+	$sort   = $_GET["s"];   // Sortierung nach Spalte
+    $dir    = $_GET["d"];   // Sortierrichtung
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $filter = $_GET["b"];   // Filterbegriff
+    // $_GET-Parameter zurück zur Funktionenliste mit den selben Einstellungen wie zuvor
+    $getp = "s=$sort&d=$dir&f=$fnum&b=$filter&st=$start&z=$zeil";
 	$ok		= $_POST["ok"];
     $sub    = $_POST["eintragen"];
     $del    = $_POST["del"];
 
     $dup    = $_POST["dup"];
-    if (!$dup) $dup = $_GET["d"];
+    if (!$dup) $dup = $_GET["dp"];
     $copy   = $_GET["c"];
 
     if ($dup)
@@ -237,7 +248,7 @@
                 }
             }
         echo "</div>\n";    
-        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ma_fkt_flist.php\" target=\"_self\" title=\"Funktionen\">Zur Funktionenliste</a></p>\n";    
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ma_fkt_flist.php?$getp\" target=\"_self\" title=\"Funktionen\">Zur Funktionenliste</a></p>\n";    
         echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ma_fkt_ed.php\" target=\"_self\" title=\"Funktion erfassen\">Weitere Funktion erfassen</a></p>\n";    
         }   
     ?>
--- a/fhiiqm/ma_fkt_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/ma_fkt_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
@@ -166,8 +166,10 @@
             }
             else  echo "<td>&nbsp;</td>";       
             echo "<td>$row->fkt_bem</td>";
-            echo "<td><a href='/fhiiqm/ma_fkt_ed.php?i=$row->mf_ID&p=$row->persknr&f=$row->fkt_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
-            echo "<td><a href='/fhiiqm/ma_fkt_ed.php?i=$row->mf_ID&d=1'><img src=\"/fhiiqm/img/duplicate.gif\" alt='duplizieren' title='duplizieren' border='0'/></a></td></tr>\n";
+            $getp = "&s=$sort&d=$dir&f=$fnum&b=$filter&st=$start&z=$zeil";
+//            echo "<td><a href='/fhiiqm/ma_fkt_ed.php?i=$row->mf_ID&p=$row->persknr&f=$row->fkt_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
+            echo "<td><a href='/fhiiqm/ma_fkt_ed.php?i=$row->mf_ID&p=$row->persknr$getp'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
+            echo "<td><a href='/fhiiqm/ma_fkt_ed.php?i=$row->mf_ID&dp=1$getp'><img src=\"/fhiiqm/img/duplicate.gif\" alt='duplizieren' title='duplizieren' border='0'/></a></td></tr>\n";
         }
         echo "</table></div>\n";
 
--- a/fhiiqm/ma_tel_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/ma_tel_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -19,7 +19,7 @@
         exit;
     }
     
-    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("fmr",$_SESSION["recht"]) && !in_array("fme",$_SESSION["recht"])))
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("mtr",$_SESSION["recht"]) && !in_array("mte",$_SESSION["recht"])))
     {
         header("Location: start.php");
         exit;
@@ -52,7 +52,7 @@
 	<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>Mitarbeiter bearbeiten</title>
+	<title>MA/O bearbeiten</title>
 
     <script type="text/javascript">
     <!--
@@ -104,24 +104,25 @@
 
     if ($pid) $text = "editieren"; else $text = "erfassen";
     echo "<div align=\"center\">";
-    echo "<h3>Mitarbeiter $text</h3>";
+    echo "<h3>Mitarbeiter/Objekte $text</h3>";
     echo "</div>\n";
     if ((!$sub && !$del) || !isset($ma) || !$ok) 
     {
         
         if ($pid && (!$sub || !$del) && !isset($ma))
         {
-            $sql = "SELECT nachname,vorname,titel,abt_tel,email,aktiv FROM Mitarbeiter WHERE persknr=$pid";
+            $sql = "SELECT nachname,vorname,titel,rag_ID,abt_tel,email,aktiv FROM Mitarbeiter WHERE persknr=$pid";
             if ($result = $dbc -> queryObjectArray($sql))
             {
                 foreach ($result as $row)
                 {
-                    $ma['name'] = $row->nachname;
-                    $ma['vname'] = $row->vorname;
-                    $ma['titel'] = $row->titel;
-                    $ma['abt'] = $row->abt_tel;
-                    $ma['email'] = $row->email;
-                    $ma['fhi'] = ($row->aktiv == 1)? 1 : 0;
+                    $ma['name']     = $row->nachname;
+                    $ma['vname']    = $row->vorname;
+                    $ma['titel']    = $row->titel;
+                    $ma['rag']      = $row->rag_ID;
+                    $ma['abt']      = $row->abt_tel;
+                    $ma['email']    = $row->email;
+                    $ma['fhi']      = ($row->aktiv == 1)? 1 : 0;
                 }    
             }
             // Haus,Raum
@@ -162,7 +163,7 @@
 			        if ($ok)  echo "checked=\"checked\""; 
 			echo " /></td>\n</tr>\n";
         }
-        if (!is_null($_SESSION["recht"]) && in_array("fme",$_SESSION["recht"]))
+        if (!is_null($_SESSION["recht"]) && in_array("mte",$_SESSION["recht"]))
         {
             echo "
            	<tr><td>&nbsp;</td>\n
@@ -184,13 +185,22 @@
         echo "<div align='center'>\n";
         
         if ($del)
-        {   // nur aktiv auf 0 setzen
-            $sql = "UPDATE Mitarbeiter SET aktiv=0 WHERE persknr = $pid";
-            $retdi = $dbc -> execute($sql);
-            $sql = "DELETE FROM Mitarbeiter_Raum WHERE persknr = $pid";
-            $retdi = $dbc -> execute($sql);
-            $sql = "DELETE FROM MA_Telefon WHERE persknr = $pid";
-            $retdi = $dbc -> execute($sql);
+        {   
+            if ($ma["fhi"])
+            {
+                // nur aktiv auf 0 setzen
+                $sql = "UPDATE Mitarbeiter SET aktiv=0 WHERE persknr = $pid";
+                $retdi = $dbc -> execute($sql);
+                $sql = "DELETE FROM Mitarbeiter_Raum WHERE persknr = $pid";
+                $retdi = $dbc -> execute($sql);
+                $sql = "DELETE FROM MA_Telefon WHERE persknr = $pid";
+                $retdi = $dbc -> execute($sql);
+            }
+            else
+            {
+                $sql = "DELETE FROM Mitarbeiter WHERE persknr = $pid";
+                $retdi = $dbc -> execute($sql);
+            }
             if ($retdi)
             {
                 echo "<p class='green'><b>DELETE: Daten  zu '".$ma["name"]. ", ". $ma['vname'] ."' wurden erfolgreich gel&ouml;scht.</b></p>\n";
@@ -205,6 +215,7 @@
         }
         else //INSERT oder UPDATE
         {
+            if ($ma['rag'] == -1) $ma['rag'] = null;
             $stmt = $dbc -> stmtinit();
             if (is_object($stmt))
             {
@@ -215,11 +226,12 @@
                                         nachname = ?,
                                         vorname = ?,
                                         titel = ?,
+                                        rag_ID = ?,
                                         email = ?,
                                         abt_tel = ?,
                                         aktiv = ?
                                         WHERE persknr = $pid");
-                    $stmt -> bind_param('ssssii',$ma['name'],$ma['vname'],$ma['titel'],$ma['email'],$ma['abt'], $aktiv);
+                    $stmt -> bind_param('sssisii',$ma['name'],$ma['vname'],$ma['titel'],$ma['rag'],$ma['email'],$ma['abt'], $aktiv);
 //                    echo "UPDATE: ". var_dump($stmt);
                     $result = $stmt -> execute();
                     if ($stmt->error) echo "error UPDATE Mitarbeiter: " . $stmt->error . "<br><br>\n";
@@ -228,8 +240,8 @@
                 {
                     $sql = "SELECT MAX(persknr) FROM Mitarbeiter WHERE persknr < 9500";
                     $pid = $dbc -> querySingleItem($sql) + 1;
-                    $stmt -> prepare ("INSERT INTO Mitarbeiter (persknr, nachname, vorname, titel,email,abt_tel,aktiv) VALUES (?,?,?,?,?,?,?)"); 
-                    $stmt -> bind_param('issssii',$pid,$ma['name'],$ma['vname'],$ma['titel'],$ma['email'],$ma['abt'], $aktiv);
+                    $stmt -> prepare ("INSERT INTO Mitarbeiter (persknr, nachname, vorname, titel,rag_ID,email,abt_tel,aktiv) VALUES (?,?,?,?,?,?,?,?)"); 
+                    $stmt -> bind_param('isssisii',$pid,$ma['name'],$ma['vname'],$ma['titel'],$ma['rag'],$ma['email'],$ma['abt'], $aktiv);
                     $result = $stmt -> execute();
                     if ($stmt->error) echo "error INSERT Mitarbeiter: " . $stmt->error . "<br><br>\n";
                 }
@@ -313,7 +325,7 @@
             include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/ma_tel_dat_show.inc.php");
         }
         echo "</div>";
-        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ma_tel_flist.php?e=1$getp\" target=\"_self\" title=\"Telefonliste\">Mitarbeiterliste</a></p>\n"; 
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"ma_tel_flist.php?e=1$getp\" target=\"_self\" title=\"Telefonliste\">&laquo; zur Telefon-Liste</a></p>\n"; 
         echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"".$_SERVER["PHP_SELF"]."\" target=\"_self\" title=\"Mitarbeiter erfassen\">Neuen Mitarbeiter erfassen</a></p>\n";    
     }
 ?>
--- a/fhiiqm/ma_tel_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/ma_tel_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -15,7 +15,7 @@
     if (isset($_GET["i"]) && $_GET["i"]) $edit = $_GET["i"]; // wegen tab_column, "i" als "e" missbraucht -> editieren ermoeglichen
     if (!$edit) $edit = $_GET["e"];
     if (!$edit) $edit = $_POST["e"];
-    if (isset($edit))
+    if (isset($edit) && $edit)
     {
         session_start();
         if (! isset($_SESSION["userid"]))
@@ -25,8 +25,7 @@
             exit;
         }
         
-        if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("fmr",$_SESSION["recht"]) && !in_array("fme",$_SESSION["recht"])
-             && !in_array("ddr",$_SESSION["recht"]) && !in_array("dde",$_SESSION["recht"])))
+        if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("mtr",$_SESSION["recht"]) && !in_array("mte",$_SESSION["recht"])))
         {
             header("Location: start.php");
             exit;
@@ -41,13 +40,13 @@
    	<link href="http://achilleus.rz-berlin.mpg.de/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
    	<link href="http://achilleus.rz-berlin.mpg.de/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
 
-	<title>MA-Telefonliste</title>
+	<title>MA/O-Telefonliste</title>
 </head>
 
 <body onload="document.ffilter.filter.focus();">
     
 <?php
-    if (isset($edit))
+    if (isset($edit) && $edit)
     {
         echo "&nbsp;";  
         echo "<div class=\"float-br smaller\" valign='top'>";
@@ -55,7 +54,7 @@
         echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
         echo "<div class=\"float-r\"><img src=\"img/group.png\" border=\"0\" alt=\"Telefonliste\" title=\"Telefonliste\"/></div>\n";
     }
-
+    
     // Felder, nach denen gefiltert werden kann
     $fields = array(2=>"Name",3=>"Vorname",5=>"Abteilung",6=>"Telefon/Fax",9=>"Haus", 10=>"Raum");
 //    $fieldf = array(2=>"trim(nachname)",3=>"vorname",5=>"abt_name",6=>"mt.telefon_nr",9=>"geb_ID", 10=>"raum_nr");
@@ -88,10 +87,10 @@
     $sql = "SELECT m.persknr, TRIM(nachname) as name, vorname, titel, abt_name, mt.telefon_nr, telefon_typ, public, geb_ID, raum_nr, email
             FROM Mitarbeiter m LEFT OUTER JOIN 
             Abteilung a ON m.abt_tel=a.abt_ID LEFT OUTER JOIN 
-            MA_Telefon mt ON m.persknr=mt.persknr INNER JOIN 
+            MA_Telefon mt ON m.persknr=mt.persknr LEFT OUTER JOIN 
             Telefon t ON mt.telefon_nr=t.telefon_nr LEFT OUTER JOIN
             Raum r ON t.raum_ID = r.raum_ID
-            WHERE aktiv>0 AND (m.abt_tel <> 7)
+            WHERE aktiv>0 AND (m.abt_tel <> 7 OR m.abt_tel IS NULL)
             UNION
             SELECT m.persknr, TRIM(nachname) as name, vorname, titel, IFNULL(rag_bez,'INF') as abt_name, mt.telefon_nr, telefon_typ, public, geb_ID, raum_nr, email
             FROM Mitarbeiter m LEFT OUTER JOIN 
@@ -102,11 +101,25 @@
             RaumArb_Gruppe rag ON ma.rag_ID=rag.rag_ID
             WHERE aktiv>0 AND m.abt_tel=7";
 */
-    $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email FROM v_tel_list";
-    if ($filter) $wher = " WHERE " . $fieldf[$fnum] . " LIKE " . "'%$filter%'"; else $wher = "";
-    if ($sort == 2) $sort = "2, 3, 5";
-    if ($sort == 5) $sort = "5, 2, 3";
-    if ($sort) $ord = " ORDER BY $sort, 6"; // immer nach Telefon-Nr als 2.
+//    $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email FROM v_tel_list";
+//  Raum zu Mitarbeiter und nicht zu Telefon
+    $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email FROM v_tel_list_ma_raum";
+    if ($filter)
+    {
+        if ($fnum > 3)
+            $wher = " WHERE " . $fieldf[$fnum] . " LIKE " . "'%$filter%'"; 
+        else
+            $wher = " WHERE " . $fieldf[$fnum] . " LIKE " . "'$filter%'"; 
+    }
+    else $wher = ""; 
+
+    if ($sort == 2) $so = "name COLLATE latin1_general_ci $dir, 3, 5";
+//    if ($sort == 2) $sort = "2, 3, 5";
+    elseif ($sort == 5) $so = "5 $dir, name COLLATE latin1_general_ci, 3";
+//    if ($sort == 5) $sort = "5, 2, 3";
+    else $so = "$sort $dir ";
+    if ($so) $ord = " ORDER BY $so, 6 "; // immer nach Telefon-Nr als 2.
+
     $sql .= $wher . $ord;
 //    echo "sql = $sql<br /><br />";
     $result = $dbc ->queryObjectArray($sql);
@@ -119,7 +132,7 @@
         $getp = "&s=$sort&d=$dir&f=$fnum&b=$filter"; // Parameter Listenanzeige
      
         echo "<div align='center'>\n";
-        echo "<p><b>Mitarbeiter - Telefonliste</b></p>\n";
+        echo "<p><b>Mitarbeiter/Objekte - Telefonliste</b></p>\n";
         
         echo "<table border='0' cellspacing='0'>\n";
         echo "<tr><td class='bigger'>Mittels '<img src='http://achilleus.rz-berlin.mpg.de/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='http://achilleus.rz-berlin.mpg.de/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />' 
@@ -129,8 +142,9 @@
         if ($edit)
             echo "<tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten der Angaben</tr>";
  
-        echo "</table><br />\n";
+        echo "</table>\n";
 
+        echo "</div><p>&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/ma_tel_pdf.php?e=$edit$getp>PDF erstellen</a></p>\n<div align='center'>\n";
         if (isset($fnum) && $fnum>1 && !$filter && !$subf)
         {
             // Formular anzeigen fuer Filterbegriff
@@ -157,6 +171,14 @@
             echo "</form>\n";
             echo "<p>&nbsp;&nbsp;&nbsp;</p>\n";
         }
+        
+        // Schnellsuche Namen
+        echo "<p>";
+        for ($j=65; $j<91; $j++)
+        {
+            echo "<a href='". $_SERVER["PHP_SELF"] . "?e=$edit&f=2&b=". chr($j)."' target=\"_self\" title=\"Telefonliste\" class=\"sc\">".chr($j)."&nbsp;&nbsp;&nbsp;</a>"; 
+        }
+        echo "</p>\n";
         echo "<table width='55%'>\n";
         
         if ($filter>'!') echo "<tr><td class='bigger' colspan=6>Filter: ". $fields["$fnum"] . " wie '$filter'</td></tr>\n";
@@ -166,10 +188,10 @@
         tab_column(2,"Name",$sort,$dir,2,$fnum,$filter,$start,$zeil,$edit);
         tab_column(3,"Vorname",$sort,$dir,3,$fnum,$filter,$start,$zeil,$edit);
         tab_column(5,"Abteilung",$sort,$dir,5,$fnum,$filter,$start,$zeil,$edit);
-        tab_column(6,"Telefon/Fax",$sort,$dir,6,$fnum,$filter,$start,$zeil,$edit);
         tab_column(9,"Haus",$sort,$dir,9,$fnum,$filter,$start,$zeil,$edit);
         tab_column(10,"Raum",$sort,$dir,10,$fnum,$filter,$start,$zeil,$edit);
-        if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+        tab_column(6,"Telefon/Fax",$sort,$dir,6,$fnum,$filter,$start,$zeil,$edit);
+        if ($edit && !is_null($_SESSION["recht"]) && in_array("mte", $_SESSION["recht"]))
             echo "<th>&nbsp</th>";
         echo "</tr>\n";
         foreach ($result as $row)
@@ -185,28 +207,33 @@
     //            echo "<td class=\"left\">$row->telnr " . ($row->telefon_typ == 'fax')? ", " . strtoupper($row->telefon_typ) : "" . "</td>";
                 $ttyp = ($row->telefon_typ == 'fax')? " " . strtoupper($row->telefon_typ) : "";
                 $rot = ($row->public)? "" : " class=\"red\"";
-                echo "<td$rot>$row->telefon_nr $ttyp</td>";
                 echo "<td>$row->geb_ID</td>";
                 echo "<td>$row->raum_nr</td>";
-                if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+                echo "<td$rot>$row->telefon_nr $ttyp</td>";
+                if ($edit && !is_null($_SESSION["recht"]) && in_array("mte", $_SESSION["recht"]))
                     echo "<td><a href='/fhiiqm/ma_tel_ed.php?i=$row->persknr$getp'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
                 echo "</tr>\n";
             }
             else
             {
-                echo "<tr bgcolor='" . $bg . "'><td colspan='3'>&nbsp;</td>";    
+                if ($vabt != $row->abt_name) $abt = $row->abt_name;
+                else $abt = '&nbsp';    
+                echo "<tr bgcolor='" . $bg . "'><td colspan='2'>&nbsp;</td>";    
                 $ttyp = ($row->telefon_typ == 'fax')? " " . strtoupper($row->telefon_typ) : "";
                 $rot = ($row->public)? "" : " class=\"red\"";
+                echo "<td>$abt</td>";
+                echo "<td>&nbsp;</td>";
+                echo "<td>&nbsp;</td>";
                 echo "<td$rot>$row->telefon_nr $ttyp</td>";
-                echo "<td>$row->geb_ID</td>";
-                echo "<td>$row->raum_nr</td>";
-                if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+                if ($edit && !is_null($_SESSION["recht"]) && in_array("mte", $_SESSION["recht"]))
                     echo "<td>&nbsp;</td>";                
                 echo "</tr>\n";
             }
             $vpnr = $row->persknr;
+            $vabt = $row->abt_name;
         }
         echo "</table></div>\n";
+        echo "<p>&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/ma_tel_pdf.php?e=$edit$getp>PDF erstellen</a></p>\n";
 
     }
     else
@@ -217,7 +244,7 @@
         else
         {
             echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider nichts gefunden f&uuml;r ". $fields["$fnum"] . " wie '$filter'!</p><br />";
-            echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "?$edit\" target=\"_self\" title=\"Telefonliste\" class=\"sc\">Telefonliste</a></p>\n";
+            echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "?e=$edit\" target=\"_self\" title=\"Telefonliste\" class=\"sc\">Telefonliste</a></p>\n";
         }
         echo "</div>";
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/ma_tel_pdf.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,102 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * Telefonliste als pdf erstellen
+ * 
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    include ($_SERVER['DOCUMENT_ROOT']."/fhiiqm/inc/pdf_ma_tel.inc.php");
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+    $dbc = new dbconnection();
+    $sub = $_POST['sub'];
+    $sortp = $_POST['sortp'];
+    if (!$sortp) $sortp = $_GET['sp'];
+    $abt = $_POST['abt'];
+    if (!$abt) $abt  = $_GET['a'];
+
+	$sort   = $_GET["s"];   // Sortierung nach Spalte
+    $dir    = $_GET["d"];   // Sortierrichtung
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $filter = $_GET["b"];  // Filterbegriff
+    $edit   = $_GET["e"];   // Telefonliste editierbar 
+    $getp = "e=$edit&s=$sort&d=$dir&f=$fnum&b=$filter"; // Parameter Listenanzeige Mitarbeiter/Objekte-Telefonliste
+      
+    if (!$sub)
+    {
+    ?>
+        <!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>MA/O-Telefonliste -&gt; PDF</title>
+         </head>
+         <body>
+         <div align="center">
+         <p><b>PDF: Mitarbeiter/Objekte - Telefonliste</b></p>
+    <?php
+        echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
+        echo "<table width=\"30%\" border=\"0\">\n";
+        echo "<tr><td>filtern nach Abteilung</td>";
+        echo "   <td valign=\"top\">
+                 <select name=\"abt\">";
+                    echo "<option value=\"-1\"></option>\n";
+                    $sql = "SELECT abt_ID, abt_name, abt_long FROM `fhiiqm`.`Abteilung` ORDER BY abt_ID+0";
+                    if ($result = $dbc->queryObjectArray($sql))
+                    {
+                        foreach ($result as $row)
+                        {
+                            if ($row->abt_ID == $ma['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";
+                        }
+                }
+        echo "       </select></td></tr>\n";
+        echo "<tr><td>sortieren nach</td>";
+        echo "  <td><select name='sortp'>";
+        echo "      <option value=\"-1\"></option>\n";
+        echo "      <option value='2'>Name</option>\n";    
+        echo "      <option value='12'>Abteilung</option>\n";    
+        echo "       </select></td></tr>\n";
+        echo "<tr><td>&nbsp;</td><td><input  class=\"button\" type=\"submit\" name=\"sub\" value=\"  pdf erstellen  \" /></td></tr>\n";
+        echo "</table>\n";
+        echo "</form>\n";
+        echo "</div>\n";
+        echo "<p><br /><br />&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/ma_tel_flist.php?$getp>&laquo; zur Telefon-Liste</a></p>\n";
+        echo "</body></html>\n";
+    }
+    else
+    {
+        $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email, abt_tel+0 FROM v_tel_list_ma_raum "; 
+    
+        if ($sortp == '2') $sortp = "name COLLATE latin1_general_ci,3,12,5,6"; // Name
+        elseif ($sortp == '12') $sortp = "12,5,name COLLATE latin1_general_ci,3,6"; // abt_ID
+        else $sortp = "name COLLATE latin1_general_ci,3,12,5,6";
+        
+        if ($abt > '-1') $wher = " WHERE abt_tel = $abt "; else $wher = "";
+        
+        $sql .= $wher . " ORDER BY $sortp";
+        if ($result = $dbc ->queryObjectArray($sql))
+        { 
+            $header=array('Name','Abteilung','Tel/Fax','Raum','E-Mail');
+            $pdf = new PDF();
+            $pdf->SetLeftMargin(25);
+            $pdf->AddPage();
+            $pdf->AliasNbPages();
+            $pdf->SetFont('helvetica','',9);
+        
+            $pdf->FancyTable($header,$result);
+            $pdf->SetDisplayMode('real');
+            $pdf->Output();
+            // als Download
+//            $pdf->Output('ma_tel_list.pdf','D');
+        }
+    }
+?>
\ No newline at end of file
--- a/fhiiqm/partner_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/partner_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
--- a/fhiiqm/produkt_ins.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/produkt_ins.php	Fri Dec 21 15:31:50 2012 +0100
@@ -128,7 +128,7 @@
         $stmt = $dbc -> stmtinit();
         if (is_object($stmt))
         {
-            $stmt -> prepare("INSERT INTO Produkt (produkt_ID,prod_name,prod_group_ID,produkt_hier,ag_ID,imp_ID,conn_ID,Bemerkung) 
+            $stmt -> prepare("INSERT INTO Produkt (produkt_ID,prod_name,prod_group_ID,produkt_hier,rag_ID,imp_ID,conn_ID,Bemerkung) 
                                 VALUES (?,?,?,?,?,?,?,?)");
             $stmt -> bind_param('isissiis', $prod['pnr'],$prod['pname'],$prod['grp'],$phier,$prod['ag'],$prod['imp'],$prod['conn'],$prod['pbem']);
             $result = $stmt -> execute();
--- a/fhiiqm/produkt_upd.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/produkt_upd.php	Fri Dec 21 15:31:50 2012 +0100
@@ -58,7 +58,7 @@
     {
         if (!$submit)
         {
-            $sql = "SELECT produkt_ID, prod_name, prod_group_ID, produkt_hier, ag_ID, imp_ID, conn_ID, Bemerkung FROM Produkt 
+            $sql = "SELECT produkt_ID, prod_name, prod_group_ID, produkt_hier, rag_ID, imp_ID, conn_ID, Bemerkung FROM Produkt 
                     WHERE produkt_ID = $pid";
             if ($result = $dbc ->queryObjectArray($sql))
             {
@@ -67,7 +67,7 @@
                     $prod['pnr']    = $row->produkt_ID;
                     $prod['pname']  = $row->prod_name;
                     $prod['grp']    = $row->prod_group_ID;
-                    $prod['ag']     = $row->ag_ID;
+                    $prod['ag']     = $row->rag_ID;
                     $prod['imp']    = $row->imp_ID;
                     $prod['conn']   = $row->conn_ID;
                     $prod['pbem']   = $row->Bemerkung;
@@ -139,7 +139,7 @@
             $stmt -> prepare("UPDATE Produkt SET 
                                 prod_name = ?, 
                                 prod_group_ID = ?,         
-                                ag_ID = ?,          
+                                rag_ID = ?,          
                                 imp_ID = ?,          
                                 conn_ID = ?,          
                                 Bemerkung = ? 
--- a/fhiiqm/prozess_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/prozess_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -72,10 +72,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
     
--- a/fhiiqm/raum_aptyp_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_aptyp_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -31,6 +31,12 @@
     $ok  = $_POST["ok"];
     $apid = $_GET["i"]; // raum_ID
     
+    $zeil = $_GET["z"];
+    $start = $_GET["st"];
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $filter = $_GET["b"];   // Filterbegriff
+    $sort = $_GET["s"];
+    $getp = "?st=$start&z=$zeil&s=$sort&f=$fnum&b=$filter"; //Link fuer Raumliste zurueck
 
 
 ?>
@@ -134,7 +140,7 @@
         }
     echo "</table>\n";
         echo "</div>\n";
-    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_aptyp_flist.php\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">&laquo; zur Raum-Arbplatztyp-Liste</a></p>\n"; 
+    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_aptyp_flist.php$getp\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">&laquo; zur Raum-Arbplatztyp-Liste</a></p>\n"; 
     echo "</form>\n";
     }
     else
@@ -180,7 +186,7 @@
                 echo "<p class='red'><b>Arbeitsplatztypen für Raum-ID '$apid'' wurden nicht oder nur teilweise gespeichert</b></p>\n";
         
         echo "</div>";
-        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_aptyp_flist.php\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">&laquo; zur Raum-Arbplatztyp-Liste</a></p>\n"; 
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_aptyp_flist.php$getp\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">&laquo; zur Raum-Arbplatztyp-Liste</a></p>\n"; 
     }
 ?>
 
--- a/fhiiqm/raum_aptyp_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_aptyp_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -72,6 +72,7 @@
     if (!isset($filter) && !$filter) $filter = "";
     if (!isset($sort) && !$sort) $sort = 2;
     if (!isset($dir) && !$dir)  $dir = "";
+    $getp = "&st=$start&z=$zeil&s=$sort&f=$fnum&b=$filter"; //Link fuer Raumliste zurueck
 
     include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
@@ -153,7 +154,7 @@
             echo "<td>". str_replace("; ","<br />",$row->arbplatz_typ_bez)."</td>";
             echo "<td>$row->raumtyp_ID</td>";
             echo "<td>$row->raumtyp_bez</td>";
-            echo "<td><a href='/fhiiqm/raum_aptyp_ed.php?i=$row->raum_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+            echo "<td><a href='/fhiiqm/raum_aptyp_ed.php?i=$row->raum_ID$getp'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
         }
         echo "</table></div>\n";
 
--- a/fhiiqm/raum_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -67,10 +67,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 /*
     $sql = "SELECT COUNT(*) AS anzr FROM fhiiqm.Raum";
     $anz = $dbc -> querySingleItem($sql);
@@ -184,7 +184,7 @@
             }
             else    
                 echo "<td>$row->raum_file</td>";
-            echo "<td><a href='/fhiiqm/raum_upd.php?uid=$row->raum_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+            echo "<td><a href='/fhiiqm/raum_upd.php?uid=$row->raum_ID&st=$start&z=$zeil'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
         }
         echo "</table></div>\n";
 
--- a/fhiiqm/raum_flist_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_flist_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -32,7 +32,7 @@
    	<link href="css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
    	<link href="css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> 
 
-	<title>Raumliste edit</title>
+	<title>Reinigungsdaten edit</title>
 </head>
 
 <body onload="foc();">
@@ -83,10 +83,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
 /*
     $sql = "SELECT COUNT(*) AS anzr FROM fhiiqm.Raum";
@@ -151,7 +151,7 @@
 		$bg = "#FFFFFF";
      
         echo "<div align='center'>\n";
-        echo "<p><b>Liste der erfassten R&auml;ume</b></p>\n";
+        echo "<p><b>Liste der erfassten R&auml;ume mit Reinigungsdaten</b></p>\n";
         
         echo "<table border='0' cellspacing='0'>\n";
         echo "<tr><td class='bigger'>Mittels '<img src='/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />' 
--- a/fhiiqm/raum_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -4,7 +4,7 @@
  * @author Bettina Schwarzer, Fritz-Haber-Institut
  * @copyright 05/2012
  * 
- * Reportauswahl Raeume - Arbeitssicherheit
+ * Reportauswahl Raeume
  * 
  */
 
@@ -16,11 +16,12 @@
     if (! isset($_SESSION["userid"]))
     { 
         include_once ("inc/func_lib.inc.php");	
-        login("raum_report.php");
+        login($_SERVER["PHP_SELF"]);
         exit;
     }
     
-    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"])))
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("rr",$_SESSION["recht"]) && !in_array("re",$_SESSION["recht"]) && 
+            !in_array("ddr",$_SESSION["recht"]) && !in_array("dde",$_SESSION["recht"])))
     {
         header("Location: start.php");
         exit;
@@ -36,7 +37,7 @@
    	<link href="css/navio.css" rel="STYLESHEET" type="TEXT/CSS" /> 
 	<meta name="author" content="Bettina Schwarzer,FHI" />
 
-	<title>Reports Raeume-Arbeitssicherheit</title>
+	<title>Reports R&auml;ume</title>
 </head>
 
 <body>
@@ -45,58 +46,23 @@
     echo "<div class=\"float-br smaller\" valign='top'>";
     echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
     echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
-    echo "<div class=\"float-r sc\"><img src=\"/fhiiqm/img/role.png\" border=\"0\" alt=\"Berichte Raeume\" title=\"Berichte Raeume\"/></div>\n";
+    echo "<div class=\"float-r sc\"><img src=\"/fhiiqm/img/house.png\" border=\"0\" alt=\"Berichte Raeume\" title=\"Berichte Raeume\"/></div>\n";
 ?>
-    <h3>&nbsp;&nbsp;&nbsp;Berichte Arbeitssicherheit</h3>
+    <h3>&nbsp;&nbsp;&nbsp;Berichte R&auml;ume</h3>
     <div align="center">
     <table width="94%" cellspacing="4" cellpadding="4">
         <tr>
             <td class="bigger">
-                <a href="/fhiiqm/report/raum_rt_report.php" title="Raum Raumtyp APTyp">(1) Raum - Raumtyp - Arbeitsplatz-Typ</a>
+                <a href="/fhiiqm/report/raum_vma_report.php" title="Raumverantwortliche">Raum - Raumverantwortliche</a>
                 <br />&nbsp;&nbsp;&nbsp;Auswahl: Haus, Raum-Typ
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Haus, Raum-Nr. Raum-Bezeichnung, Raum-Typ, Arbeitsplatz-Typ
-            </td>
-        </tr>
-        <tr>
-            <td class="bigger">
-                <a href="/fhiiqm/report/abt_raum_rt_report.php" title="Abteilung-Raum-Raumtyp">(2) Abteilung - Raum - Raumtyp</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Abteilung, Haus, Raumtyp 
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Abteilung, Arbeitsgruppe, Haus, Raum-Nr., Raumtyp 
+                <br />&nbsp;&nbsp;&nbsp;Ansicht: Haus, Raum-Nr., Raum-Bezeichnung, Raum-Typ, Fl&auml;che, Verantwortliche
             </td>
         </tr>
         <tr>
             <td class="bigger">
-                <a href="/fhiiqm/report/abt_ag_aptyp_report.php" title="Abteilung-AG-APTyp">(3) Abteilung - Arbeitsgruppe - Arbeitsplatztyp</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Abteilung
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Abteilung, Arbeitsgruppe, Arbeitsplatztyp (ohne Redundanzen)
-            </td>
-        </tr>
-        <tr>
-            <td class="bigger">
-                <a href="/fhiiqm/report/ma_abt_raumgr_report.php" title="Abteilung-MA-Raum">(4) Abteilung - Mitarbeiter - Raum</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Haus, Abteilung
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Mitarbeiter, Abteilung, Haus, Raum-Nr. 
-            </td>
-        </tr>
-        <tr>
-            <td class="bigger">
-                <a href="/fhiiqm/report/aptyp_gefahr_massn_report.php" title="Arbplatztyp_Gefahr_Massnahme">(5) Arbeitsplatztyp - Gef&auml;hrdung - Ma&szlig;nahme</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Arbeitsplatztyp, Gef&auml;hrdung
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Arbeitsplatztyp, Gef&auml;hrdung, Ma&szlig;nahme
-            </td>
-        </tr>
-        <tr>
-            <td class="bigger">
-                <a href="/fhiiqm/report/gefahr_ap_report.php" title="Gef&auml;hrdungen Arbeitsplatz">(6) Gef&auml;hrdungen am Arbeitsplatz</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Haus, Raum, Arbeitsplatz-Typ, Gef&auml;hrdung
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Haus, Raum-Nr. Raum-Bezeichnung, Arbeitsplatz-Typ, Gef&auml;hrdung, Ma&szlig;nahmen
-            </td>
-        </tr>
-        <tr>
-            <td class="bigger">
-                <a href="/fhiiqm/report/rag_gefahr_massn_report.php" title="Gef&auml;hrdungen Abt.,AG">(7) Gef&auml;hrdungen und Ma&szlig;nahmen in Arbeitsgruppen</a>
-                <br />&nbsp;&nbsp;&nbsp;Auswahl: Abteilung, Haus, Raum-Typ
-                <br />&nbsp;&nbsp;&nbsp;Ansicht: Abteilung, Arbeitsgruppe, Haus, Raum-Nr. Raum-Bezeichnung, Arbeitsplatz-Typ, Gef&auml;hrdung, Ma&szlig;nahmen
+                <a href="/fhiiqm/report/raum_dez_anl_report.php" title="dez. Anlagen">Betrieb dezentrale Anlagen</a>
+                <br />&nbsp;&nbsp;&nbsp;Auswahl: Haus, Raum, Raum-Typ
+                <br />&nbsp;&nbsp;&nbsp;Ansicht: Datenblatt 'Dauerbetrieb' (Haus, Raum-Nr., Raum-Bezeichnung, Raum-Typ, Geräte, Verantwortliche)
             </td>
         </tr>
     </table>
--- a/fhiiqm/raum_upd.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_upd.php	Fri Dec 21 15:31:50 2012 +0100
@@ -48,6 +48,8 @@
 	$dbc = new dbconnection();
     
     $rid    = $_GET["uid"];
+    $start  = $_GET["st"];
+    $zeil   = $_GET["z"];
     if (!$rid) $rid=1;
 	$ok		= $_POST["ok"];
 	$upd	= $_POST["upd"];
@@ -168,34 +170,37 @@
             $retf   = upload("rfile", $fname, $rid, "raeume");              // Datei prüfen und in Dokumentenverzeichnis verschieben
         }
         else
-        {   // nur Aenderung Dateiname
+        {   
+            // nur Aenderung Dateiname
             include_once ("inc/file_upload.inc.php");
-            $fname = gen_filename($raum['rfname'],$rfile_old,$rid,0);
-            $len = strlen($rid)+1;
-            if (substr($fname,0,$len) != "$rid" . "_") $fname = $rid . "_" . $fname;
             if ($raum['rfname'] != $rfile_old)
             {
                 if ($raum['rfname']>"!")
                 {
+                    $fname = gen_filename($raum['rfname'],$rfile_old,$rid,0);
+                    $len = strlen($rid)+1;
+                    if (substr($fname,0,$len) != "$rid" . "_") $fname = $rid . "_" . $fname;
                     $retf  = mod_file("/var/www/fhiiqm/raeume",$rid,$fname,"upd");  // Umbenennen alte Datei
                 }
                 else
                 {   // Dateiname nicht angegeben
                     $retf=1; 
-                    if ($vfile_old)
+                    if ($rfile_old)
                     {    // Loeschen alte Datei
                         $retf  = mod_file("/var/www/fhiiqm/raeume",$rid,"","del");
-                    }    
+                    }
+                    $fname = null;    
                 }
             }
             else
             {
                 //kein Upload, keine Dateinamenaenderung
+                $fname = $raum['rfname'];
                 $retf=1;
             }    
         }    
         $len = strlen($rid)+1;
-        if (isset($fname) && $retf && (substr($fname,0,$len) != "$rid" . "_")) $rfile = $rid . "_" . $fname; else $rfile = $fname;
+        if (isset($fname) && $fname && $retf && (substr($fname,0,$len) != "$rid" . "_")) $rfile = $rid . "_" . $fname; else $rfile = $fname;
 /*        
         if ($raum['rtyp']== -1) $rtyp = "NULL"; else $rtyp = "'" . $raum['rtyp'] . "'"; 
         if (isset($raum['rflae']) && $raum['rflae']>"0")
@@ -278,7 +283,7 @@
     if ($ok && ($upd || $del))
     {
         // Raumliste filtern mit zuletzt eingegeben Haus
-        $liste="?s=2&f=4&b=" . substr($raum["geb"],0,3);
+        $liste="?s=2&f=4&b=" . substr($raum["geb"],0,3)."&st=$start&z=$zeil";
         echo "</div><br /><br />\n";
         echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_flist.php$liste\" target=\"_self\" title=\"Raumliste\">Zur&uuml;ck zur Raumliste</a></p>\n";    
         echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raum_ins.php\" target=\"_self\" title=\"Raum erfassen\">Weiteren Raum erfassen</a></p>\n";    
--- a/fhiiqm/raum_vma_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_vma_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -87,7 +87,9 @@
     if (!$rid) $rid=1;
     $zeil = $_GET["z"];
     $start = $_GET["st"];
-    $geb = $_GET["b"];
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $geb = $_GET["b"];      // Filterbegriff
+    $sort = $_GET["s"];
     
 	$ok		= $_POST["ok"];
 	$sub	= $_POST["sub"];
@@ -98,7 +100,7 @@
     
     echo "<div align=\"center\"><h3>Raum - Verantwortliche editieren</h3></div>\n";
 
-    $liste="?st=$start&z=$zeil&s=2&f=2&b=$geb"; //Link fuer Raumliste
+    $liste="?st=$start&z=$zeil&s=$sort&f=$fnum&b=$geb"; //Link fuer Raumliste
 
     if (!$sub || !isset($raum) || !$ok )
     {
--- a/fhiiqm/raum_vma_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raum_vma_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -65,10 +65,10 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 /*
     $sql = "SELECT COUNT(*) AS anzr FROM fhiiqm.Raum";
     $anz = $dbc -> querySingleItem($sql);
@@ -164,7 +164,7 @@
             else    
                 echo "<td>$row->raum_file</td>";
             echo "<td>" . str_replace("; ","<br />",$row->vma)."</td>";
-            echo "<td><a href='/fhiiqm/raum_vma_ed.php?i=$row->raum_ID&st=$start&z=$zeil&b=$filter'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+            echo "<td><a href='/fhiiqm/raum_vma_ed.php?i=$row->raum_ID&st=$start&z=$zeil&s=$sort&f=$fnum&b=$filter'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
         }
         echo "</table></div>\n";
 
--- a/fhiiqm/raumarbgr_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raumarbgr_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -28,10 +28,18 @@
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
 	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
 
-    $sub = $_POST["eintragen"];
-    $rag  = $_POST["rag"];
-    $ok  = $_POST["ok"];
-    $ragid = $_GET["i"]; // raumarbgruppe_ID
+    $sub    = $_POST["eintragen"];
+    $rag    = $_POST["rag"];
+    $ok     = $_POST["ok"];
+    $ragid  = $_GET["i"]; // raumarbgruppe_ID
+
+    $zeil   = $_GET["z"];
+    $start  = $_GET["st"];
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    $filter = $_GET["b"];   // Filterbegriff
+    $sort   = $_GET["s"];
+    $gmv    = $_GET['g'];  // mit Gefahr, Massnahmen und Vorsorge
+    $getp = "?st=$start&z=$zeil&s=$sort&f=$fnum&b=$filter&g=$gmv"; //Link fuer Liste zurueck
     
 
 
@@ -143,7 +151,7 @@
         }
         echo "</table>\n";
         echo "</div>\n";
-    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raumarbgr_flist.php\" target=\"_self\" title=\"Raum-Arbeits-Gruppe-Liste\">&laquo; zur Raum-Arbeits-Gruppe-Liste</a></p>\n"; 
+    echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raumarbgr_flist.php$getp\" target=\"_self\" title=\"Raum-Arbeits-Gruppe-Liste\">&laquo; zur Raum-Arbeits-Gruppe-Liste</a></p>\n"; 
     echo "</form>\n";
     }
     else
@@ -246,7 +254,7 @@
                 echo "<p class='red'><b>Gef&auml;hrdungen für Arbeitsplatztyp '$ragbez' wurden nicht oder nur teilweise gespeichert</b></p>\n";
         
         echo "</div>";
-        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raumarbgr_flist.php\" target=\"_self\" title=\"Raum-Arbeits-Gruppe-Liste\">&laquo; zur Raum-Arbeits-Gruppe-Liste</a></p>\n"; 
+        echo "<p class='sc'>&nbsp;&nbsp;&nbsp;<a href=\"raumarbgr_flist.php$getp\" target=\"_self\" title=\"Raum-Arbeits-Gruppe-Liste\">&laquo; zur Raum-Arbeits-Gruppe-Liste</a></p>\n"; 
     }
 ?>
 </body>
--- a/fhiiqm/raumarbgr_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/raumarbgr_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -75,10 +75,11 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($filter) && !$filter) $filter = "";
-    if (!isset($sort) && !$sort) $sort = "3";
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = "3";
+    if (!isset($dir) || !$dir)  $dir = "";
+    $getp = "&st=$start&z=$zeil&s=$sort&f=$fnum&b=$filter&g=$gmv"; //Link fuer Liste zurueck
 
     include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 
@@ -186,7 +187,7 @@
                 }
                 else echo "<td>&nbsp;</td>";
             }
-            echo "<td><a href='/fhiiqm/raumarbgr_ed.php?i=$row->rag_ID'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+            echo "<td><a href='/fhiiqm/raumarbgr_ed.php?i=$row->rag_ID$getp'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
         }
         echo "</table></div>\n";
 
--- a/fhiiqm/recht_list.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/recht_list.php	Fri Dec 21 15:31:50 2012 +0100
@@ -92,6 +92,8 @@
             COUNT(CASE recht_ID WHEN 'ie' THEN 1 END) AS info_edit,
             COUNT(CASE recht_ID WHEN 'lr' THEN 1 END) AS laser_read,
             COUNT(CASE recht_ID WHEN 'le' THEN 1 END) AS laser_edit,
+            COUNT(CASE recht_ID WHEN 'mtr' THEN 1 END) AS ma_tel_read,
+            COUNT(CASE recht_ID WHEN 'mte' THEN 1 END) AS ma_tel_edit,
             COUNT(CASE recht_ID WHEN 'pr' THEN 1 END) AS prod_read,
             COUNT(CASE recht_ID WHEN 'pe' THEN 1 END) AS prod_edit,
             COUNT(CASE recht_ID WHEN 'pzr' THEN 1 END) AS proz_read,
@@ -126,6 +128,7 @@
                 <th colspan='2'>Funkt.-MA</th>
                 <th colspan='2'>Info</th>
                 <th colspan='2'>Laser</th>
+                <th colspan='2'>MA-Tel.</th>
                 <th colspan='2'>Produkt</th>
                 <th colspan='2'>Prozess</th>
                 <th colspan='2'>Raum</th>
@@ -146,35 +149,38 @@
                 <th>read</th><th>edit</th>
                 <th>read</th><th>edit</th>
                 <th>read</th><th>edit</th>
+                <th>read</th><th>edit</th>
         </tr>\n";
         foreach ($result as $row)
         {
 			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
             echo "<tr bgcolor='" . $bg . "'><td><b>$row->userid</b><img src=\"/fhiiqm/img/transp.png\" width=\"2\" height=\"12\" border='0'/></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->anlage_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->anlage_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->anlage_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->as_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->as_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->as_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->funkt_ma_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->funkt_ma_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->funkt_ma_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->info_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->info_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->info_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->laser_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->laser_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->laser_edit)) ."</b></td>";
+            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->ma_tel_read)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->ma_tel_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->prod_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->prod_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->prod_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->proz_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->proz_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->proz_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->raum_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->raum_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->raum_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertrag_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertrag_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertrag_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertr_part_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertr_part_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->vertr_part_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->dez_dat_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->dez_dat_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->dez_dat_edit)) ."</b></td>";
             echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->recht_read)) ."</b></td>";
-            echo "<td class='center'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->recht_edit)) ."</b></td>";
+            echo "<td class='center green'><b>" . str_replace("0","&nbsp;",str_replace("1","x",$row->recht_edit)) ."</b></td>";
             echo "</tr>\n";
         }
         echo "</table></div>\n";
--- a/fhiiqm/report/fkt_ma_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/report/fkt_ma_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -186,7 +186,8 @@
                     INNER JOIN Funktion f ON mf.fkt_ID=f.fkt_ID
                     LEFT OUTER JOIN Abteilung a ON m.abt_tel=a.abt_ID
                     LEFT OUTER JOIN Mitarbeiter_Raum mr ON m.persknr=mr.persknr
-                    LEFT OUTER JOIN Raum r ON mr.raum_ID=r.raum_ID WHERE (fkt_bis IS NULL OR fkt_bis>=DATE(NOW())) ";
+                    LEFT OUTER JOIN Raum r ON mr.raum_ID=r.raum_ID 
+                    WHERE (fkt_bis IS NULL OR fkt_bis>=DATE(NOW())) AND (fkt_von IS NULL OR fkt_von<=DATE(NOW())) ";
         $lim = " LIMIT $start,$zeil";
         
         if (!$rag["bind"]) $bind = " AND "; else $bind = $rag["bind"];
--- a/fhiiqm/report/info_report_gvp.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/report/info_report_gvp.php	Fri Dec 21 15:31:50 2012 +0100
@@ -190,7 +190,7 @@
             if ($inf["sort"] && $inf["sort"] != '-1') $sor = $inf["sort"]; else $sor=15;
             // Parameter: 4:ifotyp=6, 5:produkt, 16:freigabe
             // es wird immer nach Kennzeichen Info sortiert
-            $sql = "CALL info_report($sor,'',4,6,5,$prod,16,$stat,0,100,@anz)";
+            $sql = "CALL info_report($sor,'',4,6,5,$prod,16,$stat,0,500,@anz)";
     
             $result = $dbc ->queryObjectArray($sql);
             if ($dbc -> error) echo "$sql<br />".$dbc -> error."<br />";
@@ -229,7 +229,7 @@
 //                echo "<th width='10%'>Produktgruppe</th>";
                 echo "<th width='25%'>Aufgabe (prod)</th>";
                 echo "<th width='35%'>Teilgebiet (kurzinfo)</th>";
-                echo "<th>Zust&auml;ndigkeit</th>";
+                echo "<th colspan='2'>Zust&auml;ndigkeit</th>";
                 if ($stat == "''") echo "<th>Status</th>";
 
         		$bg1 = "#F8F8F8";
@@ -253,7 +253,14 @@
                     echo "<td>$prod</td>";
 //                    echo "<td>$row->iname</td>";
                     echo "<td>".nl2br($row->ilong)."</td>";
-                    echo "<td>".str_replace(";","<br />",$row->verantw)."</td>";
+                    if (strtoupper(substr($row->infsort,0,2)) == 'BK' && $row->betrag)
+                    {
+                        $colsp="";
+                        $betr = "<td class='right'>max. ".number_format($row->betrag,2,",",".")." &euro;</td>";
+                    }
+                    else {$colsp = " colspan='2'"; $betr="";}
+                    echo "<td$colsp>".str_replace(";","<br />",$row->verantw)."</td>";
+                    echo $betr;
                     if ($stat == "''") echo "<td>$row->freigabe</td>";
                     echo "</tr>\n";
                     $pgv = $pg;
@@ -296,7 +303,7 @@
                         echo "<div class='pr' align='center'><h3>Gesch&auml;ftsverteilungsplan</h3></div>\n"; // Anzeige nur im Ausdruck
                         // Produktbereich immer anzeigen
                         echo "<p><b>$pberbez</b></p>";
-                        // Produktgruppe fuer Teiliste
+                        // Produktgruppe fuer Teiliste + Bemerkung
                         $sql = "SELECT prod_group_name,IFNULL(prod_group_bem,'&nbsp;') AS bem FROM Produkt_Gruppe WHERE prod_group_ID IN ($pg)";
                         $res = $dbc -> queryObjectArray($sql);
                         if ($res)
@@ -311,7 +318,7 @@
                         echo "<th width='30%'>Aufgabe (prod)</th>";
                         echo "<th width='30%'>Teilgebiet (kurzinfo)</th>";
 //                        echo "<th width='40%'>Kurzinfo</th>";
-                        echo "<th>Zust&auml;ndigkeit</th>";
+                        echo "<th colspan='2'>Zust&auml;ndigkeit</th>";
                         if ($stat == "''") echo "<th>Status</th>";
                 		$bg1 = "#F8F8F8";
                 		$bg2 = "#DEDFE1";
@@ -325,7 +332,14 @@
                     echo "<td>".$prod."</td>";
 //                    echo "<td>$row->iname</td>";
                     echo "<td>".nl2br($row->ilong)."</td>";
-                    echo "<td>".str_replace(";","<br />",$row->verantw)."</td>";
+                    if (strtoupper(substr($row->infsort,0,2)) == 'BK' && $row->betrag)
+                    {
+                        $colsp="";
+                        $betr = "<td class='right'>max. ".number_format($row->betrag,2,",",".")." &euro;</td>";
+                    }
+                    else {$colsp = " colspan='2'"; $betr="";}
+                    echo "<td$colsp>".str_replace(";","<br />",$row->verantw)."</td>";
+                    echo $betr;
                     if ($stat == "''") echo "<td>$row->freigabe</td>";
                     echo "</tr>\n";
                     $vprodid = $row->prodid;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/ma_relation_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,266 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 12/2012
+ * 
+ * Report Mitarbeiter - Bezuege
+ * $_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("ir",$_SESSION["recht"]) && !in_array("ie",$_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"/> 
+    <link type="text/css" href="/fhiiqm/css/jquery/ui-lightness-1.8.21/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
+    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-1.7.2.min.js"></script>
+    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-ui-1.8.21.custom.min.js"></script>
+	<title>Report MA - Beziehungen</title>
+</head>
+
+<body>
+<script>
+        $(function() {
+        $("#persknr").autocomplete({
+                source: "/fhiiqm/inc/ma_list_ac.inc.php",
+    			minLength: 2,
+                select: function(event,ui){$("#pid").val(ui.item.id);}
+    		});
+        $("#dat").datepicker({
+            dateFormat: 'yy-mm-dd', //nur Datum
+            yearRange: '2000:2025',
+            changeMonth: true,
+			changeYear: true,
+            firstDay: 1,
+            dayNamesMin: ['So','Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ],
+            monthNamesShort: ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'] 
+            });
+        });
+</script>
+<?php
+    echo "&nbsp;";  
+    if (!isset($_GET['s']) || $_GET['s'] != 2 )
+    {
+        echo "<div class=\"float-br smaller sc\" valign='top'>";
+        echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+        echo "&nbsp;&nbsp;&nbsp;<a href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+        echo "<div class=\"float-r sc\"><img src=\"/fhiiqm/img/user.png\" border=\"0\" alt=\"Raum\" title=\"Raum\"/></div>\n";
+    }
+    $par    = $_POST["par"];    // Parameter aus Form
+    $search = $_POST["search"];
+    if (!$search) $search =  $_GET["s"];
+
+
+    if ($search && $_GET['s'] != 2)
+    {    
+        echo "<span class='sc'>";
+        echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/info_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+        echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"MA - Relation\" class='sc'>neuer Bericht Mitarbeiter & Zuordnungen</a>\n";    
+        echo "</span>";
+    }
+    echo "<div align='center'>\n";
+    echo "<p class='sc'><b>Mitarbeiter und ihre Zuordnungen</b></p>\n";
+    echo "</div>\n";
+    
+
+    if (!$search)
+    {
+?>
+        <div align="center">
+        <p>Bitte Kriterien f&uuml;r die Suche w&auml;hlen</p>
+        <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_raum" target="_self">	
+        <table width="30%" border="0" cellspacing="3" cellpadding="3">
+            <tr><td>Status Mitarbeiter/Objekt</td>
+                <td><select name="par[act]" size="1" onchange="this.form.submit();">
+                    <option value="0" <?php if ($par["act"]== 0) echo "selected='selected'"; ?>>ausgeschieden</option>
+                    <option value="1" <?php if ($par["act"]== 1) echo "selected='selected'"; ?>>aktiv</option>
+                    <option value="2" <?php if ($par["act"]== 2) echo "selected='selected'"; ?>>sonstig</option>
+                </select></td>
+            </tr>
+            <tr>
+                <td>Mitarbeiter</td>
+                <td><input class="long20" type="text" name="par[persknr]" id="persknr" value="<?php echo $par['persknr']; ?>"/>
+                <br />Eingabe von mind. 2 Zeichen -&gt; Namensliste
+                </td>
+            </tr>
+            <tr><td>Abteilung</td>
+                <td><select name="par[abt]" size="1">
+                        <option value=""></option>
+                <?php $sql = "SELECT abt_name FROM Abteilung ORDER BY abt_ID+0";
+                        $result = $dbc -> queryObjectArray($sql);
+                        foreach ($result as $row)
+                            echo "<option value=$row->abt_name>$row->abt_name</option>"
+                ?>
+                </select>
+                </td>
+            </tr>
+            <?php if (!isset($par["act"]) || $par["act"]== 0)
+            {
+                echo "<tr>
+                    <td>ab Datum</td>
+                    <td><input class=\"long10\" name=\"par[dat]\" id=\"dat\"  value=\"".$par['dat']."\" /></td>
+                </tr>\n";
+            }
+            ?>
+            <tr> 
+                <input type="hidden" name="par[pers]" id="pid" value="<?php echo $par['pers']; // Author ?>"/> 
+                <td>&nbsp;</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 (!isset($par["act"])) $par["act"] = 0;
+        if (isset($par["act"])) $krit = " [Status = '" . $par["act"] ."']";
+        if ($par["pers"]>0) $krit .= " UND [Mitarbeiter = '" .$par["persknr"] ."']"; else $par["pers"] = 0;
+        if ($par["abt"]>"") $krit .= " UND [Abteilung = '" .$par["abt"] ."']"; else $par["abt"] = "";
+        if ($par["dat"]>"") $krit .= " UND [Datum  >= '" .$par["dat"] ."']"; else $par["dat"] = "";
+        $sql = "CALL ma_relation('".$par["act"]."',". $par["pers"].",'".$par["abt"]."','".$par["dat"]."')";
+//echo "$sql<br />";
+        $result = $dbc -> queryObjectArray($sql);
+        if ($result)
+        {
+            echo "<p class='sc'>$krit</p>";
+            $begin = 0;
+//            print_r ($result);
+            foreach ($result as $row)
+            {
+                if ($begin) echo "<p style=\"page-break-before:always\">&nbsp;</p>";
+                echo "<table width='90%' border='0' frame='box' cellspacing='2' cellpadding='10'>\n";
+                echo "<tr><td><b>$row->name</b>, Abteilung: <b>$row->abt</b></td></tr>\n";
+                echo "</table>\n";            
+                echo "<table width='90%' border='1' frame='box' rules='rows' cellspacing='2' cellpadding='10'>\n";
+                if ($row->rag)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Arbeitsgruppe:</u> ";                    
+                    $arr = explode("; ",$row->rag);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+//                    echo str_replace("; ","<br />",substr($row->rag,strpos($row->rag,"|")+1)) ."</td></tr>\n";
+                }    
+                if ($row->fkt)
+                { 
+                    echo "<tr><td><u>Beauftragung:</u><br /> ";                    
+                    echo str_replace("; ","<br />",str_replace("|"," - ",$row->fkt)) ."</td></tr>\n";
+                }    
+                if ($row->raumva)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Raumverantwortlich:</u> ";
+                    $arr = explode("; ",$row->raumva);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+//                    echo str_replace("; ","<br />",substr($row->raumva,strpos($row->raumva,"|")+1)) ."</td></tr>\n";
+                }    
+                if ($row->infaut)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Info - Autor:</u> ";                    
+                    $arr = explode("; ",$row->infaut);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                if ($row->infva)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Info - Verantwortlich:</u> ";                    
+                    $arr = explode("; ",$row->infva);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                if ($row->vertrba)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Vertrag - Bearbeiter:</u> ";                    
+                    $arr = explode("; ",$row->vertrba);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                if ($row->lasva)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Laser - Verantwortlich:</u> ";                    
+                    $arr = explode("; ",$row->lasva);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                if ($row->anlva)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Anlage - Verantwortlich:</u> ";                    
+                    $arr = explode("; ",$row->anlva);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                if ($row->prozva)
+                { 
+                    $str=null;
+                    echo "<tr><td><u>Prozess - Verantwortlich:</u> ";                    
+                    $arr = explode("; ",$row->prozva);
+                    foreach ($arr as $e)
+                        $str .= "<br />" . substr($e,strpos($e,"|")+1);
+                    echo "$str</td></tr>\n";                   
+                }    
+                echo "</table>\n";
+//                $begin = 1;
+                echo "<p>&nbsp;</p>\n";            
+            }
+        }
+        else echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
+        
+        echo "</div>\n";
+        if ($search != 2)
+        {    
+            echo "<span  class=\"sc\">";
+            echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/info_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+            echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"MA - Relation\" class='sc'>neuer Bericht Mitarbeiter & Zuordnungen</a></span>\n";
+        }
+        else
+            echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zur&uuml;ck'; return true;}\">&laquo; Zur&uuml;ck</a>";
+    }
+       
+?>
+
+</body>
+</html>
\ No newline at end of file
--- a/fhiiqm/report/rag_gefahr_massn_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/report/rag_gefahr_massn_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -61,6 +61,8 @@
     if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen
     $start = $_GET["st"];   // Start bei DS $start+1
     if (!$start) $start=0;
+    $short = $_GET["sh"];
+    if (!$short) $short = $rag["msn"];
     
 
     if (!is_array($rag))
@@ -85,7 +87,9 @@
     $_GET["s3"] = $rag["sort3"];
     $_GET["s4"] = $rag["sort4"];
     $_GET["z"]  = $zeil;
+    $_GET["sh"]  = $short;
    
+    if ($short) $msn = ""; else $msn = "  -> Ma&szlig;nahmen";
     if ($search && $_GET['s'] != 2)
     {    
         echo "<span class='sc'>";
@@ -94,7 +98,7 @@
         echo "</span>";
     }
     echo "<div align='center'>\n";
-    echo "<p><b>(7) Bericht Gef&auml;hrdungen -> Ma&szlig;nahmen in Arbeitsgruppen</b></p>\n";
+    echo "<p><b>(7) Bericht Gef&auml;hrdungen$msn in Arbeitsgruppen</b></p>\n";
     echo "</div>\n";
     
     if (!$search)
@@ -191,6 +195,7 @@
                 ?>
                 </select></td>
             </tr>
+            <tr><td>ohne Massnahmen?</td><td><input type="checkbox" name="rag[msn]" value="1" <?php if ($short) echo "checked='checked'"; ?>/></td></tr>
             <tr> 
                   <td>Verkn&uuml;pfung</td>
                   <td>UND&nbsp;&nbsp;&nbsp;
@@ -244,18 +249,31 @@
     
     	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
     
-        $sql = "SELECT rg.abt_ID,rag_bez,geb_ID, raum_nr, r.raumtyp_ID, ra.arbplatz_typ, a.gefahr_ID,asm_bez, raum_name, raumtyp_bez, arbplatz_typ_bez, gefahr_bez, 
-                 asm_bem, gf_asm_nr, abt_name,asm_ID, r.raum_ID,rg.rag_ID  
-                FROM RaumArb_Gruppe rg 
-                    LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
-                    LEFT OUTER JOIN Abteilung abt ON rg.abt_ID=abt.abt_ID 
-                    LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
-                    LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
-                    LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
-                    LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
-                    LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
-                    LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID
-                    LEFT OUTER JOIN AS_Massnahme m ON a.gefahr_ID = m.gefahr_ID";
+        if ($short)
+            $sql = "SELECT rg.abt_ID,rag_bez,geb_ID, raum_nr, r.raumtyp_ID, ra.arbplatz_typ, a.gefahr_ID, raum_name, raumtyp_bez, arbplatz_typ_bez, gefahr_bez, 
+                     abt_name, r.raum_ID,rg.rag_ID  
+                    FROM RaumArb_Gruppe rg 
+                        LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
+                        LEFT OUTER JOIN Abteilung abt ON rg.abt_ID=abt.abt_ID 
+                        LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+                        LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
+                        LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
+                        LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID";
+        else
+            $sql = "SELECT rg.abt_ID,rag_bez,geb_ID, raum_nr, r.raumtyp_ID, ra.arbplatz_typ, a.gefahr_ID,asm_bez, raum_name, raumtyp_bez, arbplatz_typ_bez, gefahr_bez, 
+                     asm_bem, gf_asm_nr, abt_name,asm_ID, r.raum_ID,rg.rag_ID  
+                    FROM RaumArb_Gruppe rg 
+                        LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
+                        LEFT OUTER JOIN Abteilung abt ON rg.abt_ID=abt.abt_ID 
+                        LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+                        LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
+                        LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
+                        LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID
+                        LEFT OUTER JOIN AS_Massnahme m ON a.gefahr_ID = m.gefahr_ID";
         $lim = " LIMIT $start,$zeil";
         
         if (!$rag["bind"]) $bind = " AND "; else $bind = $rag["bind"];
@@ -307,22 +325,35 @@
     		$bg2 = "#DEDFE1";
     		$bg = "#FFFFFF";
 
+            if ($short)
             $sqlc = "SELECT COUNT(*)
                         FROM RaumArb_Gruppe rg 
-                    LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
-                    LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
-                    LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
-                    LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
-                    LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
-                    LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
-                    LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID
-                    LEFT OUTER JOIN AS_Massnahme m ON a.gefahr_ID = m.gefahr_ID $where";
+                            LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
+                            LEFT OUTER JOIN Abteilung abt ON rg.abt_ID=abt.abt_ID 
+                            LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+                            LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
+                            LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
+                            LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
+                            LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
+                            LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID $where";
+            else
+                $sqlc = "SELECT COUNT(*)
+                            FROM RaumArb_Gruppe rg 
+                        LEFT OUTER JOIN Raum_RaumArbGruppe rr ON rg.rag_ID=rr.rag_ID
+                        LEFT OUTER JOIN Raum r ON rr.raum_ID=r.raum_ID
+                        LEFT OUTER JOIN Raum_Typ rt ON r.raumtyp_ID = rt.raumtyp_ID
+                        LEFT OUTER JOIN Raum_Arbplatz_Typ ra ON ra.raum_ID = r.raum_ID
+                        LEFT OUTER JOIN Arbplatz_Typ at ON ra.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr_Arbplatz a ON a.arbplatz_typ = at.arbplatz_typ
+                        LEFT OUTER JOIN Gefahr g ON a.gefahr_ID = g.gefahr_ID
+                        LEFT OUTER JOIN AS_Massnahme m ON a.gefahr_ID = m.gefahr_ID $where";
             $ianz = $dbc -> querySingleItem($sqlc);
 
             //$ianz = $dbc -> numrows($sql); //liefert nur $zeil!
             printf ("<p>Anzahl gefundener Datensätze: %s</p>", $ianz);
             
-            echo "<table width='99%' border='1' cellspacing='0' cellpadding='2'>\n";
+            if ($short) $width = "'80%'"; else $width="'99%'";
+            echo "<table width=$width border='1' cellspacing='0' cellpadding='2'>\n";
             $cols=7;
             // Listenkopf
             echo "<tr bgcolor='#68ACBF'>";
@@ -346,8 +377,11 @@
             }    
             echo "<th>Arb.-Platz-Typ</th>";
             echo "<th>Gef&auml;hrdung</th>";
-            echo "<th>Ma&szlig;nahme-Bez.</th>";
-            echo "<th width='40%'>Ma&szlig;nahme</th>";
+            if (!isset($short) && !$short)
+            {
+                echo "<th>Ma&szlig;nahme-Bez.</th>";
+                echo "<th width='40%'>Ma&szlig;nahme</th>";
+            }
             echo "</tr>";
 
             foreach ($result as $row)
@@ -365,8 +399,12 @@
                     if ($rag["bind"]=="OR" || !$rag['rtyp'] || $rag['rtyp'] == -1) echo "<td>$row->raumtyp_ID - $row->raumtyp_bez</td>";
                     echo "<td>$row->arbplatz_typ - $row->arbplatz_typ_bez</td>";
                     echo "<td>$row->gefahr_ID - $row->gefahr_bez</td>";
-                    echo "<td>$row->asm_bez</td>";
-                    echo "<td>".nl2br($row->asm_bem)."</td></tr>\n";
+                    if (!isset($short) && !$short)
+                    {
+                        echo "<td>$row->asm_bez</td>";
+                        echo "<td>".nl2br($row->asm_bem)."</td>";
+                    }
+                    echo "</tr>\n";
                 }
                 elseif ($rid == $row->raum_ID && $apt != $row->arbplatz_typ)
                 {
@@ -374,23 +412,35 @@
                     echo "<td colspan ='".($cols-4)."'>&nbsp;</td>";
                     echo "<td>$row->arbplatz_typ - $row->arbplatz_typ_bez</td>";
                     echo "<td>$row->gefahr_ID - $row->gefahr_bez</td>";
-                    echo "<td>$row->asm_bez</td>";
-                    echo "<td>".nl2br($row->asm_bem)."</td></tr>\n";
+                    if (!isset($short) && !$short)
+                    {
+                        echo "<td>$row->asm_bez</td>";
+                        echo "<td>".nl2br($row->asm_bem)."</td>";
+                    }
+                    echo "</tr>\n";
                 }
                 elseif ($rid == $row->raum_ID && $apt == $row->arbplatz_typ && $gfid != $row->gefahr_ID)
                 {
                     echo "<tr bgcolor='" . $bg . "'>"; 
                     echo "<td colspan ='".($cols-3)."'>&nbsp;</td>";
                     echo "<td>$row->gefahr_ID - $row->gefahr_bez</td>";
-                    echo "<td>$row->asm_bez</td>";
-                    echo "<td>".nl2br($row->asm_bem)."</td></tr>\n";
+                    if (!isset($short) && !$short)
+                    {
+                        echo "<td>$row->asm_bez</td>";
+                        echo "<td>".nl2br($row->asm_bem)."</td>";
+                    }
+                    echo "</tr>\n";
                 }
                 elseif ($gfid == $row->gefahr_ID && $asmid != $row->asm_ID)
                 {
                     echo "<tr bgcolor='" . $bg . "'>"; 
                     echo "<td colspan ='".($cols-2)."'>&nbsp;</td>";
-                    echo "<td>$row->asm_bez</td>";
-                    echo "<td>".nl2br($row->asm_bem)."</td></tr>\n";
+                    if (!isset($short) && !$short)
+                    {
+                        echo "<td>$row->asm_bez</td>";
+                        echo "<td>".nl2br($row->asm_bem)."</td>";
+                    }
+                    echo "</tr>\n";
                     
                 }
                 $ragid  = $row->rag_ID;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/rag_raum_rt_ma_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,288 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * Report Raum-Arb.-Gruppen, Abteilung, Raeume + Raumtyp, Mitarbeiter
+ * $_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 Arbeitsgruppen: Raum+Raumtyp, Mitarbeiter</title>
+</head>
+
+<body>
+
+<?php    
+    echo "&nbsp;";  
+    if (!isset($_GET['s']) || $_GET['s'] != 2 )
+    {
+        echo "<div class=\"float-br smaller\" valign='top'>";
+        echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+        echo "&nbsp;&nbsp;&nbsp;<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["rtyp"]   = $_GET["t"];
+        $rag["bind"]    = $_GET["b"];
+        $rag["sort1"]   = $_GET["s1"];
+        $rag["sort2"]   = $_GET["s2"];
+    }
+    $_GET["a"] = $rag["abt"];
+    $_GET["t"] = $rag["rtyp"];
+    $_GET["b"] = $rag["bind"];
+    $_GET["s1"] = $rag["sort1"];
+    $_GET["s2"] = $rag["sort2"];
+    $_GET["z"]  = $zeil;
+   
+    if ($search && $_GET['s'] != 2)
+    {    
+        echo "<span class='sc'>";
+        echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/as_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+        echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"AG-Raum-MA\" class=\"sc\">neuer Arbeitsgruppe - Raum+Raumtyp, Mitarbeiter Bericht</a>\n";    
+            echo "</span>";
+        echo "</span>";
+    }
+    echo "<div align='center'>\n";
+    echo "<p><b>(2a) Bericht Arbeitsgruppe - Raum+Raumtyp, Mitarbeiter</b></p>\n";
+    echo "</div>\n";
+    
+
+    if (!$search)
+    {
+?>
+        <div align="center">
+        <p>Bitte Kriterien f&uuml;r die Suche w&auml;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 WHERE abt_ID < 8 ORDER BY 1";
+                        if ($result = $dbc->queryObjectArray($sql))
+                        {
+                            foreach ($result as $row)
+                            {
+                                if ($row->abt_ID == $rag['abt'])
+            					   echo "<option selected value=\"'$row->abt_name'\">$row->abt_name - $row->abt_long</option>\n";
+            				    else
+            					   echo "<option value=\"'$row->abt_name'\">$row->abt_name - $row->abt_long</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_bez'\">$row->raumtyp_bez</option>\n";
+        				    else
+        					   echo "<option value=\"'$row->raumtyp_bez'\">$row->raumtyp_bez</option>\n";
+                        }
+                    }
+                ?>
+                </select></td>
+            </tr>
+            <tr> 
+                  <td>Verkn&uuml;pfung</td>
+                  <td>UND&nbsp;&nbsp;&nbsp;
+                    <input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else  echo "checked";?>>
+                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODER&nbsp;&nbsp;&nbsp;
+                    <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"=>"Arbeitsgruppe","3,2"=>"Abteilung+AG","4"=>"Raum");
+                for ($i=1; $i<3; $i++)
+                { 
+                  echo "$i.&nbsp;&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;\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>&nbsp;</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["rtyp"] == -1) $rag["rtyp"] = "''";
+        if ($rag["abt"] == -1) $rag["abt"] = "''";
+        
+        if ($rag["sort1"]>0 || $rag["sort2"]>0)
+        {
+            if ($rag["sort1"]>0) $sort  = $rag["sort1"];
+            if ($rag["sort1"]>0 && $rag["sort2"]>0) $sort .= ",".$rag["sort2"];
+            elseif ($rag["sort1"]<0 && $rag["sort2"]>0) $sort = $rag["sort2"];
+        }
+        
+        $sql = "CALL raumarbgruppe_rtyp_report('$sort','',".$rag["abt"]. "," .$rag["rtyp"].",'$bind',$start,$zeil,@anz)";        
+//        echo "sql = $sql<br />\n";
+        $result = $dbc ->queryObjectArray($sql);
+        
+        if ($rag["abt"] > "''")
+        { 
+            $krit = " [Abteilung = '".$rag["abt"]."']";
+        }
+        if ($rag["rtyp"] > "''")
+        { 
+            if ($krit) $bd = " ".$bind; else $bd = "";
+            $rtn = $dbc -> querySingleItem("SELECT raumtyp_bez FROM Raum_Typ WHERE raumtyp_ID='".$rag["rtyp"]."'");
+            $krit .= $bd." [Raum-Typ = '".$rag["rtyp"]."']";
+        }
+        if ($krit )echo "Suchergebnis f&uuml;r $krit"; else echo "Suchergebnis\n";
+        $ianz = $dbc -> querySingleItem("SELECT @anz");
+        printf ("<p>Anzahl gefundener Arbeitsgruppen: %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'] == "''") echo "<th>Abteilung</th>";
+            echo "<th>Arbeitsgruppe</th>";
+            echo "<th>R&auml;ume [Raumtyp]</th>";
+            echo "<th>Mitarbeiter</th>";
+            echo "</tr>\n";
+
+            foreach ($result as $row)
+            {
+                    if ($rid) echo "</td></tr>\n"; 
+        			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                    echo "<tr bgcolor='" . $bg . "'>"; 
+                    if (!$rag['abt'] || $rag['abt'] == "''") echo "<td>$row->abt_name";
+                    if (strpos($row->rag_bez,"DynamiX")) $row->rag_bez = str_replace("X","&chi;",$row->rag_bez);
+                    echo "<td>$row->rag_bez</td>";
+                    echo "<td>". str_replace(";","<br />",$row->raeume)."</td>";
+                    echo "<td>". str_replace(";","<br />",$row->ma)."</td></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 />&nbsp;&nbsp;&nbsp;";
+            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'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
+            echo "</div>\n";
+            echo "<br />&nbsp;&nbsp;&nbsp;";
+        }
+        if ($search != 2)
+        {    
+            echo "<span class='sc'>";
+            echo "<br /><br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/as_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+            echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"AG-Raum-MA\" class=\"sc\">neuer Arbeitsgruppe - Raum+Raumtyp, Mitarbeiter Bericht</a>\n";    
+            echo "</span>";
+        }
+        else
+            echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zur&uuml;ck'; return true;}\">&laquo; Zur&uuml;ck</a>";
+    }
+
+?>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/raum_dez_anl_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,301 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 12/2012
+ *
+ * Report dezentrale Anlagen
+ * $_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("ddr",$_SESSION["recht"]) && !in_array("dde",$_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 Betrieb dez. Anlagen</title>
+</head>
+
+<body>
+<?php
+    echo "&nbsp;";  
+    if (!isset($_GET['s']) || $_GET['s'] != 2 )
+    {
+        echo "<div class=\"float-br smaller sc\" valign='top'>";
+        echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+        echo "&nbsp;&nbsp;&nbsp;<a href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+        echo "<div class=\"float-r sc\"><img src=\"/fhiiqm/img/house.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["rnum"]   = $_GET["r"];
+        $rag["rtyp"]   = $_GET["t"];
+        $rag["bind"]    = $_GET["b"];
+        $rag["sort1"]   = $_GET["s1"];
+    }
+/*
+    $_GET["g"] = $rag["geb"];
+    $_GET["r"] = $rag["rnum"];
+    $_GET["t"] = $rag["rtyp"];
+    $_GET["b"] = $rag["bind"];
+    $_GET["s1"] = $rag["sort1"];
+    $_GET["z"]  = $zeil;
+*/   
+    if ($search && $_GET['s'] != 2)
+    {    
+        echo "<span class='sc'>";
+        echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+        echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Report Raum dez. Anlagen\" class='sc'>neuer Bericht Betrieb dezentrale Anlagen</a>\n";    
+        echo "</span>";
+    }
+    echo "<div align='center'>\n";
+    echo "<p class='sc'><b>Betrieb dezentrale Anlagen</b></p>\n";
+    echo "</div>\n";
+    
+
+    if (!$search)
+    {
+?>
+        <div align="center">
+        <p>Bitte Kriterien f&uuml;r die Suche w&auml;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" onchange="this.form.submit();">
+                    <?php 
+                        if ($rag["geb"] == "") $select = " selected "; else $select = "";
+                        echo "<option $select value=\"\"></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>Raum-Nummer</td>
+                <td><select name="rag[rnum]">
+                    <?php 
+                        if ($rag["rnum"] == "0") $select = " selected "; else $select = "";
+                        echo "<option $select value=\"0\"></option>\n";
+                        if (isset($rag["geb"]) && $rag["geb"] > "") $where = " WHERE geb_ID = '".$rag["geb"]."'"; else $where = "";
+                        echo "Gebaeude: ".$rag["geb"]."<br />\n";
+                        $sql = "SELECT geb_ID, raum_ID,raum_nr,raum_name FROM fhiiqm.Raum $where ORDER BY 1,3";
+                        if ($result = $dbc->queryObjectArray($sql))
+                        {
+                            foreach ($result as $row)
+                            {
+                                if ($row->raum_ID == $rag['rnum'])
+            					   echo "<option selected value=\"$row->raum_ID\">$row->geb_ID - $row->raum_nr, $row->raum_name</option>\n";
+            				    else
+            					   echo "<option value=\"$row->raum_ID\">$row->geb_ID - $row->raum_nr, $row->raum_name</option>\n";
+                            }
+                        }
+                    ?>
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td>Raumtyp</td>
+                <td><select name="rag[rtyp]">
+                <?php 
+                    if ($rag["rtyp"] == "") $select = " selected "; else $select = "";
+                    echo "<option $select value=\"\"></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&uuml;pfung</td>
+                  <td>UND&nbsp;&nbsp;&nbsp;
+                    <input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else  echo "checked";?>>
+                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODER&nbsp;&nbsp;&nbsp;
+                    <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"=>"Geb&auml;ude, Raum-Nr.","2"=>"Raum-Nr., Geb&auml;ude","5"=>"Raum-Typ, Geb&auml;ude, Raum-Nr.");
+                for ($i=1; $i<2; $i++)
+                { 
+                  echo "<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>&nbsp;&nbsp;&nbsp;&nbsp;\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>&nbsp;</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["geb"]>"!") $krit = " [Geb&auml;ude = '" . $rag["geb"] ."']";
+        if ($krit) $bd = " ".$rag["bind"]; else $bd = "";
+        if ($rag["rnum"])
+        { 
+            $rnr = $dbc -> querySingleItem("SELECT raum_nr FROM Raum WHERE raum_ID = ". $rag["rnum"]);    
+            $krit .= $bd. " [Raum-Nr. = '$rnr']";
+        }
+        $bd = ($krit)? (" ".$rag["bind"]) : " ";
+        if ($rag["rtyp"]) $krit .= $bd . " [Raumtyp = '".$rag["rtyp"]."']";
+        
+        $sql = "CALL raum_vma_tel_laser_report('".$rag["sort1"]."','".$rag["bind"]."','".$rag["geb"]."','".$rag["rnum"]."','".$rag["rtyp"]."',$start,$zeil,@anz)";
+
+        $result = $dbc -> queryObjectArray($sql);
+        if ($result)
+        {
+//            print_r ($result);   
+            echo "<p class='sc'>$krit</p>";
+            $begin = 0;
+            foreach ($result as $row)
+            {
+                if ($begin) echo "<p style=\"page-break-before:always\">&nbsp;</p>";
+                echo "<h3>Dauerbetrieb</h3>\n";
+                echo "<table width='90%' border='1' frame='box' rules='rows' cellspacing='2' cellpadding='10'>\n";
+                echo "<tr><td width='25%'>Geb&auml;ude: <b>$row->geb_ID</b></td><td width='40%'>Raum-Nr.: <b>$row->raum_nr</b>
+                        $row->raum_name [$row->raumtyp_bez]</td>";
+                echo "<td width='35%'>Apparaturen:</td></tr>\n";
+                echo "<tr><td>Feuerwehr, Notarzt:</td><td colspan='2'>112</td></tr>\n";
+                echo "<tr><td>Polizei:</td><td colspan='2'>110</td></tr>\n";
+                echo "<tr><td colspan='2'><b>Besondere Gefahren:</b></td><td><b>Bemerkungen:</b></td></tr>\n";
+                if ($row->laser > "!")
+                    echo "<td>Ger&auml;te</td><td>Laser: ".str_replace(";","<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$row->laser).
+                        "</td></td><td>&nbsp;</td></tr>\n";
+                else
+                    echo "<td colspan='2'>Ger&auml;te</td><td>&nbsp;</td></tr>\n";
+                echo "<td colspan='2'>Gefahrstoffe</td><td>&nbsp;</td></tr>\n";
+                echo "<tr><td colspan='3'><b>Abschaltung:</b></td></tr>\n";
+                echo "<tr><td>Strom:</td><td colspan='2'>Gas:</td></tr>\n";
+                echo "<tr><td>Wasser:</td><td colspan='2'>Druckluft:</td></tr>\n";
+                echo "<tr><td colspan='3'><b>Bei Störungen zu benachrichtigen:</b></td></tr>\n";
+                if ($row->vmatel>"!")
+                {
+                    $vpnr = 0;                    
+                    $mat = explode(";",$row->vmatel);   //persknr:MA|tel
+                    $first = true;
+                    foreach ($mat as $ma)
+                    {
+                        $pnr = substr($ma,0,strpos($ma,":"));
+                        $tel = substr($ma,strpos($ma,"|")+1);
+                        $nam = substr($ma,strpos($ma,":")+1,strlen($ma)-strlen($pnr)-strlen($tel)-2);
+                        if ($pnr != $vpnr)
+                        {
+                            if (!$first) echo "</td></tr>\n";
+                            echo "<tr><td>$nam</td><td colspan='2'>Telefon: $tel";
+                        }
+                        else echo ", $tel";
+                        $vpnr = $pnr;
+                        $first = false;
+                    }
+                }
+                else echo "<tr><td colspan='3'>&nbsp;</td></tr>\n";
+                echo "</table>\n";
+                echo "<p>Innerbetrieblicher Notdienst:   Telefonzentrale: <b>9</b>,   nachts/Wochenende: <b>4444</b> oder <b>3637</b></p>\n";
+                $begin = 1;
+            }
+
+            echo "<p></p><table width=99%><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>";
+            
+        }
+        else echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
+        
+        echo "</div>\n";
+        if ($search != 2)
+        {    
+            echo "<span  class=\"sc\">";
+            echo "<br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+            echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Report Raum dez. Anlagen\">neuer Bericht Betrieb dezentrale Anlagen</a></span>\n";
+        }
+        else
+            echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zur&uuml;ck'; return true;}\">&laquo; Zur&uuml;ck</a>";
+    }
+
+?>
+
+</body>
+</html>
\ No newline at end of file
--- a/fhiiqm/report/raum_ohne_rag_report.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/report/raum_ohne_rag_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -4,7 +4,7 @@
  * @author Bettina Schwarzer, Fritz-Haber-Institut
  * @copyright 08/2012
  * 
- * Report Raeume, Raumtyp, Aptyp
+ * Report Raeume, Raumtyp, Aptyp ohne Zuordnung Arbeitsgruppe
  * 
  * 
  */
@@ -90,7 +90,7 @@
         echo "</span>";
     }
     echo "<div align='center'>\n";
-    echo "<p><b>(1a) Bericht R&auml;ume ohne Arbeitsgruppen-Zuordnung </b></p>\n";
+    echo "<p><b>(1b) Bericht R&auml;ume ohne Arbeitsgruppen-Zuordnung </b></p>\n";
     echo "</div>\n";
     
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/raum_vma_report.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,290 @@
+<?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 "&nbsp;";  
+    if (!isset($_GET['s']) || $_GET['s'] != 2 )
+    {
+        echo "<div class=\"float-br smaller\" valign='top'>";
+        echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
+        echo "&nbsp;&nbsp;&nbsp;<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 />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+        echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"R&auml;ume Verantwortliche\" class=\"sc\">neuer Bericht R&auml;ume und Verantwortliche</a>\n";    
+        echo "</span>";
+    }
+    echo "<div align='center'>\n";
+    echo "<p><b>Bericht R&auml;ume und Verantwortliche (Labore und Technik)</b></p>\n";
+    echo "</div>\n";
+    
+
+    if (!$search)
+    {
+?>
+        <div align="center">
+        <p>Bitte Kriterien f&uuml;r die Suche w&auml;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&uuml;pfung</td>
+                  <td>UND&nbsp;&nbsp;&nbsp;
+                    <input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else  echo "checked";?>>
+                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODER&nbsp;&nbsp;&nbsp;
+                    <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&auml;ude","3"=>"Raum-Nr.","5"=>"Raum-Typ");
+                for ($i=1; $i<4; $i++)
+                { 
+                  echo "$i.&nbsp;&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;\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>&nbsp;</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&auml;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&uuml;r $krit"; else echo "Suchergebnis\n";
+        $ianz = $dbc -> querySingleItem("SELECT @anz");
+        printf ("<p>Anzahl gefundener R&auml;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&auml;ude</th>";
+            echo "<th>Raum-Nr.</th>";
+            echo "<th>Raum-Bezeichnung</th>";
+            if ($rag['rtyp'] == -1) echo "<th>Raum-Typ</th>";
+            echo "<th>Fl&auml;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 />&nbsp;&nbsp;&nbsp;";
+            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'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
+            echo "</div>\n";
+            echo "<br />&nbsp;&nbsp;&nbsp;";
+        }
+        if ($search != 2)
+        {    
+            echo "<span class='sc'>";
+        echo "<br /><br />&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/raum_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>&laquo; zur Berichts&uuml;bersicht</a>";
+        echo "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"R&auml;ume Verantwortliche\" class=\"sc\">neuer Bericht R&auml;ume und Verantwortliche</a>\n";    
+            echo "</span>";
+        }
+        else
+            echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zur&uuml;ck'; return true;}\">&laquo; Zur&uuml;ck</a>";
+    }
+
+?>
+
+</body>
+</html>
\ No newline at end of file
--- a/fhiiqm/start.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/start.php	Fri Dec 21 15:31:50 2012 +0100
@@ -33,16 +33,16 @@
     
     include_once($_SERVER["DOCUMENT_ROOT"] . "/fhiiqm/inc/menu.inc.php");
     
-    echo "<p><br />&nbsp;&nbsp;&nbsp;<a href='/fhiiqm/infos/123_fhiiqm_anwenderdoc.pdf' title='Anwenderdokumentaion' target='_blank'>Anwender-Dokumentation</a></p>";
-    if (date("Y-m-d") < date("Y-m-d", mktime(0,0,0,12,25,2011)))
+    echo "<p><br />&nbsp;&nbsp;&nbsp;<a href='/fhiiqm/infos/123_fhiiqm_anwenderdoc.pdf' title='Anwenderdokumentaion' target='_blank'>Anwender-Dokumentation</a></p>\n";
+    if (date("Y-m-d") < date("Y-m-d", mktime(0,0,0,12,25,2012)))
     {
         echo "<p>&nbsp;</p><p class='red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
             <img src='/fhiiqm/img/weihnachtsmann.gif' height='75' />";
         $heute = new DateTime();
-        $weih = new DateTime('2011-12-24');
+        $weih = new DateTime('2012-12-24');
         $tage = $weih -> diff($heute)->days+1;
         if ($tage <2) $tag = "Tag"; else $tag="Tage";
-        echo "noch $tage $tag bis <em>Weihnachten</em>!</p>";
+        echo "<span class='valignt red bigger'>noch <b>$tage</b> $tag bis <em>Weihnachten</em>!</span></p>\n";
     }
 
 ?>
--- a/fhiiqm/tel_ed.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/tel_ed.php	Fri Dec 21 15:31:50 2012 +0100
@@ -17,7 +17,7 @@
         exit;
     }
     
-    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("fmr",$_SESSION["recht"]) && !in_array("fme",$_SESSION["recht"])))
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("mtr",$_SESSION["recht"]) && !in_array("mte",$_SESSION["recht"])))
     {
         header("Location: start.php");
         exit;
@@ -188,7 +188,7 @@
 			        if ($ok)  echo "checked=\"checked\""; 
 			echo " /></td>\n</tr>\n";
         }
-        if (!is_null($_SESSION["recht"]) && in_array("fme",$_SESSION["recht"]))
+        if (!is_null($_SESSION["recht"]) && in_array("mte",$_SESSION["recht"]))
         {
             echo "
            	<tr><td>&nbsp;</td>\n
@@ -230,7 +230,7 @@
             $stmt = $dbc -> stmtinit();
             if (is_object($stmt))
             {
-                if ($tf["raum"] == "-1") $tf["raum"] = 'NULL'; 
+                if ($tf["raum"] == "-1") $tf["raum"] = null; 
                 if ($tid) //UPDATE
                 {
                     $stmt -> prepare("UPDATE Telefon SET
--- a/fhiiqm/tel_flist.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/tel_flist.php	Fri Dec 21 15:31:50 2012 +0100
@@ -19,8 +19,7 @@
         exit;
     }
     
-    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("fmr",$_SESSION["recht"]) && !in_array("fme",$_SESSION["recht"])
-         && !in_array("ddr",$_SESSION["recht"]) && !in_array("dde",$_SESSION["recht"])))
+    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("mtr",$_SESSION["recht"]) && !in_array("mte",$_SESSION["recht"])))
     {
         header("Location: start.php");
         exit;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/fpdf_create.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,259 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * pdf-Dokument erstellen
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    include ($_SERVER['DOCUMENT_ROOT']."/fhiiqm/tool/fpdf.php");
+    class PDF extends FPDF
+    {
+        //Cell with horizontal scaling if text is too wide
+        function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true)
+        {
+            //Get string width
+            $str_width=$this->GetStringWidth($txt);
+            // Division by 0 avoid, 21.11.2012, bs
+            if ($str_width == 0) $str_width = 0.1;
+    
+            //Calculate ratio to fit cell
+            if($w==0)
+                $w = $this->w-$this->rMargin-$this->x;
+            $ratio = ($w-$this->cMargin*2)/$str_width;
+    
+            $fit = ($ratio < 1 || ($ratio > 1 && $force));
+            if ($fit)
+            {
+                if ($scale)
+                {
+                    //Calculate horizontal scaling
+                    $horiz_scale=$ratio*100.0;
+                    //Set horizontal scaling
+                    $this->_out(sprintf('BT %.2F Tz ET',$horiz_scale));
+                }
+                else
+                {
+                    //Calculate character spacing in points
+                    $char_space=($w-$this->cMargin*2-$str_width)/max($this->MBGetStringLength($txt)-1,1)*$this->k;
+                    //Set character spacing
+                    $this->_out(sprintf('BT %.2F Tc ET',$char_space));
+                }
+                //Override user alignment (since text will fill up cell)
+                $align='';
+            }
+    
+            //Pass on to Cell method
+            $this->Cell($w,$h,$txt,$border,$ln,$align,$fill,$link);
+    
+            //Reset character spacing/horizontal scaling
+            if ($fit)
+                $this->_out('BT '.($scale ? '100 Tz' : '0 Tc').' ET');
+        }
+    
+        //Cell with horizontal scaling only if necessary
+        function CellFitScale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,false);
+        }
+    
+        //Cell with horizontal scaling always
+        function CellFitScaleForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,true);
+        }
+    
+        //Cell with character spacing only if necessary
+        function CellFitSpace($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,false);
+        }
+    
+        //Cell with character spacing always
+        function CellFitSpaceForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+        {
+            //Same as calling CellFit directly
+            $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,true);
+        }
+    
+        //Patch to also work with CJK double-byte text
+        function MBGetStringLength($s)
+        {
+            if($this->CurrentFont['type']=='Type0')
+            {
+                $len = 0;
+                $nbbytes = strlen($s);
+                for ($i = 0; $i < $nbbytes; $i++)
+                {
+                    if (ord($s[$i])<128)
+                        $len++;
+                    else
+                    {
+                        $len++;
+                        $i++;
+                    }
+                }
+                return $len;
+            }
+            else
+                return strlen($s);
+        }
+
+        //Kopfzeile
+        function Header()
+        {
+            global $header;
+            //$this->Cell(20);
+            //Titel
+            //Arial fett 15
+            $this->SetFont('Arial','BI',11);
+            $this->Cell(55,10,'Fritz-Haber-Institut',0,0,'L');
+            $this->SetFont('Arial','B',11);
+            $this->Cell(40,10,'Telefonverzeichnis',0,0,'L');
+            $this->SetTextColor(255,0,0);
+            $this->Cell(0,10,'(intern)',0,0,'L');
+            //Logo
+            $this->Image($_SERVER['DOCUMENT_ROOT']."/fhiiqm/img/fhilogotransp.png",170,8,25);
+            //Zeilenumbruch
+            $this->Ln(20);
+            //Colors, line width and bold font
+            $this->SetFont('helvetica','',8);
+            $this->SetFillColor(104,172,191);
+            $this->SetTextColor(0,0,102);
+            $this->SetDrawColor(255,255,255);
+            $this->SetLineWidth(.0);
+            $this->SetFont('','B');
+            //Tabellen-Header immer im Kopf
+            $w=array(55,40,30,15,40);
+            for($i=0;$i<count($header);$i++)
+                $this->Cell($w[$i],5,$header[$i],1,0,'L',1);
+            $this->Ln();
+        }
+        
+        //Fusszeile
+        function Footer()
+        {
+            //Position 1,5 cm von unten
+            $this->SetY(-15);
+            //Arial kursiv 8
+            $this->SetFont('Arial','I',8);
+            //Datum der Liste
+            $heute = new DateTime();
+            $this->Cell(0,10,$heute->format('d.m.Y H:i:s'),0,0,'L');
+            //Seitenzahl
+            $this->Cell(0,10,'Seite '.$this->PageNo().'/{nb}',0,0,'R');
+        }
+        //Colored table
+        function FancyTable($header,$data)
+        {
+
+            //Colors, line width and bold font
+            $this->SetFillColor(104,172,191);
+            $this->SetTextColor(0,0,102);
+            $this->SetDrawColor(255,255,255);
+            $this->SetLineWidth(.0);
+            $this->SetFont('','B');
+
+            //Header notwendig fuer Tabelle, Hoehe = 0!
+            $w=array(55,40,30,15,40);
+            for($i=0;$i<count($header);$i++)
+                $this->Cell($w[$i],0,'',1,0,'L',1);
+            $this->Ln();
+            //Color and font restoration
+//            $this->SetFillColor(222,222,222);
+            $this->SetFillColor(238,238,238);
+            $this->SetTextColor(0);
+            $this->SetFont('');
+            //Data
+            $fill=0;
+            $fill = !$fill;
+            foreach($data as $row)
+            {
+    			if ($row->persknr != $vpnr)
+                {
+/*                    if ($newline)
+                    {
+                        $this->Cell(array_sum($w),4,'',0,'',$fill);
+                        $this->Ln();
+                        $newline = 0;
+                    } 
+*/  
+                    $fill=!$fill;
+                    $titel = ($row->titel)? ", $row->titel" : "" ;
+                    $vname = ($row->vorname)? ", $row->vorname" : "";
+                    $name = $row->name . $titel . $vname;
+/*                    $y = $this->GetY();
+                    if (strlen($row->name . $titel . $vname) > 40)
+                    {
+                        echo "name = $name<br />";
+                        $name = $row->name . $titel . "\n" . substr($vname,2);
+                        $this->MultiCell($w[0],4,$name,0,'L',$fill);
+                        $this -> SetXY($w[0]+$this->lMargin,$y);
+                        $newline = 1;
+*/
+/*                    }
+                    else
+                        $this->Cell($w[0],4,$name,'LR',0,'L',$fill);
+*/                        
+                    $this->CellFitScale($w[0],4.5,$name,0,0,'L',$fill);
+                    $this->CellFitScale($w[1],4.5,$row->abt_name,'LR',0,'L',$fill);
+                    if ($row->telefon_typ == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row->public) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row->telefon_nr.$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row->geb_ID . " " . $row->raum_nr,'LR',0,'L',$fill);
+                    $this->CellFitScale($w[4],4.5,$row->email,'LR',0,'L',$fill);
+                    $this->Ln();
+                }
+                else
+                {
+                    $newline = 0;
+                    $this->Cell($w[0],4.5,'','LR',0,'L',$fill);
+                    if ($vabt != $row->abt_name) $abt = $row->abt_name;
+                    else $abt = '';    
+                    $this->CellFitScale($w[1],4.5,$abt,'LR',0,'L',$fill);
+                    if ($row->telefon_typ == "fax") $typ = " FAX"; else $typ = "";
+                    if (!$row->public) $this->SetTextColor(255,0,0); else $this->SetTextColor(0,0,136); 
+                    $this->CellFitScale($w[2],4.5,$row->telefon_nr.$typ,'LR',0,'L',$fill);
+                    $this->SetTextColor(0);
+                    $this->CellFitScale($w[3],4.5,$row->geb_ID . " " . $row->raum_nr,'LR',0,'L',$fill);
+                    $this->Cell($w[4],4.5,'','LR',0,'L',$fill);
+                    $this->Ln();
+                    
+                }
+                $vpnr = $row->persknr;
+                $vabt = $row->abt_name;
+            }
+//            $this->Cell(array_sum($w),0,'','T');
+        }
+    }
+
+//    $pdf = new FPDF();
+    $header=array('Name','Abteilung','Tel/Fax','Raum','E-Mail');
+    $pdf = new PDF();
+    $pdf->SetLeftMargin(25);
+    $pdf->AddPage();
+    $pdf->AliasNbPages();
+/*
+    $pdf->SetFont('Arial','B',16);
+    $pdf->Cell(40,10,'Hallo Du!',0,1);
+    $pdf->SetFont('courier','i',12);
+    $pdf->Cell(100,10,'Dieser Text ist mit fpdf erstellt worden.',0,1);
+*/    
+    // Telefonliste
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+//    include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+
+	$dbc = new dbconnection();
+    $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email FROM v_tel_list 
+            ORDER BY 2,3,5,6";
+    $result = $dbc ->queryObjectArray($sql);
+    $pdf->SetFont('helvetica','',9);
+
+    $pdf->FancyTable($header,$result);
+    $pdf->Output();
+
+?>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/ma_tel_flist_mysql.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,248 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * Telefonliste für FHI-Seite nach aussen
+ * 
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+
+    function tab_column($colnum=2,$bez,$sort,$dir,$fcol=0,$fanr=0,$filtb="",$start="",$anzds="25",$id="",$g=0,$tab="",$adr="")
+    {
+      /** beliebige Tabellenspalte mit Sortier-/Filtersymbolen und Links generieren
+        * Parameter
+        * $colnum   SpaltenNr. in SELECT-Statement 
+        * $bez      Spaltenbezeichnung
+        * $sort     aktuelle SortspaltenNr.
+        * $dir      Sortrichtung (ASC/DESC)
+        * $fcol     SpaltenNr. Filter (=0, wenn nicht gefiltert werden soll)
+        * $fanr     aktuelle FilterspaltenNr.
+        * $filtb    Filterbegriff
+        * $start    ab Datensatz $start+1
+        * $anzds    Anzahl angezeigter Datensaetze
+        * $id       fuer spezielle ID als zusaetzl. Filter (Laser-Log)
+        * $g        Gesamtansicht (rag-gefahr-massnahmen-vorsorge)
+        * [$tab     fuer tab-basierte Seite
+        * $adr      wohin gehen (Teilseite)]
+        */
+        
+        if ($colnum == $sort)
+            if ($dir == 'DESC')
+            {
+                $auf = "auf";
+                $ab = "ab_activ";
+            }
+            else
+            {
+                $auf = "auf_activ";
+                $ab = "ab";
+            }
+        else
+        {
+                $auf = "auf";
+                $ab = "ab";
+        }
+        
+        if ($bez == "Haus") $tip = "Haus: A, B, BES, C, D, E, F, FAB, HAR, K, L, M, N, P, Q, R, S, T, U"; else $tip = "Filter";
+        if ($tab > "!")
+        {
+            $addr = $adr;
+            $ank = $tab; 
+        } 
+        else 
+        {
+            $addr = $_SERVER['PHP_SELF'];
+            $ank = "";
+        }
+        if ($fcol>0 && $fanr>0) // Filtern nach Spalte moeglich
+        {
+            if ($fcol == $fanr) $filt = "filter_activ"; else $filt = "filter"; 
+            $filt = "&nbsp;<a href='".$addr."$ank?f=$fcol&s=$sort&d=$dir&st=$start&z=$anzds&i=$id&g=$g'><img src='http://achilleus/fhiiqm/img/$filt.gif' border='0' width='14' hight='11' alt='$tip' title='$tip'></a>";
+        }
+        else
+            $filt="";
+        if ($filtb>'!') $where = "&f=$fanr&b=$filtb&i=$id&g=$g"; else $where="&i=$id&g=$g";
+        echo "<th align='left'>$bez&nbsp;<a href='".$addr."$ank?s=$colnum$where&st=$start&z=$anzds'><img src='http://achilleus/fhiiqm/img/$auf.gif' border='0' width='11' hight='11' alt='sort aufsteigend' title='sort aufsteigend'></a>            
+                  <a href='".$addr."$ank?s=$colnum&d=DESC$where&st=$start&z=$anzds'><img src='http://achilleus/fhiiqm/img/$ab.gif' border='0' width='11' hight='11' alt='sort absteigend' title='sort absteigend'></a>$filt</th>\n";
+    }
+
+?>
+<!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="http://www.fhi-berlin.mpg.de/fhi.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+
+	<title>MA-Telefonliste</title>
+</head>
+
+<body onload="document.ffilter.filter.focus();">
+    
+<?php
+    // Felder, nach denen gefiltert werden kann
+    $fields = array(2=>"Name",3=>"Vorname",5=>"Abteilung",6=>"Telefon/Fax",9=>"Haus", 10=>"Raum");
+//    $fieldf = array(2=>"trim(nachname)",3=>"vorname",5=>"abt_name",6=>"mt.telefon_nr",9=>"geb_ID", 10=>"raum_nr");
+    $fieldf = array(2=>"name",3=>"vorname",5=>"abt_name",6=>"telefon_nr",9=>"geb_ID", 10=>"raum_nr");
+
+	$sort   = $_GET["s"];   // Sortierung nach Spalte
+    if (!isset($sort) && !$sort) $sort = $_POST["s"];      
+
+    $dir    = $_GET["d"];   // Sortierrichtung
+    if (!isset($dir) && !$dir) $dir = $_POST["d"];
+
+    $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
+    if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
+
+    $filter = $_POST["filter"];
+    if (!isset($filter) && !$filter) $filter = $_GET["b"];   
+
+    $subf   = $_POST["subf"]; // submit
+    
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($filter) || !$filter) $filter = "";
+    if (!isset($sort) || !$sort) $sort = 2; // Name
+    if (!$dir || $dir < "!")  $dir = "";
+
+    include_once ($_SERVER["DOCUMENT_ROOT"]. "/fhiiqm/inc/conf.inc.php");
+//	include_once ("../../../../home/schwarzer/Daten/php/fhiiqm_achilleus/inc/config.inc.php");
+    $conn=mysql_connect($config["server"],$config["user"],$config["passwort"]) or die("Keine Verbindung zum SQL Server");
+    
+    $db=mysql_select_db($config["dbname"],$conn); // or die("Keine Verbindung zur DB fhiiqm");
+
+    if (mysql_errno())
+    	echo "error after connect und db select: " . mysql_errno() . ": " . mysql_error() . "<br>\n";
+    $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email FROM v_tel_list";
+    if ($filter) $wher = " WHERE " . $fieldf[$fnum] . " LIKE " . "'%$filter%'"; else $wher = "";
+    if ($sort == 2) $sort = "2, 3, 5";
+    if ($sort == 5) $sort = "5, 2, 3";
+    if ($sort) $ord = " ORDER BY $sort, 6"; // immer nach Telefon-Nr als 2.
+    $sql .= $wher . $ord;
+    if ($conn && $db)
+    {
+        $result=mysql_query($sql,$conn);
+//            echo "sql = $sql<br><br>\n";
+		
+		if ($result && mysql_num_rows($result))
+        {
+    		$bg1 = "#F8F8F8";
+    		$bg2 = "#DEDFE1";
+    		$bg = "#FFFFFF";
+            $getp = "&s=$sort&d=$dir&f=$fnum&b=$filter"; // Parameter Listenanzeige
+         
+            echo "<div align='center'>\n";
+            echo "<p><b>Mitarbeiter - Telefonliste</b></p>\n";
+            
+            echo "<table border='0' cellspacing='0'>\n";
+            echo "<tr><td class='bigger'>Mittels '<img src='http://achilleus.rz-berlin.mpg.de/fhiiqm/img/auf.gif' border='0' width='11' hight='11' />' / '<img src='http://achilleus.rz-berlin.mpg.de/fhiiqm/img/ab.gif' border='0' width='11' hight='11' />' 
+                können Sie nach bestimmten Spalten auf- bzw. absteigend sortieren</td></tr>
+                <tr><td class='bigger'>'<img src='http://achilleus.rz-berlin.mpg.de/fhiiqm/img/filter.gif' border='0' width='14' hight='11' />' erm&ouml;glicht das Filtern nach ausgew&auml;hlten Spalten der Liste</td></tr>
+                <tr><td class='bigger'>Rote Telefon-/Fax-Nummern sind nur intern erreichbar</td></tr>";
+            if ($edit)
+                echo "<tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten der Angaben</tr>";
+     
+            echo "</table>\n";
+    
+            echo "</div><p>&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/test/ma_tel_pdf_mysql.php>PDF erstellen</a></p>\n<div align='center'>\n";
+            if (isset($fnum) && $fnum>1 && !$filter && !$subf)
+            {
+                // Formular anzeigen fuer Filterbegriff
+                $text = $fields[$fnum];
+                $azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows
+                echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
+                echo "<input type='hidden' name='s' value='$sort'>";
+                echo "<input type='hidden' name='d' value='$dir'>";
+                echo "<input type='hidden' name='f' value='$fnum'>";
+                echo "<input type='hidden' name='e' value='$edit'>";
+                echo "<table width=\"45%\" border=\"0\">\n";
+                echo "<tr><td>filtern nach $text: </td>";
+                echo "<td><input id='filter' name='filter' type=\"text\" size=\"30\" maxlength=\"30\" value=\"$filter\"/></td>";
+    /*
+                echo "<td>Zeilen/Seite?   <select name='z'>\n";
+                foreach ($azeil as $key=>$val)
+                {
+                    if ($key == $zeil) $select = "selected"; else $select = "";
+                    echo "<option $select value='$key'>$val</option>\n";
+                }
+                echo "</select></td>\n";
+    */
+                echo "<td><input class=\"button\" type=\"hidden\" value=\"finden\" name=\"subf\" title=\"subf\" /></td></tr></table>\n";
+                echo "</form>\n";
+                echo "<p>&nbsp;&nbsp;&nbsp;</p>\n";
+            }
+            echo "<table width='70%'>\n";
+            
+            if ($filter>'!') echo "<tr><td class='bigger' colspan=6>Filter: ". $fields["$fnum"] . " wie '$filter'</td></tr>\n";
+    
+            // Listenkopf generieren
+            echo "<tr bgcolor='#68ACBF'>";
+            tab_column(2,"Name",$sort,$dir,2,$fnum,$filter,$start,$zeil,$edit);
+            tab_column(3,"Vorname",$sort,$dir,3,$fnum,$filter,$start,$zeil,$edit);
+            tab_column(5,"Abteilung",$sort,$dir,5,$fnum,$filter,$start,$zeil,$edit);
+            tab_column(6,"Telefon/Fax",$sort,$dir,6,$fnum,$filter,$start,$zeil,$edit);
+            tab_column(9,"Haus",$sort,$dir,9,$fnum,$filter,$start,$zeil,$edit);
+            tab_column(10,"Raum",$sort,$dir,10,$fnum,$filter,$start,$zeil,$edit);
+            if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+                echo "<th>&nbsp</th>";
+            echo "</tr>\n";
+            while ($row = mysql_fetch_assoc($result)) 
+            {
+    			if ($row["persknr"] != $vpnr)
+                {
+                    if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                    $titel = ($row["titel"])? ", ".$row["titel"] : "" ;
+                    $email = ($row->email)? "<a href='mailto:" .$row['email']. "'>" . $row['name'].$titel."</a>" : $row['name'].$titel;
+                    echo "<tr bgcolor='" . $bg . "'><td >$email</td>";    
+                    echo "<td>".$row['vorname']."</td>";
+                    echo "<td>".$row['abt_name']."</td>";
+        //            echo "<td class=\"left\">$row->telnr " . ($row->telefon_typ == 'fax')? ", " . strtoupper($row->telefon_typ) : "" . "</td>";
+                    $ttyp = ($row["telefon_typ"] == 'fax')? " " . strtoupper($row["telefon_typ"]) : "";
+                    $rot = ($row["public"])? "" : " style=\"color: red;\"";
+                    echo "<td$rot>".$row["telefon_nr"] .$ttyp."</td>";
+                    echo "<td>".$row["geb_ID"]."</td>";
+                    echo "<td>".$row["raum_nr"]."</td>";
+                    if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+                        echo "<td><a href='/fhiiqm/ma_tel_ed.php?i=$row->persknr$getp'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>";
+                    echo "</tr>\n";
+                }
+                else
+                {
+                    if ($vabt != $row["abt_name"]) $abt = $row->abt_name;
+                    else $abt = '&nbsp';    
+                    echo "<tr bgcolor='" . $bg . "'><td colspan='2'>&nbsp;</td>";    
+                    $ttyp = ($row["telefon_typ"] == 'fax')? " " . strtoupper($row["telefon_typ"]) : "";
+                    $rot = ($row["public"])? "" : " style=\"color: red;\"";
+                    echo "<td>$abt</td>";
+                    echo "<td$rot>".$row["telefon_nr"] .$ttyp."</td>";
+                    echo "<td>".$row["geb_ID"]."</td>";
+                    echo "<td>".$row["raum_nr"]."</td>";
+                    if ($edit && !is_null($_SESSION["recht"]) && in_array("fme", $_SESSION["recht"]))
+                        echo "<td>&nbsp;</td>";                
+                    echo "</tr>\n";
+                }
+                $vpnr = $row['persknr'];
+                $vabt = $row['abt_name'];
+            }
+            echo "</table></div>\n";
+            echo "<p>&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/test/ma_tel_pdf_mysql.php>PDF erstellen</a></p>\n";
+    
+        }
+        else
+        {
+            echo "<div align=center>";
+            if ($dbc -> error)  
+                echo "error: " . $dbc -> error . "<br />\n";
+            else
+            {
+                echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider nichts gefunden f&uuml;r ". $fields["$fnum"] . " wie '$filter'!</p><br />";
+                echo "&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "?$edit\" target=\"_self\" title=\"Telefonliste\" class=\"sc\">Telefonliste</a></p>\n";
+            }
+            echo "</div>";
+        }
+    }    
+?>
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/ma_tel_pdf_mysql.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,103 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 11/2012
+ * 
+ * Telefonliste als pdf erstellen
+ * 
+ */
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    include ($_SERVER['DOCUMENT_ROOT']."/fhiiqm/inc/pdf_ma_tel.inc.php");
+    include_once ($_SERVER["DOCUMENT_ROOT"]. "/fhiiqm/inc/conf.inc.php");
+//	include_once ("../../../../home/schwarzer/Daten/php/fhiiqm_achilleus/inc/config.inc.php");
+    $conn=mysql_connect($config["server"],$config["user"],$config["passwort"]) or die("Keine Verbindung zum SQL Server");
+    
+    $db=mysql_select_db($config["dbname"],$conn); // or die("Keine Verbindung zur DB fhiiqm");
+
+    if (mysql_errno())
+    	echo "error after connect und db select: " . mysql_errno() . ": " . mysql_error() . "<br>\n";
+
+    $sub = $_POST['sub'];
+    $sort = $_POST['sort'];
+    if (!$sort) $sort = $_GET['s'];
+    $abt = $_POST['abt'];
+    if (!$abt) $abt  = $_GET['a'];
+      
+    if (!$sub)
+    {
+    ?>
+        <!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="http://www.fhi-berlin.mpg.de/fhi.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> 
+        	<title>MA-Telefonliste -> PDF</title>
+         </head>
+         <body>
+         <div align="center">
+         <p><b>PDF: Mitarbeiter - Telefonliste</b></p>
+    <?php
+        echo "<form action=" . $_SERVER['PHP_SELF'] . " method='post' enctype='application/x-www-form-urlencoded' id='ffilter' name='ffilter' target='_self'>\n";
+        echo "<table width=\"30%\" border=\"0\">\n";
+        echo "<tr><td>filtern nach Abteilung</td>";
+        echo "   <td valign=\"top\">
+                 <select name=\"abt\">";
+                    echo "<option value=\"-1\"></option>\n";
+                    $sql = "SELECT abt_ID, abt_name, abt_long FROM `fhiiqm`.`Abteilung` ORDER BY abt_ID+0";
+                    if ($result = mysql_query($sql,$conn))
+                    {
+                        while ($row = mysql_fetch_assoc($result))
+                        {
+                            if ($row["abt_ID"] == $ma['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";
+                        }
+                }
+        echo "       </select></td></tr>\n";
+        echo "<tr><td>sortieren nach</td>";
+        echo "  <td><select name='sort'>";
+        echo "      <option value=\"-1\"></option>\n";
+        echo "      <option value='2'>Name</option>\n";    
+        echo "      <option value='12'>Abteilung</option>\n";    
+        echo "       </select></td></tr>\n";
+        echo "<tr><td>&nbsp;</td><td><input  class=\"button\" type=\"submit\" name=\"sub\" value=\"  pdf erstellen  \" /></td></tr>\n";
+        echo "</table>\n";
+        echo "</form>\n";
+        echo "</div>\n";
+        echo "<p><br /><br />&nbsp;&nbsp;&nbsp;<a href=/fhiiqm/test/ma_tel_flist_mysql.php>&laquo; zur Telefon-Liste</a></p>\n";
+        echo "</body></html>\n";
+    }
+    else
+    {
+        $sql = "SELECT persknr, name, vorname, titel, abt_name, telefon_nr, telefon_typ, public, geb_ID, raum_nr, email, abt_tel+0 FROM v_tel_list "; 
+    
+        if ($sort == '2') $sort = "2,3,12,5,6";
+        elseif ($sort == '12') $sort = "12,5,2,3,6";
+        else $sort = "2,3,12,5,6";
+        
+        if ($abt > '-1') $wher = " WHERE abt_tel = $abt "; else $wher = "";
+        
+        $sql .= $wher . " ORDER BY $sort";
+        $result=mysql_query($sql,$conn);
+		if ($result && mysql_num_rows($result))
+        { 
+            $header=array('Name','Abteilung','Tel/Fax','Raum','E-Mail');
+            $pdf = new PDF();
+            $pdf->SetLeftMargin(25);
+            $pdf->AddPage();
+            $pdf->AliasNbPages();
+            $pdf->SetFont('helvetica','',9);
+        
+            $pdf->FancyTableOldMySQL($header,$result);
+            $pdf->SetDisplayMode('real');
+            $pdf->Output();
+            // als Download
+//            $pdf->Output('ma_tel_list.pdf','D');
+        }
+    }
+?>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/tool/fpdf.php	Fri Dec 21 15:31:50 2012 +0100
@@ -0,0 +1,1805 @@
+<?php
+/*******************************************************************************
+* FPDF                                                                         *
+*                                                                              *
+* Version: 1.7                                                                 *
+* Date:    2011-06-18                                                          *
+* Author:  Olivier PLATHEY                                                     *
+*******************************************************************************/
+
+define('FPDF_VERSION','1.7');
+define('FPDF_FONTPATH',$_SERVER['DOCUMENT_ROOT'].'/fhiiqm/css/fpdf_font/');
+
+class FPDF
+{
+var $page;               // current page number
+var $n;                  // current object number
+var $offsets;            // array of object offsets
+var $buffer;             // buffer holding in-memory PDF
+var $pages;              // array containing pages
+var $state;              // current document state
+var $compress;           // compression flag
+var $k;                  // scale factor (number of points in user unit)
+var $DefOrientation;     // default orientation
+var $CurOrientation;     // current orientation
+var $StdPageSizes;       // standard page sizes
+var $DefPageSize;        // default page size
+var $CurPageSize;        // current page size
+var $PageSizes;          // used for pages with non default sizes or orientations
+var $wPt, $hPt;          // dimensions of current page in points
+var $w, $h;              // dimensions of current page in user unit
+var $lMargin;            // left margin
+var $tMargin;            // top margin
+var $rMargin;            // right margin
+var $bMargin;            // page break margin
+var $cMargin;            // cell margin
+var $x, $y;              // current position in user unit
+var $lasth;              // height of last printed cell
+var $LineWidth;          // line width in user unit
+var $fontpath;           // path containing fonts
+var $CoreFonts;          // array of core font names
+var $fonts;              // array of used fonts
+var $FontFiles;          // array of font files
+var $diffs;              // array of encoding differences
+var $FontFamily;         // current font family
+var $FontStyle;          // current font style
+var $underline;          // underlining flag
+var $CurrentFont;        // current font info
+var $FontSizePt;         // current font size in points
+var $FontSize;           // current font size in user unit
+var $DrawColor;          // commands for drawing color
+var $FillColor;          // commands for filling color
+var $TextColor;          // commands for text color
+var $ColorFlag;          // indicates whether fill and text colors are different
+var $ws;                 // word spacing
+var $images;             // array of used images
+var $PageLinks;          // array of links in pages
+var $links;              // array of internal links
+var $AutoPageBreak;      // automatic page breaking
+var $PageBreakTrigger;   // threshold used to trigger page breaks
+var $InHeader;           // flag set when processing header
+var $InFooter;           // flag set when processing footer
+var $ZoomMode;           // zoom display mode
+var $LayoutMode;         // layout display mode
+var $title;              // title
+var $subject;            // subject
+var $author;             // author
+var $keywords;           // keywords
+var $creator;            // creator
+var $AliasNbPages;       // alias for total number of pages
+var $PDFVersion;         // PDF version number
+
+/*******************************************************************************
+*                                                                              *
+*                               Public methods                                 *
+*                                                                              *
+*******************************************************************************/
+function FPDF($orientation='P', $unit='mm', $size='A4')
+{
+	// Some checks
+	$this->_dochecks();
+	// Initialization of properties
+	$this->page = 0;
+	$this->n = 2;
+	$this->buffer = '';
+	$this->pages = array();
+	$this->PageSizes = array();
+	$this->state = 0;
+	$this->fonts = array();
+	$this->FontFiles = array();
+	$this->diffs = array();
+	$this->images = array();
+	$this->links = array();
+	$this->InHeader = false;
+	$this->InFooter = false;
+	$this->lasth = 0;
+	$this->FontFamily = '';
+	$this->FontStyle = '';
+	$this->FontSizePt = 12;
+	$this->underline = false;
+	$this->DrawColor = '0 G';
+	$this->FillColor = '0 g';
+	$this->TextColor = '0 g';
+	$this->ColorFlag = false;
+	$this->ws = 0;
+	// Font path
+	if(defined('FPDF_FONTPATH'))
+	{
+		$this->fontpath = FPDF_FONTPATH;
+		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
+			$this->fontpath .= '/';
+	}
+	elseif(is_dir(dirname(__FILE__).'/font'))
+		$this->fontpath = dirname(__FILE__).'/font/';
+	else
+		$this->fontpath = '';
+	// Core fonts
+	$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
+	// Scale factor
+	if($unit=='pt')
+		$this->k = 1;
+	elseif($unit=='mm')
+		$this->k = 72/25.4;
+	elseif($unit=='cm')
+		$this->k = 72/2.54;
+	elseif($unit=='in')
+		$this->k = 72;
+	else
+		$this->Error('Incorrect unit: '.$unit);
+	// Page sizes
+	$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
+		'letter'=>array(612,792), 'legal'=>array(612,1008));
+	$size = $this->_getpagesize($size);
+	$this->DefPageSize = $size;
+	$this->CurPageSize = $size;
+	// Page orientation
+	$orientation = strtolower($orientation);
+	if($orientation=='p' || $orientation=='portrait')
+	{
+		$this->DefOrientation = 'P';
+		$this->w = $size[0];
+		$this->h = $size[1];
+	}
+	elseif($orientation=='l' || $orientation=='landscape')
+	{
+		$this->DefOrientation = 'L';
+		$this->w = $size[1];
+		$this->h = $size[0];
+	}
+	else
+		$this->Error('Incorrect orientation: '.$orientation);
+	$this->CurOrientation = $this->DefOrientation;
+	$this->wPt = $this->w*$this->k;
+	$this->hPt = $this->h*$this->k;
+	// Page margins (1 cm)
+	$margin = 28.35/$this->k;
+	$this->SetMargins($margin,$margin);
+	// Interior cell margin (1 mm)
+	$this->cMargin = $margin/10;
+	// Line width (0.2 mm)
+	$this->LineWidth = .567/$this->k;
+	// Automatic page break
+	$this->SetAutoPageBreak(true,2*$margin);
+	// Default display mode
+	$this->SetDisplayMode('default');
+	// Enable compression
+	$this->SetCompression(true);
+	// Set default PDF version number
+	$this->PDFVersion = '1.3';
+}
+
+function SetMargins($left, $top, $right=null)
+{
+	// Set left, top and right margins
+	$this->lMargin = $left;
+	$this->tMargin = $top;
+	if($right===null)
+		$right = $left;
+	$this->rMargin = $right;
+}
+
+function SetLeftMargin($margin)
+{
+	// Set left margin
+	$this->lMargin = $margin;
+	if($this->page>0 && $this->x<$margin)
+		$this->x = $margin;
+}
+
+function SetTopMargin($margin)
+{
+	// Set top margin
+	$this->tMargin = $margin;
+}
+
+function SetRightMargin($margin)
+{
+	// Set right margin
+	$this->rMargin = $margin;
+}
+
+function SetAutoPageBreak($auto, $margin=0)
+{
+	// Set auto page break mode and triggering margin
+	$this->AutoPageBreak = $auto;
+	$this->bMargin = $margin;
+	$this->PageBreakTrigger = $this->h-$margin;
+}
+
+function SetDisplayMode($zoom, $layout='default')
+{
+	// Set display mode in viewer
+	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
+		$this->ZoomMode = $zoom;
+	else
+		$this->Error('Incorrect zoom display mode: '.$zoom);
+	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
+		$this->LayoutMode = $layout;
+	else
+		$this->Error('Incorrect layout display mode: '.$layout);
+}
+
+function SetCompression($compress)
+{
+	// Set page compression
+	if(function_exists('gzcompress'))
+		$this->compress = $compress;
+	else
+		$this->compress = false;
+}
+
+function SetTitle($title, $isUTF8=false)
+{
+	// Title of document
+	if($isUTF8)
+		$title = $this->_UTF8toUTF16($title);
+	$this->title = $title;
+}
+
+function SetSubject($subject, $isUTF8=false)
+{
+	// Subject of document
+	if($isUTF8)
+		$subject = $this->_UTF8toUTF16($subject);
+	$this->subject = $subject;
+}
+
+function SetAuthor($author, $isUTF8=false)
+{
+	// Author of document
+	if($isUTF8)
+		$author = $this->_UTF8toUTF16($author);
+	$this->author = $author;
+}
+
+function SetKeywords($keywords, $isUTF8=false)
+{
+	// Keywords of document
+	if($isUTF8)
+		$keywords = $this->_UTF8toUTF16($keywords);
+	$this->keywords = $keywords;
+}
+
+function SetCreator($creator, $isUTF8=false)
+{
+	// Creator of document
+	if($isUTF8)
+		$creator = $this->_UTF8toUTF16($creator);
+	$this->creator = $creator;
+}
+
+function AliasNbPages($alias='{nb}')
+{
+	// Define an alias for total number of pages
+	$this->AliasNbPages = $alias;
+}
+
+function Error($msg)
+{
+	// Fatal error
+	die('<b>FPDF error:</b> '.$msg);
+}
+
+function Open()
+{
+	// Begin document
+	$this->state = 1;
+}
+
+function Close()
+{
+	// Terminate document
+	if($this->state==3)
+		return;
+	if($this->page==0)
+		$this->AddPage();
+	// Page footer
+	$this->InFooter = true;
+	$this->Footer();
+	$this->InFooter = false;
+	// Close page
+	$this->_endpage();
+	// Close document
+	$this->_enddoc();
+}
+
+function AddPage($orientation='', $size='')
+{
+	// Start a new page
+	if($this->state==0)
+		$this->Open();
+	$family = $this->FontFamily;
+	$style = $this->FontStyle.($this->underline ? 'U' : '');
+	$fontsize = $this->FontSizePt;
+	$lw = $this->LineWidth;
+	$dc = $this->DrawColor;
+	$fc = $this->FillColor;
+	$tc = $this->TextColor;
+	$cf = $this->ColorFlag;
+	if($this->page>0)
+	{
+		// Page footer
+		$this->InFooter = true;
+		$this->Footer();
+		$this->InFooter = false;
+		// Close page
+		$this->_endpage();
+	}
+	// Start new page
+	$this->_beginpage($orientation,$size);
+	// Set line cap style to square
+	$this->_out('2 J');
+	// Set line width
+	$this->LineWidth = $lw;
+	$this->_out(sprintf('%.2F w',$lw*$this->k));
+	// Set font
+	if($family)
+		$this->SetFont($family,$style,$fontsize);
+	// Set colors
+	$this->DrawColor = $dc;
+	if($dc!='0 G')
+		$this->_out($dc);
+	$this->FillColor = $fc;
+	if($fc!='0 g')
+		$this->_out($fc);
+	$this->TextColor = $tc;
+	$this->ColorFlag = $cf;
+	// Page header
+	$this->InHeader = true;
+	$this->Header();
+	$this->InHeader = false;
+	// Restore line width
+	if($this->LineWidth!=$lw)
+	{
+		$this->LineWidth = $lw;
+		$this->_out(sprintf('%.2F w',$lw*$this->k));
+	}
+	// Restore font
+	if($family)
+		$this->SetFont($family,$style,$fontsize);
+	// Restore colors
+	if($this->DrawColor!=$dc)
+	{
+		$this->DrawColor = $dc;
+		$this->_out($dc);
+	}
+	if($this->FillColor!=$fc)
+	{
+		$this->FillColor = $fc;
+		$this->_out($fc);
+	}
+	$this->TextColor = $tc;
+	$this->ColorFlag = $cf;
+}
+
+function Header()
+{
+	// To be implemented in your own inherited class
+}
+
+function Footer()
+{
+	// To be implemented in your own inherited class
+}
+
+function PageNo()
+{
+	// Get current page number
+	return $this->page;
+}
+
+function SetDrawColor($r, $g=null, $b=null)
+{
+	// Set color for all stroking operations
+	if(($r==0 && $g==0 && $b==0) || $g===null)
+		$this->DrawColor = sprintf('%.3F G',$r/255);
+	else
+		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
+	if($this->page>0)
+		$this->_out($this->DrawColor);
+}
+
+function SetFillColor($r, $g=null, $b=null)
+{
+	// Set color for all filling operations
+	if(($r==0 && $g==0 && $b==0) || $g===null)
+		$this->FillColor = sprintf('%.3F g',$r/255);
+	else
+		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
+	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
+	if($this->page>0)
+		$this->_out($this->FillColor);
+}
+
+function SetTextColor($r, $g=null, $b=null)
+{
+	// Set color for text
+	if(($r==0 && $g==0 && $b==0) || $g===null)
+		$this->TextColor = sprintf('%.3F g',$r/255);
+	else
+		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
+	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
+}
+
+function GetStringWidth($s)
+{
+	// Get width of a string in the current font
+	$s = (string)$s;
+	$cw = &$this->CurrentFont['cw'];
+	$w = 0;
+	$l = strlen($s);
+	for($i=0;$i<$l;$i++)
+		$w += $cw[$s[$i]];
+	return $w*$this->FontSize/1000;
+}
+
+function SetLineWidth($width)
+{
+	// Set line width
+	$this->LineWidth = $width;
+	if($this->page>0)
+		$this->_out(sprintf('%.2F w',$width*$this->k));
+}
+
+function Line($x1, $y1, $x2, $y2)
+{
+	// Draw a line
+	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
+}
+
+function Rect($x, $y, $w, $h, $style='')
+{
+	// Draw a rectangle
+	if($style=='F')
+		$op = 'f';
+	elseif($style=='FD' || $style=='DF')
+		$op = 'B';
+	else
+		$op = 'S';
+	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
+}
+
+function AddFont($family, $style='', $file='')
+{
+	// Add a TrueType, OpenType or Type1 font
+	$family = strtolower($family);
+	if($file=='')
+		$file = str_replace(' ','',$family).strtolower($style).'.php';
+	$style = strtoupper($style);
+	if($style=='IB')
+		$style = 'BI';
+	$fontkey = $family.$style;
+	if(isset($this->fonts[$fontkey]))
+		return;
+	$info = $this->_loadfont($file);
+	$info['i'] = count($this->fonts)+1;
+	if(!empty($info['diff']))
+	{
+		// Search existing encodings
+		$n = array_search($info['diff'],$this->diffs);
+		if(!$n)
+		{
+			$n = count($this->diffs)+1;
+			$this->diffs[$n] = $info['diff'];
+		}
+		$info['diffn'] = $n;
+	}
+	if(!empty($info['file']))
+	{
+		// Embedded font
+		if($info['type']=='TrueType')
+			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
+		else
+			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
+	}
+	$this->fonts[$fontkey] = $info;
+}
+
+function SetFont($family, $style='', $size=0)
+{
+	// Select a font; size given in points
+	if($family=='')
+		$family = $this->FontFamily;
+	else
+		$family = strtolower($family);
+	$style = strtoupper($style);
+	if(strpos($style,'U')!==false)
+	{
+		$this->underline = true;
+		$style = str_replace('U','',$style);
+	}
+	else
+		$this->underline = false;
+	if($style=='IB')
+		$style = 'BI';
+	if($size==0)
+		$size = $this->FontSizePt;
+	// Test if font is already selected
+	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
+		return;
+	// Test if font is already loaded
+	$fontkey = $family.$style;
+	if(!isset($this->fonts[$fontkey]))
+	{
+		// Test if one of the core fonts
+		if($family=='arial')
+			$family = 'helvetica';
+		if(in_array($family,$this->CoreFonts))
+		{
+			if($family=='symbol' || $family=='zapfdingbats')
+				$style = '';
+			$fontkey = $family.$style;
+			if(!isset($this->fonts[$fontkey]))
+				$this->AddFont($family,$style);
+		}
+		else
+			$this->Error('Undefined font: '.$family.' '.$style);
+	}
+	// Select it
+	$this->FontFamily = $family;
+	$this->FontStyle = $style;
+	$this->FontSizePt = $size;
+	$this->FontSize = $size/$this->k;
+	$this->CurrentFont = &$this->fonts[$fontkey];
+	if($this->page>0)
+		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
+}
+
+function SetFontSize($size)
+{
+	// Set font size in points
+	if($this->FontSizePt==$size)
+		return;
+	$this->FontSizePt = $size;
+	$this->FontSize = $size/$this->k;
+	if($this->page>0)
+		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
+}
+
+function AddLink()
+{
+	// Create a new internal link
+	$n = count($this->links)+1;
+	$this->links[$n] = array(0, 0);
+	return $n;
+}
+
+function SetLink($link, $y=0, $page=-1)
+{
+	// Set destination of internal link
+	if($y==-1)
+		$y = $this->y;
+	if($page==-1)
+		$page = $this->page;
+	$this->links[$link] = array($page, $y);
+}
+
+function Link($x, $y, $w, $h, $link)
+{
+	// Put a link on the page
+	$this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
+}
+
+function Text($x, $y, $txt)
+{
+	// Output a string
+	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
+	if($this->underline && $txt!='')
+		$s .= ' '.$this->_dounderline($x,$y,$txt);
+	if($this->ColorFlag)
+		$s = 'q '.$this->TextColor.' '.$s.' Q';
+	$this->_out($s);
+}
+
+function AcceptPageBreak()
+{
+	// Accept automatic page break or not
+	return $this->AutoPageBreak;
+}
+
+function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
+{
+	// Output a cell
+	$k = $this->k;
+	if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
+	{
+		// Automatic page break
+		$x = $this->x;
+		$ws = $this->ws;
+		if($ws>0)
+		{
+			$this->ws = 0;
+			$this->_out('0 Tw');
+		}
+		$this->AddPage($this->CurOrientation,$this->CurPageSize);
+		$this->x = $x;
+		if($ws>0)
+		{
+			$this->ws = $ws;
+			$this->_out(sprintf('%.3F Tw',$ws*$k));
+		}
+	}
+	if($w==0)
+		$w = $this->w-$this->rMargin-$this->x;
+	$s = '';
+	if($fill || $border==1)
+	{
+		if($fill)
+			$op = ($border==1) ? 'B' : 'f';
+		else
+			$op = 'S';
+		$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
+	}
+	if(is_string($border))
+	{
+		$x = $this->x;
+		$y = $this->y;
+		if(strpos($border,'L')!==false)
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
+		if(strpos($border,'T')!==false)
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
+		if(strpos($border,'R')!==false)
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
+		if(strpos($border,'B')!==false)
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
+	}
+	if($txt!=='')
+	{
+		if($align=='R')
+			$dx = $w-$this->cMargin-$this->GetStringWidth($txt);
+		elseif($align=='C')
+			$dx = ($w-$this->GetStringWidth($txt))/2;
+		else
+			$dx = $this->cMargin;
+		if($this->ColorFlag)
+			$s .= 'q '.$this->TextColor.' ';
+		$txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
+		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
+		if($this->underline)
+			$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
+		if($this->ColorFlag)
+			$s .= ' Q';
+		if($link)
+			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
+	}
+	if($s)
+		$this->_out($s);
+	$this->lasth = $h;
+	if($ln>0)
+	{
+		// Go to next line
+		$this->y += $h;
+		if($ln==1)
+			$this->x = $this->lMargin;
+	}
+	else
+		$this->x += $w;
+}
+
+function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
+{
+	// Output text with automatic or explicit line breaks
+	$cw = &$this->CurrentFont['cw'];
+	if($w==0)
+		$w = $this->w-$this->rMargin-$this->x;
+	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
+	$s = str_replace("\r",'',$txt);
+	$nb = strlen($s);
+	if($nb>0 && $s[$nb-1]=="\n")
+		$nb--;
+	$b = 0;
+	if($border)
+	{
+		if($border==1)
+		{
+			$border = 'LTRB';
+			$b = 'LRT';
+			$b2 = 'LR';
+		}
+		else
+		{
+			$b2 = '';
+			if(strpos($border,'L')!==false)
+				$b2 .= 'L';
+			if(strpos($border,'R')!==false)
+				$b2 .= 'R';
+			$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
+		}
+	}
+	$sep = -1;
+	$i = 0;
+	$j = 0;
+	$l = 0;
+	$ns = 0;
+	$nl = 1;
+	while($i<$nb)
+	{
+		// Get next character
+		$c = $s[$i];
+		if($c=="\n")
+		{
+			// Explicit line break
+			if($this->ws>0)
+			{
+				$this->ws = 0;
+				$this->_out('0 Tw');
+			}
+			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
+			$i++;
+			$sep = -1;
+			$j = $i;
+			$l = 0;
+			$ns = 0;
+			$nl++;
+			if($border && $nl==2)
+				$b = $b2;
+			continue;
+		}
+		if($c==' ')
+		{
+			$sep = $i;
+			$ls = $l;
+			$ns++;
+		}
+		$l += $cw[$c];
+		if($l>$wmax)
+		{
+			// Automatic line break
+			if($sep==-1)
+			{
+				if($i==$j)
+					$i++;
+				if($this->ws>0)
+				{
+					$this->ws = 0;
+					$this->_out('0 Tw');
+				}
+				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
+			}
+			else
+			{
+				if($align=='J')
+				{
+					$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
+					$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
+				}
+				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
+				$i = $sep+1;
+			}
+			$sep = -1;
+			$j = $i;
+			$l = 0;
+			$ns = 0;
+			$nl++;
+			if($border && $nl==2)
+				$b = $b2;
+		}
+		else
+			$i++;
+	}
+	// Last chunk
+	if($this->ws>0)
+	{
+		$this->ws = 0;
+		$this->_out('0 Tw');
+	}
+	if($border && strpos($border,'B')!==false)
+		$b .= 'B';
+	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
+	$this->x = $this->lMargin;
+}
+
+function Write($h, $txt, $link='')
+{
+	// Output text in flowing mode
+	$cw = &$this->CurrentFont['cw'];
+	$w = $this->w-$this->rMargin-$this->x;
+	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
+	$s = str_replace("\r",'',$txt);
+	$nb = strlen($s);
+	$sep = -1;
+	$i = 0;
+	$j = 0;
+	$l = 0;
+	$nl = 1;
+	while($i<$nb)
+	{
+		// Get next character
+		$c = $s[$i];
+		if($c=="\n")
+		{
+			// Explicit line break
+			$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
+			$i++;
+			$sep = -1;
+			$j = $i;
+			$l = 0;
+			if($nl==1)
+			{
+				$this->x = $this->lMargin;
+				$w = $this->w-$this->rMargin-$this->x;
+				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
+			}
+			$nl++;
+			continue;
+		}
+		if($c==' ')
+			$sep = $i;
+		$l += $cw[$c];
+		if($l>$wmax)
+		{
+			// Automatic line break
+			if($sep==-1)
+			{
+				if($this->x>$this->lMargin)
+				{
+					// Move to next line
+					$this->x = $this->lMargin;
+					$this->y += $h;
+					$w = $this->w-$this->rMargin-$this->x;
+					$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
+					$i++;
+					$nl++;
+					continue;
+				}
+				if($i==$j)
+					$i++;
+				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
+			}
+			else
+			{
+				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
+				$i = $sep+1;
+			}
+			$sep = -1;
+			$j = $i;
+			$l = 0;
+			if($nl==1)
+			{
+				$this->x = $this->lMargin;
+				$w = $this->w-$this->rMargin-$this->x;
+				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
+			}
+			$nl++;
+		}
+		else
+			$i++;
+	}
+	// Last chunk
+	if($i!=$j)
+		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
+}
+
+function Ln($h=null)
+{
+	// Line feed; default value is last cell height
+	$this->x = $this->lMargin;
+	if($h===null)
+		$this->y += $this->lasth;
+	else
+		$this->y += $h;
+}
+
+function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
+{
+	// Put an image on the page
+	if(!isset($this->images[$file]))
+	{
+		// First use of this image, get info
+		if($type=='')
+		{
+			$pos = strrpos($file,'.');
+			if(!$pos)
+				$this->Error('Image file has no extension and no type was specified: '.$file);
+			$type = substr($file,$pos+1);
+		}
+		$type = strtolower($type);
+		if($type=='jpeg')
+			$type = 'jpg';
+		$mtd = '_parse'.$type;
+		if(!method_exists($this,$mtd))
+			$this->Error('Unsupported image type: '.$type);
+		$info = $this->$mtd($file);
+		$info['i'] = count($this->images)+1;
+		$this->images[$file] = $info;
+	}
+	else
+		$info = $this->images[$file];
+
+	// Automatic width and height calculation if needed
+	if($w==0 && $h==0)
+	{
+		// Put image at 96 dpi
+		$w = -96;
+		$h = -96;
+	}
+	if($w<0)
+		$w = -$info['w']*72/$w/$this->k;
+	if($h<0)
+		$h = -$info['h']*72/$h/$this->k;
+	if($w==0)
+		$w = $h*$info['w']/$info['h'];
+	if($h==0)
+		$h = $w*$info['h']/$info['w'];
+
+	// Flowing mode
+	if($y===null)
+	{
+		if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
+		{
+			// Automatic page break
+			$x2 = $this->x;
+			$this->AddPage($this->CurOrientation,$this->CurPageSize);
+			$this->x = $x2;
+		}
+		$y = $this->y;
+		$this->y += $h;
+	}
+
+	if($x===null)
+		$x = $this->x;
+	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
+	if($link)
+		$this->Link($x,$y,$w,$h,$link);
+}
+
+function GetX()
+{
+	// Get x position
+	return $this->x;
+}
+
+function SetX($x)
+{
+	// Set x position
+	if($x>=0)
+		$this->x = $x;
+	else
+		$this->x = $this->w+$x;
+}
+
+function GetY()
+{
+	// Get y position
+	return $this->y;
+}
+
+function SetY($y)
+{
+	// Set y position and reset x
+	$this->x = $this->lMargin;
+	if($y>=0)
+		$this->y = $y;
+	else
+		$this->y = $this->h+$y;
+}
+
+function SetXY($x, $y)
+{
+	// Set x and y positions
+	$this->SetY($y);
+	$this->SetX($x);
+}
+
+function Output($name='', $dest='')
+{
+	// Output PDF to some destination
+	if($this->state<3)
+		$this->Close();
+	$dest = strtoupper($dest);
+	if($dest=='')
+	{
+		if($name=='')
+		{
+			$name = 'doc.pdf';
+			$dest = 'I';
+		}
+		else
+			$dest = 'F';
+	}
+	switch($dest)
+	{
+		case 'I':
+			// Send to standard output
+			$this->_checkoutput();
+			if(PHP_SAPI!='cli')
+			{
+				// We send to a browser
+				header('Content-Type: application/pdf');
+				header('Content-Disposition: inline; filename="'.$name.'"');
+				header('Cache-Control: private, max-age=0, must-revalidate');
+				header('Pragma: public');
+			}
+			echo $this->buffer;
+			break;
+		case 'D':
+			// Download file
+			$this->_checkoutput();
+			header('Content-Type: application/x-download');
+			header('Content-Disposition: attachment; filename="'.$name.'"');
+			header('Cache-Control: private, max-age=0, must-revalidate');
+			header('Pragma: public');
+			echo $this->buffer;
+			break;
+		case 'F':
+			// Save to local file
+			$f = fopen($name,'wb');
+			if(!$f)
+				$this->Error('Unable to create output file: '.$name);
+			fwrite($f,$this->buffer,strlen($this->buffer));
+			fclose($f);
+			break;
+		case 'S':
+			// Return as a string
+			return $this->buffer;
+		default:
+			$this->Error('Incorrect output destination: '.$dest);
+	}
+	return '';
+}
+
+/*******************************************************************************
+*                                                                              *
+*                              Protected methods                               *
+*                                                                              *
+*******************************************************************************/
+function _dochecks()
+{
+	// Check availability of %F
+	if(sprintf('%.1F',1.0)!='1.0')
+		$this->Error('This version of PHP is not supported');
+	// Check mbstring overloading
+	if(ini_get('mbstring.func_overload') & 2)
+		$this->Error('mbstring overloading must be disabled');
+	// Ensure runtime magic quotes are disabled
+	if(get_magic_quotes_runtime())
+		@set_magic_quotes_runtime(0);
+}
+
+function _checkoutput()
+{
+	if(PHP_SAPI!='cli')
+	{
+		if(headers_sent($file,$line))
+			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
+	}
+	if(ob_get_length())
+	{
+		// The output buffer is not empty
+		if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
+		{
+			// It contains only a UTF-8 BOM and/or whitespace, let's clean it
+			ob_clean();
+		}
+		else
+			$this->Error("Some data has already been output, can't send PDF file");
+	}
+}
+
+function _getpagesize($size)
+{
+	if(is_string($size))
+	{
+		$size = strtolower($size);
+		if(!isset($this->StdPageSizes[$size]))
+			$this->Error('Unknown page size: '.$size);
+		$a = $this->StdPageSizes[$size];
+		return array($a[0]/$this->k, $a[1]/$this->k);
+	}
+	else
+	{
+		if($size[0]>$size[1])
+			return array($size[1], $size[0]);
+		else
+			return $size;
+	}
+}
+
+function _beginpage($orientation, $size)
+{
+	$this->page++;
+	$this->pages[$this->page] = '';
+	$this->state = 2;
+	$this->x = $this->lMargin;
+	$this->y = $this->tMargin;
+	$this->FontFamily = '';
+	// Check page size and orientation
+	if($orientation=='')
+		$orientation = $this->DefOrientation;
+	else
+		$orientation = strtoupper($orientation[0]);
+	if($size=='')
+		$size = $this->DefPageSize;
+	else
+		$size = $this->_getpagesize($size);
+	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
+	{
+		// New size or orientation
+		if($orientation=='P')
+		{
+			$this->w = $size[0];
+			$this->h = $size[1];
+		}
+		else
+		{
+			$this->w = $size[1];
+			$this->h = $size[0];
+		}
+		$this->wPt = $this->w*$this->k;
+		$this->hPt = $this->h*$this->k;
+		$this->PageBreakTrigger = $this->h-$this->bMargin;
+		$this->CurOrientation = $orientation;
+		$this->CurPageSize = $size;
+	}
+	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
+		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
+}
+
+function _endpage()
+{
+	$this->state = 1;
+}
+
+function _loadfont($font)
+{
+	// Load a font definition file from the font directory
+	include($this->fontpath.$font);
+	$a = get_defined_vars();
+	if(!isset($a['name']))
+		$this->Error('Could not include font definition file');
+	return $a;
+}
+
+function _escape($s)
+{
+	// Escape special characters in strings
+	$s = str_replace('\\','\\\\',$s);
+	$s = str_replace('(','\\(',$s);
+	$s = str_replace(')','\\)',$s);
+	$s = str_replace("\r",'\\r',$s);
+	return $s;
+}
+
+function _textstring($s)
+{
+	// Format a text string
+	return '('.$this->_escape($s).')';
+}
+
+function _UTF8toUTF16($s)
+{
+	// Convert UTF-8 to UTF-16BE with BOM
+	$res = "\xFE\xFF";
+	$nb = strlen($s);
+	$i = 0;
+	while($i<$nb)
+	{
+		$c1 = ord($s[$i++]);
+		if($c1>=224)
+		{
+			// 3-byte character
+			$c2 = ord($s[$i++]);
+			$c3 = ord($s[$i++]);
+			$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
+			$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
+		}
+		elseif($c1>=192)
+		{
+			// 2-byte character
+			$c2 = ord($s[$i++]);
+			$res .= chr(($c1 & 0x1C)>>2);
+			$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
+		}
+		else
+		{
+			// Single-byte character
+			$res .= "\0".chr($c1);
+		}
+	}
+	return $res;
+}
+
+function _dounderline($x, $y, $txt)
+{
+	// Underline text
+	$up = $this->CurrentFont['up'];
+	$ut = $this->CurrentFont['ut'];
+	$w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
+	return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
+}
+
+function _parsejpg($file)
+{
+	// Extract info from a JPEG file
+	$a = getimagesize($file);
+	if(!$a)
+		$this->Error('Missing or incorrect image file: '.$file);
+	if($a[2]!=2)
+		$this->Error('Not a JPEG file: '.$file);
+	if(!isset($a['channels']) || $a['channels']==3)
+		$colspace = 'DeviceRGB';
+	elseif($a['channels']==4)
+		$colspace = 'DeviceCMYK';
+	else
+		$colspace = 'DeviceGray';
+	$bpc = isset($a['bits']) ? $a['bits'] : 8;
+	$data = file_get_contents($file);
+	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
+}
+
+function _parsepng($file)
+{
+	// Extract info from a PNG file
+	$f = fopen($file,'rb');
+	if(!$f)
+		$this->Error('Can\'t open image file: '.$file);
+	$info = $this->_parsepngstream($f,$file);
+	fclose($f);
+	return $info;
+}
+
+function _parsepngstream($f, $file)
+{
+	// Check signature
+	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
+		$this->Error('Not a PNG file: '.$file);
+
+	// Read header chunk
+	$this->_readstream($f,4);
+	if($this->_readstream($f,4)!='IHDR')
+		$this->Error('Incorrect PNG file: '.$file);
+	$w = $this->_readint($f);
+	$h = $this->_readint($f);
+	$bpc = ord($this->_readstream($f,1));
+	if($bpc>8)
+		$this->Error('16-bit depth not supported: '.$file);
+	$ct = ord($this->_readstream($f,1));
+	if($ct==0 || $ct==4)
+		$colspace = 'DeviceGray';
+	elseif($ct==2 || $ct==6)
+		$colspace = 'DeviceRGB';
+	elseif($ct==3)
+		$colspace = 'Indexed';
+	else
+		$this->Error('Unknown color type: '.$file);
+	if(ord($this->_readstream($f,1))!=0)
+		$this->Error('Unknown compression method: '.$file);
+	if(ord($this->_readstream($f,1))!=0)
+		$this->Error('Unknown filter method: '.$file);
+	if(ord($this->_readstream($f,1))!=0)
+		$this->Error('Interlacing not supported: '.$file);
+	$this->_readstream($f,4);
+	$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
+
+	// Scan chunks looking for palette, transparency and image data
+	$pal = '';
+	$trns = '';
+	$data = '';
+	do
+	{
+		$n = $this->_readint($f);
+		$type = $this->_readstream($f,4);
+		if($type=='PLTE')
+		{
+			// Read palette
+			$pal = $this->_readstream($f,$n);
+			$this->_readstream($f,4);
+		}
+		elseif($type=='tRNS')
+		{
+			// Read transparency info
+			$t = $this->_readstream($f,$n);
+			if($ct==0)
+				$trns = array(ord(substr($t,1,1)));
+			elseif($ct==2)
+				$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
+			else
+			{
+				$pos = strpos($t,chr(0));
+				if($pos!==false)
+					$trns = array($pos);
+			}
+			$this->_readstream($f,4);
+		}
+		elseif($type=='IDAT')
+		{
+			// Read image data block
+			$data .= $this->_readstream($f,$n);
+			$this->_readstream($f,4);
+		}
+		elseif($type=='IEND')
+			break;
+		else
+			$this->_readstream($f,$n+4);
+	}
+	while($n);
+
+	if($colspace=='Indexed' && empty($pal))
+		$this->Error('Missing palette in '.$file);
+	$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
+	if($ct>=4)
+	{
+		// Extract alpha channel
+		if(!function_exists('gzuncompress'))
+			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
+		$data = gzuncompress($data);
+		$color = '';
+		$alpha = '';
+		if($ct==4)
+		{
+			// Gray image
+			$len = 2*$w;
+			for($i=0;$i<$h;$i++)
+			{
+				$pos = (1+$len)*$i;
+				$color .= $data[$pos];
+				$alpha .= $data[$pos];
+				$line = substr($data,$pos+1,$len);
+				$color .= preg_replace('/(.)./s','$1',$line);
+				$alpha .= preg_replace('/.(.)/s','$1',$line);
+			}
+		}
+		else
+		{
+			// RGB image
+			$len = 4*$w;
+			for($i=0;$i<$h;$i++)
+			{
+				$pos = (1+$len)*$i;
+				$color .= $data[$pos];
+				$alpha .= $data[$pos];
+				$line = substr($data,$pos+1,$len);
+				$color .= preg_replace('/(.{3})./s','$1',$line);
+				$alpha .= preg_replace('/.{3}(.)/s','$1',$line);
+			}
+		}
+		unset($data);
+		$data = gzcompress($color);
+		$info['smask'] = gzcompress($alpha);
+		if($this->PDFVersion<'1.4')
+			$this->PDFVersion = '1.4';
+	}
+	$info['data'] = $data;
+	return $info;
+}
+
+function _readstream($f, $n)
+{
+	// Read n bytes from stream
+	$res = '';
+	while($n>0 && !feof($f))
+	{
+		$s = fread($f,$n);
+		if($s===false)
+			$this->Error('Error while reading stream');
+		$n -= strlen($s);
+		$res .= $s;
+	}
+	if($n>0)
+		$this->Error('Unexpected end of stream');
+	return $res;
+}
+
+function _readint($f)
+{
+	// Read a 4-byte integer from stream
+	$a = unpack('Ni',$this->_readstream($f,4));
+	return $a['i'];
+}
+
+function _parsegif($file)
+{
+	// Extract info from a GIF file (via PNG conversion)
+	if(!function_exists('imagepng'))
+		$this->Error('GD extension is required for GIF support');
+	if(!function_exists('imagecreatefromgif'))
+		$this->Error('GD has no GIF read support');
+	$im = imagecreatefromgif($file);
+	if(!$im)
+		$this->Error('Missing or incorrect image file: '.$file);
+	imageinterlace($im,0);
+	$f = @fopen('php://temp','rb+');
+	if($f)
+	{
+		// Perform conversion in memory
+		ob_start();
+		imagepng($im);
+		$data = ob_get_clean();
+		imagedestroy($im);
+		fwrite($f,$data);
+		rewind($f);
+		$info = $this->_parsepngstream($f,$file);
+		fclose($f);
+	}
+	else
+	{
+		// Use temporary file
+		$tmp = tempnam('.','gif');
+		if(!$tmp)
+			$this->Error('Unable to create a temporary file');
+		if(!imagepng($im,$tmp))
+			$this->Error('Error while saving to temporary file');
+		imagedestroy($im);
+		$info = $this->_parsepng($tmp);
+		unlink($tmp);
+	}
+	return $info;
+}
+
+function _newobj()
+{
+	// Begin a new object
+	$this->n++;
+	$this->offsets[$this->n] = strlen($this->buffer);
+	$this->_out($this->n.' 0 obj');
+}
+
+function _putstream($s)
+{
+	$this->_out('stream');
+	$this->_out($s);
+	$this->_out('endstream');
+}
+
+function _out($s)
+{
+	// Add a line to the document
+	if($this->state==2)
+		$this->pages[$this->page] .= $s."\n";
+	else
+		$this->buffer .= $s."\n";
+}
+
+function _putpages()
+{
+	$nb = $this->page;
+	if(!empty($this->AliasNbPages))
+	{
+		// Replace number of pages
+		for($n=1;$n<=$nb;$n++)
+			$this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
+	}
+	if($this->DefOrientation=='P')
+	{
+		$wPt = $this->DefPageSize[0]*$this->k;
+		$hPt = $this->DefPageSize[1]*$this->k;
+	}
+	else
+	{
+		$wPt = $this->DefPageSize[1]*$this->k;
+		$hPt = $this->DefPageSize[0]*$this->k;
+	}
+	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
+	for($n=1;$n<=$nb;$n++)
+	{
+		// Page
+		$this->_newobj();
+		$this->_out('<</Type /Page');
+		$this->_out('/Parent 1 0 R');
+		if(isset($this->PageSizes[$n]))
+			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
+		$this->_out('/Resources 2 0 R');
+		if(isset($this->PageLinks[$n]))
+		{
+			// Links
+			$annots = '/Annots [';
+			foreach($this->PageLinks[$n] as $pl)
+			{
+				$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
+				$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
+				if(is_string($pl[4]))
+					$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
+				else
+				{
+					$l = $this->links[$pl[4]];
+					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
+					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
+				}
+			}
+			$this->_out($annots.']');
+		}
+		if($this->PDFVersion>'1.3')
+			$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
+		$this->_out('/Contents '.($this->n+1).' 0 R>>');
+		$this->_out('endobj');
+		// Page content
+		$p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
+		$this->_newobj();
+		$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
+		$this->_putstream($p);
+		$this->_out('endobj');
+	}
+	// Pages root
+	$this->offsets[1] = strlen($this->buffer);
+	$this->_out('1 0 obj');
+	$this->_out('<</Type /Pages');
+	$kids = '/Kids [';
+	for($i=0;$i<$nb;$i++)
+		$kids .= (3+2*$i).' 0 R ';
+	$this->_out($kids.']');
+	$this->_out('/Count '.$nb);
+	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
+	$this->_out('>>');
+	$this->_out('endobj');
+}
+
+function _putfonts()
+{
+	$nf = $this->n;
+	foreach($this->diffs as $diff)
+	{
+		// Encodings
+		$this->_newobj();
+		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
+		$this->_out('endobj');
+	}
+	foreach($this->FontFiles as $file=>$info)
+	{
+		// Font file embedding
+		$this->_newobj();
+		$this->FontFiles[$file]['n'] = $this->n;
+		$font = file_get_contents($this->fontpath.$file,true);
+		if(!$font)
+			$this->Error('Font file not found: '.$file);
+		$compressed = (substr($file,-2)=='.z');
+		if(!$compressed && isset($info['length2']))
+			$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
+		$this->_out('<</Length '.strlen($font));
+		if($compressed)
+			$this->_out('/Filter /FlateDecode');
+		$this->_out('/Length1 '.$info['length1']);
+		if(isset($info['length2']))
+			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
+		$this->_out('>>');
+		$this->_putstream($font);
+		$this->_out('endobj');
+	}
+	foreach($this->fonts as $k=>$font)
+	{
+		// Font objects
+		$this->fonts[$k]['n'] = $this->n+1;
+		$type = $font['type'];
+		$name = $font['name'];
+		if($type=='Core')
+		{
+			// Core font
+			$this->_newobj();
+			$this->_out('<</Type /Font');
+			$this->_out('/BaseFont /'.$name);
+			$this->_out('/Subtype /Type1');
+			if($name!='Symbol' && $name!='ZapfDingbats')
+				$this->_out('/Encoding /WinAnsiEncoding');
+			$this->_out('>>');
+			$this->_out('endobj');
+		}
+		elseif($type=='Type1' || $type=='TrueType')
+		{
+			// Additional Type1 or TrueType/OpenType font
+			$this->_newobj();
+			$this->_out('<</Type /Font');
+			$this->_out('/BaseFont /'.$name);
+			$this->_out('/Subtype /'.$type);
+			$this->_out('/FirstChar 32 /LastChar 255');
+			$this->_out('/Widths '.($this->n+1).' 0 R');
+			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
+			if(isset($font['diffn']))
+				$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
+			else
+				$this->_out('/Encoding /WinAnsiEncoding');
+			$this->_out('>>');
+			$this->_out('endobj');
+			// Widths
+			$this->_newobj();
+			$cw = &$font['cw'];
+			$s = '[';
+			for($i=32;$i<=255;$i++)
+				$s .= $cw[chr($i)].' ';
+			$this->_out($s.']');
+			$this->_out('endobj');
+			// Descriptor
+			$this->_newobj();
+			$s = '<</Type /FontDescriptor /FontName /'.$name;
+			foreach($font['desc'] as $k=>$v)
+				$s .= ' /'.$k.' '.$v;
+			if(!empty($font['file']))
+				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
+			$this->_out($s.'>>');
+			$this->_out('endobj');
+		}
+		else
+		{
+			// Allow for additional types
+			$mtd = '_put'.strtolower($type);
+			if(!method_exists($this,$mtd))
+				$this->Error('Unsupported font type: '.$type);
+			$this->$mtd($font);
+		}
+	}
+}
+
+function _putimages()
+{
+	foreach(array_keys($this->images) as $file)
+	{
+		$this->_putimage($this->images[$file]);
+		unset($this->images[$file]['data']);
+		unset($this->images[$file]['smask']);
+	}
+}
+
+function _putimage(&$info)
+{
+	$this->_newobj();
+	$info['n'] = $this->n;
+	$this->_out('<</Type /XObject');
+	$this->_out('/Subtype /Image');
+	$this->_out('/Width '.$info['w']);
+	$this->_out('/Height '.$info['h']);
+	if($info['cs']=='Indexed')
+		$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
+	else
+	{
+		$this->_out('/ColorSpace /'.$info['cs']);
+		if($info['cs']=='DeviceCMYK')
+			$this->_out('/Decode [1 0 1 0 1 0 1 0]');
+	}
+	$this->_out('/BitsPerComponent '.$info['bpc']);
+	if(isset($info['f']))
+		$this->_out('/Filter /'.$info['f']);
+	if(isset($info['dp']))
+		$this->_out('/DecodeParms <<'.$info['dp'].'>>');
+	if(isset($info['trns']) && is_array($info['trns']))
+	{
+		$trns = '';
+		for($i=0;$i<count($info['trns']);$i++)
+			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
+		$this->_out('/Mask ['.$trns.']');
+	}
+	if(isset($info['smask']))
+		$this->_out('/SMask '.($this->n+1).' 0 R');
+	$this->_out('/Length '.strlen($info['data']).'>>');
+	$this->_putstream($info['data']);
+	$this->_out('endobj');
+	// Soft mask
+	if(isset($info['smask']))
+	{
+		$dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
+		$smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
+		$this->_putimage($smask);
+	}
+	// Palette
+	if($info['cs']=='Indexed')
+	{
+		$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
+		$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
+		$this->_newobj();
+		$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
+		$this->_putstream($pal);
+		$this->_out('endobj');
+	}
+}
+
+function _putxobjectdict()
+{
+	foreach($this->images as $image)
+		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
+}
+
+function _putresourcedict()
+{
+	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
+	$this->_out('/Font <<');
+	foreach($this->fonts as $font)
+		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
+	$this->_out('>>');
+	$this->_out('/XObject <<');
+	$this->_putxobjectdict();
+	$this->_out('>>');
+}
+
+function _putresources()
+{
+	$this->_putfonts();
+	$this->_putimages();
+	// Resource dictionary
+	$this->offsets[2] = strlen($this->buffer);
+	$this->_out('2 0 obj');
+	$this->_out('<<');
+	$this->_putresourcedict();
+	$this->_out('>>');
+	$this->_out('endobj');
+}
+
+function _putinfo()
+{
+	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
+	if(!empty($this->title))
+		$this->_out('/Title '.$this->_textstring($this->title));
+	if(!empty($this->subject))
+		$this->_out('/Subject '.$this->_textstring($this->subject));
+	if(!empty($this->author))
+		$this->_out('/Author '.$this->_textstring($this->author));
+	if(!empty($this->keywords))
+		$this->_out('/Keywords '.$this->_textstring($this->keywords));
+	if(!empty($this->creator))
+		$this->_out('/Creator '.$this->_textstring($this->creator));
+	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
+}
+
+function _putcatalog()
+{
+	$this->_out('/Type /Catalog');
+	$this->_out('/Pages 1 0 R');
+	if($this->ZoomMode=='fullpage')
+		$this->_out('/OpenAction [3 0 R /Fit]');
+	elseif($this->ZoomMode=='fullwidth')
+		$this->_out('/OpenAction [3 0 R /FitH null]');
+	elseif($this->ZoomMode=='real')
+		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
+	elseif(!is_string($this->ZoomMode))
+		$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
+	if($this->LayoutMode=='single')
+		$this->_out('/PageLayout /SinglePage');
+	elseif($this->LayoutMode=='continuous')
+		$this->_out('/PageLayout /OneColumn');
+	elseif($this->LayoutMode=='two')
+		$this->_out('/PageLayout /TwoColumnLeft');
+}
+
+function _putheader()
+{
+	$this->_out('%PDF-'.$this->PDFVersion);
+}
+
+function _puttrailer()
+{
+	$this->_out('/Size '.($this->n+1));
+	$this->_out('/Root '.$this->n.' 0 R');
+	$this->_out('/Info '.($this->n-1).' 0 R');
+}
+
+function _enddoc()
+{
+	$this->_putheader();
+	$this->_putpages();
+	$this->_putresources();
+	// Info
+	$this->_newobj();
+	$this->_out('<<');
+	$this->_putinfo();
+	$this->_out('>>');
+	$this->_out('endobj');
+	// Catalog
+	$this->_newobj();
+	$this->_out('<<');
+	$this->_putcatalog();
+	$this->_out('>>');
+	$this->_out('endobj');
+	// Cross-ref
+	$o = strlen($this->buffer);
+	$this->_out('xref');
+	$this->_out('0 '.($this->n+1));
+	$this->_out('0000000000 65535 f ');
+	for($i=1;$i<=$this->n;$i++)
+		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
+	// Trailer
+	$this->_out('trailer');
+	$this->_out('<<');
+	$this->_puttrailer();
+	$this->_out('>>');
+	$this->_out('startxref');
+	$this->_out($o);
+	$this->_out('%%EOF');
+	$this->state = 3;
+}
+// End of class
+}
+
+// Handle special IE contype request
+if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
+{
+	header('Content-Type: application/pdf');
+	exit;
+}
+
+?>
--- a/fhiiqm/vertrag_flist1.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/vertrag_flist1.php	Fri Dec 21 15:31:50 2012 +0100
@@ -75,9 +75,9 @@
 
     $subf   = $_POST["subf"]; // submit
     
-    if (!isset($fnum) && !$fnum) $fnum = 1;
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($fnum) || !$fnum) $fnum = 1;
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
     // $_GET-Parameter zurueck zur Vertragliste mit den selben Einstellungen wie zuvor fuer Update
     $getp = "&s=$sort&d=$dir&f=$fnum&b=$filter&st=$start&z=$zeil";
     
--- a/fhiiqm/vertrag_flist12.php	Fri Nov 16 10:40:03 2012 +0100
+++ b/fhiiqm/vertrag_flist12.php	Fri Dec 21 15:31:50 2012 +0100
@@ -55,17 +55,17 @@
 
 	$sort   = $_GET["s"];
     $dir    = $_GET["d"];
-    if (!isset($sort) && !$sort) $sort = 2;
-    if (!isset($dir) && !$dir)  $dir = "";
+    if (!isset($sort) || !$sort) $sort = 2;
+    if (!isset($dir) || !$dir)  $dir = "";
 
     $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
     $filter = $_GET["b"];
-    if (!isset($fnum) && !$fnum) $fnum = 0;
+    if (!isset($fnum) || !$fnum) $fnum = 0;
     // $_GET-Parameter zurueck zur Vertragliste mit den selben Einstellungen wie zuvor fuer Update
     $getp = "&s=$sort&d=$dir&f=$fnum&b=$filter&st=$start&z=$zeil&t=2"; 
     
     $listg  = $_GET["l"];
-    if (!isset($listg) && !$listg)
+    if (!isset($listg) || !$listg)
     {
         // Recht Produktgruppe beruecksichtigen
         if (is_array($_SESSION["prodg"]))