<?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 CURATOR - Add deregulated Molecule</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="addderegulated2.php" method="GET" name="formulaire">

<?

$id=$_GET["id"];
$species=$_GET["species"];
$moltool=$_GET["moltool"];
//print $moltool."<br>";

//$moltool=str_replace("\'","?",$moltool);

if (strlen($moltool)>0)
	{
	$GM="";
	$requete="SELECT \"ASSOCIATED_GENE_ID\" from \"MOLECULAR_TOOL\" where \"NAME\"='$moltool'";
	//print $requete;
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$GM=$row["ASSOCIATED_GENE_ID"];
	}






print "<br><center><h1>Add a deregulated molecule to $id</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=\"$GM\"></td>";
print "<td align=\"center\"><select name=\"type\"><option></option><option>loss of function</option><option>gain of function</option></select></td>";

/*
//Les mol tools
print "<td align=\"center\"><select name=\"tools\">";
print "<option></option>";
$requete="SELECT \"NAME\" from \"MOLECULAR_TOOL\"";
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
print "<option>".$row["NAME"]."</option>";
}
print "</select></td>";
*/

//Les mols tools
//print "<td align=\"center\"><input type=\"text\" name=\"tools\"></td>";
?>

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

<?

print "<td align=\"center\"><select name=\"moltools\" onchange=\"javascript: self.location.href = 'addderegulated.php?species=$species&id=$id&moltool='+this.options[ this.selectedIndex ].value\">";
print "<option></option>";
$requete="SELECT \"NAME\" from \"MOLECULAR_TOOL\" order by \"NAME\"";
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
$moltool=str_replace("\'","'",$moltool);
if ($row["NAME"]==$moltool) 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\" from \"DEV_STAGE\" where \"SPECIES\"='$species' ORDER BY \"DEV_PERCENT\"" ;
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
print "<option>".$row["NAME"]."</option>";
}
print "</select></td>";

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


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

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>