<%@ 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/work/bizGbnMan.json" />';
var url_view ='<c:url value="/bap/admin/work/bizGbnMan.view" />';

var index;

function detail(url, key) {
	$.ajax({
		type : "POST",
		url : url,
		dataType : "json",
		data : {
			cmd : 'LIST_PROP',
			bjobBzwkDstcd : key
		},
		success : function(json) {
			var data = json.prop;
			$("#grid_detail")[0].addJSONData(data);
		},
		error : function(e) {
			alert(e.responseText);
		}
	});
}
$(document).ready(function() {	
    var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: url,
		postData : gridPostData,
		colNames:[	'업무구분코드',
	            	'업무구분명'
	            	],
		colModel:[
				{ name : 'BJOBBZWKDSTCD'     , align:'left'	,sortable:false  },
				{ name : 'BJOBBZWKNAME'      , align:'left'  }
				],
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${param.rowNum}' != '' ? '${param.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 bjobBzwkDstcd = rowData['BJOBBZWKDSTCD'];
            index = rowId;
            detail(url, bjobBzwkDstcd);
        }		
	});
    
	resizeJqGridWidth('grid','title','1000');
    
	$('#grid_detail').jqGrid({
		datatype:"local",
		loadonce: true,
		rowNum: 10000,
		colNames:[	'프라퍼티명',
		            '프라퍼티설명',
		            '프라퍼티유형'
		            ],
		colModel:[
					{ name : 'PRPTYNAME'  		, align:'left'	, width:60 ,sortable:false  },
					{ name : 'PRPTYDESC'  		, align:'left'  , width:150},
					{ name : 'PRPTYTYPDSTCD'  	, align:'center'  , width:30 ,
				          formatter: function (cellvalue) {
				              if ( cellvalue == 'O' ) {
				                  return '기관';
                              } else if (cellvalue == 'F') {
                                  return '파일';
                              } else {
                                  return cellvalue;
                              }
                          },
				          unformat: function (cellvalue) {
				              if ( cellvalue == '기관' ) {
				                  return 'O';
                              } else if (cellvalue == '파일') {
                                  return 'F';
                              } else {
                                  return cellvalue;
                              }
                          }
				 }						
		],
		jsonReader : {
			repeatitems : false
		},
		loadComplete : function() {
		},
        onSortCol : function() {
        	return 'stop';	//정렬 방지
        },        
		//height : '500',
		autowidth : true,
		autoheight : true,
		height: $("#container").height(),
		viewrecords : true
	});

	resizeJqGridWidth('grid_detail', 'title', '1000');
	
	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$("#grid").setGridParam({ postData: postData ,page : "1"  }).trigger("reloadGrid");
	});
	$("#btn_input").click(function(){
		var data = $("#grid").getRowData(index)['BJOBBZWKDSTCD'];
		window.returnValue = data;
	    window.close();
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	$("#btn_close").click(function(){
		var data = "${param.key}";
		window.returnValue = data;
		window.close();
	});
	
	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="title">
				<div class="search_wrap">
					<img src="<c:url value="/img/btn_input.png"/>" alt="" id="btn_input" level="W" />
					<img src="<c:url value="/img/btn_search.png"/>" alt="" id="btn_search" level="R" />
					<img src="<c:url value="/img/btn_close.png"/>" alt="" id="btn_close" level="R" />
				</div>
				<div class="title">전문 프로퍼티 목록</div>
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:100px;">업무구분코드</th>
							<td><input type="text" name="searchbjobBzwkDstcd" value="${param.searchbjobBzwkDstcd}"></td>
							<th style="width:100px;">업무구분명</th>
							<td><input type="text" name="searchbjobBzwkName" value="${param.searchbjobBzwkName}"></td>
						</tr>
					</tbody>
				</table>
				<table id="grid" ></table>
				<div id="pager"></div>
				<div class="title" style="margin-top:15px; text-align:left;">전문 프로퍼티 상세</div>
				<table id="grid_detail" ></table>				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

