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

<html>
<body bgcolor="#999966" text="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">
<title>ANISEED CURATOR - Add Anatomical Part</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 target="_self" action="addmultpartanat2.php" method="GET" name="formulaire">

<?php
	$region = $_GET["region"];
	$dev = $_GET["dev"];
	$cloneid=$_GET["cloneid"];
	$substrate=$_GET["substrate"];
	$species=$_GET["species"];
	$insituid=$_GET["insituid"];
	
	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;
	}
	
	
	//connection
	include("connection.php");
	

	$requete= "SELECT \"NAME\", \"SPECIES\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"= $dev";
    $stmt = pg_query($c,$requete);
    if( $row=pg_fetch_array($stmt) ){
		print "<center><h2><strong><em>".$row["SPECIES"]."  (".$row["NAME"].")<br>Anatomical tree</em></strong> </h2></center><br><br>";
		print '<center><TABLE >
				<tr><td>Clone name :</td><td> <input type=text VALUE= "'.$cloneid.'" size=20 name=cloneid></td> 
				<td>Method : </td><td><select name=method size="1">
						<option selected>in situ hybridisation</option>	<option>immunohistochemestry</option>
						<option>reporter gene lac Z ISH</option>	<option>reporter gene X gal</option>
						<option>reporter gene lac Z immunohistochemestry</option>	
						<option>reporter gene GFP ISH</option>	<option>reporter gene GFP immunohistochemestry</option>
						<option>reporter gene GFP fluorescence</option>	<option>other</option>
						</select></td></tr>
				<tr><td>Substrate :</td><td> <input type=text VALUE= "'.$substrate.'" size=20 name=substrate></td>
				<td>Intensity: </td><td><select name=intensity size="1">
											<option></option>
											<option>+</option>
											<option>++</option>
											<option>+++</option>
											</select></td></tr>
				<tr><td> Not sure :</td><td> <input type="checkbox" name="notsure" value="X" unchecked></td>
				<td> Part of :</td><td> <input type="checkbox" name="partof" value="X" unchecked></td></tr>
				<tr><td> Subcellular position:</td><td> <select name=subcell size="1">
				        <option></option>
						<option>membrane</option>
						<option>nuclear</option>
						<option>perinuclear</option>
						<option>nucleoli</option>
						<option>cytoplasmic</option>
						
						<option>myoplasm</option>
						<option>CAB</option>
						<option>animal</option>
						<option>vegetal</option>
						<option>anterior</option>
						<option>posterior</option>
						
						<option>vesicule</option>
						<option>mitochondria</option>
						<option>endoplasmic reticulum</option>
						<option>golgi</option>
						<option>cilia</option>
						<option>dendrite</option>
						<option>axon</option>
						<option>synapse</option>
						<option>mitotic spindle</option>
						<option>cytoskeleton</option>

						<option>nuclear,cytoplasmic</option>


						</select></td>

				</TABLE></center>'
				;
		print "<input name=\"insituid\" type=\"hidden\" value=\"$insituid\">";
		print "<input name=\"species\" type=\"hidden\" value=\"$species\">";
		print "<input name=\"dev\" type=\"hidden\" value=\"$dev\">";

$nivo=0;


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

//print "la";
if ($start!='')
{
$requete2="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\"= $start ";
//print $start;
$level++;
}
else {
$requete2="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\" is null";
//$level=0;
}

$stmt2=pg_query($conn,$requete2);

//if (pg_num_rows($stmt2)==0) {$level--;}

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

while($row2=pg_fetch_array($stmt2))
	{
for($a=0;$a<$nivo-1;++$a){
				if( $nivo>1 )
					echo '&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
			}
			
			if( $row2["TYPE"]=='cell' )
				print "<img src=\"pictures/cell.gif\">";
			else if( $row2["TYPE"]=='organism' )
				print "<img src=\"pictures/tetard.gif\">";
			else
				print "<img src=\"pictures/region.gif\">";
			
			
			if($row2["ANAT_ID"]==$region){
				echo '<A NAME="tag"> <font color="#FF9900"><strong>'.$row2["NAME"]."</strong></font> </A>";//.OCIResult($stmt, "ANAT_ID");
				print "<input name=\"region[]\" type=\"checkbox\" value=\"".$row2["ANAT_ID"]."\" ";
			    if($nivo==1)
				    //print "checked ";
				print ">";
			}else{
				echo $row2["NAME"];
				if((strlen($region)>0)){
					print "<input name=\"region[]\" type=\"checkbox\" value=\"".$row2["ANAT_ID"]."\">";//.OCIResult($stmt, "ANAT_ID");
				}else{
					print "<input name=\"region[]\" type=\"checkbox\" value=\"".$row2["ANAT_ID"]."\">";//.OCIResult($stmt, "ANAT_ID");
			        /*if($nivo==1)
					    //print "checked ";
					print ">";
					*/
				}
			}
				print '<br/>';
	
	$res=select_recursif_descendant_2($conn,$row2["ANAT_ID"],$res,$nivo);

	
	}

return $res;
}

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

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

<center><input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit"></center>                                          
</form>




</body>
</html>