<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ 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/common/unifbwkMan.json" />';
var url_view = '<c:url value="/onl/admin/common/unifbwkMan.view" />';
var url_excel = '<c:url value="/onl/admin/common/unifbwkMan.excel" />';

var selectName = "searchInputDstCd,searchDiscardYn";	//

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

function dateFormater(cellvalue, options, rowObject){
	if (cellvalue==null|| cellvalue==undefined) return "";
	if (cellvalue.trim().length < 8) return "";
	var display = "";
	display=display+cellvalue.substr(0,4)+"/";
	display=display+cellvalue.substr(4,2)+"/";
	display=display+cellvalue.substr(6,2);
	return display;
}	

$(document).ready(function() {	
	
	init();	
	
    var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: url,
		postData : gridPostData,
		colNames:['<%= localeMessage.getString("eaiMsg.bizCode") %>',
                  '<%= localeMessage.getString("unifbwk.search3") %>',
                  '<%= localeMessage.getString("unifbwk.applCd") %>',
                  '<%= localeMessage.getString("unifbwk.description") %>',
                  '<%= localeMessage.getString("unifbwk.trackAsisKey1") %>',
                  '<%= localeMessage.getString("unifbwk.trackAsisKey2") %>',
                  '<%= localeMessage.getString("unifbwk.rsempName") %>',
                  '<%= localeMessage.getString("unifbwk.rspblpsncntpctnt") %>',
                  '<%= localeMessage.getString("unifbwk.groupCoCd") %>', 
                  '<%= localeMessage.getString("unifbwk.lastModDtm") %>',
                  '<%= localeMessage.getString("unifbwk.discardDate") %>',
                  '<%= localeMessage.getString("unifbwk.inputdstcd") %>'
                  
                  ],
		colModel:[
				{ name : 'EAIBZWKDSTCD'      , align:'center'	,sortable:false ,width:50},
				{ name : 'BZWKDSTICNAME'     , align:'left'   },
				{ name : 'APPLCD'     		 , align:'center'   ,width:50 },
				{ name : 'BZWKDSTICDESC'     , align:'left'  , width:200 },
				{ name : 'TRACKASISKEY1NAME' , align:'left'  , width:80 },
				{ name : 'TRACKASISKEY2NAME' , align:'left'  , width:80 },
				{ name : 'RSEMPNAME'  		 , align:'center', width:50 },
				{ name : 'RSPBLPSNCNTPCTNT'  , align:'left'  , width:80 },
				{ name : 'GROUPCOCD'  		 , align:'center', width:50 },
				{ name : 'LAST_MOD_DTM' 	 , align:'center', width:100 },	
				{ name : 'DISCARDDATE'  	 , align:'center', width:50 , formatter: dateFormater},
				{ name : 'INPUTDSTCD'  		 , align:'center', width:50 }
				],
        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['EAIBZWKDSTCD'];
            var url2 = url_view;
            url2 += '?cmd=DETAIL';
            url2 += '&page='+$(this).getGridParam("page");
            url2 += '&returnUrl='+getReturnUrl();
            url2 += '&menuId='+'${param.menuId}';
			//검색값
            url2 += '&'+getSearchUrl();
            //key값
            url2 += '&eaiBzwkDstcd='+key;
            goNav(url2);
        },loadError: function (jqXHR, textStatus, errorThrown) {
        	
        	var location ='<%=request.getContextPath()%>/';
        	comloadError(jqXHR, textStatus, errorThrown ,location);
        	
    	}
	});
	
	
	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 url2 = url_view;
		url2 += '?cmd=DETAIL';
		url2 += '&page='+$("#grid").getGridParam("page");
		url2 += '&returnUrl='+getReturnUrl();
        url2 += '&menuId='+'${param.menuId}';
		//검색값
        url2 += '&'+getSearchUrl();

        goNav(url2);
	});
	
	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	$("#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"),'업무그룹관리'); 
		return false;
	});
	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("unifbwk.title") %><span class="tooltip"><%= localeMessage.getString("unifbwk.tooltip") %></span></div>
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:100px;"><%= localeMessage.getString("eaiMsg.bizCode") %></th>
							<td>
								<input type="text" name="searchEaiBzwkDstcd" value="${param.searchEaiBzwkDstcd}">
							</td>
							<th style="width:110px;"><%= localeMessage.getString("unifbwk.search2") %></th>
							<td>
								<input type="text" name="searchApplCd" value="${param.searchApplCd}">
							</td>
							<th style="width:100px;"><%= localeMessage.getString("unifbwk.search3") %></th>
							<td>
								<input type="text" name="searchBzwkDsticName" value="${param.searchBzwkDsticName}">
							</td>
						</tr>
						<tr>
							<th><%= localeMessage.getString("unifbwk.inputdstcd") %></th>
							<td><div class="select-style">	
									<select name="searchInputDstCd" value="${param.searchInputDstCd}"> 
									</select>
								</div></td>
							<th><%= localeMessage.getString("unifbwk.search4") %></th>
							<td>
								<div class="select-style">	
									<select name="searchDiscardYn" value="${param.searchDiscardYn}"> 
									</select>
								</div>
							</td>
							<th></th>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table id="grid" ></table>
				<div id="pager"></div>				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

