fhiiqm/gefahr_massn_flist.php
changeset 28 8d8bce56918f
child 29 72f79dab938e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/gefahr_massn_flist.php	Thu Jul 12 13:29:11 2012 +0200
@@ -0,0 +1,230 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 05/2012
+ * 
+ * Liste Arbeitsplatztyp - AS Massnahme 
+ * 
+ */
+
+    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>Gef&auml;hrdungen-AS-Ma&szlig;nahme-Liste</title>
+</head>
+
+<body onload="document.ffilter.filter.focus();">
+
+    <script>
+      $(document).ready(function() {
+       $(".dialogl").dialog({
+            	bgiframe: true,
+            	autoOpen: false,
+                position: [500,100],
+            	height: 300,
+                width: 400,
+                resizable: true,
+            	modal: true
+                });
+        $('a[id!=open_]').click(function() {
+                var dialog_ID = $(this).attr('id');
+                var dialogPrefix = 'open_';
+                var dialogNum = dialog_ID.substring(dialogPrefix.length);
+                $('#dialog_' + dialogNum).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&auml;rdungs-Nr.",3=>"Gef&auml;hrdung",4=>"Ma&szlig;nahme");
+
+    $zeil = $_GET["z"];
+    if (!$zeil) $zeil = $_POST["z"];
+    if (!$zeil) $zeil = 25; // Anzahl der gezeigten Zeilen
+    $start = $_GET["st"];
+    if (!$start) $start=0;
+    
+	$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,6";
+    if (!isset($dir) && !$dir)  $dir = "";
+
+
+    $sql = "SELECT asm_ID, m.gefahr_ID, gefahr_bez,asm_bez,asm_bem, gf_asm_nr
+            FROM fhiiqm.AS_Massnahme m INNER JOIN Gefahr g
+            ON m.gefahr_ID=g.gefahr_ID ";
+    $where = "";
+    if ($fnum == 2 & $filter > " ")
+        $where = " WHERE m.gefahr_ID LIKE '%$filter%' ";
+    if ($fnum == 3 & $filter > " ")
+        $where = " WHERE gefahr_bez LIKE '%$filter%' ";
+    if ($fnum == 4 & $filter > " ")
+        $where = " WHERE asm_bez LIKE '%$filter%' ";
+    $sql .= "$where ORDER BY $sort $dir LIMIT $start,$zeil";
+    
+    $result = $dbc ->queryObjectArray($sql);
+    
+    echo "<div align='center'>\n";
+    echo "<p><b>Liste Gef&auml;hrdung - Arbeitssicherheit Ma&szlig;nahmen</b></p>\n";
+        
+    if ($result)
+    {
+        $sql = "SELECT COUNT(*) FROM fhiiqm.AS_Massnahme m INNER JOIN Gefahr g
+            ON m.gefahr_ID=g.gefahr_ID $where";
+        $anz = $dbc -> querySingleItem($sql);
+        
+		$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 relevanten Spalte 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 ausgew&auml;hlten Spalten 
+                und/oder die Festlegung der Anzahl Zeilen/Bildschirm</td></tr>\n
+            <tr><td class='bigger'>Klick auf '<img src='/fhiiqm/img/edit.gif' border='0' width='11' hight='11'>' - Bearbeiten Gef&auml;hrdung - Ma&szlig;nahme</td></tr>\n";
+        echo "</table>\n";
+        
+        printf ("<p>Anzahl Ma&szlig;nahmen: %s</p>", $anz);
+        
+        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='f' value='$fnum'>";
+            echo "<table width=\"50%\" 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>Prozesse/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=\"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
+        if ($filter>'!') echo "<tr><td class='bigger' colspan=6>Filter: ". $fields["$fnum"] . " wie '$filter'</td><tr>\n";
+
+        echo "<tr bgcolor='#68ACBF'>";
+        tab_column(2,"Gef.-ID",$sort,$dir,2,$fnum,$filter,$start,$zeil);
+        tab_column(3,"Gef&auml;hrdung",$sort,$dir,3,$fnum,$filter,$start,$zeil);
+        tab_column(4,"Ma&szlig;nahme-Bezeichnung",$sort,$dir,4,$fnum,$filter,$start,$zeil);
+        echo "<th>Ma&szlig;nahme</th>";
+        tab_column(6,"lfd.Nr.",$sort,$dir,0,$fnum,$filter,$start,$zeil);
+        echo "<th>&nbsp;</th></tr>";
+   
+        if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+        
+        foreach ($result as $row)
+        {
+            if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;                
+            echo "<tr bgcolor='" . $bg . "'>";
+                
+            echo "<td>$row->gefahr_ID</td>";
+            echo "<td>$row->gefahr_bez</td>";
+            echo "<td>$row->asm_bez</td>";
+            if (strlen($row->asm_bem) > 80)
+            { 
+                $plus = "<a href='#' id='open_".$row->asm_ID."' title='vollst&auml;ndiger Text'> ... </a>";
+                echo "<div id='dialog_".$row->asm_ID."' class='dialogl' title='gesamter Text - Ma&szlig;nahme' style='display:none'>";
+                echo nl2br($row->asm_bem);
+                echo "</div>";
+            }    
+            else $plus = "";    
+            echo "<td>". nl2br(substr($row->asm_bem,0,80)). $plus;  
+            echo "<td class='right'>$row->gf_asm_nr</td>";
+            echo "</td><td><a href='/fhiiqm/gefahr_massn_ed.php?i=$row->asm_ID&z=$zeil'><img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td></tr>\n";
+        }
+        echo "</table>\n</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,$anz,$liste);
+        
+    }
+    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=\"Gefahr-Massnahmen\" class=\"sc\">Liste Gefahr AS-Ma&szlig;nahmen</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