--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/vertrag_ins.php Wed Aug 31 14:22:19 2011 +0200
@@ -0,0 +1,195 @@
+<!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 Vertragsdaten</title>
+</head>
+
+<body>
+ <div class="float-r"><img src="img/document_mark_as_final.png" border="0" alt="Vertragsdaten eingeben" title="Vertragsdaten eingeben"/></div>
+
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 05/2011
+ *
+ * INSERT Vertragsdaten
+ */
+
+ 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();
+
+ $ok = $_POST["ok"];
+ $submit = $_POST["ins"];
+ $vtr = $_POST["vertrag"];
+ if (!$vtr['okn']) $ok=false;
+
+// print_r($vtr);
+// echo "<br><br>\n";
+// echo "Vertragsbezeichnung: " . $vtr['cname'] ."<br><br>\n";
+
+ if (!$ok || !$submit)
+ {
+ include_once("form/vertrag_form.inc.php");
+
+ if ($submit)
+ {
+ echo
+ "<tr>
+ <td>Upload Vertragsdokument </td>
+ <td><input type=\"file\" name=\"vfile\" size=\"50\" maxlength=\"50\" value=\"" .
+ $_FILES["vfile"]["name"] . "\"/></td>
+ </tr>";
+
+ $frage = "Alle Angaben ok?<br>
+ erst wenn Haken gesetzt, Upload-File wählen!";
+ 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=\"eingeben\" name=\"ins\" title=\"insert\" /></td>\n";
+ echo "</tr>\n";
+ echo "</table>\n";
+ echo "</div>\n";
+ echo "</form>\n";
+
+ }
+ else
+ {
+ echo "<div align='center'>\n";
+ //daten speichern
+// echo "1realer filename: " . $_FILES["vfile"]["name"] . "<br><br>\n";
+ //INSERT Vertrag
+/*
+ if ($vtr['vtyp']== -1 || !(is_numeric($vtr['vtyp']))) $vtr['vtyp'] = "NULL";
+ if ($vtr['bjahr'] && $vtr['bmon'] && $vtr['btag'])
+ {
+ $vbegin = $vtr['bjahr'] . "-" . $vtr['bmon'] . "-" . $vtr['btag'];
+ $vbegin = "'$vbegin'";
+ $vbd = $vtr['btag'] . "." . $vtr['bmon'] . "." . $vtr['bjahr'];
+ }
+ else
+ $vbegin = "NULL";
+ if ($vtr['ejahr'] && $vtr['emon'] && $vtr['etag'])
+ {
+ $vend = $vtr['ejahr'] . "-" . $vtr['emon'] . "-" . $vtr['etag'];
+ $vend = "'$vend'";
+ $ved = $vtr['etag'] . "." . $vtr['emon'] . "." . $vtr['ejahr'];
+ }
+ else
+ $vend = "NULL";
+ if (!is_numeric($vtr['cnot'])) $vtr['cnot'] = "NULL";
+ if ($vtr['cbem']) $vtr['cbem'] = "'" . str_replace("'","\"",substr($vtr['cbem'],0,500)) . "'"; else $vtr['cbem']="NULL";
+*/
+ $vtr['cname'] = substr($vtr['cname'],0,50);
+// $vtr['cshort'] = substr($vtr['cshort'],0,50);
+ $vtr['clong'] = substr($vtr['clong'],0,100);
+ if ($vtr['vtyp']== -1 || !(is_numeric($vtr['vtyp']))) $vtr['vtyp'] = null;
+ $vbegin = date_obj($vtr['bjahr'], $vtr['bmon'], $vtr['btag']);
+ $vend = date_obj($vtr['ejahr'], $vtr['emon'], $vtr['etag']);
+ if (!is_numeric($vtr['cnot'])) $vtr['cnot'] = null;
+ if ($vtr['cbem']) $vtr['cbem'] = substr($vtr['cbem'],0,500); else $vtr['cbem']=null;
+ // Filename Vertrag
+ $vtr['cfname'] = substr($vtr['cfname'],0,50);
+
+ if (!isset($dbc) || !$dbc)
+ $dbc = new dbconnection();
+
+/* $sql = "INSERT INTO Vertrag (contract_name, contract_l,vtyp_ID,contract_begin, contract_end,contract_mon_notice,
+ contract_file,bemerkung)
+ VALUES('" . $vtr['cname'] .
+ "', '" . $vtr['clong'] .
+ "', " . $vtr['vtyp'] .
+ ", " . $vbegin .
+ ", " . $vend .
+ ", " . $vtr['cnot'] .
+ ", '" . $vtr['cfname'] .
+ "', " . $vtr['cbem'] .
+ ")";
+
+// echo "INSERT = $sql<br />\n";
+
+ $result=$dbc->execute($sql);
+*/
+ $stmt = $dbc -> stmtinit();
+ if (is_object($stmt))
+ {
+ $stmt -> prepare("INSERT INTO Vertrag (contract_name, contract_l,vtyp_ID,contract_begin, contract_end,contract_mon_notice,
+ contract_file,bemerkung)
+ VALUES(?,?,?,?,?,?,?,?)");
+ $stmt -> bind_param('ssississ',$vtr["cname"],$vtr["clong"],$vtr['vtyp'],$vbegin,$vend,$vtr['cnot'],$cfile,$vtr['cbem']);
+ $result = $stmt -> execute();
+ }
+ if ($dbc->error) echo "error: " . $dbc->error . "<br><br>\n";
+ if ($result)
+ { // INSERT o.k.
+ // contract_ID ermitteln
+ $cid = $dbc -> insertId();
+
+ // DELETE, INSERT n:m Tabellen
+ include ("inc/vertragtab_ins.inc.php");
+
+ // upload File
+ if (is_uploaded_file($_FILES["vfile"]["tmp_name"]) && isset($_FILES["vfile"]["name"]) && $_FILES["vfile"]["name"] )
+ {
+ include ("inc/file_upload.inc.php");
+ $fname = gen_filename($vtr['cfname'],"vfile",$cid);
+ $ret = upload("vfile", $fname, $cid);
+
+ if ($ret)
+ { // upload o.k.
+ //UPDATE des Filenamens
+ $sql = "UPDATE Vertrag SET contract_file = '" . $cid . "_" . $fname ."' WHERE contract_ID=$cid";
+ $retv=$dbc->execute($sql);
+ if (!$retv)
+ echo $dbc -> error . "<br>\n";
+ }
+
+ }
+ else
+ { // upload failed
+ //UPDATE des Filenamens
+ $sql = "UPDATE Vertrag SET contract_file = NULL WHERE contract_ID=$cid";
+ $retv=$dbc->execute($sql);
+ if (!$retv)
+ echo $dbc -> error . "<br>\n";
+ }
+
+ if ($retb && $retp && $retd && $retk) // INSERT n:m Tabellen zu Vertrag
+ {
+ //Eingabe Daten, Upload File erfolgreich
+ echo "<p class='green'><b>Vertragsdaten zu ID '$cid' wurden erfolgreich gespeichert.</b></p>\n";
+ echo "<br /><br />\n";
+
+ // Anzeigen gespeicherte Vertragsdaten
+ if ($fname)
+ $cfile = $cid . "_" . $fname;
+ else
+ $cfile = "";
+ include ("inc/vertrag_dat_show.inc.php");
+ }
+ }
+ $dbc -> close();
+ echo "</div>\n";
+ echo "<p> <a href=\"vertrag_flist1.php\" target=\"_self\" title=\"Vertragsliste\">Zur Vertragsliste</a></p>\n";
+ echo "<p> <a href=\"vertrag_ins.php\" target=\"_self\" title=\"Vertrag erfassen\">Weiteren Vertrag erfassen</a></p>\n";
+
+ }
+
+?>
+
+</body>
+</html>
\ No newline at end of file