<?php

$ruid = $_POST['ruid'];

?>

<!doctype html public "-//w3c//dtd html 3.2//ja">
<html>
<head>
<title>delete refered image from server</title>
<meta http-equiv=content-type content="image/jpeg; charset=x-euc-jp">


</head>
<body BACKGROUND="./img/yellow.jpg" onLoad="setTimeout('window.close()',500)">

<?php

//
//	2002.1.1
//	DICOM to WWW Gateway :PHP script
//	Made by Norya Yokohama % Medical Division @ WERC
//  2004.9.19
//  added by tadashi tsuchimoto @ MITT belong to yokohamazyuku
//  insert/delete refered images menu
//


  include "init.inc";
  include "param_setting.ini";
  include "sql_generator.ini";
  include "file_mod.inc";
  $include_path=".";
  require("$include_path/dbconnect.ini");


//DB query

$db_handle = db_contact_start($db_type,$target_host,$target_db);



//$result = pg_query("BEGIN");


//$sql="update reportlevel set refimage=null where stutim2='$stutim2'";
$sql="update reportlevel set refimage5=null where ruid='$ruid'";


  $rtn_update = $db_handle->prepare($sql);
  $rtn_update->execute();
  


  $sql2 = "select 
  reportlevel.refimage2 as refimage2,
  reportlevel.refimage3 as refimage3,
  reportlevel.refimage4 as refimage4,
  reportlevel.refimage5 as refimage5,
  reportlevel.refimage6 as refimage6,
  reportlevel.refimage6 as refimage7,
  reportlevel.refimage6 as refimage8,
  reportlevel.refimage6 as refimage9,
  reportlevel.refimage6 as refimage10,
  reportlevel.refimage as refimage from reportlevel
  where reportlevel.ruid ='$ruid'";
/*
  $rtn2 = pg_exec($sql2);

  $flag = pg_num_rows($rtn2);
*/

	$rtn_select = $db_handle->prepare($sql2);
	$rtn_select->execute();
  
  $row_count = $rtn_select->rowCount();

  if ($row_count>=1){
	while ($rtn_select_row = $rtn_select->fetch(PDO::FETCH_ASSOC)) {
	
    $refimage = $rtn_select_row['refimage'] ;
    $refimage2 = $rtn_select_row['refimage2'] ;
    $refimage3 = $rtn_select_row['refimage3'] ;
    $refimage4 = $rtn_select_row['refimage4'] ;
    $refimage5 = $rtn_select_row['refimage5'] ;
    $refimage6 = $rtn_select_row['refimage6'] ;
	$refimage7 = $rtn_select_row['refimage7'] ;
	$refimage8 = $rtn_select_row['refimage8'] ;
	$refimage9 = $rtn_select_row['refimage9'] ;
	$refimage10 = $rtn_select_row['refimage10'] ;
	
	}

  }else{
  print("no report registered");


  }


print("<p>");

if($refimage){
	if($refimage2){
		if($refimage3){
			if($refimage4){
				if($refimage5){
					$ref_num = 6;
					      }
					$ref_num = 5;
				      }	
				$ref_num = 4;
				}
			$ref_num = 3;
			}
		$ref_num = 2;
	      }

if(!@$ref_num){
  $ref_num = 1;
}

// print($ref_num);
// print("<br>");


if($refimage){
print("key image");
print("<br>");
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage\" Width=310 Height=310>");
}

if($refimage2){
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage2\" Width=310 Height=310>");
}

if($refimage3){
print("<br>");
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage3\" Width=310 Height=310>");
}

if($refimage4){
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage4\" Width=310 Height=310>");
}


if($refimage5){
print("<br>");
print("<img src=\"show_refimage.php?ruid=$ruid&refimage=$refimage5\" Width=310 Height=310>");
}



?>


</body>
</html>
