|
1 <?php |
|
2 |
|
3 /** |
|
4 * @author Bettina Schwarzer, Fritz-Haber-Institut |
|
5 * @copyright 05/2013 |
|
6 * |
|
7 * Report Gefahrgruppe - Gefaehrdung - Pictogramm |
|
8 */ |
|
9 |
|
10 error_reporting(E_ALL ^ E_NOTICE); |
|
11 |
|
12 if (!isset($_GET['s']) || $_GET['s'] != 2 ) |
|
13 { |
|
14 session_start(); |
|
15 if (! isset($_SESSION["userid"])) |
|
16 { |
|
17 include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php"); |
|
18 login($_SERVER["PHP_SELF"]); |
|
19 exit; |
|
20 } |
|
21 |
|
22 if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("asr",$_SESSION["recht"]) && !in_array("ase",$_SESSION["recht"]))) |
|
23 { |
|
24 header("Location: start.php"); |
|
25 exit; |
|
26 } |
|
27 } |
|
28 include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php"); |
|
29 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
|
30 |
|
31 |
|
32 ?> |
|
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
34 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|
35 |
|
36 <head> |
|
37 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> |
|
38 <link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> |
|
39 <link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> |
|
40 <title>Report Gefährdungsgruppe-Gefährdung-Piktogramm</title> |
|
41 </head> |
|
42 |
|
43 <body> |
|
44 |
|
45 <?php |
|
46 echo " "; |
|
47 if (!isset($_GET['s']) || $_GET['s'] != 2 ) |
|
48 { |
|
49 echo "<div class=\"float-br smaller\" valign='top'>"; |
|
50 echo " user: " . $_SESSION["userid"]; |
|
51 echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n"; |
|
52 } |
|
53 echo "<div class=\"float-r\"><img src=\"/fhiiqm/img/role.png\" border=\"0\" alt=\"Arbeitssicherheit\" title=\"Arbeitssicherheit\"/></div>\n"; |
|
54 |
|
55 $rag = $_POST["rag"]; // Parameter aus Form |
|
56 $search = $_POST["search"]; |
|
57 if (!$search) $search = $_GET["s"]; |
|
58 |
|
59 $zeil = $rag["z"]; |
|
60 if (!$zeil) $zeil = $_GET["z"]; |
|
61 if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen |
|
62 $start = $_GET["st"]; // Start bei DS $start+1 |
|
63 if (!$start) $start=0; |
|
64 |
|
65 if (!is_array($rag)) |
|
66 { |
|
67 $rag["gef"] = $_GET["g"]; |
|
68 $rag["gru"] = $_GET["u"]; |
|
69 $rag["bind"] = $_GET["b"]; |
|
70 $rag["sort1"] = $_GET["s1"]; |
|
71 $rag["sort2"] = $_GET["s2"]; |
|
72 $rag["sort3"] = $_GET["s3"]; |
|
73 } |
|
74 $_GET["g"] = $rag["gef"]; |
|
75 $_GET["u"] = $rag["gru"]; |
|
76 $_GET["b"] = $rag["bind"]; |
|
77 $_GET["s1"] = $rag["sort1"]; |
|
78 $_GET["s2"] = $rag["sort2"]; |
|
79 $_GET["s3"] = $rag["sort3"]; |
|
80 $_GET["z"] = $zeil; |
|
81 |
|
82 if ($search && $_GET['s'] != 2) |
|
83 { |
|
84 echo "<span class='sc'>"; |
|
85 echo "<br /> <a href=\"/fhiiqm/as_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>« zur Berichtsübersicht</a>"; |
|
86 echo " | <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Gefgruppe-Gef.-Pic\" class=\"sc\">neuer Bericht Gefährdungsgruppe - Gefährdung - Piktogramm</a>\n"; |
|
87 echo "</span>"; |
|
88 } |
|
89 echo "<div align='center'>\n"; |
|
90 echo "<p><b>(5b) Bericht Gefährdungsgruppe - Gefährdung - Piktogramm</b></p>\n"; |
|
91 echo "</div>\n"; |
|
92 |
|
93 |
|
94 if (!$search) |
|
95 { |
|
96 ?> |
|
97 <div align="center"> |
|
98 <p>Bitte Kriterien für die Suche wählen</p> |
|
99 <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_as_report.php" target="_self"> |
|
100 <table width="50%" border="0" cellspacing="3" cellpadding="3"> |
|
101 <tr> |
|
102 <td>Gefährdungs-Gruppe</td> |
|
103 <td><select name="rag[gru]" onchange="this.form.submit();"> |
|
104 <?php |
|
105 if ($rag["atyp"] == -1) $select = " selected='selected' "; else $select = ""; |
|
106 echo "<option $select value=\"-1\"></option>\n"; |
|
107 $sql = "SELECT gefahrgr_ID,gefahrgr_bez FROM fhiiqm.Gefahr_Gruppe ORDER BY 1"; |
|
108 if ($result = $dbc->queryObjectArray($sql)) |
|
109 { |
|
110 foreach ($result as $row) |
|
111 { |
|
112 $select = ($row->gefahrgr_ID == $rag['gru'])? " selected='selected'" : ""; |
|
113 echo "<option$select value=\"$row->gefahrgr_ID\">$row->gefahrgr_ID - $row->gefahrgr_bez</option>\n"; |
|
114 } |
|
115 } |
|
116 ?> |
|
117 </select> |
|
118 </td> |
|
119 </tr> |
|
120 <tr> |
|
121 <td>Gefährdung</td> |
|
122 <td><select name="rag[gef]"> |
|
123 <?php |
|
124 if ($rag["gru"] && $rag["gru"]>0) $wher = " WHERE gefahrgr_ID = " . $rag["gru"]; else $wher = ""; |
|
125 if ($rag["gef"] == -1) $select = " selected='selected' "; else $select = ""; |
|
126 echo "<option $select value=\"-1\"></option>\n"; |
|
127 $sql = "SELECT gefahr_ID,gefahrgr_ID,gefahr_bez FROM fhiiqm.Gefahr $wher |
|
128 ORDER BY CONVERT(substring(gefahr_ID,1,INSTR(gefahr_ID,'.')-1),DECIMAL),CONVERT(SUBSTRING(gefahr_ID,INSTR(gefahr_ID,'.')+1),DECIMAL);"; |
|
129 if ($result = $dbc->queryObjectArray($sql)) |
|
130 { |
|
131 foreach ($result as $row) |
|
132 { |
|
133 $select = ($row->gefahr_ID == $rag['gef'])? " selected='selected'" : ""; |
|
134 echo "<option$select value=\"$row->gefahr_ID\">$row->gefahr_ID - $row->gefahr_bez</option>\n"; |
|
135 } |
|
136 } |
|
137 ?> |
|
138 </select> |
|
139 </td> |
|
140 </tr> |
|
141 <tr> |
|
142 <td>Verknüpfung</td> |
|
143 <td>UND |
|
144 <input type="radio" name="rag[bind]" value="AND" <?php if (isset($rag["bind"]) && $rag["bind"]=="AND") echo "checked"; else echo "checked";?>> |
|
145 ODER |
|
146 <input type="radio" name="rag[bind]" value="OR" <?php if (isset($rag["bind"]) && $rag["bind"]=="OR") echo "checked"; ?>></td> |
|
147 </tr> |
|
148 <tr> |
|
149 <td>Sortierung nach<br />(in dieser Reihenfolge)</td><td> |
|
150 <?php |
|
151 $sort = array("-1"=>"","1"=>"Gefährdungsgruppe","2"=>"Gefährdung"); |
|
152 for ($i=1; $i<3; $i++) |
|
153 { |
|
154 echo "$i. <select name='rag[sort$i]'>\n"; |
|
155 foreach ($sort as $key=>$val) |
|
156 { |
|
157 $rsort = "sort" . $i; |
|
158 if ($rag[$rsort] == $val) $select= " selected"; else $select = ""; |
|
159 echo "<option$select value='$key'>$val</option>\n"; |
|
160 } |
|
161 echo "</select> \n"; |
|
162 } |
|
163 echo "</td></tr>\n"; |
|
164 |
|
165 $azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows |
|
166 echo "<tr><td>Zeilen/Seite?</td><td><select name='rag[z]'>\n"; |
|
167 if (!$rag['z']) $rag['z'] = 9999; |
|
168 foreach ($azeil as $key=>$val) |
|
169 { |
|
170 if ($key == $rag['z']) $select = "selected"; else $select = ""; |
|
171 echo "<option $select value='$key'>$val</option>\n"; |
|
172 } |
|
173 echo "</select></td></tr>\n"; |
|
174 |
|
175 ?> |
|
176 <tr> |
|
177 <td> </td> |
|
178 <td><input class="button" type="submit" name="search" value="Bericht erstellen"/></td> |
|
179 </tr> |
|
180 </table> |
|
181 </div> |
|
182 </form> |
|
183 |
|
184 <?php |
|
185 } |
|
186 else |
|
187 { |
|
188 echo "<div align='center'>\n"; |
|
189 $sql = "SELECT gg.gefahrgr_ID,g.gefahr_ID,gefahrgr_bez,gefahr_bez,gefahr_pic,gefahr_pic_bez |
|
190 FROM Gefahr_Gruppe gg LEFT OUTER JOIN Gefahr g ON gg.gefahrgr_ID=g.gefahrgr_ID "; |
|
191 |
|
192 $lim = " LIMIT $start,$zeil"; |
|
193 |
|
194 if (!$rag["bind"]) $bind = " AND "; else $bind = $rag["bind"]; |
|
195 |
|
196 if ($rag["gru"]> -1) |
|
197 { |
|
198 if ($where) $where .= "$bind g.gefahrgr_ID = '$rag[gru]' "; else $where = " g.gefahrgr_ID = '$rag[gru]' "; |
|
199 $krit = " [Gefährdungsgruppe = '" . $dbc -> querySingleItem("SELECT gefahrgr_bez FROM Gefahr_Gruppe WHERE gefahrgr_ID='".$rag['gru'] ."'")."']"; |
|
200 } |
|
201 if ($rag["gef"]> -1) |
|
202 { |
|
203 $where = " g.gefahr_ID = '$rag[gef]' "; |
|
204 if ($krit) $bd = " ".$bind; else $bd = ""; |
|
205 $krit .= "$bd [Gefährdung = '" . $dbc -> querySingleItem("SELECT gefahr_bez FROM Gefahr WHERE gefahr_ID='".$rag['gef'] ."'")."']"; |
|
206 } |
|
207 if ($where) $where = " WHERE ($where)"; |
|
208 |
|
209 if ($rag["sort1"]>0 || $rag["sort2"]>0 || $rag["sort3"]>0) |
|
210 { |
|
211 if ($rag["sort1"]>0) $ord = " ORDER BY " . $rag["sort1"]; |
|
212 if ($rag["sort2"]>0) $ord .= ",".$rag["sort2"]; |
|
213 if ($rag["sort3"]>0) $ord .= ",".$rag["sort3"]; |
|
214 } |
|
215 $sql .= $where; |
|
216 if ($ord && strpos($ord,'2')>0) $ord = str_replace("2","CONVERT(substring(g.gefahr_ID,1,INSTR(g.gefahr_ID,'.')-1),DECIMAL),CONVERT(SUBSTRING(g.gefahr_ID,INSTR(g.gefahr_ID,'.')+1),DECIMAL)",$ord); |
|
217 $sql .= $ord . $lim; |
|
218 // echo "sql = $sql<br />\n"; |
|
219 $result = $dbc ->queryObjectArray($sql); |
|
220 |
|
221 if ($krit )echo "Suchergebnis für $krit"; else echo "Suchergebnis\n"; |
|
222 $ianz = $dbc -> querySingleItem("SELECT COUNT(*) |
|
223 FROM Gefahr_Gruppe gg LEFT OUTER JOIN Gefahr g |
|
224 ON gg.gefahrgr_ID=g.gefahrgr_ID $where"); |
|
225 printf ("<p>Anzahl: %s</p>", $ianz); |
|
226 |
|
227 if ($result) |
|
228 { |
|
229 include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php"); |
|
230 |
|
231 $bg1 = "#F8F8F8"; |
|
232 $bg2 = "#DEDFE1"; |
|
233 $bg = "#FFFFFF"; |
|
234 echo "<table border='1' width='50%' cellspacing='0' cellpadding='2'>\n"; |
|
235 // Listenkopf |
|
236 echo "<tr bgcolor='#68ACBF'>"; |
|
237 echo "<th>Gefährdungsgruppe</th>"; |
|
238 echo "<th>Gefährdung</th>"; |
|
239 echo "<th>pic</th>"; |
|
240 echo "<th>pic_bez</th>"; |
|
241 echo "</tr>\n"; |
|
242 |
|
243 foreach ($result as $row) |
|
244 { |
|
245 $gid = $row->gefahr_ID; |
|
246 if ($gru != $row->gefahrgr_ID) |
|
247 { |
|
248 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1; |
|
249 echo "<tr bgcolor='" . $bg . "'>"; |
|
250 echo "<td>$row->gefahrgr_ID - $row->gefahrgr_bez</td>"; |
|
251 echo "<td nowrap='1'>$row->gefahr_ID - $row->gefahr_bez</td>"; |
|
252 $gid = urlencode(trim($gid)); |
|
253 echo "<td><img name='gefahr' width='30px' src=" . "'/fhiiqm/inc/show_img_gef.inc.php?gid=$gid' alt='$gef' title='$gef'></td>"; |
|
254 echo "<td>$row->gefahr_pic_bez</td></tr>\n"; |
|
255 } |
|
256 elseif ($gru == $row->gefahrgr_ID && $gfid != $row->gefahr_ID) |
|
257 { |
|
258 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1; |
|
259 echo "<tr bgcolor='" . $bg . "'>"; |
|
260 echo "<td> </td>"; |
|
261 echo "<td nowrap='1'>$row->gefahr_ID - $row->gefahr_bez</td>"; |
|
262 $gid = urlencode(trim($gid)); |
|
263 echo "<td><img name='gefahr' width='30px' src=" . "'/fhiiqm/inc/show_img_gef.inc.php?gid=$gid' alt='$gef' title='$gef'></td>"; |
|
264 echo "<td>$row->gefahr_pic_bez</td></tr>\n"; |
|
265 } |
|
266 $gfid = $row->gefahr_ID; |
|
267 $gru = $row->gefahrgr_ID; |
|
268 } |
|
269 echo "</table>\n"; |
|
270 echo "<p></p><table width=60%><tr><td class='right'><a href=\"javascript:window.print()\" class='sc'> |
|
271 <img src=\"/fhiiqm/img/printer.png\" alt=\"Bericht drucken\" border=\"0\" align=\"right\" title=\"Bericht drucken\"></a></td></tr></table>"; |
|
272 echo "</div>\n"; |
|
273 |
|
274 echo "<br /> "; |
|
275 if ($search != 2) // Aufruf aus fhiiqm |
|
276 { |
|
277 // Parameter aus $_GET fuer weitere Seiten |
|
278 $_GET["s"] = 1; // bewirkt weitere Suche |
|
279 foreach ($_GET as $key=>$val) |
|
280 { |
|
281 if ($key != "st") $liste .= "&" . $key ."=".$val; |
|
282 } |
|
283 // Links auf andere Seiten generieren |
|
284 liste_links($start,$zeil,$ianz,$liste); |
|
285 } |
|
286 } |
|
287 else |
|
288 { |
|
289 echo "<p class='red'> Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>"; |
|
290 echo "</div>\n"; |
|
291 } |
|
292 if ($search != 2) |
|
293 { |
|
294 echo "<span class='sc'>"; |
|
295 echo "<br /><br /> <a href=\"/fhiiqm/as_report.php\" target=\"_self\" title=\"Berichte\" class='sc'>« zur Berichtsübersicht</a>"; |
|
296 echo " | <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Gefgruppe-Gef.-Pic\" class=\"sc\">neuer Bericht Gefährdungsgruppe - Gefährdung - Piktogramm</a>\n"; |
|
297 echo "</span>"; |
|
298 } |
|
299 else |
|
300 echo "<a href='javascript:history.back();' onMouseOver=\"{window.status='Zurück'; return true;}\">« Zurück</a>"; |
|
301 |
|
302 } |
|
303 ?> |
|
304 </body> |
|
305 </html> |