<!-- Copyright (C) 2009 DNA Bank Network
http://www.dnabank-network.org

The contents of this file are subject to the Mozilla Public License Version 1.1
See LICENSE.TXT at the top of this package for the full license terms. -->

<?php
    include ("head.php");
    include ("auth.php");
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>DNA Bank Network - Location Stock Administration</title>
<link rel="stylesheet" type="text/css" href="format.css">
<SCRIPT LANGUAGE="JavaScript1.1" src="Functions.js"></SCRIPT>
<NOSCRIPT>Bitte aktivieren Sie Javascript!</NOSCRIPT>

</head>
<body>
<form name="formular" method="POST" action="new_Stock.php"> 
<table id="tablemain" border="0">
	<tr>
  <td id="tdLogo"><img border="0" src="images/Logo-DNA-Bank-Network-ocker.jpg" width="123" height="78"></td>
  		<td>
		<h1>DNA Bank Network - Location Stock Administration</h1></td>
    <td id="tdLogo"><img border="0" src="images/Logo.jpg"></td>
	</tr>
  <tr>
  <td><?php
    echo "Logged in as: ";
    $log = $_SESSION["log"];
    echo $log;

    ?></td><td colspan="2"><a href="logout.php">Logout</a>.</td>
  </tr>
<tr>
<td valign="top" align="center" valign="middle" colspan="3">
<table id="table" width="70%" border="0" style="margin:30 0 0 0">
<tr>
<td align="center" width="50%" valign="top">
<?php
if($formSubmitSaveBox)
{  

  if(empty($formNewBox))
    { unset($formNewBox); }

  else 
    {      
     $result= mysql_query ("SELECT ID_Stock_Box, Stock_Box FROM tablestock_box " .
                            "WHERE Stock_Box = '$formNewBox'");
  
     if(mysql_num_rows($result))
       {  
       echo "<p id='DescriptionRed'>Eintrag existiert schon!";
       }

     else    
       {
        $result = "INSERT INTO tablestock_box (Stock_Box, Created_Who)" .
                          "VALUES ('$formNewBox','$log')";   
        $sql = mysql_query($result);

#######################################Error 1###############################################################

if(!$sql)
{ $msg = $result."\n";
  $msg .= "####Error 1####";
  trigger_error($msg, E_USER_ERROR);
  include ("Errorreport.php");   }
  
#############################################################################################################
                          
        else {
        echo "<span class='fine'>Changes accepted!</span>"; }                            
       }
   }
}//if ($formSubmitSaveBox)

if($formSubmitSaveRack)
{
  if(empty($formNewRack))
    { unset($formNewRack); }

  else 
    {      
     $result= mysql_query ("SELECT ID_Stock_Rack, Stock_Rack FROM tablestock_rack " .
                            "WHERE Stock_Rack = '$formNewRack'");
  
     if(mysql_num_rows($result))
       {  
       echo "<p id='DescriptionRed'>Eintrag existiert schon!";
       }

     else    
       {
        $result = "INSERT INTO tablestock_rack (Stock_Rack, Created_Who)" .
                          "VALUES ('$formNewRack','$log')";   
        $sql = mysql_query($result);

#######################################Error 2###############################################################

if(!$sql)
{ $msg = $result."\n";
  $msg .= "####Error 2####";
  trigger_error($msg, E_USER_ERROR);
  include ("Errorreport.php");   }
  
#############################################################################################################

        else {
        echo "<span class='fine'>Changes accepted!</span>"; }                            
       }
   }
}//if ($formSubmitSaveRack)

if($formSubmitSaveFridge)
{
  if(empty($formNewFridge))
    { unset($formNewFridge); }

  else 
    {      
     $result= mysql_query ("SELECT ID_Stock_Fridge, Stock_Fridge FROM tablestock_fridge " .
                            "WHERE Stock_Fridge = '$formNewFridge'");
  
     if(mysql_num_rows($result))
       {  
       echo "<p id='DescriptionRed'>Eintrag existiert schon!";
       }

     else    
       {
        $result = "INSERT INTO tablestock_fridge (Stock_Fridge, Created_Who)" .
                          "VALUES ('$formNewFridge','$log')";   
        $sql = mysql_query($result);

#######################################Error 3###############################################################

if(!$sql)
{ $msg = $result."\n";
  $msg .= "####Error 3####";
  trigger_error($msg, E_USER_ERROR);
  include ("Errorreport.php");   }
  
#############################################################################################################

        else {
        echo "<span class='fine'>Changes accepted!</span>"; }                            
       }
   }
}//if ($formSubmitSaveFridge)
?>
<table border="0" style="margin:0 0 0 0">

<?php
$result= mysql_query ("SELECT Stock_Box FROM tablestock_box " .
                      "ORDER BY Stock_Box");
      
$num_rows = mysql_num_rows($result);

$num_fields = mysql_num_fields($result);

for ($i=0; $i<$num_fields; $i++)
    echo"<th>".htmlentities(mysql_field_name($result, $i))."</th>";

while ($row = mysql_fetch_row($result))
{
    echo "<tr>";

    for ($j=0; $j<$num_fields; $j++)
        echo "<td align='left'>".htmlentities($row[$j])."&nbsp;</td>";
    echo "</tr>";
}

mysql_free_result($result);
?>
</table>
</td>
<td valign="top">
<table border="0" style="margin:0 0 0 0">

<?php
$result= mysql_query ("SELECT Stock_Rack FROM tablestock_rack " .
                      "ORDER BY Stock_Rack");
      
$num_rows = mysql_num_rows($result);

$num_fields = mysql_num_fields($result);

for ($i=0; $i<$num_fields; $i++)
    echo"<th>".htmlentities(mysql_field_name($result, $i))."</th>";

while ($row = mysql_fetch_row($result))
{
    echo "<tr>";

    for ($j=0; $j<$num_fields; $j++)
        echo "<td align='left'>".htmlentities($row[$j])."&nbsp;</td>";
    echo "</tr>";
}

mysql_free_result($result);
?>
</table>
</td>
<td valign="top">
<table border="0" style="margin:0 0 0 0">

<?php
$result= mysql_query ("SELECT Stock_Fridge FROM tablestock_fridge " .
                      "ORDER BY Stock_Fridge");
      
$num_rows = mysql_num_rows($result);

$num_fields = mysql_num_fields($result);

for ($i=0; $i<$num_fields; $i++)
    echo"<th>".htmlentities(mysql_field_name($result, $i))."</th>";

while ($row = mysql_fetch_row($result))
{
    echo "<tr>";

    for ($j=0; $j<$num_fields; $j++)
        echo "<td align='left'>".htmlentities($row[$j])."&nbsp;</td>";
    echo "</tr>";
}

mysql_free_result($result);
?>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<table border="0"><tr><td>Add new Box: </td><td><input type="text" name="formNewBox"></td>
<td>Add new Rack:</td><td><input type="text" name="formNewRack"></td><td>Add new fridge: </td><td><input type="text" name="formNewFridge"></td>
</tr>
<tr><td></td><td><input type="submit" id="button" name="formSubmitSaveBox" value="Save New Box" style="float:right"></td><td></td><td><input type="submit" id="button" name="formSubmitSaveRack" value="Save New Rack" style="float:right"></td><td></td><td><input type="submit" id="button" name="formSubmitSaveFridge" value="Save New Fridge" style="float:right"></td></tr></table>
</td>
</tr>
<tr>
<td colspan="3">
<br><input type="submit" id="button" name="formSubmitClose" value="Close Form" style="float:right" onclick="window.close();">
</td>
</tr>
<tr><td colspan="3">Nach Schließen des Formulares müssen Sie die Input- bzw. Suchmaske neu laden, damit die Änderungen aktiv werden.</td></tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>