|
1 <?php |
|
2 |
|
3 /** |
|
4 * @author Bettina Schwarzer, Fritz-Haber-Institut |
|
5 * @copyright 07/2013 |
|
6 * |
|
7 * Report Historie Keytyp in Depots |
|
8 */ |
|
9 |
|
10 error_reporting(E_ALL ^ E_NOTICE); |
|
11 |
|
12 session_start(); |
|
13 if (! isset($_SESSION["userid"])) |
|
14 { |
|
15 include_once ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/inc/func_lib.inc.php"); |
|
16 login($_SERVER["PHP_SELF"]); |
|
17 exit; |
|
18 } |
|
19 |
|
20 if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ke",$_SESSION["recht"]))) |
|
21 { |
|
22 header("Location: start.php"); |
|
23 exit; |
|
24 } |
|
25 |
|
26 include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php"); |
|
27 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
|
28 |
|
29 // zulaessige Depots |
|
30 $uid = $_SESSION["userid"]; |
|
31 $sql = "SELECT depot_ID FROM KeyDepot_userweb WHERE userid = '$uid'"; |
|
32 $res = $dbc -> queryObjectArray($sql); |
|
33 foreach ($res as $row) |
|
34 $adep[] = $row->depot_ID; |
|
35 |
|
36 ?> |
|
37 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
38 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|
39 |
|
40 <head> |
|
41 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> |
|
42 <link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS" media="screen"/> |
|
43 <link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS" media="print"/> |
|
44 <title>Historie Schlüsseltypen</title> |
|
45 </head> |
|
46 |
|
47 <body> |
|
48 |
|
49 <?php |
|
50 echo " "; |
|
51 echo "<div class=\"float-br smaller\" valign='top'>"; |
|
52 echo " user: " . $_SESSION["userid"]; |
|
53 echo " <a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n"; |
|
54 echo "<div class=\"float-r\"><img src=\"/fhiiqm/img/key.png\" border=\"0\" alt=\"Keytyp Ü:bersicht\" title=\"Schlüsseltypen im Depot\"/></div>\n"; |
|
55 |
|
56 // Korrektur Bemerkung |
|
57 $t = $_POST["t"]; |
|
58 $save = $_POST["save"]; |
|
59 $kt = $_GET["kt"]; |
|
60 $dp = $_GET["dp"]; |
|
61 $dd = $_GET["dd"]; |
|
62 |
|
63 $ky = $_POST["ky"]; // Parameter aus SearchForm |
|
64 $search = $_POST["search"]; |
|
65 if (!$search) $search = $_GET["s"]; |
|
66 if (!$search) $search = $t[s]; |
|
67 $zeil = $ky["z"]; |
|
68 if (!$zeil) $zeil = $_GET["z"]; |
|
69 if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen |
|
70 $start = $_GET["st"]; // Start bei DS $start+1 |
|
71 if (!$start) $start=0; |
|
72 |
|
73 if (!is_array($ky)) |
|
74 { |
|
75 $ky["dep"] = $_GET["d"]; |
|
76 $ky["kt"] = $_GET["k"]; |
|
77 $ky["bind"] = $_GET["b"]; |
|
78 $ky["sort1"] = $_GET["s1"]; |
|
79 $ky["sort2"] = $_GET["s2"]; |
|
80 $ky["sort3"] = $_GET["s3"]; |
|
81 } |
|
82 $_GET["d"] = $ky["dep"]; |
|
83 $_GET["k"] = $ky["kt"]; |
|
84 $_GET["b"] = $ky["bind"]; |
|
85 $_GET["s1"]= $ky["sort1"]; |
|
86 $_GET["s2"]= $ky["sort2"]; |
|
87 $_GET["s3"]= $ky["sort3"]; |
|
88 $_GET["z"] = $zeil; |
|
89 |
|
90 $ps="d=".$ky["dep"]."&k=".$ky["kt"]."&b=".$ky["bind"]."&s1=".$ky["sort1"]."&s2=".$ky["sort2"]."&s3=".$ky["sort3"]; |
|
91 |
|
92 if ($save) |
|
93 { |
|
94 // Korrektur Bemerkungsfeld in Keytyp_Depot |
|
95 if (trim($t['bem'])>'!') $t['bem'] = substr(trim($t['bem']),0,100); |
|
96 $stmt = $dbc -> stmtinit(); |
|
97 if (is_object($stmt)) |
|
98 { |
|
99 $stmt -> prepare( "UPDATE fhiiqm.Keytyp_Depot SET depot_bem = ? |
|
100 WHERE keytyp_ID=? AND depot_ID=? AND depot_date=?") ; |
|
101 $stmt -> bind_param('ssss',$t['bem'],$t["kt"],$t["dp"],$t["dd"]); |
|
102 $res = $stmt -> execute(); |
|
103 if ($stmt->error) |
|
104 { |
|
105 echo " UPDATE Keytyp_Depot, error: " . $stmt->errno . " - ". $stmt->error . "<br><br>\n"; |
|
106 $ddate = new DateTime($t["dd"]); |
|
107 echo "<p class='red'> <b>Ändern Keytyp_Depot: Bemerkung zu Keytyp = '".$t["kt"]."', Depot = '".$t["dp"]."', Datum = ".$ddate->format("d.m.Y"). |
|
108 " konnte nicht aktualisiert werden</b></p>\n"; |
|
109 } |
|
110 else |
|
111 { |
|
112 $ddate = new DateTime($t["dd"]); |
|
113 echo "<p class='green'> <b>Ändern Keytyp_Depot: Bemerkung zu Keytyp = '".$t["kt"]."', Depot = '".$t["dp"]."', Datum = ".$ddate->format("d.m.Y"). |
|
114 " wurde aktualisiert</b></p>\n"; |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 if ($search) |
|
120 { |
|
121 echo "<span class='sc'>"; |
|
122 echo "<br /> <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Historie Keytyp\" class=\"sc\">neue Historie Schlüsseltypen</a>\n"; |
|
123 echo "</span>"; |
|
124 } |
|
125 |
|
126 echo "<div align='center'>\n"; |
|
127 echo "<p><b>Historie Schlüsseltypen -> Korrektur Bemerkung</b></p>\n"; |
|
128 echo "</div>\n"; |
|
129 |
|
130 |
|
131 if (!$search) |
|
132 { |
|
133 ?> |
|
134 <div align="center"> |
|
135 <p>Bitte Kriterien für die Suche wählen</p> |
|
136 <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_raum" target="_self"> |
|
137 <table width="50%" border="0" cellspacing="3" cellpadding="3"> |
|
138 <tr> |
|
139 <td>Depot</td> |
|
140 <td><select name="ky[dep]"> |
|
141 <?php |
|
142 if ($ky["dep"] == -1) $select = "selected='selected'"; else $select = ""; |
|
143 // echo "<option $select value=\"-1\"></option>\n"; |
|
144 $strdep = "'". implode("','",$adep) ."'"; |
|
145 $sql = "SELECT * FROM fhiiqm.KeyDepot WHERE depot_ID IN ($strdep)"; |
|
146 if ($res = $dbc -> queryObjectArray($sql)) |
|
147 foreach ($res as $row) |
|
148 { |
|
149 if ($row->depot_ID == $ky['dep']) $select = "selected='selected'"; else $select = ""; |
|
150 echo "<option $select value=\"$row->depot_ID\">$row->depot_ID: $row->depot_bez</option>\n"; |
|
151 } |
|
152 $beg=0; |
|
153 ?> |
|
154 </select> |
|
155 </td> |
|
156 </tr> |
|
157 <tr> |
|
158 <td>Schlüsseltyp</td> |
|
159 <td><select name="ky[kt]"> |
|
160 <?php |
|
161 if ($ky["kt"] == -1) $select = "selected='selected'"; else $select = ""; |
|
162 echo "<option $select value=\"-1\"></option>\n"; |
|
163 $sql = "SELECT key_level,keytyp_ID,keytyp_bez |
|
164 FROM Keytyp |
|
165 ORDER BY key_level"; |
|
166 if ($res = $dbc -> queryObjectArray($sql)) |
|
167 foreach ($res as $row) |
|
168 { |
|
169 if ($row->keytyp_ID == $ky['kt']) $select = "selected='selected'"; else $select = ""; |
|
170 echo "<option $select value=\"$row->keytyp_ID\">$row->key_level - $row->keytyp_ID [$row->keytyp_bez]</option>\n"; |
|
171 } |
|
172 $beg=0; |
|
173 ?> |
|
174 </select> |
|
175 </tr> |
|
176 <tr> |
|
177 <td>Verknüpfung</td> |
|
178 <td>UND |
|
179 <input type="radio" name="ky[bind]" value="AND" <?php if (isset($ky["bind"]) && $ky["bind"]=="AND") echo "checked='checked'"; else echo "checked='checked'";?>> |
|
180 ODER |
|
181 <input type="radio" name="ky[bind]" value="OR" <?php if (isset($ky["bind"]) && $ky["bind"]=="OR") echo "checked='checked'"; ?>></td> |
|
182 </tr> |
|
183 <tr> |
|
184 <td>Sortierung nach<br />(in dieser Reihenfolge)</td><td> |
|
185 <?php |
|
186 $sort = array("-1"=>"","1,2"=>"Schlüsseltyp", "5"=>"Datum"); |
|
187 for ($i=1; $i<3; $i++) |
|
188 { |
|
189 echo "$i. <select name='ky[sort$i]'>\n"; |
|
190 foreach ($sort as $key=>$val) |
|
191 { |
|
192 $rsort = "sort" . $i; |
|
193 if ($ky[$rsort] == $val) $select = "selected='selected'"; else $select = ""; |
|
194 echo "<option $select value='$key'>$val</option>\n"; |
|
195 } |
|
196 echo "</select> \n"; |
|
197 } |
|
198 echo "</td></tr>\n"; |
|
199 |
|
200 $azeil = array(10=>'10',20=>'20',25=>'25',50=>'50',100=>'100',9999=>'alle'); // Anzahl gezeigter rows |
|
201 echo "<tr><td>Zeilen/Seite?</td><td><select name='ky[z]'>\n"; |
|
202 if (!$ky['z']) $ky['z'] = 9999; |
|
203 foreach ($azeil as $key=>$val) |
|
204 { |
|
205 if ($key == $ky['z']) $select = "selected='selected'"; else $select = ""; |
|
206 echo "<option $select value='$key'>$val</option>\n"; |
|
207 } |
|
208 echo "</select></td></tr>\n"; |
|
209 |
|
210 ?> |
|
211 <tr> |
|
212 <td> </td> |
|
213 <td><input class="button" type="submit" name="search" value="anzeigen"/></td> |
|
214 </tr> |
|
215 </table> |
|
216 </div> |
|
217 </form> |
|
218 <?php |
|
219 } |
|
220 else |
|
221 { |
|
222 |
|
223 echo "<div align='center'>\n"; |
|
224 $sql = "SELECT key_level, d.keytyp_ID,keytyp_bez,depot_ID,depot_date,depot_action,depot_anz,depot_bem |
|
225 FROM fhiiqm.Keytyp_Depot d INNER JOIN Keytyp k ON d.keytyp_ID=k.keytyp_ID"; |
|
226 |
|
227 $lim = " LIMIT $start,$zeil"; |
|
228 |
|
229 if (!$ky["bind"]) $bind = " AND "; else $bind = $ky["bind"]; |
|
230 |
|
231 if ($ky["dep"]> -1) $where = " depot_ID = '$ky[dep]' "; |
|
232 if ($ky["kt"]> -1) |
|
233 if ($where) $where .= "$bind d.keytyp_ID = '$ky[kt]' "; else $where = " d.keytyp_ID = '$ky[kt]' "; |
|
234 if ($where) $where = " WHERE ($where)"; |
|
235 |
|
236 if ($ky["sort1"]>0 || $ky["sort2"]>0) |
|
237 { |
|
238 if ($ky["sort1"]>0) $ord = " ORDER BY " . $ky["sort1"]; |
|
239 if ($ky["sort2"]>0) $ord .= ",".$ky["sort2"]; |
|
240 } |
|
241 |
|
242 $sql .= $where; |
|
243 $ianz = $dbc -> numrows($sql); |
|
244 $sql .= $ord . $lim; |
|
245 $result = $dbc ->queryObjectArray($sql); |
|
246 if ($dbc -> error) |
|
247 { |
|
248 echo "error SELECT: " . $dbc -> error . "<br /><br />"; |
|
249 echo "sql = $sql<br />\n"; |
|
250 } |
|
251 if ($ky["dep"]> -1) $krit = " [Depot = <b>'" . $ky["dep"] ."'</b>]"; |
|
252 if ($ky["kt"] > -1) |
|
253 { |
|
254 if ($krit) $bd = " ".$bind; else $bd = ""; |
|
255 $krit .= $bd." [Schlüsseltyp = <b>'".$ky["kt"]."'</b>]"; |
|
256 } |
|
257 echo "<p>Mittels Klick auf '<img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/>' - Ändern der Bemerkung des gewünschten Transfers</p>\n"; |
|
258 if ($krit )echo "Suchergebnis für $krit"; else echo "Suchergebnis\n"; |
|
259 printf ("<p>Anzahl Transfers: %s</p>", $ianz); |
|
260 |
|
261 if ($result) |
|
262 { |
|
263 include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php"); |
|
264 $aaction = array("get" => "erhalten", "out" => "ausgegeben", "lost" => "verloren"); |
|
265 |
|
266 $bg1 = "#F8F8F8"; |
|
267 $bg2 = "#DEDFE1"; |
|
268 $bg = "#FFFFFF"; |
|
269 echo "<table border='0' cellspacing='2' cellpadding='2'>\n"; |
|
270 // Listenkopf |
|
271 echo "<tr bgcolor='#68ACBF'>"; |
|
272 echo "<th>Schlüsseltyp</th><th>Schlüsseltyp-Bezeichnung</th>"; |
|
273 if ($ky["dep"] == -1) echo "<th>Depot</th>"; |
|
274 echo "<th>Datum</th><th>Aktion</th><th>Anzahl</th><th>Bemerkung</th>"; |
|
275 echo "<th> </th></tr>\n"; |
|
276 foreach ($result as $row) |
|
277 { |
|
278 if ($bg == $bg1) $bg = $bg2; else $bg = $bg1; |
|
279 if ($kt == $row->keytyp_ID && $dp == $row->depot_ID && $dd == $row->depot_date) $bg = "#D6E6E6"; |
|
280 echo "<tr bgcolor='" . $bg . "'>"; |
|
281 echo "<td>$row->key_level - $row->keytyp_ID</td><td>$row->keytyp_bez</td>"; |
|
282 if ($ky["dep"] == -1) echo "<td>$row->depot_ID</td>"; |
|
283 $ddate = new DateTime($row->depot_date); |
|
284 echo "<td>".$ddate->format("d.m.Y")."</td><td>".$aaction["$row->depot_action"]."</td><td class='right'>$row->depot_anz</td>"; |
|
285 if ($kt == $row->keytyp_ID && $dp == $row->depot_ID && $dd == $row->depot_date) |
|
286 { |
|
287 // Bemerkung editierbar |
|
288 echo "<form action='". $_SERVER['PHP_SELF'] ."' method='post' enctype='application/x-www-form-urlencoded' name='fkb'>\n"; |
|
289 echo "<td><input type='text' name='t[bem]' size='80' maxlen='100' value='".$row->depot_bem. "' />"; |
|
290 echo "<input type='hidden' name='t[s]' value='1' />"; |
|
291 echo "<input type='hidden' name='t[kt]' value='".$row->keytyp_ID."' />"; |
|
292 echo "<input type='hidden' name='t[dp]' value='".$row->depot_ID."' />"; |
|
293 echo "<input type='hidden' name='t[dd]' value='".$row->depot_date."' />"; |
|
294 echo "<input type='hidden' name='ky[kt]' value='".$ky["kt"]."' />"; |
|
295 echo "<input type='hidden' name='ky[dep]' value='".$ky["dep"]."' />"; |
|
296 echo "<input type='hidden' name='ky[bind]' value='".$ky["dep"]."' />"; |
|
297 echo "<input type='hidden' name='ky[sort1]' value='".$ky["sort1"]."' />"; |
|
298 echo "<input type='hidden' name='ky[sort2]' value='".$ky["sort2"]."' />"; |
|
299 echo "<input type='hidden' name='ky[sort3]' value='".$ky["sort3"]."' />"; |
|
300 echo " <input class=\"button\" type=\"submit\" name=\"save\" id=\"sub\" value=\"ändern\" /></td>"; |
|
301 echo "<td> </td>"; |
|
302 echo "</form>"; |
|
303 } |
|
304 else |
|
305 { |
|
306 echo "<td>$row->depot_bem</td>"; |
|
307 echo "<td><a href='".$_SERVER["PHP_SELF"]."?kt=$row->keytyp_ID&dp=$row->depot_ID&dd=$row->depot_date&s=1&$ps'> |
|
308 <img src=\"/fhiiqm/img/edit.gif\" alt='edit' title='edit' border='0'/></a></td>"; |
|
309 } |
|
310 echo "</tr>\n"; |
|
311 } |
|
312 echo "</table>\n"; |
|
313 echo "<p></p><table width=40%><tr><td class='right'><a href=\"javascript:window.print()\" class='sc'> |
|
314 <img src=\"/fhiiqm/img/printer.png\" alt=\"Bericht drucken\" border=\"0\" align=\"right\" title=\"Bericht drucken\"></a></td></tr></table>"; |
|
315 echo "</div>\n"; |
|
316 |
|
317 echo "<br /> "; |
|
318 if ($search != 2) // Aufruf aus fhiiqm |
|
319 { |
|
320 // Parameter aus $_GET fuer weitere Seiten |
|
321 $_GET["s"] = 1; // bewirkt weitere Suche |
|
322 foreach ($_GET as $key=>$val) |
|
323 { |
|
324 if ($key != "st") $liste .= "&" . $key ."=".$val; |
|
325 } |
|
326 // Links auf andere Seiten generieren |
|
327 liste_links($start,$zeil,$ianz,$liste); |
|
328 } |
|
329 } |
|
330 else |
|
331 { |
|
332 echo "<p class='red'> Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>"; |
|
333 echo "</div>\n"; |
|
334 echo "<br /> "; |
|
335 } |
|
336 echo "<span class='sc'>"; |
|
337 echo "<br /><br /> <a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" title=\"Historie Keytyp\" class=\"sc\">neue Historie Schlüsseltypen</a>\n"; |
|
338 echo "</span>"; |
|
339 } |
|
340 ?> |
|
341 </body> |
|
342 </html> |