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


<html>
<body bgcolor="#999966" text="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">
<title>ANISEED CURATOR - Mol Edit</title>

<?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;
	}
?>


<?php
    $type = $_POST["type"];
    $part = $_POST["part"];
    $id = $_POST["id"];
    $text = $_POST["text"];
    $text = ereg_replace( "'", "", $text);
	$text = stripslashes($text);
	
	
    
	    $requete="update \"".strtoupper($type)."\" set \"".strtoupper($part)."\"= '".$text."' where \"".strtoupper($type)."_ID\"=$id";
	
pg_query($c,"begin");		
		$resultset = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
		$requete = "update \"ENTRY_ORIGIN\" set \"CURATOR_ID\"=".$_SESSION['curationauthor'].", \"CURATION_DATE\"=now() where \"BIO_ID\"=$id";
		$resultset = pg_query($c,$requete);
		
		if($part=="name"){
			$requete = "update \"MOL_ENTITY\" set \"NAME\"='$text' where \"MOL_ID\"=$id";
			$resultset = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
			
			$requete = "update \"TARGET\" set \"NAME\"='$text' where \"TARGET_ID\"=$id";
			$resultset = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
		}
	
		// Validation de la transaction
		//$committed = OCICommit($connection);
pg_query($c,"commit");
	
		// V�ification de la validation : si une erreur est survenue, afficher le message d'erreur
		/*if(!$committed) {
			$error = OCIError($connection);
			echo 'ERROR:'.$error['message'];
		}else{*/
			print '<center><H1>Update done</H1><br>';
			print '<input name="Exit" type="button" value="-= Close window =-" onClick="javascript:self.close();"></center>';
		/*}*/
		



?>

</body>
</html>