<?
	// 인클루드
	require_once( "../inc/session.php" );
	require_once( "../inc/common.inc" );      // 공통 함수 모음
	require_once( "../inc//db_pgsql.inc" ); // 데이터베이스 인터페이스
	require_once( "../inc/drpchart.inc" ); // vml 그래프 출력용

	$suid = $HTTP_COOKIE_VARS[SUID];

	if ($suid != "guru222")
	{
	    AlertBack("전체관리자만 접근할 수 있습니다.");
	    exit;
	}

	$rc_name = isset($_GET['rc_name']) ? $_GET['rc_name'] : $_GET['rc_name'];
	$rc_id = isset($_GET['rc_id']) ? $_GET['rc_id'] : $_GET['rc_id'];
	$porder = isset($_GET['porder']) ? $_GET['porder'] : $_GET['porder'];
	$arrange = isset($_GET['arrange']) ? $_GET['arrange'] : $_GET['arrange'];

	// 윈도우 사이즈(Height) 결정
	$objConn = new DB_Sql;

	$sql  = " SELECT COUNT(rc_server_seq) AS cnt ";
	$sql .= " FROM t_rms_rc_server_index ";
	$sql .= " WHERE rcid = '$rc_id' AND deleted_yn = 'N' ";
	$objConn->query( $sql );

	if( $objConn->nf() != 0 )
	{
		$objConn->next_record();
		$list_cnt = $objConn->f(0);
	}
	$default = 220;
	$default_right_padding = 20;
	$win_height = $default + ($list_cnt * 28);
	$default_div_height = $list_cnt * 28;
	if ($list_cnt >= 20)
	{
		$win_height = $default + 28*20;
		$default_div_height = 28*20;
		$default_right_padding = 0;
	}
	$objConn->close();
	
?>
<html>
<head>
<title>POP 서버 관리</title>
<link rel="stylesheet" href="../css/style.css" type="text/css">
<style type="text/css">
#hscroll_box {
	border-width:0;
	border-style:solid;
	border-color:#d9d9d9;
	overflow-h:hidden;
	overflow-y:auto;
	height: <?=$default_div_height?>px;
	width: 480px;
	
	scrollbar-3dlight-color : #F1f1f1;
	scrollbar-arrow-color : #666666 ;
	scrollbar-base-color : #f1f1f1;
	scrollbar-darkshadow-color : #f1f1f1;
	scrollbar-face-color : #f1f1f1;
	scrollbar-highlight-color : #666666;
	scrollbar-shadow-color : 666666;
	scrollbar-track-color : #FFFFFF;	
}
</style>

<SCRIPT LANGUAGE="JavaScript">
window.focus();
window.resizeTo(500, <?=$win_height?>);

function deleteRc(rc_id, rc_name, rc_seq)
{
	frm = document.list;
	
	frm.prcid.value = rc_id;
	frm.pname.value = rc_name;
	frm.prcseq.value = rc_seq;
	
	if (confirm("정말 삭제 하시겠습니까?"))
	{
		frm.method="POST"
		frm.action="./rc_server_del_proc.html";
		frm.submit();
	}
	else
		return;
}

function win_close()
{
	opener.window.location.reload();
	self.close();
}
</SCRIPT>
</head>

<body>
<form name="list">
<input type="hidden" name="prcid">
<input type="hidden" name="pname">
<input type="hidden" name="prcseq">
<input type="hidden" name="mode" value="del">

<table width="100%" bordercolor="#e7e7e7" bgcolor="#e7e7e7">
  <tr bordercolor="#e7e7e7">
	<td width="100%" height="24" bgcolor="#e7e7e7" class="style2" scope="col" align="center">
	<b><?=$rc_name?>(<?=$rc_id?>)</b>
	</td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height='0'>&nbsp;</td>
</tr>
                          
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" class="ContentTable">
	<tr>
		<td colspan="6" height="2" bgcolor="#B9B9B9"></td>
	</tr>
	<tr align="center">
		<td bgcolor="#F6F5F2" width="20%"><b><a href="./rc_server_pop.html?rc_name=<?=$rc_name?>&rc_id=<?=$rc_id?>&arrange=<?=$arrange?>&porder=name">서버명</a></b></td>
		<td bgcolor="#F6F5F2" width="20%"><b><a href="./rc_server_pop.html?rc_name=<?=$rc_name?>&rc_id=<?=$rc_id?>&arrange=<?=$arrange?>&porder=ip">IP</a></b></td>
		<td bgcolor="#F6F5F2" width="10%"><b><a href="./rc_server_pop.html?rc_name=<?=$rc_name?>&rc_id=<?=$rc_id?>&arrange=<?=$arrange?>&porder=port">Port</b></a></td>
		<td bgcolor="#F6F5F2" width="10%"><b><a href="./rc_server_pop.html?rc_name=<?=$rc_name?>&rc_id=<?=$rc_id?>&arrange=<?=$arrange?>&porder=type">서버타입</b></a></td>
		<td bgcolor="#F6F5F2" width="5%"> <b>  감시</b></td>
		<td bgcolor="#F6F5F2" width="18%"><b>관리</b></td>
	</tr>
	<tr>
		<td colspan="5" height="1" bgcolor="E1E1E1"></td>
	</tr>
</table>

<div id="hscroll_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ContentTable">
<?php
$objConn = new DB_Sql;

$sql  = " SELECT rc_server_seq, rcid, name, ip, port, type, monitor_yn ";
$sql .= " FROM t_rms_rc_server_index ";
$sql .= " WHERE rcid = '$rc_id' AND deleted_yn = 'N' ";
if ($porder == "name")
	$sql .= " ORDER BY name asc ";
else if ($porder == "ip")
	$sql .= " ORDER BY ip asc ";
else if ($porder == "port")
	$sql .= " ORDER BY port asc ";
else if ($porder == "type")
	$sql .= " ORDER BY type asc ";
else
	$sql .= " ORDER BY type, name asc ";
$objConn->query( $sql );

if( $objConn->nf() != 0 )
{
	while( $objConn->next_record() )
	{
		$pseq = $objConn->f(0);
		$pname = $objConn->f(2);
		$pip = $objConn->f(3);
		$pport = $objConn->f(4);
		$ptype = $objConn->f(5);
		$pmonitor_yn = $objConn->f(6);
		
		switch($ptype)
		{
			case "RC" :
				$ptype = "RC";
				break;
			case "RTS" :
				$ptype = "RTS";
				break;
			case "CACHE" :
				$ptype = "CACHE";
				break;
			case "RCDB" :
				$ptype = "RCDB";
				break;
			case "RCTS" :
				$ptype = "RCTS";
				break;
			case "STAT" :
				$ptype = "STAT";
				break;
			case "TIMED" :
				$ptype = "TIMED";
				break;
			default :
				break;
		}
?>
	<tr align="center">
		<td bgcolor="#FFFFFF" width="20%"><?=$pname?></td></a>
		<td bgcolor="#FFFFFF" width="20%"><?=$pip?></td></a>
		<td bgcolor="#FFFFFF" width="10%"><?=$pport?></td></a>
		<td bgcolor="#FFFFFF" width="10%"><?=$ptype?></td></a>
		<td bgcolor="#FFFFFF" width="5%"><?if($pmonitor_yn=='Y')echo "on";else echo "off";?></td></a>
		<td bgcolor="#FFFFFF" width="20%" style="padding-right:<?=$default_right_padding?>">
		<a href="javascript:deleteRc('<?=$rc_id?>','<?=$pname?>', '<?=$pseq?>')"><img src="../images/icon_delete.gif" border="0"></a>
		</td>
	</tr>
	<tr>
		<td colspan="6" height="1" bgcolor="E1E1E1"></td>
	</tr>
	<tr>
		<td colspan="6" height="5"></td>
	</tr>

<?php
	}
}
$objConn->close();
?>
</table>
</div>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td height="5">
	</tr>
	<tr>
		<td align="right" style="padding-right:40">
		<a href="rc_server_mod.html?mode=mod&rc_seq=<?=$pseq?>&rc_id=<?=$rc_id?>&arrange=<?=$arrange?>"><img src="../images/icon_modify2.gif" border="0"></a>&nbsp;
		<a href="./rc_server_add.html?rc_id=<?=$rc_id?>&arrange=<?=$arrange?>&mode=add">
		<img src="../images/icon_regist.gif" border="0">
		</a>
	</td>
	</tr>
</table>

<table width="100%" bordercolor="#e7e7e7" bgcolor="#e7e7e7">
	<tr bordercolor="#e7e7e7">
		<td width="100%" height="24" bgcolor="#e7e7e7" class="style2" scope="col" align="center">
		<a href="javascript:win_close();"><img src="../images/icon_close.gif" border="0"></a>
		</td>
	</tr>
</table>
</form>
</body>
</html>
