<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="ct" tagdir="/WEB-INF/tags" %>
<script type="text/javaScript" defer="defer">
	<!--
	
	$(document).ready(function(){
		$("#sdate").datepicker({
			dateFormat: 'yy-mm-dd',
			onSelect: function(date){
				$("#sdate").val(date);
			}
		});
		$("#edate").datepicker({
			dateFormat: 'yy-mm-dd',
			onSelect: function(date){
				$("#edate").val(date);
			}
		});
		
		$('.order img').attr('src', (document.searchForm.order.value == '1') ? '/images/cmmn/order_desc.gif' : '/images/cmmn/order_asc.gif');
		$('.order').click(function(){
			if (document.searchForm.order.value == 1) {
				document.searchForm.order.value = 0;
			} else {
				document.searchForm.order.value = 1;
			}
			fn_searchList();
		});
		
		$("#name").keypress(function(e){
			if (e.keyCode == 13){
				fn_searchList();
			}
		});
	});
	
	/* 글 목록 화면 function */
    function fn_searchList() {
    	document.searchForm.pageIndex.value = 1;
       	document.searchForm.action = "<c:url value='/admin/userLogStatistics.do'/>";
       	document.searchForm.submit();
    }
	
	/* 검색초기화 function */
    function fn_selectList() {
       	location.href = "/admin/userLogStatistics.do";
    }
	
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/admin/userLogStatistics.do'/>";
		document.searchForm.submit();
	}
	//-->
</script>
<form:form commandName="logSearchVO" name="searchForm" method="get">
<div class="search2">
	<ul>
		<li><b>검색타입</b> 　</li>
		<li class="form_radio">
			<form:radiobutton path="type" value="0"/>이용메뉴 현황
			<form:radiobutton path="type" value="1"/>로그인 현황
	 	</li>
	</ul>
	<ul class="mt-20">
	 	<li><b>기간</b> 　</li>
	 	<li class="margin-left">
	 		<form:input path="sdate" readonly="true"/> ~ <form:input path="edate" readonly="true"/>
	 	</li>	 
	 	<li class="margin-left"><b>이름</b> 　</li>
	 	<li class="margin-left">
	 		<form:input path="name"/>
	 	</li>
		<li>
			<span class="btn_blue"> 
				<a href="javascript:fn_searchList();"><spring:message code="button.goSearch" /></a>
			</span>
		</li>
		<li>
			<span class="btn_gray"> 
				 <a href="javascript:fn_selectList();"><spring:message code="button.initSearch" /></a>
			</span>
		</li>
	</ul>	       	       
</div>
<form:hidden path="pageIndex" />
<form:hidden path="order" />
</form:form>
<form:form name="listForm" method="get">
		<input type="hidden" name="userid" />
       	<!-- List -->
		<div id="table">
			<div class="pageinfo">
				<ct:pageInfo />
			</div>
			<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0">
			<colgroup>
	   			<col width="50"/>
	   			<col width="183"/>
	   			<col width="300"/>
	   			<col width=""/>
	   			<col width="125"/>
	   			<col width="176"/>
		    </colgroup>	  
				<c:choose>
					<c:when test="${logSearchVO.type == 1}">
						<thead>
							<tr>
								<th align="center"><spring:message code="log.view.rnum" /></th>
								<th align="center"><spring:message code="log.view.user" /></th>
								<th align="center"><spring:message code="log.view.loginout" /></th>
								<th align="center">
									<span class="order">
										<spring:message code="log.view.regdate" />
										<img src="/images/cmmn/blank_1x1.png"/>
									</span>
								</th>
							</tr>
						</thead>
						<c:forEach var="result" items="${resultList}" varStatus="status">
							<tr>
								<td align="center" class="listtd"><c:out value="${result.rnum}" /></td>
								<td align="center" class="listtd"><c:out value="${result.position}" /> <c:out value="${result.name}" />(<c:out value="${result.userid}"/>)</td>
								<td align="center" class="listtd">
									<c:choose>
										<c:when test="${result.type == '1'}">로그인</c:when>
										<c:when test="${result.type == '2'}">로그아웃</c:when>
									</c:choose>
								</td>
								<td align="center" class="listtd"><c:out value="${result.regdate}" /></td>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<thead>
							<tr>
								<th align="center"><spring:message code="log.view.rnum" /></th>
								<th align="center"><spring:message code="log.view.user" /></th>
								<th align="center"><spring:message code="log.view.menu" /></th>
								<th align="center"><spring:message code="log.view.page" /></th>
								<th align="center"><spring:message code="log.view.ip" /></th>
								<th align="center">
									<span class="order">
										<spring:message code="log.view.regdate" />
										<img src="/images/cmmn/blank_1x1.png"/>
									</span>
								</th>
							</tr>
						</thead>
						<c:forEach var="result" items="${resultList}" varStatus="status">
							<tr>
								<td align="center"><c:out value="${result.rnum}" /></td>
								<td align="center"><c:out value="${result.position}" /> <c:out value="${result.name}" />(<c:out value="${result.userid}"/>)</td>
								<td align="left"><c:out value="${result.location1}" /></td>
								<td align="left"><c:out value="${result.location3}" /></td>
								<td align="center"><c:out value="${result.ip}" /></td>
								<td align="center"><c:out value="${result.regdate}" /></td>
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
			</table>
		</div>
		<!-- /List -->
		<div id="paging">
			<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
		</div>
</form:form>