<%@ 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" />
<script type="text/javascript" src="${ctx }/scripts/lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<c:url value='/scripts/My97DatePicker/WdatePicker.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>
<style type="text/css">
	th{ text-align:center;}
	td{ text-align:center;vertical-align:middle;}
</style>
</head>
<script type="text/javascript">
function goPage(pageNo){
	showBlock();
	if(pageNo=="gopage"){
		$("#pageNo").val($("#gopage").val());
	}else{
		$("#pageNo").val(pageNo);
	}
	$("#conditionform").submit();
}

function dele(id){
	if(confirm("确定删除？")){
		window.location.href="delete/"+id+"&"+$("#funcid").val();
	}	
}

//置顶/取消置顶
function setTop(id,isTop){
	showBlock();
	var contextPath=$("#contextPath").val();
	$.ajax({
		url :contextPath+"/announcement/setTop",
		type : "GET",
		data : {id:id,isTop:isTop},
		dataType:"json",
		success : function(data) {
			hideBlock();
			if(data=="1"){
				alert("设置成功");
				$("#conditionform").submit();
			}
			else{
				alert("设置失败");
			}
		},
		error : function(data) {
			hideBlock();
			alert("服务异常，设置失败");
		}
	});
}

</script>
<body>
	<input type="hidden" value="${ctx}" id="contextPath">
	<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<div class="boxlist">
				<div class="box-body table-responsive">
					<form action="${ctx}/announcement/list?funcid=${funcid}" method="post" id="conditionform" >
						<input type="hidden" id="pageNo" name="pageNo" />
						<input type="hidden" id="funcid" name="funcid" value="${funcid}" />
						<div class="form-group">
							<label style="margin-bottom: 5px;">校区名称</label> 
							<select style="margin-bottom: 5px;" name="organizationId" id="organizationId" style="width: 200px;">
								<c:if test="${operateName=='admin' }">
									<option value="0">所有粉丝用户</option>
								</c:if>
								<c:forEach items="${organizationList }" var="obj">
									<c:choose>
										<c:when test="${obj.id==organizationId }">
										<option value="${obj.id }" selected="selected">${obj.name }</option>
										</c:when>
										<c:otherwise>
										<option value="${obj.id }">${obj.name }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</select>
							<label style="margin-bottom: 5px;">标题</label>
							<input style="margin-bottom: 5px;" type="text" name="title" value="${title}" placeholder="请输入标题" style="width: 200px;" />
							<br/>
							<label>通知类型</label> 
							<select name="type" style="width: 200px;">
								<option value="">请选择类型</option>
								<c:forEach items="${announcementTypeGroup }" var="obj">
									<c:choose>
										<c:when test="${obj.itemcode==type }">
										<option value="${obj.itemcode }" selected="selected">${obj.itemname }</option>
										</c:when>
										<c:otherwise>
										<option value="${obj.itemcode }">${obj.itemname }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</select>
							
							<label for="">创建时间</label>
	                            <input type="text" name="bgTime" id="bgTime" value="${bgTime }" 
										class="Wdate" onfocus="WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})"
										readonly="true" placeholder="请选择开始时间" style="width: 200px;" />
	                            <input type="text" name="endTime" id="endTime" value="${endTime }" 
										class="Wdate" onfocus="WdatePicker({startDate:'%y-%M-%d 23:59:59',dateFmt:'yyyy-MM-dd HH:mm:ss'})"
										readonly="true" placeholder="请选择结束时间" style="width: 200px;" /> 
						</div>
						
					</form>
					<div class="form-search-wp">
							<button type="submit" class="btn btn-red">查询</button>
							<c:if test="${addAct =='1' }">
								<button class="btn btn-white" onclick="window.location.href='<c:url value='/announcement/form?funcid=${funcid}' />'">新增</button>
							</c:if>
						</div>
					<table class="table table-bordered table-hover">
						<thead>
							<tr>
								<th>序号</th>
								<th>标题</th>
								<th>阅读数</th>
								<th>创建人</th>
								<th>创建时间</th>
								<th>通知类型</th>
								<th>定时群发时间</th>
								<th>群发状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${page.items}" var="model" varStatus="status">
								<tr>
									<td width="5%">${ (page.currentPage-1)*page.pageSize+(status.index+1)}</td>	
									<td>${model.title }</td>
									<td>${model.readerNum }</td>
									<td>${model.creator }</td>
									<td>${model.createTime }</td>
									<td>
										<c:forEach items="${announcementTypeGroup }" var="obj">
											<c:if test="${obj.itemcode==model.type }">${obj.itemname }</c:if>
										</c:forEach>
									</td>
									<td>
										<c:choose>
											<c:when test="${!empty model.timerSendTime && model.timerSendTime!='' }">${model.timerSendTime }</c:when>
											<c:otherwise>--</c:otherwise>
										</c:choose>
									</td>
									<td>
										<c:choose>
											<c:when test="${model.sendStatus=='0' }">待发送</c:when>
											<c:when test="${model.sendStatus=='1' }">发送成功</c:when>
											<c:otherwise>--</c:otherwise>
										</c:choose>
									</td>
									<td>
										<c:if test="${updateAct =='1' }">
										<a href="update/${model.id}&${funcid}" class="btn-table btn-gray" title="修改"> 
											<span>修改</span>
										</a>
										</c:if>
										
										<c:if test="${deleteAct =='1' }">
                                   		<a href="javascript:dele('${model.id}');" class="btn-table btn-red" title="删除">
                                   			<span>删除</span>
                                   		</a>
                                  		</c:if>
									</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-red" href="javascript:goPage('gopage');" id='bindBtn'>确定</a>
	                	</div>
		            </div>
				</div>
			</div>
		</div>
	</div>
	</section>
</body>
</html>