<%@ 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" %>
<%@ page import="com.eactive.eai.rms.common.login.SessionManager"%>
<%@ page import="com.eactive.eai.common.util.SystemUtil"%>
<%@ page import="com.eactive.eai.rms.common.context.MonitoringContext"%>
<%@ page import="com.eactive.eai.rms.common.util.CommonUtil"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");

	MonitoringContext monitoringContext = (MonitoringContext)CommonUtil.getBean(request, "monitoringContext");
	String deployYnStr = monitoringContext.getStringProperty(MonitoringContext.IOMAP_DEPLOY_YN_BY_RMS, "N");
	boolean deployYn = "Y".equalsIgnoreCase(deployYnStr);
%>
<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/adapter/adapterAuditMan.json" />';
var url_view ='<c:url value="/onl/admin/adapter/adapterAuditMan.view" />';
var url_excel='<c:url value="/onl/admin/adapter/adapterAuditMan.excel"/>';
var roleString	= "<%=SessionManager.getRoleIdString(request)%>";
var devSvr		= <%=SystemUtil.isDevServer()%>;
var stageSvr	= <%=SystemUtil.isStagingServer()%>;
var selectName = "searchEaiBzwkDstcd";

var select_useYn = new Array();
var select_adptrMsgPtrnCdRows = new Array();
var select_testMasterYnRows = new Array();

function init(callback) {
	return $.ajax({  
		type : "POST",
		url:url,
		dataType:"json",
		data:{cmd: 'LIST_SEARCH_INIT_COMBO'},
		success:function(json){
			new makeOptions("CODE","NAME").setObj($("select[name=searchEaiBzwkDstcd]")).setNoValueInclude(true).setNoValue("", "<%=localeMessage.getString("combo.all")%>").setData(json.bzwkCodeRows).setFormat(codeName3OptionFormat).rendering();
			
			setSearchable(selectName);
			putSelectFromParam();
			
			if (typeof callback === 'function') {
				callback();
			}
		},
		error:function(e){
			alert(e.responseText);
		}
	});
}

function list(_page)
{   
	var page = "${param.page}";
	if(_page) page = _page;
	var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	
	postData["sortName"] ='${param.sortName}';
    postData["sortOrder"]="${param.sortOrder}";
	$("#grid").setGridParam({ url:url, postData: postData ,sortName:'${param.sortName}', sortOrder:"${param.sortOrder}",page : page }).trigger("reloadGrid");
}

$(document).ready(function() {
	
	init().done(function(result) {
		jqGridInit();
	});

	$("#btn_search").click(function(){
		list("1");
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});

	buttonControl();

});

function jqGridInit() {
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		colNames:['변경번호',
		          '변경일자',
		          /* '타입', */
		          '작업자ID',
		          '<%= localeMessage.getString("adapter.adptrBzwkGroupName")%>',
                  '<%= localeMessage.getString("adapter.adptrBzwkGroupDesc")%>',
                  '<%= localeMessage.getString("adapter.adptrIoDstCd")%>',
                  '<%= localeMessage.getString("adapter.adptrMsgpTrnCdType")%>',
                  '<%= localeMessage.getString("adapter.eaiBzwkDstCd")%>',
<%--                   '<%= localeMessage.getString("adapter.adptrCd")%>', --%>
                  '<%= localeMessage.getString("adapter.adptrMsgDstCd")%>',
                  '<%= localeMessage.getString("adapter.adptrUseYn")%>',
<%--                   '<%= localeMessage.getString("adapter.kesauseyn")%>', --%>
<%--                   '<%= localeMessage.getString("adapter.testmasteryn")%>', --%>
                  '<%= localeMessage.getString("adapter.adptrnickname")%>'
<%--                   '<%= localeMessage.getString("adapterDetail.eaisevrdstcd")%>', --%>
<%--                   '<%= localeMessage.getString("adapterDetail.dradptryn")%>' --%>
                  ],
		colModel:[
				{ name : 'revNo'              , align:'left'   ,width:80},
				{ name : 'revTstmp'           , align:'left'   ,width:140},
				{ name : 'revUserId'          , align:'left'   ,width:80},
				{ name : 'adptrbzwkgroupname' , align:'left'   ,width:120},
				{ name : 'adptrbzwkgroupdesc' , align:'left'   ,width:250 },
				{ name : 'adptriodstcd'       , align:'center'  ,width:100, edittype:'select',editoptions:{value : "I:INBOUND;O:OUTBOUND"}, formatter:"select"},
				{ name : 'adptrmsgptrncd'     , align:'center'  ,width:70, edittype:'select' , editoptions:{value : "K:표준;N:비표준;B:은행표준"}, formatter:"select"},
				{ name : 'eaibzwkdstcd'       , align:'center'  ,width:70},
// 				{ name : 'ADPTRCD'            , align:'center'  ,width:70},
				{ name : 'adptrmsgdstcd'      , align:'center'  ,width:70},
				{ name : 'adptruseyn'         , align:'center'  ,width:80, edittype:'select', editoptions:{value : "0:사용안함;1:사용"}, formatter:"select"},
// 				{ name : 'KESAUSEYN'          , align:'center'  ,width:100},
//				{ name : 'testmasteryn'       , align:'center'  ,width:100, edittype:'select', editoptions:select_testMasterYnRows, formatter:"select"},
				{ name : 'adptrnickname'      , align:'center'  ,width:100},
// 				{ name : 'EAISEVRDSTCD'       , align:'center'  ,width:80 ,formatter : formatter},
// 				{ name : 'DRADPTRYN'          , align:'center'  ,width:100}
				], 
				
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		multiselect: false,
		multiboxonly: false,		
		sortname : '${param.sortName}',
		sortorder : '${param.sortOrder}',
		rowList : eval('[${rmsDefaultRowList}]'),
		loadComplete:function (d){
			//$(this).setGridParam({datatype:'local'});
		},
        loadError: function (jqXHR, textStatus, errorThrown) {
        	if(jqXHR.status == 401) {
	    		alert('HTTP status code: ' + jqXHR.status + '\n' +
	                    '에러:  세션이 종료되었습니다. ');
	    		parent.location.href='<%=request.getContextPath()%>/';	
	    	}
        	
    	}, 
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId); 
            var url2 = url_view;
            url2 += '?cmd=DETAIL';
            url2 += '&page='+$(this).getGridParam("page");
            url2 += '&returnUrl='+getReturnUrl();
            url2 += '&menuId='+'${param.menuId}';
        	url2 += '&sortName='+$("#grid").getGridParam("sortname");
        	url2 += '&sortOrder='+$("#grid").getGridParam("sortorder");            
			//검색값
            url2 += '&'+getSearchUrl();
            
            //key값
            url2 += '&adptrBzwkGroupName='+encodeURIComponent(rowData['adptrbzwkgroupname']);
            url2 += '&revNo='+encodeURIComponent(rowData['revNo']);
            goNav(url2);
            
        },
        onSortCol :function(sidx,colnum,sort_order){
          	var gridPostData = getSearchForJqgrid("cmd","LIST");
          	var sortorder="";
          	if( sort_order == "") 
          		sortorder ='asc';
          	else
          		sortorder = sort_order;
          	gridPostData["sortName"] =sidx;
        	gridPostData["sortOrder"]=sortorder;
        	$("#grid").setGridParam({ url:url, postData: gridPostData, sortname:sidx, sortorder:sortorder, page:"1"}).trigger("reloadGrid");	 
        	 
        	
        }
            		
	});
	
	resizeJqGridWidth('grid','content_middle','1000');
	
	list();
}

</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_search" level="R" ><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>						
				</div>
				<div class="title"><%= localeMessage.getString("adapter.title")%>(변경이력)</div>
				<form id = "ajaxForm">
					<table class="search_condition" cellspacing=0;>
						<tbody>
							<tr>
								<th width="13%"><%= localeMessage.getString("adapter.adptrBzwkGroupName")%></th>
								<td width="20%"> <input type="text" name="searchAdptrBzwkGroupName" value="${param.searchAdptrBzwkGroupName}"></td>
								<th width="13%"><%= localeMessage.getString("adapter.adptrBzwkGroupDesc")%></th>
								<td width="20%"><input type="text" name="searchAdptrBzwkGroupDesc" value="${param.searchAdptrBzwkGroupDesc}"></td>
								<th><%= localeMessage.getString("adapterDetail.eaibzwkdstcd")%></th>
								<td>
									<div class="select-style">
										<select name="searchEaiBzwkDstcd" value="${param.searchEaiBzwkDstcd}">
										</select>
									</div>	
								</td>
							</tr>
						</tbody>
					</table>
				</form>
				<table id="grid" ></table>
				<div id="pager"></div>
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

