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

print "<title>ANISEED CURATOR - Create InSitu</title>";
    include("frames_header.php");


$species=$_GET["species"];

$wild=$_GET["wild"];


?>

<?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>';
	   include ("frames_footer.php");
		return;
	}
?>


<script>
function reloadit(){
  	tab=window.document.formulaire2.iddev.value.split(":");
	dev='';
	for(a=1; a<window.document.formulaire.devstage.options.length; ++a){
  		if(window.document.formulaire.devstage.options[a].selected==true){
	  		dev+= tab[a-1]+':';
		}	
  	}
	window.document.formulaire.selectediddev.value=dev;
	
	
	if( (window.document.anat_keywords != null)&&(window.document.anat_keywords.closed == false) ) {
		window.document.anat_keywords.close();
		popup_anatomy_selector();
	}
}
</script>

<!--<form name="formulaire" action="createISH2.php" method="get" target="_blank">-->
<form name="formulaire" action="createISH2.php" method="get">

    <table width="99%" border="0" cellspacing="0" cellpadding="0" background="pictures/barre.jpg">
      <tr bgcolor="#990000"> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right" background="pictures/barre-red.jpg"><em><strong>Create a new In situ data</strong></em></td>
      </tr>
	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>

              <tr> 
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td> <center>
                    <strong>Developmental stages</strong></center></td>
              </tr>
              <tr> 
                <td align="right"><center>
                    <strong>Species:</strong></center></td>
                <td> <div align="left"> 

                    <select name="species" size="1" onChange="javascript: self.location.href = 'createISH.php?species=' + this.options[ this.selectedIndex ].value + '&wild=<? print $wild;?>';">
                      <option ></option>
                      <?php
					  if ($species=="Ciona intestinalis")
						echo "<option value=\"Ciona intestinalis\" selected>Ciona intestinalis</option>";
					  else
						echo "<option value=\"Ciona intestinalis\">Ciona intestinalis</option>";
		
					  if ($species=="Halocynthia roretzi")
						echo "<option value=\"Halocynthia roretzi\" selected>Halocynthia roretzi</option>";
					  else
						echo "<option value=\"Halocynthia roretzi\">Halocynthia roretzi</option>";
				    ?>
                    </select>
                  </div></td>
                <td>&nbsp;</td>
                <td align="center"> <select name="devstage" size="5" multiple onChange="self.reloadit()">
                    <option>_____________any____________</option>
                    <?php
						 $id="";
							if(strlen($species)>0){
							$query="SELECT \"NAME\", \"DEV_STAGE_ID\" FROM \"DEV_STAGE\" WHERE \"SPECIES\"='$species' ORDER BY \"DEV_PERCENT\"";
						$stmt = pg_query($c,$query);
						}
	
						 while($row=pg_fetch_array($stmt))
						 {
							print "<option value=\"".$row["DEV_STAGE_ID"]."\">";
							print $row["NAME"]."</option>\n";
							
							$id .= $row["DEV_STAGE_ID"].":";
						 }
					  	?>
                  </select>                 
                </td>
              </tr>
	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>

	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>

	<tr>
<?
if ($wild=="n") $wildcheck="";else $wildcheck="checked";
?>

	<td align="center"><input type="checkbox" name="wild" value="yes" <?print $wildcheck;?>> <strong>Wild type</strong></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>

	<tr>
	<td> &nbsp;</td>
	<td> &nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>

	<tr>
	<td> &nbsp;</td>
	<td align="center"><strong>Choose an author for this new ISH in the list below: </strong><br>
	
 	<select name="author">
<?
	$requete="select \"AUTHOR_ID\",\"NAME\" from \"AUTHOR\" order by \"NAME\"";
	$stmt=pg_query($c,$requete);
	while ($row=pg_fetch_array($stmt))
	{
?>

		<option value="<? print $row["AUTHOR_ID"]; ?>">
		<? print $row["NAME"]; ?></option> 


<?
	}
?>
	</select>
	

</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>




	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<!--<td align="center"><input name="submit" type="image" src="pictures/button-submit.jpg" onClick="javascript:alert('Warning you\'re going to create a new ISH entry in the database !');"> </td>-->
	<td align="center"><input name="submit" type="image" src="pictures/button-submit.jpg"> </td>
	</tr>

	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>



</table>
</form>
<?
include ("frames_footer.php");
?>