<?php
	//connection
	include("connection.php");
?>

<!-- AUTOCOMPLETION WITH AJAX FOR SEARCH FIELD -->
<script type="text/javascript" src="./AJAX/editderegulated.js"></script>
        <link rel="stylesheet" type="text/css" href="./AJAX/autocompletion.css" />

<script type="text/javascript">
window.onload = function(){initAutoComplete(document.getElementById('formulaire'),
document.getElementById('tools'),document.getElementById('submit'))};
</script>
<!-- /AUTOCOMPLETION WITH AJAX FOR SEARCH FIELD -->

<html>
<body bgcolor="#999966" text="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">
<title>ANISEED</title>
<br>
 
<?php
    if ( (!isset($_SESSION["login"]))or(!isset($_SESSION["pass"])) ) {
	    print "<center><strong>you need to <a href=\"login.php\">login</a> as an authorised curator to proceed.</strong>";
	    print '</center></body></html>';
		return;
	}
?>


<form action="editderegulated2.php" method="GET" name="formulaire">

<?

$id=$_GET["id"];$oldid=$id;
$species=$_GET["species"];
$name=$_GET["name"];$oldname=$name;
$from=$_GET["from"];$oldfrom=$from;
$to=$_GET["to"];$oldto=$to;
$inib=$_GET["inib"];$oldinib=$inib;
$updown=$_GET["updown"];$oldupdown=$updown;



print "<br><center><h1>Edit a deregulated molecule</h1></center><br><br>";

 print '<center><table width="99%" cellpadding="0" cellspacing="0" border="1" bordercolor="#333333">  <tr bgcolor="#990000" bordercolor="#990000" align="center" valign="middle">  <td><strong>Genemodel*</strong></td>  <td><strong>Regulation type*</strong></td>  <td><strong>Molecular tool</strong></td>  <td><strong>From stage*</strong></td>  <td><strong>To stage</strong></td></tr>';

print "<tr>";
print "<td align=\"center\"><input type=\"text\" name=\"name\" value=\"$name\"></td>";
if ($updown=="downregulated")
{
print "<td align=\"center\">
<select name=\"type\">
<option></option>
<option selected>loss of function</option>
<option>gain of function</option>
</select>
</td>";
}
if ($updown=="gain of function")
{
print "<td align=\"center\">
<select name=\"type\">
<option></option>
<option>loss of function</option>
<option selected>gain of function</option>
</select>
</td>";
}


?>

<!--<td align="center"> <input name="tools" id="tools" type="text" size="20" autocomplete="on"></td>-->

<?

print "<td align=\"center\"><select name=\"tools\">";
$requete="SELECT \"MOLECULAR_TOOL_ID\",\"NAME\" from \"MOLECULAR_TOOL\" order by \"NAME\"";

$stmt=pg_query($c,$requete);
print "<option></option>";
while ($row=pg_fetch_array($stmt))
{

$mol=$row["MOLECULAR_TOOL_ID"];
if ($mol==$inib)
{
print "<option selected>".$row["NAME"]."</option>";
}
else print "<option>".$row["NAME"]."</option>";
}
print "</select></td>";




//Les stages
print "<td align=\"center\"><select name=\"from\">";
print "<option></option>";
$requete="SELECT \"NAME\",\"DEV_STAGE_ID\" from \"DEV_STAGE\" where \"SPECIES\"='$species' ORDER BY \"DEV_PERCENT\"" ;
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
if ($row["DEV_STAGE_ID"]==$from) print "<option selected>".$row["NAME"]."</option>";
else print "<option>".$row["NAME"]."</option>";

//print "<option>".$row["NAME"]."</option>";

}
print "</select></td>";


print "<td align=\"center\"><select name=\"to\">";
print "<option></option>";
$requete="SELECT \"NAME\",\"DEV_STAGE_ID\" from \"DEV_STAGE\" where \"SPECIES\"='$species' ORDER BY \"DEV_PERCENT\"" ;
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
if ($row["DEV_STAGE_ID"]==$to) print "<option selected>".$row["NAME"]."</option>";
else print "<option>".$row["NAME"]."</option>";
}
print "</select></td>";


print "<input type=\"hidden\" name=\"id\" value=\"$id\">";
print "<input type=\"hidden\" name=\"species\" value=\"$species\">";

//Les vieux parametres pour la reference de mises a jour
print "<input type=\"hidden\" name=\"oldid\" value=\"$oldid\">";
print "<input type=\"hidden\" name=\"oldname\" value=\"$oldname\">";
print "<input type=\"hidden\" name=\"oldfrom\" value=\"$oldfrom\">";
print "<input type=\"hidden\" name=\"oldto\" value=\"$oldto\">";
print "<input type=\"hidden\" name=\"oldinib\" value=\"$oldinib\">";
print "<input type=\"hidden\" name=\"oldupdown\" value=\"$oldupdown\">";




print "</tr>";
print "</table>";

?>
&nbsp;<br>&nbsp;<br>&nbsp;<br>

<center><input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit"></center>                  <br>
<br>
</form>
* Mandatory
</body>
</html>