|
1 <?php |
|
2 |
|
3 /** |
|
4 * @author Bettina Schwarzer, Fritz-Haber-Institut |
|
5 * @copyright 06/2012 |
|
6 * |
|
7 * INSERT/UPDATE Arbeitsplatz - Massnahmen |
|
8 * |
|
9 */ |
|
10 |
|
11 |
|
12 error_reporting(E_ALL ^ E_NOTICE); |
|
13 |
|
14 session_start(); |
|
15 if (! isset($_SESSION["userid"])) |
|
16 { |
|
17 include_once ("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 $sub = $_POST["eintragen"]; |
|
32 $ap = $_POST["ap"]; |
|
33 $ok = $_POST["ok"]; |
|
34 $apid = $_GET["i"]; // arbeitsplatz_ID |
|
35 |
|
36 |
|
37 |
|
38 ?> |
|
39 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
40 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|
41 |
|
42 <head> |
|
43 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> |
|
44 <link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> |
|
45 <link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> |
|
46 <title>Arbeitsplatztyp - AS Maßnahmen</title> |
|
47 |
|
48 <script type="text/javascript"> |
|
49 <!-- |
|
50 var counter = 0; |
|
51 var limit = 99; |
|
52 var arr = new Array(); |
|
53 function addInput(divId){ |
|
54 if (counter == limit) { |
|
55 alert("Das Limit von " + counter + " zusätzlichen inputs ist erreicht"); |
|
56 } |
|
57 else { |
|
58 var newdiv = document.createElement('div'); |
|
59 var count; |
|
60 var opt="<option value='-1'></option>"; |
|
61 for (var key in arr) |
|
62 { |
|
63 opt = opt.concat("<option value='",key,"'>",arr[key],"</option>\n" ); |
|
64 } |
|
65 opt += "</select>\n"; |
|
66 newdiv.innerHTML += "<select name='ap[asm][]'>"+opt; |
|
67 document.getElementById(divId).appendChild(newdiv); |
|
68 counter++; |
|
69 } |
|
70 } |
|
71 function delInput(divId){ |
|
72 var kn = document.getElementById(divId); |
|
73 while (kn.childNodes.length>0 && kn.lastChild.nodeName != "SELECT" && kn.lastChild.nodeName != "A") |
|
74 { |
|
75 // alert ("vor "+kn.lastChild.nodeName+", nodetyp = "+ kn.lastChild.nodeType); |
|
76 var knc = kn.lastChild; |
|
77 document.getElementById(divId).removeChild(knc); |
|
78 } |
|
79 if (kn.lastChild.nodeName == "SELECT") document.getElementById(divId).removeChild(kn.lastChild); |
|
80 } |
|
81 //--> |
|
82 </script> |
|
83 |
|
84 </head> |
|
85 |
|
86 <body> |
|
87 |
|
88 <?php |
|
89 echo " "; |
|
90 echo "<div class=\"float-br smaller\" valign='top'>"; |
|
91 echo " user: " . $_SESSION["userid"]; |
|
92 echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n"; |
|
93 echo "<div class=\"float-r\"><img src=\"img/role.png\" border=\"0\" alt=\"Arbeitsplatztyp - Massnahmen bearbeiten\" title=\"Arbeitsplatztyp - Massnahme bearbeiten\"/></div>\n"; |
|
94 |
|
95 if ($apid) $text = "editieren"; else $text = "erfassen"; |
|
96 echo "<div align=\"center\">"; |
|
97 echo "<h3>Arbeitsplatztyp - Arbeitssicherheit Maßnahmen $text</h3>"; |
|
98 echo "</div>\n"; |
|
99 if (!$sub || !isset($ap) || !$ok) |
|
100 { |
|
101 if ($apid && !$sub && !isset($ap)) |
|
102 { |
|
103 $sql = "SELECT asm_ID, arbplatz_typ FROM AS_Massnahme_Arbplatz WHERE arbplatz_typ = '" . $apid . "'"; |
|
104 if ($res = $dbc -> queryObjectArray($sql)) |
|
105 { |
|
106 foreach ($res as $row) |
|
107 { |
|
108 $ap["aptyp"] = $row->arbplatz_typ; |
|
109 $ap["asm"][] = $row->asm_ID; |
|
110 } |
|
111 } |
|
112 else $ap["aptyp"] = $apid; |
|
113 } |
|
114 include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/form/ap_massn_form.inc.php"); |
|
115 |
|
116 if ($sub) |
|
117 { |
|
118 $frage = "Alle Angaben ok?"; |
|
119 echo "<tr> |
|
120 <td class=\"red\" valign=\"top\" align=\"left\">$frage</td> |
|
121 <td><input type=\"checkbox\" name=\"ok\" value=\"1\""; |
|
122 if ($ok) echo "checked=\"checked\""; |
|
123 echo " /></td>\n</tr>\n"; |
|
124 } |
|
125 if (!is_null($_SESSION["recht"]) && in_array("ase",$_SESSION["recht"])) |
|
126 { |
|
127 echo " |
|
128 <tr><td> </td>\n |
|
129 <td><input class=\"button\" type=\"submit\" name=\"eintragen\" value=\" eintragen \" />"; |
|
130 echo "</td></tr>\n"; |
|
131 } |
|
132 echo "</table>\n"; |
|
133 echo "</div>\n"; |
|
134 echo "<p class='sc'> <a href=\"ap_massn_flist.php\" target=\"_self\" title=\"Arbplatztyp-Massnahmenen-Liste\">« zur Arbeitsplatztyp-Massnahmenen-Liste</a></p>\n"; |
|
135 echo "</form>\n"; |
|
136 } |
|
137 else |
|
138 { |
|
139 echo "<div align='center'>\n"; |
|
140 |
|
141 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
|
142 |
|
143 $stmt = $dbc -> stmtinit(); |
|
144 if (is_object($stmt)) |
|
145 { |
|
146 $retd = 1; |
|
147 if ($apid && is_array($ap['asm'])) |
|
148 { //UPDATE |
|
149 // Loeschen alte Arbeitsplatztypen |
|
150 $retd = $dbc -> execute("DELETE FROM AS_Massnahme_Arbplatz WHERE arbplatz_typ = '". $ap["aptyp"] ."'"); |
|
151 } |
|
152 |
|
153 if ($retd && is_array($ap['asm'])) |
|
154 { |
|
155 $rett = 1; |
|
156 $stmt -> prepare("INSERT INTO AS_Massnahme_Arbplatz (asm_ID,arbplatz_typ) VALUES(?,?)"); |
|
157 for ($k=0; $k<count($ap["asm"]); $k++) |
|
158 { |
|
159 if ($ap["asm"][$k] && $ap["asm"][$k] != -1) |
|
160 { |
|
161 $stmt -> bind_param('is',$ap["asm"][$k], $ap["aptyp"]); |
|
162 $rett = $stmt -> execute(); |
|
163 if (!$rett) $rett = false; |
|
164 } |
|
165 } |
|
166 if (!$rett) echo "error INSERT Massnahme: $stmt->error<br />\n"; |
|
167 |
|
168 } |
|
169 } |
|
170 if ($rett) |
|
171 { |
|
172 echo "<p class='green'><b>AS Maßnahmenen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden erfolgreich gespeichert.</b></p>\n"; |
|
173 echo "<table>\n"; |
|
174 if (is_array($ap["asm"])) |
|
175 { |
|
176 echo "<tr><td>AS Maßnahmen: </td>"; |
|
177 foreach ($ap["asm"] as $gf) |
|
178 { |
|
179 $sql = "SELECT asm_bez FROM AS_Massnahme WHERE asm_ID=$gf"; |
|
180 $asmbez = $dbc -> querySingleItem($sql); |
|
181 if ($next) $next ="<tr><td> </td>"; else $next =" "; |
|
182 if ($gf && $gf != -1) echo "$next<td>$asmbez</td></tr>\n"; |
|
183 } |
|
184 } |
|
185 echo "</table>\n"; |
|
186 } |
|
187 else |
|
188 echo "<p class='red'><b>AS Maßnahmen für Arbeitsplatztyp '".$ap["aptyp"]."' wurden nicht oder nur teilweise gespeichert</b></p>\n"; |
|
189 |
|
190 echo "</div>"; |
|
191 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"; |
|
192 } |
|
193 ?> |
|
194 </body> |
|
195 </html> |