<?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/>.

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

	//CONSTRUCTION_ID
	$id = $_GET["constructid"];	
	
	$khoueiry = "SELECT * FROM \"CONSTRUCTION\" WHERE \"CONSTRUCTION_ID\"=".$id.";";		
	$stmt = pg_query($c,$khoueiry);
	if($row=pg_fetch_array($stmt)){
	    $name=$row["NAME"];
	    $comments=$row["COMMENTS"];
	    $promoter_id = $row["PROMOTER_ID"];
	    $reporter = $row["REPORTER_ID"];
	    $min_prom_id=$row["MIN_PROMOT_ID"];	
			    
	    $promoter_name = "Unable to determine";
		$khoueiry = "SELECT \"NAME\" FROM \"PROMOTER\" WHERE \"PROMOTER_ID\"=".$promoter_id.";";		
		$stmt = pg_query($c,$khoueiry);
		if($row=pg_fetch_array($stmt)){			  
			$promoter_name = $row["NAME"];
		}	    	    	    
	    
	    $min_prom_name = "Unable to determine";
	    if($promoter_id==$min_prom_id){
			$min_prom_name = "Endogenous Promoter";
		} else {
			$khoueiry = "SELECT \"NAME\" FROM \"PROMOTER\" WHERE \"PROMOTER_ID\"=".$min_prom_id.";";		
			$stmt = pg_query($c,$khoueiry);
			if($row=pg_fetch_array($stmt)){			  
				$min_prom_name = $row["NAME"];
			}
		}	    
	}
	
   
    print "<h2><strong><em>Construct: ".$name."</em></strong> <a href=\"insitu-result.php?target=".$name."&MOLtype=1\" target=\"_blank\"> <img src=\"pictures/button-getPics.jpg\" border=\"0\" title=\"View Insitu data\"></a></h2> ";
    print "<strong>Regulatory Region:</strong><a target=\"_BLANK\" href=\"reg-region-edit.php?id=$promoter_id\">$promoter_name</a><br/><br/>";
    print "<u><strong><font size=\"+2\">Features:</font></strong></u><br><br>";
	print "<a target=\"_BLANK\" href=\"curator-mol-edit.php?type=construction&part=name&id=$id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a><strong>Name: </strong>".$name."<br>";		
    print "<a target=\"_BLANK\" href=\"curator-mol-edit.php?type=construction&part=comments&id=$id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a><strong>Comments:</strong>".$comments."<br/>";
    print "<a target=\"_BLANK\" href=\"construct-edit-minprom.php?id=$id&promid=$promoter_id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a><strong>Minimal Promoter: </strong>";    
    if($promoter_id==$min_prom_id){
	     print "Endogenous Promoter<br/>"; 	  
	} else {
	     print "<a target=\"_BLANK\" href=\"reg-region-edit.php?id=$min_prom_id\">$min_prom_name</a><br/>"; 
	}
	
	$khoueiry = "SELECT \"NAME\" FROM \"MOLECULAR_TOOL\" WHERE \"MOLECULAR_TOOL_ID\"=$reporter;";
	$stmt = pg_query($c,$khoueiry);		
	if($row=pg_fetch_array($stmt)){ 
		print "<a target=\"_BLANK\" href=\"construct-edit-reporter.php?id=$id&reporter=$reporter&promid=$promoter_id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a><strong>Reporter:</strong>".$row["NAME"]."<br/>";
	 
	} else {
		print "<a target=\"_BLANK\" href=\"construct-edit-reporter.php?id=$id&reporter=$reporter&promid=$promoter_id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a><strong>Reporter:</strong>Unable to determine<br/>";
	}
			
	include ("frames_footer.php"); 

?>