--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/raum_aptyp_ed.php Mon May 07 16:21:00 2012 +0200
@@ -0,0 +1,188 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 04/2012
+ *
+ * INSERT/UPDATE Raum - Arbeitsplatztyp
+ */
+
+ 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("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();
+
+ $sub = $_POST["eintragen"];
+ $ap = $_POST["ap"];
+ $ok = $_POST["ok"];
+ $apid = $_GET["i"]; // raum_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>Raum - Arbeitsplatztyp</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[aptyp][]'>"+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/house.png\" border=\"0\" alt=\"Raum - Arbeitsplatztyp bearbeiten\" title=\"Raum - Arbeitsplatztyp bearbeiten\"/></div>\n";
+
+ if ($apid) $text = "editieren"; else $text = "erfassen";
+ if ($copy) $duptext = " (Kopie)";
+ echo "<div align=\"center\">";
+ echo "<h3>Raum - Arbeitsplatztypen $text</h3>";
+ echo "</div>\n";
+ if (!$sub || !isset($ap) || !$ok)
+ {
+ if ($apid && !$sub && !isset($ap))
+ {
+ $sql = "SELECT geb_ID, a.raum_ID,a.arbplatz_typ
+ FROM Raum_Arbplatz_Typ a INNER JOIN Raum r ON a.raum_ID = r.raum_ID
+ WHERE a.raum_ID = $apid
+ ORDER BY a.arbplatz_typ";
+ if ($res = $dbc -> queryObjectArray($sql))
+ {
+ foreach ($res as $row)
+ {
+ $ap["geb"] = $row->geb_ID;
+ $ap["raum"] = $row->raum_ID;
+ $ap["aptyp"][] = $row->arbplatz_typ;
+ }
+ }
+ }
+
+ include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/form/raum_aptyp_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("re",$_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=\"raum_aptyp_flist.php\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">« zur Raum-Arbplatztyp-Liste</a></p>\n";
+ echo "</form>\n";
+ }
+ else
+ {
+// print_r($ap); print("<br />");
+ 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['aptyp']))
+ { //UPDATE
+ // Loeschen alte Arbeitsplatztypen
+ $retd = $dbc -> execute("DELETE FROM Raum_Arbplatz_Typ WHERE raum_ID = ". $ap["raum"]);
+ }
+
+ if ($retd && is_array($ap['aptyp']))
+ {
+ $rett = 1;
+ $stmt -> prepare("INSERT INTO Raum_Arbplatz_Typ (raum_ID,arbplatz_typ) VALUES(?,?)");
+ for ($k=0; $k<count($ap["aptyp"]); $k++)
+ {
+ if ($ap["aptyp"][$k] && $ap["aptyp"][$k] != -1)
+ {
+ $stmt -> bind_param('is',$ap["raum"], $ap["aptyp"][$k]);
+ $rett = $stmt -> execute();
+ if (!$rett) $rett = false;
+ }
+ }
+ if (!$rett) echo "error INSERT Arbeitsplatz-Typ: $stmt->error<br />\n";
+
+ }
+ }
+ if ($rett)
+ {
+ echo "<p class='green'><b>Arbeitsplatztypen für Raum-ID '$apid' wurden erfolgreich gespeichert.</b></p>\n";
+ include ("inc/raum_aptyp_dat_show.inc.php");
+ }
+ else
+ 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'> <a href=\"raum_aptyp_flist.php\" target=\"_self\" title=\"Raum-Arbplatztyp-Liste\">« zur Raum-Arbplatztyp-Liste</a></p>\n";
+ }
+?>
+
+</body>
+</html>
\ No newline at end of file