<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ page import="com.eactive.eai.rms.common.login.SessionManager"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%@ page import="com.eactive.eai.common.util.SystemUtil"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setHeader("Expires", "0");

	request.setCharacterEncoding("UTF-8");

%>
<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/rule/standardLayoutHistoryMan.json"/>';
var url_view	= '<c:url value="/onl/admin/rule/standardLayoutHistoryMan.view"/>';
var roleString	= "<%=SessionManager.getRoleIdString(request)%>";
var devSvr		= <%=SystemUtil.isDevServer()%>;
var svrInst = new Array();


function timeFormatter (cellvalue, options, rowObject){
	const dateFormat = new Date(cellvalue);
	return dateFormat.toLocaleString();
}

function operationTypeFormatter (cellvalue, options, rowObject){
	switch(cellvalue){
		case 'NEW': return '<%= localeMessage.getString("standardLayoutHistory.operationDescNew") %>';
		case 'MODIFY': return '<%= localeMessage.getString("standardLayoutHistory.operationDescModify") %>';
		case 'DEPLOY': return '<%= localeMessage.getString("standardLayoutHistory.operationDescDeploy") %>';
		case 'DELETE': return '<%= localeMessage.getString("standardLayoutHistory.operationDescDelete") %>';
		default: return cellvalue;
	}
}

$(document).ready(function() {	
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: url,
		postData : { cmd : 'LIST'
			       , searchLoutName     	: $('input[name=searchLoutName]').val()
			       , searchLoutDesc     	: $('input[name=searchLoutDesc]').val()
		},
		colNames:[
			'NO',
			'<%= localeMessage.getString("standardLayout.layoutName") %>',
			'<%= localeMessage.getString("standardLayout.layoutDesc") %>',
			'<%= localeMessage.getString("standardLayoutHistory.operationType") %>',
			'<%= localeMessage.getString("standardLayoutHistory.operatorName") %>',
			'<%= localeMessage.getString("standardLayoutHistory.operationDatetime") %>'
		],
		colModel:[
			{ name: 'operationSeq', align: 'center', width: "15"  },
			{ name: 'layoutName', align: 'center', sortable: false },
			{ name: 'layoutDesc', align: 'left'  },
			{ name: 'operationType', align: 'center', width: "40", formatter: operationTypeFormatter  },
			{ name: 'operatorName', align: 'center', width: "40"  },
			{ name: 'operationDatetime', align: 'center', width: "60", formatter: timeFormatter}
		],
        jsonReader: {
             repeatitems:false
        },	          
		pager : $('#pager'),
		page : '${param.page}',
		rowNum : '${rmsDefaultRowNum}',
	    autoheight: true,
	    height: $("#container").height(),
		autowidth: true,
		viewrecords: true,
		multiselect: false,
		multiboxonly:false,
		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});			
			}
		},
		loadComplete:function (){
			var ids=$("#grid").jqGrid('getDataIDs');
			for(var i=0;i<ids.length;i++){
				var rowObject = $("#grid").getRowData(ids[i]);
				if(rowObject.FLAG=="X"){
					var cbs = $("tr#"+ids[i]+".jqgrow>td>input.cbox",$("#grid")[0]);
					cbs.attr("disabled","disabled");
				}
			}
		},	
		beforeSelectRow:function(rowId,e){
			var cbsdis = $("tr#"+rowId+".jqgrow>td>input.cbox:disabled",$("#grid")[0]);
			if(cbsdis.length === 0){
				return true;
			}else{
				return false;
			}
		},
		ondblClickRow: function(rowId) {
			var rowData = $(this).getRowData(rowId); 
            var operationSeq = rowData['operationSeq'];
            var url2 = url_view;
            url2 += '?cmd=DETAIL';
            url2 += '&page='+$(this).getGridParam("page");
            url2 += '&returnUrl='+getReturnUrl();
            url2 += '&menuId='+'${param.menuId}';
			//검색값
			url2 += '&' + getSearchUrl();
            //key값
            url2 += '&operationSeq='+operationSeq;
    		goNav(url2);
        },loadError: function (jqXHR, textStatus, errorThrown) {
        	
        	var location ='<%=request.getContextPath()%>/';
        	comloadError(jqXHR, textStatus, errorThrown ,location);
        	
    	},onSelectAll:function(rowId,status){
    		if(status){ 
    			var cbs = $("tr.jqgrow>td>input.cbox:disabled",$("grid")[0]);
    			cbs.removeAttr("checked");
	    		$("#grid")[0].p.selarrow = $("#grid").find("tr.jqgrow:has(td > input.cbox:checked)").map(function(){
	    			return this.id;
		    	}).get();
    		}else{
    			$("#grid")[0].p.selarrow = "";
    		}
    		
    	}
	});
	
	resizeJqGridWidth('grid','content_middle','1000');
	
	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		$("#grid").setGridParam({ postData: postData ,page : "1"  }).trigger("reloadGrid");

	});
});

function setBtnControl(roleString, condiVal, compoId)
{
	var strRole		= roleString;
	var strVal		= condiVal;
	var arrRoleID	= strRole.split(',');
	var arrVal		= strVal.split(',');
	var flag		= false;
	
	$(arrRoleID).each(function(i, role) {
		$(arrVal).each(function(j, val) {
			if (role == val) {
				flag = true;
				return false;
			}
		});
	});
	if(flag)
		$("#"+compoId).show();
	else
		$("#"+compoId).hide();
}

 
</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_search" level="R" ><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
				</div>
				<div class="title"><%= localeMessage.getString("standardLayoutHistory.title") %><span class="tooltip"><%= localeMessage.getString("standardLayoutHistory.toolbar") %></span></div>
				<!--
				<form id="ajaxForm"  onsubmit="return false;">
					<table class="search_condition" cellspacing=0;>
						<tbody>
							<tr>
								<th width="10%"><%=localeMessage.getString("layoutMan.layoutCd")%></th>
								<td width="25%">
									<input type="text" name="searchLoutName" value="${param.searchLoutName}">
								</td>
								<th width="10%"><%=localeMessage.getString("layoutMan.bzwkdstcd")%></th>
								<td width="25%">
									<input type="text" name="searchEaiBzwkDstcd" value="${param.searchEaiBzwkDstcd}">
								</td>
								<th width="10%"><%=localeMessage.getString("layoutMan.layoutDesc")%></th>
								<td width="20%">
									<input type="text" name="searchLoutDesc" value="${param.searchLoutDesc}">
								</td>
							</tr>
							<tr>
								<th><%=localeMessage.getString("layoutMan.sevrDstCd")%></th>
								<td>
									<div class="select-style">
										<select name="searchEaiSevrDstcd" value="${param.searchEaiSevrDstcd}"/>
									</div>
								</td>
								<th><%=localeMessage.getString("layoutMan.layoutTypeName")%></th>
								<td>
									<div class="select-style">
										<select name="searchLayoutTypeName" value="${param.searchLayoutTypeName}"/>
									</div>
								</td>
								<th><%=localeMessage.getString("combo.useYn")%></th>
								<td>
									<div class="select-style">
										<select name="searchUseYn" value="${param.searchUseYn}"/>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>
					-->
				<table id="grid"></table>
				<div id="pager"></div>			
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

