--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/info_upd.php Wed Aug 31 14:22:19 2011 +0200
@@ -0,0 +1,241 @@
+<!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="css/db.css" rel="STYLESHEET" type="TEXT/CSS" />
+
+ <title>Eingabe Informationen</title>
+</head>
+
+<body>
+ <div class="float-r"><img src="img/document_image_ver.png" border="0" alt="Informationen eingeben" title="Informationen eingeben"/></div>
+
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 08/2011
+ *
+ * INSERT Informationen
+ */
+
+ error_reporting(E_ALL ^ E_NOTICE);
+
+ include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+ include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+ $dbc = new dbconnection();
+
+ $infid = $_GET["uid"];
+ if (!$inf) $inf=1;
+ $upd = $_POST["upd"];
+ $del = $_POST["del"];
+ $inf = $_POST["inf"];
+ $ok = $_POST["ok"];
+ if (!$inf["okn"]) $ok = false;
+
+ if (!$ok && ((!$upd && !$del) || $upd || $del))
+ {
+ if (!$upd && !$del)
+ {
+ $sql = "SELECT info_ID,info_name_s,info_name_l,info_date,info_valid_from,info_valid_to,infotyp_ID,
+ persknr,lang,info_file,info_rel_ID,info_freigabe FROM fhiiqm.Info WHERE info_ID = $infid";
+ if ($result = $dbc -> queryObjectArray($sql))
+ {
+ foreach ($result as $row)
+ {
+ $inf["infid"] = $infid;
+ $inf["iname"] = $row->info_name_s;
+ $inf["ilong"] = $row->info_name_l;
+ $inf["ityp"] = $row->infotyp_ID;
+ $inf["ijahr"] = substr($row->info_date,0,4);
+ $inf["imon"] = substr($row->info_date,5,2);
+ $inf["itag"] = substr($row->info_date,8,2);
+ $inf["bjahr"] = substr($row->info_valid_from,0,4);
+ $inf["bmon"] = substr($row->info_valid_from,5,2);
+ $inf["btag"] = substr($row->info_valid_from,8,2);
+ $inf["ejahr"] = substr($row->info_valid_to,0,4);
+ $inf["emon"] = substr($row->info_valid_to,5,2);
+ $inf["etag"] = substr($row->info_valid_to,8,2);
+ $inf["pers"] = $row->persknr;
+ $inf["infrel"] = $row->info_rel_ID;
+ $inf["ifname"] = $row->info_file;
+ $inf["lang"] = $row->lang;
+ }
+ }
+ // Produkt
+ $sql = "SELECT produkt_ID FROM Info_Produkt WHERE info_ID = $infid";
+ if ($result = $dbc -> queryObjectArray($sql))
+ {
+ foreach ($result as $row)
+ {
+ $inf['prid'][] = $row->produkt_ID;
+ }
+ }
+ // Adressat
+ $sql = "SELECT info_adr_ID FROM Info_Adressat WHERE info_id = $infid";
+ if ($result = $dbc->queryObjectArray($sql))
+ {
+ foreach ($result as $row)
+ $inf["adr"][] = $row->info_adr_ID;
+ }
+
+ }
+ include_once("form/info_form.inc.php");
+
+ if ($upd)
+ {
+ echo
+ "<tr>
+ <td>Upload Infodokument </td>
+ <td><input type=\"file\" name=\"ifile\" size=\"50\" maxlength=\"50\" value=\"" .
+ $_FILES["ifile"]["name"] . "\"/></td>
+ </tr>";
+
+ }
+ if ($upd || $del)
+ {
+ if ($upd)
+ $frage = "Alle Angaben ok?<br>
+ erst wenn Haken gesetzt, Upload-File wählen!";
+ elseif ($del)
+ $frage = "Information wirklich löschen?";
+ echo "<tr>
+ <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
+ <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
+ if ($ok) echo "checked";
+ echo "></td>\n</tr>\n";
+ }
+
+ echo "<tr>\n";
+ echo "
+ <td> </td>
+ <td><input class=\"button\" type=\"submit\" value=\"ändern\" name=\"upd\" title=\"update\" />
+ <input class=\"button\" type=\"submit\" value=\"löschen\" name=\"del\" title=\"delete\" /></td>\n";
+ echo "</tr>\n";
+ echo "</table>\n";
+ echo "</div>\n";
+ echo "</form>\n";
+
+
+ }
+ elseif ($ok && $upd)
+ {
+ echo "<div align='center'>\n";
+ //daten speichern
+ $inf["iname"] = substr($inf["iname"],0,300);
+ $inf["ilong"] = substr($inf["ilong"],0,8000);
+ if ($inf["ityp"] == -1) $inf["ityp"] = null;
+
+ //Datumswerte validieren
+ $idat = date_obj($inf["ijahr"], $inf["imon"], $inf["itag"]);
+ $bdat = date_obj($inf["bjahr"], $inf["bmon"], $inf["btag"]);
+ $edat = date_obj($inf["ejahr"], $inf["emon"], $inf["etag"]);
+
+ if ($inf["pers"] == -1) $inf["pers"] = null;
+ if ($inf["infrel"] == -1) $inf["infrel"] = null;
+ if ($inf["lang"] == -1) $inf["lang"] = null;
+ //echo "datcreate: $idat, datevalidfrom: $bdat, datevalidto: $edat, author: " . $inf["pers"] . "<br />\n";
+
+ if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+ $stmt = $dbc -> stmtinit();
+ if (is_object($stmt))
+ {
+ $stmt -> prepare("UPDATE fhiiqm.Info SET
+ info_name_s = ?,
+ info_name_l = ?,
+ info_date = ?,
+ info_valid_from = ?,
+ info_valid_to = ?,
+ infotyp_ID = ?,
+ persknr = ?,
+ lang = ?,
+ info_rel_ID = ? WHERE info_ID = $infid");
+ $stmt -> bind_param('sssssiisi',$inf["iname"],$inf["ilong"],$idat,$bdat,$edat,$inf["ityp"],$inf["pers"],$inf["lang"],$inf["infrel"]);
+ $result = $stmt -> execute();
+// print_r($stmt);
+ }
+ if ($dbc->error) echo "error: " . $dbc->error . "<br><br>\n";
+ if ($result)
+ { // UPDATE o.k.
+
+ // n:m Tabellen INSERT
+ include ("inc/info_tab_ins.inc.php");
+
+ // upload File
+ // echo "upload-error: " . $_FILES["ifile"]["error"] . "<br />\n";
+ if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] )
+ {
+ echo "file hochgeladen: " . $_FILES["ifile"]["name"] ."<br />\n";
+ include ("inc/file_upload.inc.php");
+ $fname = gen_filename($inf['ifname'],"ifile",$infid);
+ $retdf = mod_file("/var/www/fhiiqm/infos",$infid,"","del"); // Loeschen alte Datei
+ $retf = upload("ifile", $fname, $infid, "infos"); // Datei prüfen und in Dokumentenverzeichnis verschieben
+
+ if ($retf)
+ { // upload o.k.
+ //UPDATE des Filenamens
+ $sql = "UPDATE Info SET info_file = '" . $infid . "_" . $fname ."' WHERE info_ID=$infid";
+ $retv=$dbc->execute($sql);
+ if (!$retv)
+ echo $dbc -> error . "<br>\n";
+ }
+
+ }
+ else
+ {
+ $retf=1; //kein Infodoc hochgeladen
+ }
+ if ($result && $retf && $reta && $retp) // INSERT Raum
+ {
+ //Eingabe Daten, Upload File erfolgreich
+ echo "<p class='green'><b>Infodaten zu ID '$infid' wurden erfolgreich gespeichert.</b></p>\n";
+ echo "<br /><br />\n";
+
+ // Anzeigen gespeicherte Raumdaten
+ if ($fname)
+ $ifile = $infid . "_" . $fname;
+ else
+ $ifile = $inf['ifname'];
+ include ("inc/info_dat_show.inc.php");
+ }
+ }
+ }
+ elseif ($ok & $del)
+ {
+ // DELETE aus Tab Info und abhaengigen Tabellen
+ echo "<div align='center'>\n";
+
+ $idat = date_obj($inf["ijahr"], $inf["imon"], $inf["itag"]);
+ $bdat = date_obj($inf["bjahr"], $inf["bmon"], $inf["btag"]);
+ $edat = date_obj($inf["ejahr"], $inf["emon"], $inf["etag"]);
+
+ $sql = "DELETE FROM Info WHERE info_ID = $infid";
+ $retid = $dbc -> execute($sql);
+ if ($retid)
+ {
+ include ("inc/file_upload.inc.php");
+ $retdf = mod_file("/var/www/fhiiqm/infos",$infid,"","del"); // Loeschen Dokument
+ if ($retdf) echo "<p class='green'><b>Infodokument zu ID '$infid' wurde gelöscht.</b></p>\n";
+ echo "<p class='green'><b>Infodaten zu ID '$infid' wurden gelöscht.</b></p>\n";
+ echo "<br /><br />\n";
+
+ // Anzeigen geloeschter Vertragsdaten
+ if ($fname)
+ $ifile = $infid . "_" . $fname;
+ else
+ $ifile = $inf['ifname'];
+ include ("inc/info_dat_show.inc.php");
+ }
+
+ }
+ if ($ok && ($upd || $del))
+ {
+ echo "</div><br /><br />\n";
+ echo "<p> <a href=\"info_flist.php\" target=\"_self\" title=\"Infoliste\">Zurück zur Infoliste</a></p>\n";
+ echo "<p> <a href=\"info_ins.php\" target=\"_self\" title=\"Info erfassen\">Weitere Info erfassen</a></p>\n";
+ }
+
+?>
+</body>
+</html>
\ No newline at end of file