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


if (isset($_GET["species"])) $species=$_GET["species"];

	if( (isset($_GET["species"])) and (strlen($species)>0) ){
		$query="SELECT \"LIBRARY_ID\", \"TITLE\", \"DEV_STAGE\" FROM \"LIBRARY\" WHERE \"SPECIES\"='$species'";
		$stmt = pg_query($c,$query) or die("<strong>Error</strong> ".pg_last_error($c));
	}
?>

<script language="JavaScript" >
function choix(){
	if (window.document.formulaire.lib_id.options[0].selected==true){
		window.document.formulaire.first5.disabled=true;
		window.document.formulaire.last5.disabled=true;
		window.document.formulaire.first3.disabled=true;
		window.document.formulaire.last3.disabled=true;
	}
	else{
		window.document.formulaire.first5.disabled=false;
		window.document.formulaire.last5.disabled=false;
		window.document.formulaire.first3.disabled=false;
		window.document.formulaire.last3.disabled=false;
	}
}
</script>
  


<h2><strong><em>ADD clones from UNIGENE libraries. </em></strong> </h2>
<center>
	<form target="_blank" action="add-clones2.php" method="get" name="formulaire" onsubmit="this.filepath.value=this._filepath.value">
		<table width="99%" border="0" cellspacing="0" background="pictures/barre.jpg">
		<tr bgcolor="#990000">
			<td>&nbsp;</td>
			<td align="right" background="pictures/barre-red.jpg">
			    <em><strong>Add clones</strong></em>
			</td>
		</TR><TR>
			<td colspan="2" align="center"><br><strong>Species: </strong>&nbsp;
					<select name="species" size="1" onChange="self.location.href = 'add-clones.php?species=' + this.options[ this.selectedIndex ].value">
                      <option ></option>
                      <?php
                      
                      $requete="select \"NAME\" from \"SPECIES\" ";
                      $stmt0 = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
                      while($row0=pg_fetch_array($stmt0))
                      {
                        $species2=$row0["NAME"];
                        /*echo "<option value=\"$species2\" >$species2</option>";*/
				
                        if ($species==$species2)
						    echo "<option value=\"$species\" selected>$species</option>";
					    else
						    echo "<option value=\"$species2\">$species2</option>";
					  }
				    ?>
                    </select>
                </td>
            </tr><tr>
                    
        		<td colspan="2" align="center"><br><strong>select the library :</strong>
        			<br><select name="lib_id" size="10" onclick="javascript: self.choix();">
                        <option value="null"  checked> -------------Additional sequences--------------</option>
                        <?php
						 $id="";
						 while($row=pg_fetch_array($stmt))
						 {
							print "<option value=\"".$row["LIBRARY_ID"]."\">";
							print "Lib_id :".$row["LIBRARY_ID"]."&nbsp; ----->&nbsp; ".$row["TITLE"]."</option>\n";
							
							$id .= $row["LIBRARY_ID"].":";
						 }
					  	?>
                      </select>
				</td>
	 	</tr><tr>
                      
			<td>
				<br><input type="checkbox" name="test" value="y" checked>
				<strong>Perform read test without recording data.</strong>
			</td>
			<td>&nbsp;</td>
			
		</TR><TR>
			<td>
				<br><input type="checkbox" name="update" value="y">
				<strong>Update previous clones.</strong><br>
			</td>
			<td>&nbsp;</td>
		</TR><TR>
			<td>
				<br><strong>Clones file to load:</strong>			
				<input type="file" name="_filepath" >
				<input type="hidden" name="filepath">
			</td>
			<td>&nbsp;</td>
		</TR><TR>
			<td colspan="2" align="center"><br><br>
				<strong>Please enter the format for the name of the clone : (e.g. : clone name 5' = ciNNNN and 3' = rciNNNN)</strong>
			</td>
		</tr><tr>
			
			
					<td colspan="2" align="center">
					<strong>for 5' clones ::::>
						<strong>(&nbsp; <input name="first5" type="text" size="10" disabled> "Clone name"
						<input name="last5" type="text" size="10" disabled> &nbsp;)
						<br><br>
					for 3' clones ::::>
					(&nbsp; <input name="first3" type="text" size="10" disabled> "Clone name"
					<input name="last3" type="text" size="10" disabled> &nbsp;)</strong>
					</td>
			
				
		</TR><TR>
			<td>&nbsp;</td>
    		<td align="right">
				<br><br>
					<input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit">&nbsp;&nbsp;&nbsp;
				<br>
			</td>
  		</tr>
 		</table>
	</form>
</center>
<br><br><br>




<?php
include("frames_footer.php");
?>
