<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	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="/bap/admin/common/comErrMessageMan.json" />';
var urlView = '<c:url value="/bap/admin/common/comErrMessageMan.view" />';

$(document).ready(function() {	
    var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
    var svrDstcd = ("${param.searchSvrDstcd}"=="")?"BAP":"${param.searchSvrDstcd}";
    gridPostData['searchSvrDstcd'] = svrDstcd;
	$("#svrDst").val(svrDstcd);
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: '<c:url value="/bap/admin/common/comErrMessageMan.json" />',
		postData : gridPostData,
		colNames:['오류메시지 코드',
                  '오류메시지'
                  ],
		colModel:[
				{ name : 'MSG'    , align:'left' ,width:50 ,sortable:false  },
				{ name : 'MSGCTNT'  , align:'left'  }
				],
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		rowList : eval('[${rmsDefaultRowList}]'),
		loadComplete:function (d){
			 var data = d.rows;
			if(svrDstcd=="BAT"){
				for(var i=0; i<data.length; i++){
					$(this).jqGrid('setCell',i+1,'MSG',data[i]['MSGID']);
				}
			} 
		},
		gridComplete:function (d){
			var colModel = $(this).getGridParam("colModel");
			for(var i = 0 ; i< colModel.length; i++){
				$(this).setColProp(colModel[i].name, {sortable : true});	//그리드 헤더 화살표 삭제(정렬X)		
			}
		},		
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId); 
            var msgId = rowData['MSG'];
            var url = '<c:url value="/bap/admin/common/comErrMessageMan.view" />';
            url = url + '?cmd=DETAIL';
            url = url + '&page='+$(this).getGridParam("page");
            url = url + '&returnUrl='+getReturnUrl();
            url = url + '&menuId='+'${param.menuId}';
            url = url + '&searchSvrDstcd='+$("#svrDst").val();
			//검색값
            url = url + '&'+getSearchUrl();
            //key값
            url = url + '&msg='+msgId;
            goNav(url);
        }      
	});
	
	
	resizeJqGridWidth('grid','content_middle','1000');

	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$("#grid").setGridParam({ postData: postData ,page : "1" }).trigger("reloadGrid");
	});
	$("#btn_new").click(function(){
		var url = '<c:url value="/bap/admin/common/comErrMessageMan.view"/>';
		url = url + '?cmd=DETAIL';
		url = url + '&page='+$("#grid").getGridParam("page");
		url = url + '&returnUrl='+getReturnUrl();
        url = url + '&menuId='+'${param.menuId}';
        url = url + '&searchSvrDstcd='+$("#svrDst").val();
		//검색값
        url = url + '&'+getSearchUrl();

        goNav(url);
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	$("#svrDst").change(function(){
		var postData = getSearchForJqgrid("cmd","LIST");
		postData['searchSvrDstcd']= $(this).val();
		svrDstcd = $(this).val();
		$("#grid").setGridParam({postData: postData ,page : "1" }).trigger("reloadGrid");
	});
	
	buttonControl();
	
});
 
</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">
					<img src="<c:url value="/img/btn_new.png"/>" alt="" id="btn_new" level="W" />
					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" />		
				</div>
				<div class="title">오류메시지 관리<span class="tooltip">표준화된 IF시스템 에러 응답코드를 조회합니다. 메시지 키 및 내용으로 그에 해당하는 오류메시지를 조회할 수 있습니다.</span></div>
				<div class="select-style" style="display : inline-block;">
					<!-- <select id="svrDst" name="searchSvrDstcd" style="width: 60px ; height: 25px; margin: 0px 0px 4px 0px;">
						<option value="BAP">&nbsp;&nbsp;일괄</option>
 						<option value="BAT">&nbsp;&nbsp;배치</option>
					</select> -->
				</div>
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:180px;">오류메시지 코드</th>
							<td>
								<input type="text" name="searchMsg" value="${param.searchMsg}">
							</td>
							<th style="width:180px;">오류메시지 내용</th>
							<td>
								<input type="text" name="searchDesc" value="${param.searchDesc}">
							</td>
						</tr>
					</tbody>
				</table>
				<table id="grid" ></table>
				<div id="pager"></div>				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

