--- a/fhiiqm/deprecated/ap_massn_ed.php Fri Jan 17 08:50:55 2014 +0100
+++ b/fhiiqm/deprecated/ap_massn_ed.php Wed Aug 06 09:42:40 2014 +0200
@@ -1,195 +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ß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 " ";
- 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 - Massnahmen bearbeiten\" title=\"Arbeitsplatztyp - Massnahme bearbeiten\"/></div>\n";
-
- if ($apid) $text = "editieren"; else $text = "erfassen";
- echo "<div align=\"center\">";
- echo "<h3>Arbeitsplatztyp - Arbeitssicherheit Maß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> </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_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Massnahmenen-Liste\">« 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ß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ß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> </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ßnahmen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden nicht oder nur teilweise gespeichert</b></p>\n";
-
- echo "</div>";
- echo "<p class='sc'> <a href=\"ap_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Maßnahmen-Liste\">« zur Arbeitsplatztyp-Maßnahmen-Liste</a></p>\n";
- }
-?>
-</body>
+<?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ß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 " ";
+ 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 - Massnahmen bearbeiten\" title=\"Arbeitsplatztyp - Massnahme bearbeiten\"/></div>\n";
+
+ if ($apid) $text = "editieren"; else $text = "erfassen";
+ echo "<div align=\"center\">";
+ echo "<h3>Arbeitsplatztyp - Arbeitssicherheit Maß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> </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_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Massnahmenen-Liste\">« 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ß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ß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> </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ßnahmen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden nicht oder nur teilweise gespeichert</b></p>\n";
+
+ echo "</div>";
+ echo "<p class='sc'> <a href=\"ap_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Maßnahmen-Liste\">« zur Arbeitsplatztyp-Maßnahmen-Liste</a></p>\n";
+ }
+?>
+</body>
</html>
\ No newline at end of file