<html>
<head>
<title>ANISEED anatomy-fate results - Ciona intestinalis, Halocynthia roretzy anatomy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Aniseed hosts information concerning Ciona intestinalis lineage and fate. Feel free to contact aniseed@ibdm.univ-mrs.fr to have more information">
<meta name="keywords" content="Aniseed, Ciona intestinalis, Halocynthia roretzi, anatomy, lineage, fate, tunicate, ascidian, tunicate database, ciona intestinalis database, lemaire, tassy, daian, dauga, sobral">
<meta name = "robots" content = "index, follow, all">
<META HTTP-EQUIV="Content-Language" CONTENT="EN">
<style type="text/css">
</style>
</head>

<?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");
        include("frames_header.php");
?>

<script language="JavaScript">
function getValue(){
    for(a=0; a< document.formu.length; a++){
        if(document.formu[a].checked==true){
			obj=document.formu[a];
            return obj.value;
        }
    }
}            
</script>

<form action="anatomy-fate-update.php" method="post" name="formu" target="_blank">

<?php
    $region="";
	$dev="";
	$fates=array();

    if(isset($_GET["region"]))
		$region = $_GET["region"];
	if(isset($_GET["dev"]))
		$dev = $_GET["dev"];
	if(isset($_GET["fate"]))
		$fates = $_GET["fate"];
	
	
	if( (strlen($dev)<=0)or(ereg("___",$dev)) ){
	    print "<center><h2><strong>No match</strong></h2><br>please select one developmental stage</center>";
		include("frames_footer.php");
	    return;
	}

	$requete= "SELECT \"NAME\", \"SPECIES\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"= $dev";
    $stmt = pg_query($c,$requete);
    if($row=pg_fetch_array($stmt)){
	    print '<input name="dev" type="hidden" value="'.$dev.'">';  //memorise le dev_stage_id
		print "<center><h2><strong><em>".$row["SPECIES"]."  (".$row["NAME"].")<br>Anatomical tree</em></strong> </h2></center><br><br>";
	    print "Select anatomical part below and click on buttons to access the relevant information.<br>";
		print "\n&nbsp;&nbsp;<img src=\"pictures/button-getPics.jpg\" border=\"0\" onClick=\"self.location.href = 'insitu-result.php?BOOLanat=1&xref=2&idanat=' + self.getValue()+':'\">    &nbsp;<img src=\"pictures/button-lineage.jpg\" border=\"0\"onClick=\"self.location.href = 'lineage.php?idanat=' + self.getValue()\">    &nbsp;<img src=\"pictures/button-position.jpg\" border=\"0\" onClick=\"self.location.href = 'position.php?idanat=' + self.getValue()\">    &nbsp;<img src=\"pictures/button-fates.jpg\" border=\"0\" onClick=\"self.location.href = 'fates.php?idanat=' + self.getValue()\">\n<br><br><br>";		
	    
		
	
		//creation des colonnes pour les fates
		print '<center><table width="99%" border="0" cellspacing="0" cellpadding="0" ><tr bgcolor="#990000"><td align="center" width="500"><strong><u>___________________Anatomical_tree___________________</u></strong></td>';
		for($a=0; $a<count($fates); ++$a){
		    print '<td align="center"><strong>&nbsp;</strong></td>';
		}
		print "</tr>";
		

$nivo=0;


function select_recursif_descendant_2($conn,$start,$res,$nivo)
{
global $fates;
global $region;
global $dev;
/*ON ECRIT SA REQUETE*/


if ($start!='')
{
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\"= $start order by \"NAME\"";
$level++;
}
else {
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\" is null order by \"NAME\"";
}


$stmt=pg_query($conn,$requete);


if (pg_num_rows($stmt)!=0) $nivo++;//print "Nz";
if (pg_num_rows($stmt)==0) $nivo--;//print "Ze";

while($row=pg_fetch_array($stmt))
	{
	
			print "<tr>";
			for($a=0;$a<count($fates)+1;++$a){
				print '<td valign="top"><hr size="1"></td>';
			}
			print "</tr>";
		
		
	        print "<tr><td>";
			for($a=0;$a<$nivo-1;++$a){
				if( $nivo>1 )
					echo '&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
			}
			
			if( $row["TYPE"]=='cell' )
				print "<img src=\"pictures/cell.gif\">";
			else if( $row["TYPE"]=='organism' )
				print "<img src=\"pictures/tetard.gif\">";
			else
				print "<img src=\"pictures/region.gif\">";
			
			
			if($row["ANAT_ID"]==$region){
				echo '<A NAME="tag"> <font color="#FF9900"><strong>'.$row["NAME"]."</strong></font> </A>";
			    if($nivo==1)
				    print "checked ";
				print ">";
			}else{
				
				print $row["NAME"].'<input name="region" type="radio" value="'.$row["ANAT_ID"].'">';
				
				
			}
			
			    //recup des fates deja definis
				$requete2= "SELECT \"KEYWORDS\" FROM \"FATE\" WHERE \"ANAT_ID\"= ".$row["ANAT_ID"];
				$stmt2 = pg_query($conn,$requete2);
				$fkw = (array) null;
				$a=0;
				while($row2=pg_fetch_array($stmt2)){
				    $fkw[$a++]=$row2["KEYWORDS"];
				}
			
			
			print "</td>";
			//generation des checkbox pour les differents fates
            for($a=0;$a<count($fates);++$a){
			    //print "<td align=\"center\"><input name=\"f[]\" type=\"checkbox\" value=\"".$fates[$a]."--".OCIResult($stmt, "ANAT_ID")."\"";
				if( in_array($fates[$a], $fkw) )
				    print '<td align="center" valign="top"><img src="pictures/yes.gif">&nbsp;'."<br><font color=\"#FFFFFF\" size=\"-1\"><strong>".$fates[$a]."&nbsp;</strong></font></td>";
				else
				    print '<td align="center" valign="top"><img src="pictures/no.gif">&nbsp;'."<br><font color=\"#000000\" size=\"-2\">".$fates[$a]."&nbsp;</font></td>";
				
				//print "<br><font color=\"#CC3300\" size=\"-1\">".$fates[$a]."&nbsp;</font></td>";
			}
		    print "</tr>";
		
		






	$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res,$nivo);

	
	}

return $res;
}

$res=select_recursif_descendant_2($c,null,$res,$nivo);



/* FIN DE LA SIMULATION */



		print "</table>";
		//print '<br><table width="99%" border="0" cellspacing="0" cellpadding="0"><tr><td align="right"><input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table></center>';
	





	}else{ print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>"; }
?>

</form>
<br>
</center>

<? 
$fatelist=implode("@",$_GET["fate"]);
print '<a href="FLATexport-anatomy-fate.php?region='.$region.'&dev='.$dev.'&fate='.$fatelist.'">Display tree in raw text format</a>'; ?>

<br>
<br>
<br>

<table width="50%" border="0">
<tr><td><img src="pictures/yes.gif"></td><td>Fate described for this anatomical part.</td></tr>
<td><img src="pictures/no.gif"></td><td>Fate not described for this anatomical part.</td></tr>
</table>
<?php
    include("frames_footer.php");
?>