<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>

<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<hejin:header title="登录日志管理 "></hejin:header>
		<!-- 图片上传样式 -->
		<link rel="stylesheet" type="text/css" href="static/css/bootstrap/jquery.fileupload-ui.css">
		<style type="text/css">
			.span {
				position: absolute;
				left: 50%;
				top: 50%;
				margin-top: 5px;
			}
		</style>
	</head>
	<body>
		<!-- 菜单 -->
		<jsp:include page="../../menu.jsp"/>
		<!-- BEGIN 面包屑 -->
		<div class="container-fluid">
			<ol class="breadcrumb"><!-- BEGIN 面包屑 -->
				<li><a href="javascript:void(0);">系统管理</a></li>
				<li><a href="system/logUser/logUserIndex.do">登录日志</a></li>
			</ol>
		</div>
		<!-- END 面包屑 -->
		<!-- BEGIN 条件 -->
		<div class="container-fluid">
			<div class="row">
				<div class="col-sm-1">
  					<span class="span">登录名称</span>
				</div>
				<div class="col-sm-2">
					<div class="form-group">
 						<input type="text" class="form-control" id="f_loginName" name="f_loginName" placeholder="请输入登录名称">
 					</div>
				</div>
				<div class="col-sm-1">
  					<span class="span">用户名称</span>
				</div>
				<div class="col-sm-2">
					<div class="form-group">
 						<input type="text" class="form-control" name="f_userName" id="f_userName" placeholder="请输入用户名称">
 					</div>
				</div>
<%--				<div class="col-sm-1">
  					<span class="span">来源</span>
				</div>
				<div class="col-sm-2">
					<div class="form-group">
 						<select class="form-control" name="f_loginPlat" id="f_loginPlat">
 							<option value="">请选择</option>
 							<option value="manager">manager</option>
 							<option value="fuwu">fuwu</option>
 							<option value="development">development</option>
 							<option value="local_test">local_test</option>
 							<option value="other">other</option>
 						</select>
 					</div>
				</div>--%>
				
				<div class="col-sm-2">
					<div class="form-group">
                        <a class="btn btn-block btn-primary btn-query" id="searchBtn" data-target="#compose-modal"><i class="fa fa-pencil"></i>查询</a>
 					</div>
				</div>
				<div class="col-sm-1"></div>
			</div>
		</div>
		<!-- END 条件 -->
		<!-- BEGIN Tables -->
		<div class="container-fluid">
			<div class="row"><!-- BEGIN row-fluid -->
				<div class="col-sm-12"><!-- BEGIN col-sm-12 -->
					<div class="box">
                        <div class="box-header">
                        	<h3 class="box-title">登录日志列表</h3>
                        </div><!-- /.box-header -->
						<div class="box-body table-responsive">
                             <table class="table table-bordered table-striped" id="table_log_user">
				            	<thead>
				                	<tr>
				                    	<th>用户名称</th>
				                        <th>登录名称</th>
				                        <th>IP地址</th>
				                        <th>Host地址</th>
				                       	<th>登录时间</th>
				                       	<th>状态</th>
		<%--		                       	<th>来源</th>--%>
				                       	<th>备注</th>
				                    </tr>
				                </thead>
				                <tbody>
				                </tbody>
				             </table>
			             </div>
		             </div>
             	</div><!-- END col-sm-12 -->
            </div><!-- END row-fluid -->
		</div>
		<!-- END Tables -->
		
		<hejin:commonScript></hejin:commonScript>
	    <script type="text/javascript">
		    Date.prototype.format = function(format)
		    {
			     var o = {
			     "M+" : this.getMonth()+1, //month
			     "d+" : this.getDate(),    //day
			     "h+" : this.getHours(),   //hour
			     "m+" : this.getMinutes(), //minute
			     "s+" : this.getSeconds(), //second
			     "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
			     "S" : this.getMilliseconds() //millisecond
			     }
			     if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
			     (this.getFullYear()+"").substr(4 - RegExp.$1.length));
			     for(var k in o)if(new RegExp("("+ k +")").test(format))
			     format = format.replace(RegExp.$1,
			     RegExp.$1.length==1 ? o[k] :
			     ("00"+ o[k]).substr((""+ o[k]).length));
			     return format;
		    }	
	    
		    $(function(){
				// datatable load data
				var tables = $('#table_log_user').platformDataTable({
					"bSort":false,
					//数据源     返回数据必须封装aaData
					"sAjaxSource" : 'system/logUser/loadLogUserList.do?'+ new Date().getTime(),
					"aoColumns" : [ //列
					    {"sClass" : "center", "mDataProp" : "userName"},
						{"sClass" : "center", "mDataProp" : "loginName"},
						{"sClass" : "center", "mDataProp" : "loginIp"},
						{"sClass" : "center", "mDataProp" : "loginHost"},
						{"sClass" : "center",
							 "mDataProp" : "loginTime",
							 "bSearchable" : false,
							 "fnRender" : function(obj) {
								 	var curTime = new Date(obj.aData.loginTime);
									return curTime.format("yyyy-MM-dd hh:mm:ss");
								}
						},
						{"sClass" : "center",
							 "mDataProp" : "loginStatus",
							 "bSearchable" : false,
							 "fnRender" : function(obj) {
								 	if(obj.aData.loginStatus == "10") return "登录失败";
								 	else if(obj.aData.loginStatus == "20") return "登录";
								 	else if(obj.aData.loginStatus == "40") return "强制注销";
									return "注销";
								}
						},
					/*	{"sClass" : "center", "mDataProp" : "loginPlat"},*/
						{"sClass" : "center", "mDataProp" : "logDesc"}
					]
				});
				
				// 查询事件
	            $('#searchBtn').click(function(){
	            	var loginName = $('#f_loginName').val();
	        		var userName = $('#f_userName').val();
	        		var loginPlat = $('#f_loginPlat').val();

	        		if((loginName==null || loginName.trim()=="") && (userName==null || userName.trim()=="") && (loginPlat==null || loginPlat.trim()=="") ){
                        $(".modal-body").html("请填写至少一项查询条件！");
                        $("#myModal").modal("show");
                        return false;
					}

	            	var data=[];//存放json类型的查询条件，可以放多个
	            	data.push({ "name": "loginName", "value": loginName});
	            	data.push({ "name": "userName", "value": userName});
	            	data.push({ "name": "loginPlat", "value": loginPlat});
	            	//Ajax重新load控件数据
	            	drawTable(tables,data);
					tables.fnPageChange(0);
	            });
		    });

			function redirect(){
				if($('#page').val() && $('#page').val()>=0){
					var tables = $('#table_log_user').dataTable();
					var oSettings = tables.fnSettings();
					var maxPage = oSettings.fnRecordsTotal() % oSettings._iDisplayLength == 0?
					oSettings.fnRecordsTotal() / oSettings._iDisplayLength :
					Math.floor(oSettings.fnRecordsTotal() / oSettings._iDisplayLength)+ 1;
					if($('#page').val() == 0){
						$('#page').val(1);
					}
					if($('#page').val() > maxPage){
						$('#page').val(maxPage);
					}
					var redirectpage = $('#page').val() - 1;
					tables.fnPageChange(redirectpage);
				}else{
					return;
				}
			}

			function onlyNum(){
				$('#page').val($("#page").val().replace(/\D/g, ''));
			}
    	</script>



		<!-- 模态提示框 -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title" id="myModalLabel">
							温馨提示：
						</h4>
					</div>
					<div class="modal-body">

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-submit" data-dismiss="modal">确定</button>
						<!-- 					<button type="button" class="btn btn-default btn-cancel" data-dismiss="modal">取消</button> -->
					</div>
				</div>
			</div>
		</div>

	</body>
</html>