<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>优惠卷管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 优惠卷管理 <span class="c-gray en">&gt;</span> 优惠券列表 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<form action="${pageContext.request.contextPath }/admin/couponType/typeList" method="post" id="searchForm">
	<div class="text-c"> 
		优惠券名称:  
		<input type="text" class="input-text" style="width:250px" placeholder="输入优惠券名称" value="${couponName }" id="" name="couponName">
	   	 优惠券类型: <span class="select-box inline">
		    <select class="select" id="" name="couponType">
		    	<option value="">请选择优惠券类型</option>
		      	<option value="1" <c:if test="${couponType == 1 }">selected="selected"</c:if>>现金券</option>
				<option value="2" <c:if test="${couponType == 2 }">selected="selected"</c:if>>折扣券</option>
		    	<%-- <c:choose>
		    		<c:when test="${couponType == 1 }">
		    			<option value="">请选择优惠券类型</option>
				      	<option value="1" selected="selected">已使用</option>
				      	<option value="2">未使用</option>
		    		</c:when>
		    		<c:when test="${cStatus == 2 }">
		    			<option value="">请选择使用状态</option>
				      	<option value="1">已使用</option>
				      	<option value="2" selected="selected">未使用</option>
		    		</c:when>
		    		<c:otherwise>
		    			<option value="">请选择使用状态</option>
				      	<option value="1">已使用</option>
				      	<option value="2">未使用</option>
		    		</c:otherwise>
		    	</c:choose> --%>

		    </select>
	    </span>
		
		<button type="button" class="btn btn-success radius" id="searchButton" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</div>
	</form>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<tr class="text-c">
				<th width="50">id</th>
				<th width="150">优惠券名称</th>
				<th width="50">券总数</th>
				<!-- <th width="50">已领券数</th> -->
				<th width="50">剩余券数</th>
				
				<!-- <th width="100">限领券数</th> -->
				<th width="100">优惠券折扣类型</th>
				<!-- <th width="40">必须关注</th>
				<th width="40">必须购买</th> -->
				<th width="50">领券条件</th>
				
				<th width="50">减免率/额</th>
				<!-- <th width="100">有效天数</th> -->
				<!-- <th width="100">有效时间</th> -->
				<th width="100">券截止时间</th>
				<!-- <th width="100">创建时间</th> -->
				
				<!-- <th width="100">更新时间</th> -->
				<!-- <th width="80">可否赠送他人</th>
				<th width="40">券优先级别</th> -->
				<th width="200">备注</th>
				<th width="200">操作</th>
			</tr>
		</thead>
		
		<tbody>
			<c:if test="${!empty typeList }">
				<c:forEach items="${typeList }" var="cType">
				<tr class="text-c">
					<td>${cType.couponId }</td>
					<td>${cType.couponName }</td>
					<td class='text-l'>${cType.couponTotal }</td>
					<%-- <td>${cType.couponUsedNum }</td> --%>
					<td>${cType.couponRemainingNum }</td>
					
					<%-- <td>${cType.couponGetLimit }</td> --%>
					<td>
						<c:if test="${cType.couponType == 1}">现金券</c:if>
						<c:if test="${cType.couponType == 2}">折扣券</c:if>
					</td>
					<%-- <td>
						<c:if test="${cType.couponIsConcern == 1}">是</c:if>
						<c:if test="${cType.couponIsConcern == 2}">否</c:if>
					</td>
					<td>
						<c:if test="${cType.couponIsPurchase == 1}">是</c:if>
						<c:if test="${cType.couponIsPurchase == 2}">否</c:if>
					</td> --%>
					<td id="couponConsumeEnough">${cType.couponConsumeEnough / 100}</td>
					
					<td id="couponReduce">${cType.couponReduce / 100}</td>
					<%-- <td>${cType.couponGetDays }</td> --%>
					<%-- <td>${cType.couponLimitHours }</td> --%>
					<td><fmt:formatDate value="${cType.couponEndDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td>
					<%-- <td><fmt:formatDate value="${cType.couponCreateDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td> --%>
					
					<%-- <td><fmt:formatDate value="${cType.couponUpdateDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td> --%>
					<%-- <td>
						<c:if test="${cType.couponIsGive == 1}">不允许</c:if>
						<c:if test="${cType.couponIsGive == 2}">允许</c:if>
					</td> --%>
					<%-- <td>${cType.couponPriorityLevels }</td> --%>
					<td>${cType.couponRemark }</td>
					<td class="td-manage">
						<input id="through" class="btn btn-primary radius upload-btn" onclick="detailCType('优惠券类型详情','${pageContext.request.contextPath }/admin/couponType/toTypeDetail/${cType.couponId }','','700');" type="button" value="详情" />&nbsp;
						<input id="through" class="btn btn-primary radius upload-btn" onclick="updateCType('修改优惠券类型','${pageContext.request.contextPath }/admin/couponType/toUpdateType/${cType.couponId }','','700');" type="button" value="修改" />&nbsp;
						<input id="through" class="btn btn-primary radius upload-btn" onclick="deleteCType(this,${cType.couponId });" type="button" value="删除" />
					</td>
				</tr>
				</c:forEach>
			</c:if>
			<c:if test="${empty typeList }">
				<tr class="text-c">
					<td colspan="9">没有查询到数据</td>
				</tr>
			</c:if>
		</tbody>
	</table>
	</div>
</div>
<div align="right">
	<%@include file="/common/other/paper/pager.jsp"%>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script> 
<script type="text/javascript">
$(document).ready(function() {
	$("#searchButton").click(function() {
		var action = $("#searchForm").attr("action");
		$("#searchForm").attr("action", action).submit();
	});
})
/*优惠券类型-编辑*/
function updateCType(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*优惠券类型-详情*/
function detailCType(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*优惠券类型-删除*/
function deleteCType(obj,id){
	//alert("-----------");
	layer.confirm('确认要删除吗？',function(){
		$.ajax({
			url: '${pageContext.request.contextPath }/admin/couponType/deleteType/'+id,
			//data:{ "couponId":id },
			dataType:'json',//服务器返回json格式数据
			type:'post',	//HTTP请求类型
			error:function(data){
				//alert("-----error:function----->>" + data);
	      	  	layer.msg("删除失败!",{icon: 5,time:2000});
	        },
	        success:  function(data){
	        	//alert("----success------>>" + data);
	      	  	//layer.msg(data.status,{icon: 1,time:2000});
	      	  	if(data.status){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:3000});
	      	  	}else{
	      	  		layer.msg(data.message,{icon:1,time:3000});
	      	  	}
	        }
		});
	});
}
</script> 
</body>
</html>