<%@ 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" >

 $(document).ready(function() {	
	
	// 일괄전송전문관리 모든 TAB의 조회조건을 특정 업무구분코드로 동기화한다. 
	<% String sessionAttr = (String)session.getAttribute("searchbjobBzwkPrcssDstcd"); %>
	var sessionAttr = "<%= sessionAttr %>";
	if (sessionAttr != "null" && sessionAttr != "") {
		$("input[name=searchbjobBzwkPrcssDstcd]").val(sessionAttr); 
	}  
	 
	var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: '<c:url value="/bap/admin/message/flowRuleMan.json" />',
		postData : gridPostData,
		colNames:['BATCH작업 업무처리구분코드',
                  '흐름규칙유형설명',
                  ],
		colModel:[		
				{ name : 'BJOBBZWKPRCSSDSTCD'  	, align:'left'		,sortable:false  },
				{ name : 'FLOWRULEPTRNDESC'     , align:'center'	 }	
				],
        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)		
			}
		
		},			
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId); 
            var key = rowData['BJOBBZWKPRCSSDSTCD'];
            var url = '<c:url value="/bap/admin/message/flowRuleMan.view" />';
            url = url + '?cmd=DETAIL';
            url = url + '&page='+$(this).getGridParam("page");
            url = url + '&returnUrl='+getReturnUrl();
            url = url + '&menuId='+'${param.menuId}';
			//검색값
            url = url + '&'+getSearchUrl();
            //key값
            url = url + '&key='+key;
            goNav(url);
        }      
	});
	
	resizeJqGridWidth('grid','content_middle','1000');

	$("#btn_search").click(function(){

/* 	   	var url = '<c:url value="/bap/admin/message/flowRuleMan.json" />';
		var postData = $('#ajaxForm').serializeArray();
		postData.push({
			name : "cmd",
			value : "LIST_SESSION"
		});
		postData.push({
			name : "searchbjobBzwkPrcssDstcd",
			value : $("input[name=searchbjobBzwkPrcssDstcd]").val()
		});
		
		$.ajax({
			type : "POST",
			url:url,
			data:postData,
			success:function(args){
			},
			error:function(e){
				alert(e.responseText);
			}
		}); */
		
	    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/message/flowRuleMan.view"/>';
		url = url + '?cmd=DETAIL';
		url = url + '&page='+$("#grid").getGridParam("page");
		url = url + '&returnUrl='+getReturnUrl();
        url = url + '&menuId='+'${param.menuId}';
		//검색값
        url = url + '&'+getSearchUrl();
		
        goNav(url);
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	$("#btn_session").click(function(){
		
		var url = '<c:url value="/bap/admin/message/flowRuleMan.json" />';
		var postData = $('#ajaxForm').serializeArray();
		postData.push({
			name : "cmd",
			value : "LIST_SESSION"
		});
		postData.push({
			name : "searchbjobBzwkPrcssDstcd",
			value : $("input[name=searchbjobBzwkPrcssDstcd]").val()
		});
		
		$.ajax({
			type : "POST",
			url:url,
			data:postData,
			success:function(args){
			},
			error:function(e){
				alert(e.responseText);
			}
		});
/* 		$("#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">
					<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">메시지메타 정보를 등록 관리합니다</span></div>
				
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:50px;">BATCH작업 업무처리구분코드</th>
							<td style="width:150px;">
							<input type="text" name="searchbjobBzwkPrcssDstcd" value="${param.searchbjobBzwkPrcssDstcd}" />
							<%-- <input type="text" name="searchbjobBzwkPrcssDstcd" value="${param.searchbjobBzwkPrcssDstcd}" style="display:inline-block; width:calc(100% - 70px);">
							<img id="btn_session" src="<c:url value="/img/btn_pop_select.png" />" level="R" class="btn_img"/> --%>
							</td>
							<th style="width:50px;">흐름규칙 유형 설명</th>
							<td style="width:150px;"><input type="text" name="searchflowRulePtrnDesc" value="${param.searchflowRulePtrnDesc}"></td>
						</tr>
					</tbody>
				</table>
				<table id="grid" ></table>
				<div id="pager"></div>	
				
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>