|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|
3 |
|
4 <head> |
|
5 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> |
|
6 <link href="css/db.css" rel="STYLESHEET" type="TEXT/CSS" /> |
|
7 |
|
8 <title>Eingabe Informationen</title> |
|
9 </head> |
|
10 |
|
11 <body> |
|
12 <div class="float-r"><img src="img/document_image_ver.png" border="0" alt="Informationen eingeben" title="Informationen eingeben"/></div> |
|
13 |
|
14 <?php |
|
15 |
|
16 /** |
|
17 * @author Bettina Schwarzer, Fritz-Haber-Institut |
|
18 * @copyright 08/2011 |
|
19 * |
|
20 * INSERT Informationen |
|
21 */ |
|
22 |
|
23 error_reporting(E_ALL ^ E_NOTICE); |
|
24 |
|
25 include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php"); |
|
26 //$dbc = new dbconnection(); |
|
27 |
|
28 $ok = $_POST["ok"]; |
|
29 $inf = $_POST["inf"]; |
|
30 $submit = $_POST["ins"]; |
|
31 if (!$inf["okn"]) $ok = false; |
|
32 if (!$ok || !$submit) |
|
33 { |
|
34 include($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/form/info_form.inc.php"); |
|
35 if ($submit) |
|
36 { |
|
37 echo |
|
38 "<tr> |
|
39 <td>Upload Infodokument </td> |
|
40 <td><input type=\"file\" name=\"ifile\" size=\"50\" maxlength=\"50\" value=\"" . |
|
41 $_FILES["ifile"]["name"] . "\"/></td> |
|
42 </tr>"; |
|
43 |
|
44 $frage = "Alle Angaben ok?<br> |
|
45 erst wenn Haken gesetzt, Upload-File wählen!"; |
|
46 echo "<tr> |
|
47 <td class=\"red\" valign=\"top\" align=\"left\">$frage</td> |
|
48 <td><input type=\"checkbox\" name=\"ok\" value=\"1\""; |
|
49 if ($ok) echo "checked"; |
|
50 echo "></td>\n</tr>\n"; |
|
51 } |
|
52 |
|
53 echo "<tr>\n"; |
|
54 echo " |
|
55 <td> </td> |
|
56 <td><input class=\"button\" type=\"submit\" value=\"eingeben\" name=\"ins\" title=\"insert\" /></td>\n"; |
|
57 echo "</tr>\n"; |
|
58 echo "</table>\n"; |
|
59 echo "</div>\n"; |
|
60 echo "</form>\n"; |
|
61 |
|
62 } |
|
63 else |
|
64 { |
|
65 echo "<div align='center'>\n"; |
|
66 //daten speichern |
|
67 $inf["iname"] = substr($inf["iname"],0,300); |
|
68 $inf["ilong"] = substr($inf["ilong"],0,8000); |
|
69 if ($inf["ityp"] == -1) $inf["ityp"] = null; |
|
70 |
|
71 if ($inf["ijahr"] && $inf["imon"] && $inf["itag"]) |
|
72 { |
|
73 $idat = $inf["ijahr"]."-".$inf["imon"]."-".$inf["itag"]; |
|
74 // Datum valid? |
|
75 if (!$idat = new DateTime_s($idat)) $idat = null; |
|
76 } |
|
77 else |
|
78 $idat = null; |
|
79 if ($inf["bjahr"] && $inf["bmon"] && $inf["btag"]) |
|
80 { |
|
81 $bdat = $inf["bjahr"]."-".$inf["bmon"]."-".$inf["btag"]; |
|
82 if (!$bdat = new DateTime_s($bdat)) $bdat = null; |
|
83 } |
|
84 else |
|
85 $bdat = null; |
|
86 if ($inf["ejahr"] && $inf["emon"] && $inf["etag"]) |
|
87 { |
|
88 $edat = $inf["ejahr"]."-".$inf["emon"]."-".$inf["etag"]; |
|
89 if (!$edat = new DateTime_s($edat)) $edat = null; |
|
90 } |
|
91 else |
|
92 $edat = null; |
|
93 |
|
94 if ($inf["pers"] == -1) $inf["pers"] = null; |
|
95 if ($inf["prid"] <1 ) $inf["prid"] = null; |
|
96 if ($inf["infrel"] == -1) $inf["infrel"] = null; |
|
97 if ($inf["lang"] == -1) $inf["lang"] = null; |
|
98 //echo "datcreate: $idat, datevalidfrom: $bdat, datevalidto: $edat, author: " . $inf["pers"] . "<br />\n"; |
|
99 |
|
100 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
|
101 $stmt = $dbc -> stmtinit(); |
|
102 if (is_object($stmt)) |
|
103 { |
|
104 $stmt -> prepare ("INSERT INTO Info (info_name_s,info_name_l,info_date,info_valid_from,info_valid_to, |
|
105 infotyp_ID,persknr,lang,info_rel_ID) VALUES (?,?,?,?,?,?,?,?,?)"); |
|
106 $stmt -> bind_param('sssssiisi', $inf["iname"],$inf["ilong"],$idat,$bdat,$edat,$inf["ityp"],$inf["pers"],$inf["lang"],$inf["infrel"]); |
|
107 $result = $stmt -> execute(); |
|
108 } |
|
109 if ($dbc->error) echo "error: " . $dbc->error . "<br><br>\n"; |
|
110 if ($result) |
|
111 { // INSERT o.k. |
|
112 // info_ID ermitteln |
|
113 $infid = $dbc -> insertId(); |
|
114 |
|
115 // n:m Tabellen INSERT |
|
116 include ("inc/info_tab_ins.inc.php"); |
|
117 |
|
118 // upload File |
|
119 if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] ) |
|
120 { |
|
121 include ("inc/file_upload.inc.php"); |
|
122 $fname = gen_filename($inf['ifname'],"ifile",$infid); |
|
123 $retf = upload("ifile", $fname, $infid, "infos"); // Datei prüfen und in Dokumentenverzeichnis verschieben |
|
124 |
|
125 if ($retf) |
|
126 { // upload o.k. |
|
127 //UPDATE des Filenamens |
|
128 $sql = "UPDATE Info SET info_file = '" . $infid . "_" . $fname ."' WHERE info_ID=$infid"; |
|
129 $retv=$dbc->execute($sql); |
|
130 if (!$retv) |
|
131 echo $dbc -> error . "<br>\n"; |
|
132 } |
|
133 |
|
134 } |
|
135 else |
|
136 { |
|
137 $retf=1; //kein Infodoc hochgeladen |
|
138 } |
|
139 if ($result && $retf && $reta && $retp) // INSERT Raum |
|
140 { |
|
141 //Eingabe Daten, Upload File erfolgreich |
|
142 echo "<p class='green'><b>Infodaten zu ID '$infid' wurden erfolgreich gespeichert.</b></p>\n"; |
|
143 echo "<br /><br />\n"; |
|
144 |
|
145 // Anzeigen gespeicherte Raumdaten |
|
146 if ($fname) |
|
147 $ifile = $infid . "_" . $fname; |
|
148 else |
|
149 $ifile = $inf['ifname']; |
|
150 include ("inc/info_dat_show.inc.php"); |
|
151 } |
|
152 } |
|
153 $dbc -> close(); |
|
154 echo "</div>\n"; |
|
155 echo "<p> <a href=\"info_flist.php\" target=\"_self\" title=\"Infoliste\">Zur Infolisteliste</a></p>\n"; |
|
156 echo "<p> <a href=\"info_ins.php\" target=\"_self\" title=\"Information erfassen\">Weitere Information erfassen</a></p>\n"; |
|
157 } |
|
158 |
|
159 |
|
160 ?> |
|
161 |
|
162 </body> |
|
163 </html> |