<?php
/*
    ANISEED, NISEED System and Database
    Copyright (C) 2007 Olivier Tassy, Fabrice Daian, Patrick Lemaire

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
//connection
include("connection.php");

//Title before frames_header
print '<title>ANISEED - All clones</title>';

include("frames_header.php");



?>
<SCRIPT>
function CheckALL() {
	
	for(a=0; a<document.form.length; ++a){
		if (document.form[a].checked==false) document.form[a].checked=true;
		else document.form[a].checked=false;
	}
}
</SCRIPT>


<?php

	
    $name=$_GET["name"];
	
	if(! strlen($name)>0){
	    print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
	}else{
        print "<h2><strong><em>Cluster &nbsp;&nbsp;&nbsp;$name</em></strong></h2>";
		print "<br><br><u><strong>Cluster composition</strong></u><br>";
		
	    //$requete="select \"GENBANK_ID\", \"CLONE_NAME\", \"END\" from \"CLONE_SEQ\" where \"ANISEED_CLUSTER_ID\"='$name' order by \"CLONE_NAME\"";
	$requete="select \"GENBANK_ID\", \"CLONE_NAME\", \"END\" from \"CLONE_SEQ\" where \"ANISEED_CLUSTER_ID\"='$name' or \"ANISEED_KYOTO_CLUSTER_ID\"='$name' order by \"CLONE_NAME\"";
	    $stmt = pg_query($c,$requete);
		
        print '<form name="form" action="AllClonesFASTA.php" target="_BLANK" method="POST"><table width="50%" border="0" cellspacing="0" cellpadding="0">';
        print '<tr align="center" valign="middle" bgcolor="#990000"><td>&nbsp;</td><td>Clone name</td><td>Genbank ID</td><td background="pictures/barre-red.jpg">End</td></tr>';
        $count=0;
    	while($row=pg_fetch_array($stmt)){
	        ++$count;
	        print "<tr align=\"center\"><td><input name=\"id[]\" type=\"checkbox\" value=\"".$row["GENBANK_ID"]."\"></td><td width=\"33%\"><a href=\"molecule-clone.php?name=".$row["GENBANK_ID"]."\">".$row["CLONE_NAME"]."</a></td><td width=\"33%\"><a href=\"molecule-clone.php?name=".$row["GENBANK_ID"]."\">".$row["GENBANK_ID"]."</a></td><td width=\"33%\">".$row["END"]."</td></tr>";
	    }
	    print "</table></form>";
	
	    if($count==0){
	        print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
	    }else{
		    print "&nbsp;&nbsp;&nbsp;<img border=\"0\" src=\"pictures/button-selectALL.jpg\" onClick=\"CheckALL()\">";
		    //print "&nbsp;&nbsp;&nbsp;<img border=\"1\" src=\"pictures/button-download.jpg\" onClick=\"self.getSelected();\">";
			print "&nbsp;&nbsp;&nbsp;<img border=\"0\" src=\"pictures/button-download.jpg\" onClick=\"document.form.submit();\">";
		}
		
		/*
        print '<table width="50%" border="0" cellspacing="0" cellpadding="0">';
        print '<tr align="center" valign="middle" bgcolor="#990000"><td>Clone name</td><td background="pictures/barre-red.jpg">Genbank ID</td></tr>';

		$count=0;
	    while(OCIFetch($stmt)){
		    ++$count;
		    print "<tr align=\"center\"><td width=\"20%\"><a href=\"molecule-clone.php?name=".OCIresult($stmt,"GENBANK_ID")."\">".OCIresult($stmt,"NAME")."</a></td><td>".OCIresult($stmt,"GENBANK_ID")."</td></tr>";
		}
	    print "</table>";
		
		if($count==0){
		    print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
		}
		*/
		
	}	

?>


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