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

	//$suid = $HTTP_COOKIE_VARS[SUID];
	$suid = $_COOKIE[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'];

?>
<html>
<head>
<title>서비스 관리</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();

function deleteService(rc_id, service_name, tran_id)
{
	frm = document.list;
	
	frm.prcid.value = rc_id;
	frm.pname.value = service_name;
	frm.ptranid.value = tran_id;
	
	msg = "서비스 " + service_name+ " 를 정말 삭제 하시겠습니까?"
	if (confirm(msg))
	{
		frm.method="POST"
		frm.action="./rc_service_del_proc.html";
		frm.submit();
	}
	else
		return;
}

</SCRIPT>
</head>

<body>
<form name="list">
<input type="hidden" name="prcid">
<input type="hidden" name="pname">
<input type="hidden" name="ptranid">
<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" 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";
				continue;
				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;
		}
	if ($ptype != "RCDB"  || strstr($pname, "DBLB") == FALSE || $pmonitor_yn !='Y')
	    continue;
	$dblbip = $pip;
	$dblbport = $pport;
?>
	<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>
	</tr>
	<tr>
		<td colspan="6" height="1" bgcolor="E1E1E1"></td>
	</tr>
	<tr>
		<td colspan="6" height="5"></td>
	</tr>

<?php
	}
}
$objConn->close();
?>
</table>
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" class="ContentTable">
	<tr>
		<td bgcolor="#F6F5F2"><b>서버스명</b></td>
		<td bgcolor="#F6F5F2" width="20%"><b>관리</b></td>
	</tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ContentTable">
<?
	    if(empty($dblbip) || empty($dblbport) )
	    {
	        echo " <script>alert('Error(Get RCDB)');";
	        echo " history.go(-1);";
	        echo " </script>";
	        exit();
	    }  

    	$objpsql = new DB_Sql2;
    	
		$objpsql->Host = $dblbip;
		$objpsql->Port = $dblbport;
		$objpsql->Database = "localdb";
    	
    	$sql = "SELECT * FROM t_sms_sp_svc_product;";
    	$objpsql->query( $sql );
    	if( $objpsql->nf() != 0 )
        {
            while( $objpsql->next_record() )
        	{
        	    $userseq = $objpsql->f("sp_user_seq");
				$tranid = $objpsql->f("sp_svc_tran_id");				
				$svcid = $objpsql->f("sp_svc_id");
        	    //echo "$userseq, $tranid, $svcid</br>";
?>
	<tr align="center">
		<td bgcolor="#FFFFFF"><?=$svcid?></td>
		<td bgcolor="#FFFFFF" width="20%" style="padding-right:<?=$default_right_padding?>">
		<a href="javascript:deleteService('<?=$rc_id?>','<?=$svcid?>', '<?=$tranid?>')"><img src="../images/icon_delete.gif" border="0"></a>
		</td>
    </tr>
	<tr>
		<td colspan="2" height="1" bgcolor="E1E1E1"></td>
	</tr>
<?
        	}
        }
        $objpsql->close();
	
?>
</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:self.close();"><img src="../images/icon_close.gif" border="0"></a>
		</td>
	</tr>
</table>
</form>
</body>
</html>
