
<?php

	include ("frames_header.php"); 

	include ("connection.php");
	
    if ( (!isset($_SESSION["login"]))or(!isset($_SESSION["pass"])) ) {
	    print "<strong>you need to <a href=\"login.php\">login</a> as an authorised curator to proceed.</strong>";
	    print '</center></body></html>';
		return;
	}
		    
   	$id = $_POST["id"];
	$type = $_POST["type"];
	    
	pg_query($c, "BEGIN") or die("<strong>ERROR </strong>".pg_last_error($c));     

	$khoueiry="UPDATE \"PROMOTER\" SET \"TYPE\"='$type' WHERE \"PROMOTER_ID\"=$id;"; 	  	
	pg_query($c,$khoueiry) or die("<strong>ERROR </strong>".pg_last_error($c));
	  
	$test="SELECT \"IS_ADMIN\" from \"AUTHOR\" where \"LOGIN\"='".$_SESSION["login"]."'";
	$stest=pg_query($c,$test);
	$rtest=pg_fetch_array($stest);
	if ($rtest["IS_ADMIN"]=='y'){
	      $khoueiry = "update \"ENTRY_ORIGIN\" set \"CURATOR_ID\"=".$_SESSION['curationauthor'].", \"CURATION_DATE\"=now() where \"BIO_ID\"='$id'";	  
	} else {
	      $khoueiry = "update \"ENTRY_ORIGIN\" set \"ANNOTATOR_ID\"=".$_SESSION['curationauthor'].", \"ANNOTATION_DATE\"=now() where \"BIO_ID\"='$id'";		  
	}
	pg_query($c,$khoueiry) or die("<strong>ERROR </strong>".pg_last_error($c)); 
	  
	pg_query($c, "COMMIT") or die("<strong>ERROR </strong>".pg_last_error($c)); 			     
	echo '<SCRIPT LANGUAGE="JavaScript"> javascript:opener.location.reload(); self.close(); </script>';
	include ("frames_footer.php"); 

?>