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

$(document).ready(function() {
	$("input[name=searchStartYYYYMMDD],input[name=searchEndYYYYMMDD]").inputmask({
		mask: "9999-99-99",
	    inputFormat: "yyyy-mm-dd",
	    autoUnmask: true
	});
	$("input[name=searchStartHHMM],input[name=searchEndHHMM]").inputmask({
	    mask: "99:99:99",
	    placeholder: "HH:MM:ss",
	    autoUnmask: true
	});
	
	$("input[name=searchStartYYYYMMDD],input[name=searchEndYYYYMMDD]").each(function(){
		if ($(this).val() == undefined || $(this).val() == null || $(this).val() == "" || $(this).val() == "yyyymmdd"){
			$(this).val(getToday());
		}
	});
	$("input[name=searchStartHHMM]").each(function(){
		if ($(this).val() == undefined || $(this).val() == null || $(this).val() == "" || $(this).val() == "HHMMss"){
			$(this).val(getStartTime());
		}
	});
	$("input[name=searchEndHHMM]").each(function(){
		if ($(this).val() == undefined || $(this).val() == null || $(this).val() == "" || $(this).val() == "HHMMss"){
			$(this).val(getEndTime());
		}
	});
	
	var gridPostData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
	gridPostData['searchStartDateTime'] = $("input[name=searchStartYYYYMMDD]").val() + $("input[name=searchStartHHMM]").val();
	gridPostData['searchEndDateTime'] = $("input[name=searchEndYYYYMMDD]").val() + $("input[name=searchEndHHMM]").val();
	$('#grid').jqGrid({
		datatype:"json",
		mtype: 'POST',
		url: '<c:url value="/common/acl/audit/auditLogMan.json" />',
		postData : gridPostData,
		colNames : [ '<%= localeMessage.getString("auditLogMan.logSeqNo") %>',
			'<%= localeMessage.getString("auditLogMan.logamndHMS") %>',
			'<%= localeMessage.getString("auditLogMan.userId") %>',
			'<%= localeMessage.getString("auditLogMan.systemCode") %>',
			'<%= localeMessage.getString("auditLogMan.logTypeText") %>',
			'<%= localeMessage.getString("auditLogMan.command") %>',
			'<%= localeMessage.getString("auditLogMan.remoteAddress") %>',
			'<%= localeMessage.getString("auditLogMan.parameters") %>' ],
		colModel:[
				{ name : 'id'   , 	align:'left'	, width:80},
				{ name : 'LOGAMNDHMS' , 	align:'left', width:80},
				{ name : 'USERID'    , 		align:'left', width:50},
				{ name : 'systemCode'    , 		align:'left', width:50},
				{ name : 'LOGTYPETEXT', 	align:'left'  },
				{ name : 'command' , 		align:'left', width:50  },
				{ name : 'REMOTEADDRESS', 	align:'left', width:80},
				{ name : 'PARAMETERS' , 	align:'left', hidden:true }
				], 
        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){
				
		},		
		ondblClickRow: function(logSeqNo) {
			var rowData = $(this).getRowData(logSeqNo); 
            var logSeqNo = rowData['id'];
            var url = '<c:url value="/common/acl/audit/auditLogMan.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 + '&logSeqNo='+logSeqNo;
            goNav(url);
            
        }		
	});
	
	
	resizeJqGridWidth('grid','content_middle','1000');

	$("#btn_search").click(function(){
		var postData = getSearchForJqgrid("cmd","LIST"); //jqgrid에서는 object 로 
		postData['searchStartDateTime'] = $("input[name=searchStartYYYYMMDD]").val() + $("input[name=searchStartHHMM]").val();
		postData['searchEndDateTime'] = $("input[name=searchEndYYYYMMDD]").val() + $("input[name=searchEndHHMM]").val();
		$("#grid").setGridParam({ postData: postData ,page : "1" }).trigger("reloadGrid");

	});

	$("input[name^=search]").keydown(function(key){
		if (key.keyCode == 13){
			$("#btn_search").click();
		}
	});
	
	buttonControl();
	
});
function getStartTime(){
	return "000000";
}

function getEndTime(){
	var now = new Date();
	now.setSeconds(now.getSeconds()+50)
	var tm = right("0" + now.getHours(), 2);
	tm += right("0" + now.getMinutes(), 2);
	tm += right("0" + now.getSeconds(), 2)
	return tm;
}
</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_search.png"/>" alt="" id="btn_search" level="R" />	
				</div>
				<div class="title"><%= localeMessage.getString("auditLogMan.title") %></div>
				
				<table class="search_condition" cellspacing=0;>
					<tbody>
						<tr>
							<th style="width:180px;"><%= localeMessage.getString("auditLogMan.logamndHMS") %></th>
							<td>
								<input type="text" name="searchStartYYYYMMDD" value="" size="10" style="width:100px; border:1px solid #ebebec;">
								<input type="text" name="searchStartHHMM" value="" size="8" style="width:100px; border:1px solid #ebebec;">
								~
								<input type="text" name="searchEndYYYYMMDD" value="" size="10" style="width:100px; border:1px solid #ebebec;">
								<input type="text" name="searchEndHHMM" value="" size="8" style="width:100px; border:1px solid #ebebec;">
								<input type="hidden" name="searchStartDateTime" />
								<input type="hidden" name="searchEndDateTime" />
							</td>
							<th style="width:180px;"><%= localeMessage.getString("auditLogMan.userId") %></th>
							<td><input type="text" name="searchUserId" name="searchUserId" value="${param.searchUserId}" style="width:100%"></td>
							
							<th style="width:180px;"><%= localeMessage.getString("auditLogMan.systemCode") %></th>
							<td><div class = "select-style">
								<select id="searchSystemCode" name="searchSystemCode">
									<option value=""><%= localeMessage.getString("combo.all")%></option>
									<c:forEach items="${serviceTypeCombos }" var="serviceTypeCombo">
										<option value="${serviceTypeCombo.code }">${serviceTypeCombo.codename }</option>
									</c:forEach>
								</select>
								</div>
							</td>
						</tr>
						<tr>

							<th style="width:180px;"><%= localeMessage.getString("auditLogMan.logTypeText") %></th>
							<td>
								<input type="text" value="" name="searchLogTypeText" checked="checked"/>
							</td>
							<th style="width:180px;"><%= localeMessage.getString("auditLogMan.remoteAddress") %></th>
							<td><input type="text" name="searchRemoteAddress" value="${param.searchRemoteAddress}" style="width:100%"></td>
							<th style="width:180px;"></th>
							<td>
							</td>
						</tr>
					</tbody>
				</table>
				
				<table id="grid" ></table>
				<div id="pager"></div>
				
			</div><!-- end content_middle -->
		</div><!-- end right_box -->				
	</body>	
</html>

