<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/styles/lib/bootstrap.min.css'/>" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="<c:url value='/styles/lib/font-awesome.min.css'/>" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href='<c:url value='/styles/lib/ionicons.min.css' />' rel="stylesheet" type="text/css" />
<!-- DATA TABLES -->
<link href="<c:url value='/styles/lib/datatables/dataTables.bootstrap.css' />" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="<c:url value='/styles/AdminLTE.css'/>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="${ctx }/styles/notification/commentList.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/scripts/layer/skin/layer.css" />

<script type="text/javascript" src="${ctx }/scripts/lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="${ctx }/scripts/layer/layer.js"></script>
<script type="text/javascript" src="${ctx }/scripts/layer/commonNew.js"></script>
<script type="text/javascript" src="<c:url value='/scripts/loading/jquery.blockUI.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/loading/loading.js'/>"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
	function fn(selector,container){
	    $(selector).click(function(){
	        var stats = $(this).prop('checked') || false;
	        $(container).each(function(idx,item){
	            $(item).prop('checked',stats);
	        });
	    });
	    
	    $(container).click(function(){
	     var chklen = $(container).filter(function(idx,el){
		     if($(el).prop('checked')){
		    	 return el;
		     }
	     }).length;
		var chkStats = $(container).length === chklen;
	 		$(selector).prop('checked',chkStats);
	    });
	};
	fn("#checkAll","input[name='chkBtn']");
	
	$(".btn_pass").click(function(){
		var contextPath =$("#contextPath").val();
		if($("#dataareaid input:checked[name='chkBtn']").length < 1){
			alert('请选全部通过的数据！');
			return;
		}
		var dataAreaIds="";
		for(var i=0;i<$("#dataareaid input:checked[name='chkBtn']").length;i++){
			dataAreaIds+=$("#dataareaid input:checked[name='chkBtn']")[i].value+";";
		}
		operateFunc(dataAreaIds,"1");
	});
	
	$(".btn_pass_no").click(function(){
		var contextPath =$("#contextPath").val();
		if($("#dataareaid input:checked[name='chkBtn']").length < 1){
			alert('请选不通过的数据！');
			return;
		}
		var dataAreaIds="";
		for(var i=0;i<$("#dataareaid input:checked[name='chkBtn']").length;i++){
			dataAreaIds+=$("#dataareaid input:checked[name='chkBtn']")[i].value+";";
		}
		operateFunc(dataAreaIds,"2");
	});
});

function goPage(pageNo){
	showBlock();
	if(pageNo=="gopage"){
		$("#pageNo").val($("#gopage").val());
	}else{
		$("#pageNo").val(pageNo);
	}
	$("#conditionform").submit();
}

function operateFunc(id,flag){
	var authorizeFlag=false;
	
	if(flag=="2"){
// 		if(confirm("确定不通过?")){
			authorizeFlag=true;
// 		}	
	}
	else{
		/* if(confirm("确定通过?")){
			authorizeFlag=true;
		} */
		var contextPath=$("#contextPath").val();
		layer.prompt({
			  formType: 2,
			  value: ' ',
			  title: '填写回复内容，并确认通过！或不填写回复内容，直接通过！',
			  area: ['400px', '250px'] //自定义文本域宽高
			}, function(value, index, elem){
				if(null != value && value != '' && value.length > 400){
		  			layer.alert("回复内容不能大于400字符");
		  			return;
		  		}
				$.ajax({
					url :contextPath+"/info/commentOperate",
					type : "POST",
					data:{
						id:id,
						flag:1,
						replyContent:$.trim(value)
					},
					success : function(data) {
						if(data=="success"){
							alert("处理成功");
						}
						$("#conditionform").submit();
						hideBlock();
					},
					error : function(data) {
//						layer.alert("系统繁忙,请稍后再试");
					}
				});

			  layer.close(index);
			});
	}
	if(authorizeFlag){
		var contextPath=$("#contextPath").val();
		layer.prompt({
			  formType: 2,
			  value: ' ',
			  title: '填写回复内容，并确认不通过！或不填写回复内容，直接不通过！',
			  area: ['400px', '250px'] //自定义文本域宽高
			}, function(value, index, elem){
				if(null != value && value != '' && value.length > 400){
		  			layer.alert("回复内容不能大于400字符");
		  			return;
		  		}
				$.ajax({
					url :contextPath+"/info/commentOperate",
					type : "POST",
					data:{
						id:id,
						flag:flag,
						replyContent:$.trim(value)
					},
					success : function(data) {
						if(data=="success"){
							alert("处理成功");
						}
						$("#conditionform").submit();
						hideBlock();
					},
					error : function(data) {
//						alert("系统繁忙,请稍后再试");
					}
				});

			  layer.close(index);
			});
	}
}

//删除
function deleteFunc(id,status,type){
	var contextPath=$("#contextPath").val();
	$.ajax({
		type:'POST',
		url :contextPath+"/info/deleteFunc",
		data:{"status":status,"id":id,"type":type},
		dataType: 'json',//返回值类型 一般设置为json
		success: function (data)  //服务器成功响应处理函数
		{
			alert(data.msg);
			if(data.code == '0'){
				$("#conditionform").submit();
				hideBlock();
			}
		}
	});
}
</script>
<body>
	<input type="hidden" value="${ctx}" id="contextPath">
	<div class="outDiv ">
		<nav class="navbar navbar-default" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<c:if test="${type=='1' }">
					<a class="navbar-brand" href="${ctx}/announcement/list?funcid=${funcid}">< 留言数(${page.totalCount}条)</a>
				</c:if>
				<c:if test="${type=='2' }">
					<a class="navbar-brand" href="${ctx}/activity/list?funcid=${funcid}">< 留言数(${page.totalCount}条)</a>
				</c:if>
			</div>
			<form action="${ctx}/info/commentManage/${type}&${infoId}&${status}&${funcid}" method="POST" id="conditionform">
				<input type="hidden" name="pageNo" value="${pageNo }" id="pageNo">
				<input type="hidden" name="funcid" value="${funcid }">
				<ul class="nav navbar-nav">
					<c:choose>
					<c:when test="${status=='0' }">
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&&${funcid}" class="nav_a">全部</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&0&${funcid}" class="active">待审核</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&1&${funcid}" class="nav_a">已通过</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&2&${funcid}" class="nav_a">未通过</a></li>
					</c:when>
					<c:when test="${status=='1' }">
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&&${funcid}" class="nav_a">全部</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&0&${funcid}" class="nav_a">待审核</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&1&${funcid}" class="active">已通过</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&2&${funcid}" class="nav_a">未通过</a></li>
					</c:when>
					<c:when test="${status=='2' }">
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&&${funcid}" class="nav_a">全部</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&0&${funcid}" class="nav_a">待审核</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&1&${funcid}" class="nav_a">已通过</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&2&${funcid}" class="active">未通过</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&&${funcid}" class="active">全部</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&0&${funcid}" class="nav_a">待审核</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&1&${funcid}" class="nav_a">已通过</a></li>
					<li><a href="${ctx}/info/commentManage/${type}&${infoId}&2&${funcid}" class="nav_a">未通过</a></li>
					</c:otherwise>
					</c:choose>
				</ul>
			</form>
		</div>
		</nav>
		<hr style="FILTER: alpha(opacity = 100, finishopacity = 0, style = 3)"
			color=#c8c8c8 SIZE=1 />
		<div style="float: right;">
			<button class="btn_pass">全部通过</button>
			<button class="btn_pass_no">不通过</button>
		</div>
		<div class="table_title">
			<label class="table_title_head">${model.title }</label>
		</div>
		<div class="tableList">
			<table class="table table-bordered table-hover" id="dataareaid">
				<thead>
					<tr style="background: #f8f8f8;">
						<th><input type="checkbox" id="checkAll" class="checkbox_type"></th>
						<th class="table_center">用户名</th>
						<th class="table_center">留言时间</th>
						<th class="table_center">留言内容</th>
						<th class="table_center">回复内容</th>
						<th class="table_center">回复时间</th>
						<th class="table_center">审核操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${page.items}" var="model" varStatus="status">
						<tr>
							<td>
							<c:if test="${model.status=='0' }">
							<input type="checkbox" name="chkBtn" class="checkbox_type" value="${model.id }" />
							</c:if>
							</td>
							<td class="table_center">${model.userName }</td>
							<td class="table_center">${model.createTime}</td>
							<td class="table_center">${model.content }</td>
							<td class="table_center">${model.replyContent }</td>
							<td class="table_center">${model.replyTime }</td>
							<td class="table_center">
							<c:choose>
								<c:when test="${model.status=='0'}">
									<a href="javascript:operateFunc('${model.id}','1');" title="">
                              			<span style="text-decoration:underline">回复</span>
                              		</a>
                              		<a href="javascript:operateFunc('${model.id}','2');" title="">
                              			<span style="text-decoration:underline">不通过</span>
                              		</a>
								</c:when>
								<c:when test="${model.status=='1'}">
								<a href="javascript:void(0);" title="" style="color:gray;">
                              			<span>已通过</span>
                              		</a>
								</c:when>
								<c:when test="${model.status=='2'}">
								<a href="javascript:void(0);" title="" style="color:gray;">
                              			<span>未通过</span>
                              		</a>
								</c:when>
							</c:choose>
							<a href="javascript:deleteFunc('${model.id}','0','${type}');" title="" style="color:gray;">
                              	<span style="text-decoration:underline">删除</span>
                            </a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div class="btn-page">
				<!-- 页码 -->
				<div align="center" class="pages clearfix">
					<c:forEach items="${page.iterPages }" var="pageNo">
						<c:choose>
							<c:when test="${pageNo == page.currentPage }">
								<span class='current'>${pageNo }</span>
							</c:when>
							<c:when test="${pageNo != null}">
								<a href="javascript:void(0);" onclick='goPage(${pageNo});'>${pageNo}</a>
							</c:when>
							<c:otherwise>
								<em>...</em>
							</c:otherwise>
						</c:choose>
					</c:forEach>
					<strong>共<span
						style="color: black; font-weight: bold; font-size: 16px;">${page.totalCount}</span>条
					</strong> <strong>跳转到第</strong><input type="text" id="gopage"
						style="width: 40px;"
						onkeyup="this.value=this.value.replace(/\D/g,'')"
						onkeypress="this.value=this.value.replace(/\D/g,'')" /><strong>页</strong>
					<a class="btn-sm btn-success" href="javascript:goPage('gopage');"
						id='bindBtn'>确定</a>
				</div>
			</div>
		</div>
	</div>
</body>
</html>