
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");

%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
	var url      = '<c:url value="/onl/admin/service/resourceConnMan.json" />';
	var url_view = '<c:url value="/onl/admin/service/resourceConnMan.view" />';
	var url_excel= '<c:url value="/onl/admin/service/resourceConnMan.excel" />';
	var svrInst = new Array();
	function init(callback){
		$.ajax({  
			type : "POST",
			url:url,
			dataType:"json",
			data:{cmd: 'LIST_INIT'},
			success:function(json){
				svrInst = json.listInoutType;
			},
			error:function(e){
				alert(e.responseText);
			}
		});
	}
	function svrFormatter (cellvalue, options, rowObject){
		if(cellvalue!=null && cellvalue.trim()!=""){
			for(var i=0; i<svrInst.length; i++){
				if(cellvalue==svrInst[i].CODE){
					return svrInst[i].NAME;
				}
			}
		}else{
			return "";
		}
	}
	function typeFormatter (cellvalue, options, rowObject){
		if(cellvalue=="S"){
			return "요청";
		}else if(cellvalue=="R"){
			return "응답";
		}else if(cellvalue=="E"){
			return "에러";
		}else if(cellvalue==null){
			return "";
		}else if(cellvalue.trim()!=""){
			return "";
		}
	}
	$(document).ready(function() {	
		init();
		var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$('#grid').jqGrid({
			datatype:"json",
			mtype: 'POST',
			//url: url,
			//postData : gridPostData,
			colNames:[
					  '<%=localeMessage.getString("resConnMan.eaiSvcCd")%>',
	                  '<%=localeMessage.getString("resConnMan.serClaCd")%>',
					  '<%=localeMessage.getString("resConnMan.pat")%>',
	                  '<%=localeMessage.getString("resConnMan.chgNm")%>',
	                  '<%=localeMessage.getString("resConnMan.chgTp")%>',
					  '<%=localeMessage.getString("resConnMan.serClaCd")%>',
	                  '<%=localeMessage.getString("resConnMan.layNm")%>',
	                  '<%=localeMessage.getString("resConnMan.serClaCd")%>',
	                  '<%=localeMessage.getString("resConnMan.layNm")%>',
	                  '<%=localeMessage.getString("resConnMan.serClaCd")%>'
	                  ],
			colModel:[
					{ name : 'EAISVCNAME'	, align:'center'	,width : 150},
					{ name : 'IFSVRDSTCD'	, align:'center'	,width : 80		,formatter : svrFormatter },
					{ name : 'PATTERN'		, align:'center'	,width : 100},
					{ name : 'TRNAME'		, align:'center'	,width : 200},
					{ name : 'TYPE'			, align:'center'	,width : 80		,formatter : typeFormatter },
					{ name : 'TRSVRDSTCD'	, align:'center'	,width : 80		,formatter : svrFormatter },
					{ name : 'SRCLOUTNAME'	, align:'center'	,width : 180},
					{ name : 'SRCSVRDSTCD'	, align:'center'	,width : 80		,formatter : svrFormatter },
					{ name : 'TGTLOUTNAME'	, align:'center'	,width : 180},
					{ name : 'TGTSVRDSTCD'	, align:'center'	,width : 80		,formatter : svrFormatter }
					],
	        jsonReader: {
	             repeatitems:false
	        },	          
			pager : $('#pager'),
			page : '${param.page}',
			rowNum :  10000,
		    autoheight: true,
		    height: $("#container").height(),
			autowidth: true,
			viewrecords: true,
			gridview: true,
			rowList : eval('[${rmsDefaultRowList}]'),
			loadComplete:function (d){
				var colModel = $(this).getGridParam("colModel");
				for(var i = 0 ; i< colModel.length; i++){
					$(this).setColProp(colModel[i].name, {sortable : false});			
				}
	
			},
	        loadError: function (jqXHR, textStatus, errorThrown) {

	        	var location ='<%=request.getContextPath()%>/';
	        	comloadError(jqXHR, textStatus, errorThrown ,location);
	        	
	    	},			
			ondblClickRow: function(rowId) {
	        },
	        loadBeforeSend : function (xhr,settings){
				if(this.p.url ==null || this.p.url == ""){
					this.p.loadBeforeSend = null;
					return false;
				}
			}		
		});
		$("#grid").jqGrid('setGroupHeaders', {
	  		useColSpanStyle: true, 
	  		 groupHeaders:[
	 			{startColumnName: 'EAISVCNAME', numberOfColumns: 3, titleText: '<%=localeMessage.getString("resConnMan.if")%>'},
	 			{startColumnName: 'TRNAME', numberOfColumns: 3 , titleText: '<%=localeMessage.getString("resConnMan.chg")%>'},
	 			{startColumnName: 'SRCLOUTNAME', numberOfColumns: 2, titleText: '<%=localeMessage.getString("resConnMan.souLay")%>'},
	 			{startColumnName: 'TGTLOUTNAME', numberOfColumns: 2, titleText: '<%=localeMessage.getString("resConnMan.tarLay")%>'}
	   		]
		});
		
		resizeJqGridWidth('grid','content_middle','1000');
		$("#btn_excel").click(function(event) {
	        event.stopPropagation(); // Do not propagate the event.
	        // Create an object that will manage to download the file.
	        var target = "excelDown" ; // iframe의 name
	        //(url,cmd,gridObj,formObject,fileName,merge)
			gridToExcelSubmit(url_excel,"LIST_GRID_TO_EXCEL",$("#grid"),$("#ajaxForm"),'자원연결정보');
			return false;
		});
		$("#btn_search").click(function(){
			var rName = $("input[name=searchResourceName]").val();
			if(rName.trim().length==0){
				alert("자원명을 입력 해 주세요");
				return;
			}
			var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
			$("#grid").setGridParam({ url:url,postData: postData ,page:1 }).trigger("reloadGrid");
		});
		$("input[name^=search]").keydown(function(key){
			if (key.keyCode == 13){
				$("#btn_search").click();
			}
		});
		
		buttonControl();
		//detail();
	});
 
</script>
</head>
	<body>		
		<div class="right_box">
			<div class="content_top">
				<ul class="path">
					<li><a href="#">${rmsMenuPath}</a></li>					
				</ul>					
			</div><!-- end content_top -->
			<div class="content_middle" id="content_middle">
				<div class="search_wrap">
					<button type="button" class="cssbtn" id="btn_excel" level="W"><i class="material-icons">table_view</i> <%= localeMessage.getString("button.excel") %></button>
					<button type="button" class="cssbtn" id="btn_search" level="R"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
<%-- 					<img src="<c:url value="/img/btn_excel.png"/>" id="btn_excel" level="W"/> --%>
<%-- 					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" />	 --%>
				</div>
				<div class="title"><%=localeMessage.getString("resConnMan.title")%></div>
				<form id="ajaxForm"  onsubmit="return false;">
					<table class="search_condition" cellspacing=0;>
						<tbody>
							<tr>
								<th style="width:100px;"><%=localeMessage.getString("resConnMan.resTp")%></th>
								<td>
									<input type="radio" name="searchType" value="eaiSvcName" checked> <%=localeMessage.getString("resConnMan.eaiSvcCd")%>
									<input type="radio" name="searchType" value="transform"> <%=localeMessage.getString("resConnMan.chg")%>
									<input type="radio" name="searchType" value="layout"> <%=localeMessage.getString("resConnMan.lay")%>
								</td>
								<th style="width:100px;"><%=localeMessage.getString("resConnMan.resNm")%></th>
								<td>
									<input type="text" name="searchResourceName" value="${param.searchResourceName}"/>
								</td>
							</tr>
						</tbody>
					</table>
				</form>
				<table id="grid" ></table>
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

