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


<center><font size="5" color="crimson"><b>Embryo collection</b></font><br><br>


<table width="100%" cellspacing="0">

<tr>
<td align="center" style="background-color:lightgray;">
<font color="#486898" size="-1"><b>Species</b></font>
</td>
<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Developmental stage</b></font></td><td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Embryo Name</b></font></td><td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Wild Type</b></font></td><td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Software</b></font></td>

<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Obj File</b></font></td>
<!--<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>AM File</b></font></td>
<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>LSM File</b></font></td>-->

<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Surfaces and Volumes Data</b></font></td>
<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Biometry Shape Data</b></font></td>
<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Contact Data</b></font></td>

<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Asymetric division</b></font></td>

<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>LSM Data</b></font></td>

<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Edit</b></font></td>
<td align="center" style="background-color:lightgray;"><font color="#486898" size="-1"><b>Delete</b></font></td>


</tr>


<?


$requete="SELECT e.\"EMBRYO_ID\",e.\"NAME\",e.\"WILD_TYPE\",e.\"SPECIES\",dev.\"NAME\" as \"DEV\",e.\"SOFTWARE\",e.\"OBJ_DATA\" from \"EMBRYO\" e,\"DEV_STAGE\" dev  where e.\"DEV_STAGE_ID\"=dev.\"DEV_STAGE_ID\" order by dev.\"DEV_PERCENT\"";
$stmt=pg_query($c,$requete);
/*if (pg_num_rows($stmt)==0)
	{
	print "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><center><br><br><font color=\"#D64642\" size=\"2\"><b>There is no embryo into the database.</b></font><br> 
<a target=\"_blank\" href=\"add-embryo.php\"></a>
</center></td><td>&nbsp;</td><td>&nbsp;</td>";
	}*/

print "<center><a target=\"_blank\" href=\"add-embryo.php\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center></a><br><br>";


$NUM=pg_num_rows($stmt);

print "<center><b>$NUM</b> embryos</center><br><br>";


while ($row=pg_fetch_array($stmt))
{
print "<tr>";


$name=$row["NAME"];

$name=str_replace("@","_",$name);



print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\">".$row["SPECIES"]."</font></td>";
print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\">".$row["DEV"]."</font></td>";
print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\">$name</font></td>";
print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\">".$row["WILD_TYPE"]."</font></td>";

print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\">".$row["SOFTWARE"]."&nbsp;</font></td>";

if (strlen($row["OBJ_DATA"])>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a target=\"_blank\"  href=\"embryo-card.php?embryoid=".$row["EMBRYO_ID"]."&mode=update\"><small>Update</small></a></font>

<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-obj.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>


</td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a  target=\"_blank\" href=\"add-embryo-obj.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Upload</small></a></font></td>";

/*
if (strlen($row["AM_DATA"])>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"></font></td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"></font></td>";

if (strlen($row["LSM_DATA"])>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"></font></td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"></font></td>";
*/




$requete0= "SELECT * from \"EMBRYO_BIOMETRY\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
$stmt0=pg_query($c,$requete0);
if (pg_num_rows($stmt0)>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a  target=\"_blank\" href=\"add-embryo-biometry.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Update</small></a></font>

<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-biometry.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>

</td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a  target=\"_blank\" href=\"add-embryo-biometry.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Upload</small></a></font></td>";


$requete0="SELECT * from \"EMBRYO_BIOMETRY_SHAPE\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
$stmt0=pg_query($c,$requete0);
if (pg_num_rows($stmt0)>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a  target=\"_blank\" href=\"add-embryo-biometryshape.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Update</small></a></font>

<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-biometryshape.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>


</td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a  target=\"_blank\" href=\"add-embryo-biometryshape.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Upload</small></a></font></td>";

$requete0="SELECT * from \"EMBRYO_NEIGHBOR\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
$stmt0=pg_query($c,$requete0);
if (pg_num_rows($stmt0)>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a target=\"_blank\" href=\"add-embryo-neighbor.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Update</small></a></font>

<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-neighbor.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>


</td>"; else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a target=\"_blank\" href=\"add-embryo-neighbor.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Upload</small></a></font></td>";

$requete0="SELECT * from \"EMBRYO_DIVISION\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);
if (pg_num_rows($stmt0)>0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a  target=\"_blank\" href=\"add-embryo-division.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Update</small></a></font>

<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-division.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>


</td>";
else
	{
	$requete0="SELECT * from \"EMBRYO_BIOMETRY\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
	$stmt0=pg_query($c,$requete0);
	if (pg_num_rows($stmt0)>0)
		{
		print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a  target=\"_blank\" href=\"add-embryo-division.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Compute</small></a></font></td>";
		}
	else
		{
		print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><small>Upload Volume first</small></td>";
		}
	}



$requete0="SELECT \"LSM\" from \"EMBRYO\" where \"EMBRYO_ID\"='".$row["EMBRYO_ID"]."'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);
if (strlen(trim($row0["LSM"]))!=0) print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/yes.gif\"><br><a target=\"_blank\" href=\"add-embryo-lsm.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Update</small></a></font>
<br><font size=\"-1\"><small>or</small><br><a target=\"_blank\" href=\"delete-embryo-lsm.php?embryoid=".$row["EMBRYO_ID"]."\"><font size=\"-1\" color=\"#D64242\"><small>Delete</small></font></a>
</td>";

else print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><font size=\"-1\"><img src=\"pictures/no.gif\"><br><a target=\"_blank\" href=\"add-embryo-lsm.php?embryoid=".$row["EMBRYO_ID"]."\"><small>Upload</small></a></font></td>";






print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><a target=\"_blank\" href=\"embryo-card.php?embryoid=".$row["EMBRYO_ID"]."&mode=update\"><img border=\"0\" width=\"25\" src=\"pictures/button-cur-edit.gif\"></a></font></td>";

print "<td align=\"center\" style=\"background-color:white;color:black;border-top:1px solid black;\"><a target=\"_blank\" href=\"delete-embryo.php?embryoid=".$row["EMBRYO_ID"]."\"><img border=\"0\" width=\"25\" src=\"pictures/button-cur-delete.gif\"></a></font></td>";

print "</tr>";
}


?>
</table>



<?

include ("frames_footer.php");

?>