fhiiqm/info_betrst_ed.php
changeset 31 0a1eb975fbd9
parent 30 d02d02efc55a
child 36 4411d3239444
equal deleted inserted replaced
30:d02d02efc55a 31:0a1eb975fbd9
     2 
     2 
     3 /**
     3 /**
     4  * @author Bettina Schwarzer, Fritz-Haber-Institut
     4  * @author Bettina Schwarzer, Fritz-Haber-Institut
     5  * @copyright 07/2012, 08/2012
     5  * @copyright 07/2012, 08/2012
     6  *
     6  *
     7  * INSERT,UPDATE Informationen Betriebsstoerung, Betriebssicherheit  
     7  * INSERT,UPDATE Informationen Betriebsstoerung, Betriebsanweisung  
     8  */
     8  */
     9 
     9 
    10     error_reporting(E_ALL ^ E_NOTICE);
    10     error_reporting(E_ALL ^ E_NOTICE);
    11     
    11     
    12     session_start();
    12     session_start();
    15         include_once ("inc/func_lib.inc.php");	
    15         include_once ("inc/func_lib.inc.php");	
    16         login($_SERVER["PHP_SELF"]);
    16         login($_SERVER["PHP_SELF"]);
    17         exit;
    17         exit;
    18     }
    18     }
    19     
    19     
    20     if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ir",$_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"])))
    20     $ityp   = $_GET["t"]; // t=7 - Betriebsstoerung, t=8 - Betriebsanweisung
       
    21     if ($ityp == 71) $repr = "dd"; else $repr = "i";
       
    22     if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array($repr."r",$_SESSION["recht"]) && !in_array($repr."e",$_SESSION["recht"])))
    21     {
    23     {
    22         header("Location: start.php");
    24         header("Location: start.php");
    23         exit;
    25         exit;
    24     }    
    26     }    
    25 
    27 
    26     $ityp   = $_GET["t"]; // t=7 - Betriebsstoerung, t=8 - Betriebssicherheit
       
    27     
    28     
    28     $infid  = $_GET["i"];
    29     $infid  = $_GET["i"];
    29 
    30 
    30     $zeil = $_GET["z"];
    31     $zeil = $_GET["z"];
    31     if (!$zeil) $zeil = 10; // Anzahl der gezeigten Zeilen
    32     if (!$zeil) $zeil = 10; // Anzahl der gezeigten Zeilen
    46 	$inf    = $_POST["inf"];
    47 	$inf    = $_POST["inf"];
    47     $ok		= $_POST["ok"];
    48     $ok		= $_POST["ok"];
    48     if (!$inf["okn"]) $ok = false;
    49     if (!$inf["okn"]) $ok = false;
    49     $duptext="";
    50     $duptext="";
    50 
    51 
    51     if ($ityp == 7) $titel = "Betriebsstörung";
    52     switch ($ityp)
    52     elseif ($ityp == 8) $titel = "Betriebsanweisung";
    53     {
    53     elseif ($ityp == 81) $titel = "Betriebsanweisung Anlage";
    54         case 7: $titel = "Betriebsstörung";
    54     
    55             break;
    55 //    print_r($inf); echo "<br /><br />";
    56         case 71: $titel = "Betriebsst&ouml;rung dezentrale Technik";
       
    57             break;
       
    58         case 8: $titel = "Betriebsanweisung";
       
    59             break;
       
    60         case 81: $titel = "Betriebsanweisung Anlage";
       
    61             break;
       
    62     }
       
    63 
       
    64     if ($_FILES["ifile"]["error"] == 1 || $_FILES["ifile"]["error"] == 2)
       
    65     {
       
    66         echo "<p class='red'><b>Uploadfile zu ID '$infid'  > 32MByte!.</b></p>\n";
       
    67         $retf=0; $reti=0;
       
    68     }    
    56 
    69 
    57 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
    70 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
    58     include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
    71     include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
    59 	$dbc = new dbconnection();
    72 	$dbc = new dbconnection();
    60     
    73     
   205     echo "<div class=\"float-br smaller\" valign='top'>";
   218     echo "<div class=\"float-br smaller\" valign='top'>";
   206     echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
   219     echo "&nbsp;&nbsp;&nbsp;user: " . $_SESSION["userid"];
   207     echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
   220     echo "&nbsp;&nbsp;&nbsp;<a class='sc' href='/fhiiqm/logout.php' title='Session beenden'>logout</a></div>\n";
   208     echo "<div class=\"float-r\"><img src=\"img/document_image_ver.png\" border=\"0\" alt=\"Infodaten &auml;ndern\" title=\"Infodaten &auml;ndern\"/></div>\n";
   221     echo "<div class=\"float-r\"><img src=\"img/document_image_ver.png\" border=\"0\" alt=\"Infodaten &auml;ndern\" title=\"Infodaten &auml;ndern\"/></div>\n";
   209 
   222 
   210 
   223 //print_r($inf); echo "<br />ok = $ok, okn = " .$inf['okn'].", upload: " . $_FILES["ifile"]["error"] .", sub = $sub<br /><br />";
       
   224 //print_r($_FILES["ifile"]); echo "<br /><br />";
   211     echo "<div align='center'>";
   225     echo "<div align='center'>";
   212     if ($infid) $text = "editieren"; else $text = "erfassen";
   226     if ($infid) $text = "editieren"; else $text = "erfassen";
   213     if ($copy) $duptext = " (Kopie)";
   227     if ($copy) $duptext = " (Kopie)";
   214     echo "<h3>$titel $text$duptext<h3>";
   228     echo "<h3>$titel $text$duptext<h3>";
   215     
   229     
   297 			  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
   311 			  <td class=\"red\" valign=\"top\" align=\"left\">$frage</td>
   298 			        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
   312 			        <td><input type=\"checkbox\" name=\"ok\" value=\"1\"";
   299 			        if ($ok)  echo "checked=\"checked\""; 
   313 			        if ($ok)  echo "checked=\"checked\""; 
   300 			echo " /></td>\n</tr>\n"; 
   314 			echo " /></td>\n</tr>\n"; 
   301 		}
   315 		}
   302         if (!is_null($_SESSION["recht"]) && in_array("ie",$_SESSION["recht"]))
   316         if (!is_null($_SESSION["recht"]) && in_array($repr."e",$_SESSION["recht"]))
   303         {
   317         {
   304             echo "
   318             echo "
   305            	<tr><td>&nbsp;</td>\n
   319            	<tr><td>&nbsp;</td>\n
   306             	<td><input  class=\"button\" type=\"submit\" name=\"eintragen\" value=\"  eintragen  \" />";
   320             	<td><input  class=\"button\" type=\"submit\" name=\"eintragen\" value=\"  eintragen  \" />";
   307             if ($infid)
   321             if ($infid)
   414                     }    
   428                     }    
   415                 } 
   429                 } 
   416             }   // stmt-Objekt
   430             }   // stmt-Objekt
   417             if ($result)
   431             if ($result)
   418             {
   432             {
       
   433 //                echo "upload error: ". $_FILES["ifile"]["error"] . "<br /><br />";    
   419                  // n:m Tabellen INSERT
   434                  // n:m Tabellen INSERT
   420                 include ("inc/info_tab_ins.inc.php");
   435                 include ("inc/info_tab_ins.inc.php");
   421 
   436 
   422                 // upload File
   437                 // upload File
   423                 if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] )
   438                 if ($_FILES["ifile"]["error"] == 1 || $_FILES["ifile"]["error"] == 2)
       
   439                 {
       
   440                     echo "<p class='red'><b>Uploadfile zu ID '$infid'  > 32MByte!.</b></p>\n";
       
   441                     $retf=0; $reti=0;
       
   442                 }    
       
   443                 elseif (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] )
   424                 {
   444                 {
   425                     include ("inc/file_upload.inc.php");
   445                     include ("inc/file_upload.inc.php");
   426                     $fname  = gen_filename($inf['ifname'],"ifile",$infid);
   446                     $fname  = gen_filename($inf['ifname'],"ifile",$infid);
   427                     $retdf  = mod_file("/var/www/fhiiqm/infos",$infid,"","del");     // Loeschen alte Datei
   447                     $retdf  = mod_file("/var/www/fhiiqm/infos",$infid,"","del");     // Loeschen alte Datei
   428                     $retf   = upload("ifile", $fname, $infid, "infos");              // Datei prüfen und in Dokumentenverzeichnis verschieben
   448                     $retf   = upload("ifile", $fname, $infid, "infos");              // Datei prüfen und in Dokumentenverzeichnis verschieben
   464                             if (substr($fname,0,$len) == "$infid" . "_") $fname = substr($fname,$len,50);
   484                             if (substr($fname,0,$len) == "$infid" . "_") $fname = substr($fname,$len,50);
   465                             $retf=1; $reti=1;
   485                             $retf=1; $reti=1;
   466                         }
   486                         }
   467                     }
   487                     }
   468                     else // kein Dateiname angegeben
   488                     else // kein Dateiname angegeben
   469                     {$retf=1; $reti=1;}
   489                     {
       
   490                         include ("inc/file_upload.inc.php");
       
   491                         $retf=1; $reti=1;
       
   492                         if ($ifile_old)
       
   493                         {    // Loeschen alte Datei
       
   494                             $retf  = mod_file("/var/www/fhiiqm/infos",$infid,"","del");
       
   495                             if ($retf) 
       
   496                             {
       
   497                                 $sql = "UPDATE Info SET info_file = null WHERE info_ID=$infid";
       
   498                                 $reti=$dbc->execute($sql);
       
   499                                 if (!$reti) 
       
   500                                     echo $dbc -> error . "<br>\n";
       
   501                             }
       
   502                         }    
       
   503                     }
   470                 }
   504                 }
   471             }            
   505             }            
   472             if ($result && $retf && $reti && $reta && $retp && $retv && $retl) // INSERT/UPDATE Info
   506             if ($result && $retf && $reti && $reta && $retp && $retv && $retl) // INSERT/UPDATE Info
   473             {
   507             {
   474                 //Eingabe Daten, Upload File erfolgreich 
   508                 //Eingabe Daten, Upload File erfolgreich