<%@ page language="java" contentType="text/html;charset=UTF-8" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>直播管理</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<link rel="stylesheet" href="<%=request.getContextPath() %>/js/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="<%=request.getContextPath() %>/js/bootstrap/css/bootstrap-theme.min.css">
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/js/jquery/jquery-1.11.2.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/js/jquery/Jquery.Query.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/js/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/js/jquery.twbsPagination/jquery.twbsPagination.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/js/layer/layer.js"> </script>
</head>
<body>
<br/>
<div class="container-fluid">
	<form cssClass="form-horizontal" action="<%=request.getContextPath() %>/live/listContent.do" method="get">
	<div class="panel panel-default">
		<div class="panel-heading">
			直播管理
		</div>
		<div class="panel-body">
			<div class="form-group-sm">
				<label class="control-label col-md-1">标题:</label>
				<div class="col-md-3">
					<input type="text" name="contentTitle" value="${param.contentTitle}" class="form-control" placeholder="">
				</div>
			</div>
		</div>
	</div>

<div class="form-group-sm text-center padding10" >
	<a href="<%=request.getContextPath()%>/live/preAddContent.do" class="btn btn-sm btn-info">添加</a>
	<button type="submit" class="btn btn-sm btn-success">查询</button>
	<button type="reset" class="btn btn-sm btn-default" id="reset">重置</button>
</div>

<div class="panel panel-default">
	<table class="table table-striped table-hover">
		<thead>
		<tr >
			<th  class="text-center order" data-field="name" data-order="asc,1" >
				标题
			</th>
			<th data-field="" class="text-center order">
				开始时间
			</th>
			<th data-field="" class="text-center order">
				结束时间
			</th>
			<th data-field="" class="text-center order">
				限制人数
			</th>
			<th data-field="" class="text-center order">
				视频时长
			</th>
			<th data-field="email" class="text-center order">
				操作
			</th>
		</tr>
		</thead>
		<tbody>
		<c:forEach var="item" items="${items.list}">
			<tr>
				<td class="text-center">${item.contentTitle}</td>
				<td class="text-center"><fmt:formatDate value="${item.startDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td class="text-center"><fmt:formatDate value="${item.endDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td class="text-center">${item.userCount}</td>
				<td class="text-center">${item.videoTime}</td>
				<td class="text-center">
					<button type="button" class="btn btn-sm btn-info" onclick="update(${item.contentId})">修改</button>
					<button type="button" class="btn btn-sm btn-danger" onclick="del(${item.contentId})">删除</button>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</div>

		<input type="hidden" id="pageval" name="page" class="form-control" value="${param.page==null?1:param.page}">
		<input type="hidden" name="limit" class="form-control" value="10">
		<div class="row" id="pageShow" style="text-align: center;">
			<nav id="pagination_box"><ul class="pagination" id="pagercontent"></ul></nav>
		</div>

</form>
</div>
<script>
	$('#pagercontent').twbsPagination({
		startPage: ${param.page==null?1:param.page},
		initiateStartPageClick: false,
		totalPages: ${items.totalCount}==0?1:Math.ceil(${items.totalCount}/10),
		onPageClick: function (event, page) {
		$('#pageval').val(page);
		$("form").submit();
	}
	});
	$("#reset").on("click",function(){
		window.location.href="listContent.do";
	})
	function del(id){
		$.ajax({
			type : "post",
			url : "<%=request.getContextPath() %>/live/deleteContent.do",
			data : {id:id},
			dataType : "json",
			success : function(json){
				window.location.reload();
			},
			error:function(e){
				console.log(e);
			}
		});
	}
	function update(id){
		window.location.href="<%=request.getContextPath() %>/live/preUpdateContent.do?id="+id;
	}
</script>
</body>
</html>
