--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/ap_gefahr_ed.php Fri Jun 08 15:04:22 2012 +0200
@@ -0,0 +1,193 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 06/2012
+ *
+ * INSERT/UPDATE Arbeitsplatz - Gefahr
+ *
+ */
+
+
+ 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 - Gefährdung</title>
+
+ <script type="text/javascript">
+ <!--
+ var counter = 0;
+ var limit = 99;
+ var arr = new Array();
+ function addInput(divName){
+ 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,"'>",key, " - ",arr[key],"</option>\n" );
+ }
+ opt += "</select>\n";
+ newdiv.innerHTML += "<select name='ap[gf][]'>"+opt;
+ document.getElementById(divName).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 " ";
+ echo "<div class=\"float-br smaller\" valign='top'>";
+ echo " user: " . $_SESSION["userid"];
+ echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
+ echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"Arbeitsplatztyp - Gefährdung bearbeiten\" title=\"Arbeitsplatztyp - Gefährdung bearbeiten\"/></div>\n";
+
+ if ($apid) $text = "editieren"; else $text = "erfassen";
+ echo "<div align=\"center\">";
+ echo "<h3>Arbeitsplatztyp - Gefährdung $text</h3>";
+ echo "</div>\n";
+ if (!$sub || !isset($ap) || !$ok)
+ {
+ if ($apid && !$sub && !isset($ap))
+ {
+ $sql = "SELECT gefahr_ID, arbplatz_typ FROM Gefahr_Arbplatz WHERE arbplatz_typ = '" . $apid . "'";
+ if ($res = $dbc -> queryObjectArray($sql))
+ {
+ foreach ($res as $row)
+ {
+ $ap["aptyp"] = $row->arbplatz_typ;
+ $ap["gf"][] = $row->gefahr_ID;
+ }
+ }
+ else $ap["aptyp"] = $apid;
+ }
+ include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/form/ap_gefahr_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> </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'> <a href=\"ap_gefahr_flist.php\" target=\"_self\" title=\"Arbplatztyp-Gefährdungen-Liste\">« zur Arbeitsplatztyp-Gefährdungen-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['gf']))
+ { //UPDATE
+ // Loeschen alte Arbeitsplatztypen
+ $retd = $dbc -> execute("DELETE FROM Gefahr_Arbplatz WHERE arbplatz_typ = '". $ap["aptyp"] ."'");
+ }
+
+ if ($retd && is_array($ap['gf']))
+ {
+ $rett = 1;
+ $stmt -> prepare("INSERT INTO Gefahr_Arbplatz (gefahr_ID,arbplatz_typ) VALUES(?,?)");
+ for ($k=0; $k<count($ap["gf"]); $k++)
+ {
+ if ($ap["gf"][$k] && $ap["gf"][$k] != -1)
+ {
+ $stmt -> bind_param('ss',$ap["gf"][$k], $ap["aptyp"]);
+ $rett = $stmt -> execute();
+ if (!$rett) $rett = false;
+ }
+ }
+ if (!$rett) echo "error INSERT Gefahr: $stmt->error<br />\n";
+
+ }
+ }
+ if ($rett)
+ {
+ echo "<p class='green'><b>Gefährdungen für Arbeitsplatztyp '$apid' wurden erfolgreich gespeichert.</b></p>\n";
+ echo "<table>\n";
+ if (is_array($ap["gf"]))
+ {
+ echo "<tr><td>Gefahren: </td>";
+ foreach ($ap["gf"] as $gf)
+ {
+ if ($next) $next ="<tr><td> </td>"; else $next =" ";
+ if ($gf && $gf != -1) echo "$next<td>$gf</td></tr>\n";
+ }
+ }
+ echo "</table>\n";
+ }
+ else
+ echo "<p class='red'><b>Gefährdungen für Arbeitsplatztyp '$apid'' wurden nicht oder nur teilweise gespeichert</b></p>\n";
+
+ echo "</div>";
+ echo "<p class='sc'> <a href=\"ap_gefahr_flist.php\" target=\"_self\" title=\"Arbplatztyp-Gefährdungen-Liste\">« zur Arbeitsplatztyp-Gefährdung-Liste</a></p>\n";
+ }
+?>
+</body>
+</html>
\ No newline at end of file