<%@ 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/jmsQueueMan.json" />';
var url_view = '<c:url value="/onl/admin/service/jmsQueueMan.view" />';
var url_excel= '<c:url value="/onl/admin/service/jmsQueueMan.excel" />';

var select_UseYn = new Array();
var select_SendReceiveSts = new Array();

function init(callback){
	$.ajax({
		type : "POST",
		url:url,
		dataType:"json",
		data:{cmd: 'LIST_INIT_COMBO'},
		success:function(json){
			new makeOptions("CODE","NAME").setObj($("select[name=searchQueuseyn]")).setNoValueInclude(true)
			.setNoValue('','<%=localeMessage.getString("combo.all")%>').setFormat(codeName3OptionFormat).setData(json.useYnRows).rendering();
			
			select_UseYn['value'] = ": ;"+getGridSelectText("CODE","NAME",json.useYnRows);
			select_SendReceiveSts['value'] = ": ;"+getGridSelectText("CODE","NAME",json.sendReceiveStsRows);
			if (typeof callback === 'function') {
				callback();
			}
		},
		error:function(e){
			alert(e.responseText);
		}
	});
}
function gridRendering() {
	var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: url,
		postData : gridPostData,
		colNames:['<%=localeMessage.getString("jmsQueue.nonsyncztranquename")%>',
                  '<%=localeMessage.getString("jmsQueue.sevrinstncname")%>',
                  '<%=localeMessage.getString("jmsQueue.quebzwkctnt")%>',
                  '<%=localeMessage.getString("jmsQueue.queuseynname")%>',
                  '<%=localeMessage.getString("jmsQueue.queusagdstname")%>',
                  '<%=localeMessage.getString("jmsQueue.bzwkdstcd")%>',
                  '<%=localeMessage.getString("jmsQueue.quebzwkdtalsctnt")%>'
                  ],
		colModel:[
				{ name : 'NONSYNCZTRANQUENAME'	, align:'left'	 , sortable:false  },
				{ name : 'SEVRINSTNCNAME'		, align:'center' , width:'100px'},
				{ name : 'QUEBZWKCTNT'			, align:'left'   , },
				{ name : 'QUEUSEYN'				, align:'center' , width:'80px', edittype:'select',editoptions : select_UseYn, formatter:"select"},
				{ name : 'QUEUSAGDSTCD'			, align:'center' , width:'80px', edittype:'select',editoptions : select_SendReceiveSts, formatter:"select"},
				{ name : 'BZWKDSTCD'			, align:'center' , width:'50px'	},
				{ name : 'QUEBZWKDTALSCTNT'		, align:'left'   , }
				],
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
 		autowidth: true,
		viewrecords: true,
		rowList : eval('[${rmsDefaultRowList}]'),
		gridComplete:function (d){
			var colModel = $(this).getGridParam("colModel");
			for(var i = 0 ; i< colModel.length; i++){
				$(this).setColProp(colModel[i].name, {sortable : false});	//그리드 헤더 화살표 삭제(정렬X)		
			}
		
		},			
		loadComplete:function (d){
		},
        loadError: function (jqXHR, textStatus, errorThrown) {
        	
        	var location ='<%=request.getContextPath()%>/';
        	comloadError(jqXHR, textStatus, errorThrown ,location);
        	
    	},		
		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 += '&'+getSearchUrl();
            //key값
            url2 += '&nonSynczTranQueName='+rowData['NONSYNCZTRANQUENAME'];
            url2 += '&sevrInstncName='+rowData['SEVRINSTNCNAME'];
            goNav(url2);
        }		
	});
	
	
	resizeJqGridWidth('grid','content_middle','1000');
}

$(document).ready(function() {	
	init(gridRendering);
	$("#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)
		gridToExcelSubmit2(url_excel,"LIST_GRID_TO_EXCEL",$("#grid"),$("#ajaxForm"),'<%=localeMessage.getString("jmsQueue.title")%>');
		return false;
	});
	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로
		$("#grid").setGridParam({ postData: postData ,page : "1" }).trigger("reloadGrid");
	});
	$("#btn_new").click(function(){
		var url2 = url_view;
		url2 += '?cmd=DETAIL';
		url2 += '&page='+$("#grid").getGridParam("page");
		url2 += '&returnUrl='+getReturnUrl();
        url2 += '&menuId='+'${param.menuId}';
		//검색값
		url2 += '&'+getSearchUrl();
		
        goNav(url2);
	});
	//검색값  enter시  조회
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});

	
	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">
					<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_new" level="W"><i class="material-icons">add</i> <%= localeMessage.getString("button.new") %></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_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"><%=localeMessage.getString("jmsQueue.title")%><span class="tooltip">비동기 거래를 위해 사용되는 큐를 관리하는 화면입니다</span></div>
				<form id="ajaxForm"  onsubmit="return false;">
					<table class="search_condition" cellspacing=0;>
						<tbody>
							<tr>
								<th style="width:10%; min-width:100px;"><%=localeMessage.getString("jmsQueue.nonsyncztranquename")%></th>
								<td>
									<input type="text" name="searchNonSynczTranQueName" value="${param.searchNonSynczTranQueName}">
								</td>
								<th style="width:10%; min-width:100px;"><%=localeMessage.getString("jmsQueue.bzwkdstcd")%></th>
								<td>
									<input type="text" name="searchBzwkdstcd" value="${param.searchBzwkdstcd}">
								</td>
								<th style="width:10%; min-width:100px;"><%=localeMessage.getString("jmsQueue.sevrinstncname")%></th>
								<td>
									<input type="text" name="searchSevrinstncname" value="${param.searchSevrinstncname}">
								</td>							
							</tr>
							<tr>
								<th><%=localeMessage.getString("jmsQueue.quebzwkdtalsctnt")%></th>
								<td colspan=3>
									<input type="text" name="searchQuebzwkdtalsctnt" value="${param.searchQuebzwkdtalsctnt}">
								</td>
								<th><%=localeMessage.getString("jmsQueue.queuseynname")%></th>
								<td>
									<div class="select-style"><select name="searchQueuseyn" value="${param.searchQueuseyn}"></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>

