<?
include ("connection.php");
print "<title>ANISEED CURATOR - Edit Article</title>";
include ("frames_header.php");

$id=$_GET["id"];


print "<center><h3>Article Card - Edition page </h3></center><br>";

print "<form name=\"formu\" action=\"edit-article2.php\" method=\"POST\" target=\"blank\">";

//// TABLE ARTICLE ///////
$requete="SELECT * from \"ARTICLE\" where \"ARTICLE_ID\"='$id'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$pmid=$row["PUBMED_ID"];
$title=$row["TITLE"];
$paper=$row["PAPER"];
$authors=$row["AUTHORS"];
$url=$row["URL"];
$comments=$row["COMMENTS"];

print "<b><u>Article Features</u></b><br><br>";
print "<table width=\"100%\">";
print "<tr><td>Aniseed Article ID</td><td><input style=\"text-align:center;\" type=\"text\" name=\"id\" value=\"$id\" size=\"5\" disabled></td></tr>";
print "<tr><td>Pubmed ID</td><td><input style=\"text-align:center;\" type=\"text\" name=\"pmid\" value=\"$pmid\" size=\"15\"></td></tr>";
print "<tr><td>Authors</td><td><input type=\"text\" name=\"authors\" value=\"$authors\" size=\"90\"></td></tr>";
print "<tr><td>Title</td><td><input type=\"text\" name=\"title\" value=\"$title\" size=\"120\"></td></tr>";
print "<tr><td>Paper</td><td><input type=\"text\" name=\"paper\" value=\"$paper\" size=\"80\"></td></tr>";
print "<tr><td>Url</td><td><input type=\"text\" name=\"url\" value=\"$url\" size=\"80\"></td></tr>";
print "<tr><td>Comments</td><td><textarea name=\"comments\" rows=\"5\" cols=\"80\">$comments</textarea></td></tr>";

print "</table>";
print "<br>";
print "<center>
<a href=\"http://www.ncbi.nlm.nih.gov/sites/entrez?Db=pubmed&Cmd=ShowDetailView&TermToSearch=$pmid&ordinalpos=1&itool=EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_RVDocSum\">View in PubMed</a><br>
<br><input type=\"image\" name=\"submit\" src=\"pictures/button-submit.jpg\" onclick=\"submit;\"></center>";

print "<input type=\"hidden\" name=\"id\" value=\"$id\">";


print "</form>";
print "<br>";


//// TABLE ARTICLE_GENE ///////


print "<br><br><b><u>Genes studied in article</u></b><br><br>";




$requete="SELECT * from \"ARTICLE_GENE\" where \"ARTICLE_ID\"='$id' order by \"TYPE\"";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0)
	{
	print "<center><small><font color=\"#D64242\"><b>No Genes studied have been entered for this article</b></font></center></small><br>";
	print "<center><a target=\"blank\" href=\"edit-article-gene.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";
	}

else 
{

print "<table cellspacing=0 style=\"border:1px solid white;padding:0px;margin:0px;\" width=\"100%\">";

print "<tr><td align=\"center\">Transcript ID</td><td align=\"center\"><b>Aniseed Gene Model ID</b></td><td align=\"center\"><b>Gene Name</b></td><td align=\"center\"><b>Type of Analysis</b></td><td align=\"center\"><b>Edit</b></td><td align=\"center\"><b>Delete</b></td></tr>";

while ($row=pg_fetch_array($stmt))
{


//$clust=$row["GENE_CLUSTER_ID"];
$transcript=$row["TRANSCRIPT"];
$type=$row["TYPE"];

$genename="";

$requete0="SELECT \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
select \"GENE_ID\" from \"GENE\" where \"NAME\"='$transcript'
)";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$clust=$row0["GENE_CLUSTER_ID"];
$myclust=$clust;
$clust=str_replace("cluster","aniseedV3_",$clust);

$requete0="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$myclust'";
$stmt0=pg_query($c,$requete0);
$genename="";
while ($row0=pg_fetch_array($stmt0))
{
if (strlen($genename)==0) $genename=$row0["GENE_CLUSTER_NAME"];
else $genename.=" / ".$row0["GENE_CLUSTER_NAME"];
}

if (strlen($genename)==0)
	{
	$requete0="SELECT \"GENE_CLUSTER_NAME_BLAST\" from \"GENE_CONCEPT_NAME_BLAST\" where \"GENE_CLUSTER_ID\"='$myclust'";
	$stmt0=pg_query($c,$requete0);
	while ($row0=pg_fetch_array($stmt0))
	{
	if (strlen($genename)==0) $genename=$row0["GENE_CLUSTER_NAME_BLAST"];
	else $genename.=" / ".$row0["GENE_CLUSTER_NAME_BLAST"];
	}

	}


print "<tr>
<td align=\"center\" style=\"border: 1px solid white;\"><font color=\"black\">$transcript</font></td>
<td align=\"center\" style=\"border:1px solid white;\">$clust</td>
<td align=\"center\" style=\"border:1px solid white;\">$genename&nbsp;</td>
<td align=\"center\" style=\"border:1px solid white;\"><i>
";

if ($type=="Function")
	{
	////// FUNCTION ///////
	//print "<a target=\"blank\" href=\"edit-article-gene-function.php?id=$id&gene=$transcript\">Function</a>";

	print "
	<div style=\"background-color:white;\">
	<table width=\"100%\">
	<tr><td align=\"center\"><b><i><font color=\"purple\">Function</font></i></b></td></tr>
	<tr><td align=\"center\"><a target=\"blank\" href=\"edit-article-gene-function.php?id=$id&gene=$transcript\"><font size=\"-1\">Show experimental evidence</font></a></td></tr>
	<tr><td><hr size=\"1\"></td></tr>
	<tr><td align=\"center\"><a href=\"view-moltool.php?id=$id&gene=$transcript\"><font size=\"-1\">All Molecular tools already entered in database</font></a></td></tr>

	</table>




	</div>	
	";
	}





if ($type=="Regulation")
	{
	///// REGULATION //////
	//print "<a target=\"blank\" href=\"edit-article-gene-regulation.php?id=$id&gene=$transcript\">Regulation</a>";
	print "
	<div style=\"background-color:white;\">
	<table width=\"100%\">
	<tr><td align=\"center\"><b><i><font color=\"#D64242\">Regulation</font></i></b></td></tr>
	<tr><td align=\"center\"><a target=\"blank\" href=\"edit-article-gene-regulation.php?id=$id&gene=$transcript\"><font size=\"-1\">Show experimental evidence</font></a></td></tr>
	<tr><td><hr size=\"1\"></td></tr>
	<tr><td align=\"center\"><a href=\"reg-region-search-results.php?target=$transcript&rtype=-----ANY-----&pmid=$pmid\"><font size=\"-1\">Cis-regulatory region</font></a></td></tr>
	</table>
	</div>	
	";
	}





if ($type=="Wild type expression")
	{
	///// WILD TYPE EXPRESSION //////
	//print "<a target=\"blank\" href=\"edit-article-gene-marker.php?id=$id&gene=$transcript\">Wild type expression</a>";
	print "
	<div style=\"background-color:white;\">
	<table width=\"100%\">
	<tr><td align=\"center\"><b><i><font color=\"orange\">Wild type expression</font></i></b></td></tr>
	<tr><td align=\"center\"><a target=\"blank\" href=\"edit-article-gene-marker.php?id=$id&gene=$transcript\"><font size=\"-1\">Show experimental evidence</font></a></td></td>
	</table>
	</div>	
	";
	}

print "</i></td><td align=\"center\" style=\"border:1px solid white;\"><a  target=\"blank\"href=\"edit-article-gene.php?id=$id&name=$transcript&type=$type&update=1\"><img width=\"25\" border=\"0\" src=\"pictures/button-cur-edit.gif\"></a></td><td align=\"center\" style=\"border:1px solid white;\"><a target=\"blank\" href=\"delete-article-gene.php?id=$id&name=$transcript&type=$type\"><img  width=\"25\" border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></td></tr>";




}

print "</table>";
print "<br>";
print "<center><a target=\"blank\" href=\"edit-article-gene.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";

}

print "<br><center><a href=\"insitu-result.php?pmid=$pmid\">Show All experimental evidences</a></center><br>";



//// TABLE ARTICLE ANATOMY //////

print "<br><br><b><u>Territories affected</u></b><br><br>";

$requete="SELECT * from \"ARTICLE_ANATOMY\" where \"ARTICLE_ID\"='$id'";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0)
	{
	print "<center><small><font color=\"#D64242\"><b>No Territories affected have been entered for this article</b></font></center></small><br>";
	print "<center><a target=\"blank\" href=\"edit-article-anatomy.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";
	}

else 
{
print "<table cellspacing=0 style=\"border:1px solid white;padding:0px;margin:0px;\" width=\"100%\">";

print "<tr><td align=\"center\"><b>Anatomical Territories</b></td><td>Gene</td><td align=\"center\"><b>Delete</b></td></tr>";


	while ($row=pg_fetch_array($stmt))
	{
	$anat=$row["ANAT_ID"];
	$gene=$row["TRANSCRIPT"];

	$requete0="SELECT anat.\"SPECIES\",anat.\"NAME\" as \"NAME\" ,dev.\"NAME\" as \"DEV\" from \"ANAT_ENTITY\" anat, \"DEV_STAGE\" dev where anat.\"ANAT_ID\"='$anat' and anat.\"DEV_STAGE_ID\"=dev.\"DEV_STAGE_ID\"";
	$stmt0=pg_query($c,$requete0);
	$row0=pg_fetch_array($stmt0);

	print "<tr><td align=\"center\" style=\"border:1px solid white;\">".$row0["NAME"]." (".$row0["DEV"].") <i>".$row0["SPECIES"]."</i></td><td align=\"center\" style=\"border:1px solid white;\" ><font color=\"black\">$gene</font></td><td align=\"center\" style=\"border:1px solid white;\"><a target=\"blank\" href=\"delete-article-anatomy.php?id=$id&anat=$anat&gene=$gene\"><img  width=\"25\" border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></td></tr>";





	}

print "</table>";


print "<br><center><a target=\"blank\" href=\"edit-article-anatomy.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";


}



////


////// TABLE FATE /////////

print "<br><br><b><u>Fates affected</u></b><br><br>";

$requete="SELECT * from \"ARTICLE_FATE\" where \"ARTICLE_ID\"='$id'";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0)
	{
	print "<center><small><font color=\"#D64242\"><b>No Fate affected have been entered for this article</b></font></center></small><br>";
	print "<center><a target=\"blank\" href=\"edit-article-fate.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";
	}
else
	{

print "<table cellspacing=0 style=\"border:1px solid white;padding:0px;margin:0px;\" width=\"100%\">";

print "<tr><td align=\"center\"><b>Fate</b></td><td align=\"center\">Gene</td><td align=\"center\"><b>Delete</b></td></tr>";


	while ($row=pg_fetch_array($stmt))
	{
	$fate=$row["FATE"];
	$gene=$row["TRANSCRIPT"];

		print "<tr><td align=\"center\" style=\"border:1px solid white;\">$fate</td><td align=\"center\" style=\"border:1px solid white;\"><font color=\"black\">$gene</font></td><td align=\"center\" style=\"border:1px solid white;\"><a target=\"blank\" href=\"delete-article-fate.php?id=$id&fate=$fate&gene=$gene\"><img  width=\"25\" border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></td></tr>";





	}

print "</table>";


print "<br><center><a target=\"blank\" href=\"edit-article-fate.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";

	}

//////////// TABLE MORPHOGENETIC_PROCESS ///////////

print "<br><br><b><u>Phenotypes</u></b><br><br>";

$requete="SELECT * from \"ARTICLE_MORPHOGEN\" where \"ARTICLE_ID\"='$id'";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0)
	{
	print "<center><small><font color=\"#D64242\"><b>No Phenotypes process data have been entered for this article</b></font></center></small><br>";
	print "<center>|<br>click on this button to add a Phenotype<br>|<br>|<br>V<br></center><center><a target=\"blank\" href=\"edit-article-morphogen.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";
	}
else
	{
	

	
	while ($row=pg_fetch_array($stmt))
		{

			
		$morpho=$row["MORPHOGEN_ID"];
		//$gene=$row["GENE_CLUSTER_ID"];
		$gene=$row["TRANSCRIPT"];

		$name=$row["NAME"];

		$devstage=$row["DEV_STAGE_ID"];
		$requete0="SELECT \"NAME\" from \"DEV_STAGE\" where \"DEV_STAGE_ID\"='$devstage'";
		$stmt0=pg_query($c,$requete0);
		$row0=pg_fetch_array($stmt0);
		$devname=$row0["NAME"];


		$genename="";
		$requete0="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"=(
		select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
		select \"GENE_ID\" from \"GENE\" where \"NAME\"='$gene'
		)
		)";
		$stmt0=pg_query($c,$requete0);
		
		if (pg_num_rows($stmt0)==0)
		{
		$requete0="SELECT \"GENE_CLUSTER_NAME_BLAST\" as \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME_BLAST\" where \"GENE_CLUSTER_ID\"=(
		select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
		select \"GENE_ID\" from \"GENE\" where \"NAME\"='$gene'
		)
		)";
		$stmt0=pg_query($c,$requete0);
		}
		while ($row0=pg_fetch_array($stmt0))
			{
			if (strlen($genename)==0) $genename=$row0["GENE_CLUSTER_NAME"];
			else $genename.=" / ".$row0["GENE_CLUSTER_NAME"];
			}

		$requete0="SELECT \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
		select \"GENE_ID\" from \"GENE\" where \"NAME\"='$gene'
		)";
		$stmt0=pg_query($c,$requete0);
		$row0=pg_fetch_array($stmt0);

		$genemod=str_replace("cluster","aniseedV3_",$row0["GENE_CLUSTER_ID"]);

		$comments=$row["COMMENTS"];

/////// NOUVEAU ////////
print "<center>";
		print "<div style=\"background-color:#4568FF;padding:5px;margin:5px;width:80%; border: 1px solid white;\">";
		print "<div align=\"right\">$devname</div>";

print "<table border=\"0\" width=\"100%\">";
print "<tr>";
print "<td>";
////// PIX ////////

		print "<font size=\"-1\">click on this button to add a picture<br>|<br>|<br>V</font><br>";
		print "<a target=\"blank\" href=\"add-morphogen-picture.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a><br><br>";



	$requete0="SELECT \"PICTURE_MORPHOGEN_ID\" from \"ARTICLE_MORPHOGEN_PICTURE\" where \"MORPHOGEN_ID\"='$morpho'";
		$stmt0=pg_query($c,$requete0);
		if (pg_num_rows($stmt0)==0)
			{
			print "<center><small><font color=\"#D64242\"><b>No Pictures</b></font></center></small><br>";
						
			}
		else
			{
		
		//print "<table><tr>";
		print "<table>";
		$COUNT=0;
		while ($row0=pg_fetch_array($stmt0))
		{
		if ($COUNT%3==0) print "<tr>";
		print "<td><div style=\"border:1px solid black;\"><a target=\"blank\" href=\"delete-morphogen-picture.php?picid=".$row0["PICTURE_MORPHOGEN_ID"]."\"><img  border=\"0\" src=\"pictures/button-cur-delete.gif\"></a>&nbsp; <img width=\"150\" src=\"picture-mini-morphogen.php?id=".$row0["PICTURE_MORPHOGEN_ID"]."\"></div></td>";
		if ($COUNT%3==0) print "</tr>";
		$COUNT++;
		}
		print "</table>";
		//print "</tr></table>";
		
			}
		
///////////////////
print "</td>";

print "<td>";

print "<table>";
print "<tr><td><b>$name</b></td></tr>";
print "<tr><td><b>$gene </b> ( $genemod )</td></tr>";
print "<tr><td>$genename</td></tr>";
print "<tr><td>$comments</td></tr>";



print "</table>";


print "</td>";




print "</tr>";
print "</table>";


		//print "<b>$name</b><br>";
		//print "<br><b>$gene </b> ( $genemod )<br>";
		//print "$genename<br>";
		//print "<br>";
		//print "<i>$comments</i><br>";
		//print "<br>";
		print "<div align=\"right\"><a target=\"blank\" href=\"edit-article-morphogen.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a>&nbsp;&nbsp;<a target=\"blank\" href=\"delete-article-morphogen.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></div>";
	
		print "</div>";
		print "<br>";
		}

				
		print "<br>";
print "</center>";


////////////////////////

		/*print "<center>";
		print "<div style=\"width:80%; border: 1px solid white;\">";
		print "<center>";
		print "<b>$name</b><br>";
		print "$devname<br>";
		print "<br><b>$gene </b> ( $genemod )<br>";
		print "$genename<br>";
		print "<br>";
		print "<i>$comments</i><br>";
		print "<br>";
		print "<center><a target=\"blank\" href=\"edit-article-morphogen.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a>&nbsp;&nbsp;<a target=\"blank\" href=\"delete-article-morphogen.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></center>";
		print "<br>";


		$requete0="SELECT \"PICTURE_MORPHOGEN_ID\" from \"ARTICLE_MORPHOGEN_PICTURE\" where \"MORPHOGEN_ID\"='$morpho'";
		$stmt0=pg_query($c,$requete0);
		if (pg_num_rows($stmt0)==0)
			{
			print "<center><small><font color=\"#D64242\"><b>No Pictures</b></font></center></small><br>";
						
			}
		else
			{
		
		print "<table><tr>";
		while ($row0=pg_fetch_array($stmt0))
		{
		print "<td><div style=\"border:1px solid black;\"><a target=\"blank\" href=\"delete-morphogen-picture.php?picid=".$row0["PICTURE_MORPHOGEN_ID"]."\"><img  border=\"0\" src=\"pictures/button-cur-delete.gif\"></a>&nbsp; <img width=\"150\" src=\"picture-mini-morphogen.php?id=".$row0["PICTURE_MORPHOGEN_ID"]."\"></div></td>";
		}
		print "</tr></table>";
		
			}
		
		print "<br><br><font size=\"-1\"><center>click on this button to add a picture<br>|<br>|<br>V</font><br></center>";
		print "<a target=\"blank\" href=\"add-morphogen-picture.php?morphoid=$morpho\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a><br><br>";


		print "</div>";
		print "</center>";
		print "<br>";
		}

		print "</center>";
		
		print "<br>";
		*/

	print "<br><center><font size=\"-1\">Click on this button if you want to Add a new Morphogenetic process -----></font> <a target=\"blank\" href=\"edit-article-morphogen.php?id=$id\"><img border=\"0\" src=\"pictures/button-add.jpg\"></a></center>";


	}












/////////////////////////////////////////////////////////



include ("frames_footer.php");
?>