<%@ 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/icheck/icheck.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>
<style type="text/css">
	.col-2{width: 20%;}
	.col-10{width: 80%;}
</style>
</head>
<body>
<div class="pd-20">
	<form action="${pageContext.request.contextPath }/admin/couponType/updateType" method="post" class="form form-horizontal" id="form-member-add">
		<input name="couponId" type="hidden" value="${cType.couponId }">
		<div class="row cl">
			<label class="form-label col-3"><strong>【优惠券基本信息】</strong></label>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>优惠券名称：</label>
			<div class="formControls col-10">
				<input id="couponName" name="couponName" type="text" class="input-text" value="${cType.couponName }" placeholder="">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>优惠券总数：</label>
			<div class="formControls col-2">
				<input id="couponTotal" type="text" name="couponTotal"  placeholder="" value="${cType.couponTotal }" class="input-text" style="width:90%"></div>
			<%--<label class="form-label col-2"><span class="c-red">*</span>已领券数：</label>
			<div class="formControls col-2">
				<input id="couponUsedNum" type="text" name="couponUsedNum"  placeholder="" value="${cType.couponUsedNum }" class="input-text" style="width:90%"></div>--%>
			<label class="form-label col-2"><span class="c-red">*</span>剩余券数：</label>
			<div class="formControls col-2">
				<input id="couponRemainingNum" type="text" name="couponRemainingNum"  placeholder="" value="${cType.couponRemainingNum }" class="input-text" style="width:90%"></div>
		</div>
			
		<div class="row cl">

			<label class="form-label col-2"><span class="c-red">*</span>每人限领数：</label>
			<div class="formControls col-2">
				<input id="couponGetLimit" type="text" name="couponGetLimit"  placeholder="" value="${cType.couponGetLimit }" class="input-text" style="width:90%"></div>

			<label  class="form-label col-2"><span class="c-red">*</span>优惠券类型：</label>
			<div  class="formControls col-2">
				<span class="select-box">
				<select id="couponType" name="couponType" class="select">
					<option value="1" <c:if test="${cType.couponType == 1 }">selected="selected"</c:if>>现金券</option>
					<option value="2" <c:if test="${cType.couponType == 2 }">selected="selected"</c:if>>折扣券</option>
				</select>
				</span>
			</div>
		</div>
			
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>优惠券金额：</label>
			<div class="formControls col-2">
				<input id="couponReduce" type="text" name="couponReduce"  placeholder="" value="${cType.couponReduce / 100}" class="input-text" style="width:90%"></div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>未领取有效天数：</label>
			<div class="formControls col-2">
				<input id="couponGetDays" type="text" name="couponGetDays"  placeholder="" value="${cType.couponGetDays }" class="input-text" style="width:90%"></div>
			<label class="form-label col-2"><span class="c-red">*</span>领取后的有效天数：</label>
			<div class="formControls col-2">
				<input id="couponLimitHours" type="text" name="couponLimitHours" id="couponLimitHours" placeholder="" value="${cType.couponLimitHours }" class="input-text" style="width:90%"></div>
		</div>
		<%--<div class="row cl">

			<label class="form-label col-2"><span class="c-red">*</span>优惠券截止时间：</label>
			<div class="formControls col-4">
				<input type="text" class="input-text" placeholder="" onfocus="WdatePicker({maxDate:'2050-10-01', dateFmt:'yyyy-MM-dd HH:mm:ss'})"
					   readonly name="couponEndTime" id=couponEndTime datatype="*" nullmsg="请输入截止时间！"  style="width:90%"
					   value="<fmt:formatDate value='${cType.couponEndDate }' pattern='YYYY-MM-dd HH:MM:ss'/>">
			</div>
		</div>--%>
		<div class="row cl">
			<label class="form-label col-3"><strong>【优惠券领取条件】</strong></label>
		</div>
		<div class="row cl">
				<label  class="form-label col-2"><span class="c-red">*</span>是否需要购买：</label>
				<div  class="formControls col-2">
					<span class="select-box">
					<select id="couponIsPurchase" name="couponIsPurchase" class="select">
						<option value="1" <c:if test="${cType.couponIsPurchase == 1 }">selected="selected"</c:if>>是</option>
						<option value="2" <c:if test="${cType.couponIsPurchase == 2 }">selected="selected"</c:if>>否</option>
					</select>
					</span>
				</div>

			<label  class="form-label col-2"><span class="c-red">*</span>是否需要关注：</label>
			<div  class="formControls col-2">
				<span class="select-box">
				<select id="couponIsConcern" name="couponIsConcern" class="select">
					<option value="1" <c:if test="${cType.couponIsConcern == 1 }">selected="selected"</c:if>>是</option>
					<option value="2" <c:if test="${cType.couponIsConcern == 2 }">selected="selected"</c:if>>否</option>
				</select>
				</span>
			</div>
			</div>

		<div class="row cl">
		<label  class="form-label col-2"><span class="c-red">*</span>消费总金额：</label>
		<div  class="formControls col-2">
			<input id="couponConsumeEnough" name="couponConsumeEnough" type="text" class="input-text" value="${cType.couponConsumeEnough / 100}" placeholder="消费总金额要求（满足条件才能领券）">
		</div>


		<div class="row cl">
			<label class="form-label col-3"><strong>【其他】</strong></label>
		</div>
			<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>是否允许赠送别人：</label>
				<div  class="formControls col-2">
					<span class="select-box">
					<select id="couponIsGive" name="couponIsGive" class="select">
						<option value="1" <c:if test="${cType.couponIsGive == 1 }">selected="selected"</c:if>>不允许</option>
						<option value="2" <c:if test="${cType.couponIsGive == 2 }">selected="selected"</c:if>>允许</option>
					</select>
					</span>
				</div>
			</div>
				<div class="row cl">
					<label class="form-label col-2">优惠券备注：</label>
					<div  class="formControls col-2">
						<textarea id="couponRemark" name="couponRemark" class="textarea-text" placeholder="" style="width:200px;height:60px;">${cType.couponRemark }</textarea>
					</div>
				</div>

				<div class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>券优先级别：</label>
				<div class="formControls col-2">
					<input id="couponPriorityLevels" type="text" name="couponPriorityLevels"  placeholder="" value="${cType.couponPriorityLevels }" class="input-text" style="width:90%">
				</div>
				</div>
			</div>
			

			
	    <div class="row cl">
	      <div class="col-9 col-offset-3">
	        <input class="btn btn-primary radius" type="submit" id="submitBtn" onclick="return checkForm()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
	      </div>
	    </div>
  	</form>
</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/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/tips.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/My97DatePicker/WdatePicker.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">
$(function(){
	/* $("#form-member-add").Validform({
		tiptype:2,
		callback:function(form){
			form[0].submit();
		}
	}); */
});
function checkForm(){
    //名称验证
    if(!commonTypeJdg('couponName',null,null,true)){
        layer.msg("优惠券名称不能为空",{icon: 2,time:2000});
        return false;
    }
    //优惠券总数验证
    if(!commonTypeJdg('couponTotal','pInteger',null,true)){
        layer.msg("优惠券总数不能为空!且只能是数字",{icon: 2,time:2000});
        return false;
    }
    //剩余券数验证
    if(!commonTypeJdg('couponRemainingNum','pInteger',null,true)){
        layer.msg("剩余券数不能为空!且只能是数字",{icon: 2,time:2000});
        return false;
    }
    //限领券数验证
    if(!commonTypeJdg('couponGetLimit','pInteger',null,true)){
        layer.msg("限领券数不能为空!且只能是数字",{icon: 2,time:2000});
        return false;
    }
    //领券条件验证
    if(!commonTypeJdg('couponConsumeEnough','money',null,true)){
        layer.msg("消费总金额不能为空!且须为金钱格式",{icon: 2,time:2000});
        return false;
    }
    if(!commonLengthJdg('couponConsumeEnough',1,9,null,true)){
        layer.msg("消费总金额不能为空长度为1-9位",{icon: 2,time:2000});
        return false;
    }
    //优惠券金额不能为空数据验证
    if(!commonTypeJdg('couponReduce','money',null,true)){
        layer.msg("优惠券金额不能为空!且须为金钱格式",{icon: 2,time:2000});
        return false;
    }
    if(!commonLengthJdg('couponReduce',1,9,null,true)){
        layer.msg("优惠券金额不能为空长度为1-9位",{icon: 2,time:2000});
        return false;
    }
    //截止时间验证
	/*if(!commonTypeJdg('couponEndTime',null,null,true)){
	 layer.msg("截止时间不能为空",{icon: 2,time:2000});
	 return false;
	 }*/
    //有效天数验证
    if(!commonTypeJdg('couponGetDays','pInteger',null,true)){
        layer.msg("有效天数不能为空!且只能是数字",{icon: 2,time:2000});
        return false;
    }
    //领券后有效时长验证
    if(!commonTypeJdg('couponLimitHours','pInteger',null,true)){
        layer.msg("领券后有效时长不能为空!且只能是数字",{icon: 2,time:2000});
        return false;
    }
	
	//减免额不能为空乘100 取整
	var couponReduce = $("#couponReduce").val();
	$("#couponReduce").val(Math.round(couponReduce * 100));
	//领券条件 乘100 取整
	var couponConsumeEnough = $("#couponConsumeEnough").val();
	$("#couponConsumeEnough").val(Math.round(couponConsumeEnough * 100));
	return true;
}
</script>
</body>
</html>