<?php
include("connection.php");
include("frames_header.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;
}

include("update-interactions.php");

$khoueiry = "SELECT \"ID\",\"ISH_ID\" FROM \"UPDATE_INTERACTIONS\"";
$stmt = pg_query($c,$khoueiry);
if($row=pg_fetch_array($stmt)){ 
	pg_query($c,"BEGIN");
	update_evidence($c,$row["ISH_ID"]);
	pg_query($c,"DELETE FROM \"UPDATE_INTERACTIONS\" WHERE \"ISH_ID\" = ".$row["ISH_ID"]);
	pg_query($c,"END");	
	//break;
}
print "<strong>ISH ".$row["ISH_ID"]." Finished</strong><br/>";

$khoueiry = "SELECT COUNT(DISTINCT \"ISH_ID\") AS \"ISH\" FROM \"UPDATE_INTERACTIONS\"";
$stmt = pg_query($c,$khoueiry);
if($row=pg_fetch_array($stmt)){ 
	print "<strong>".$row["ISH"]." more ISH to go!</strong><br/>";	
}
include("frames_footer.php");
?>