<%@page pageEncoding="utf-8" 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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<%@include file="/WEB-INF/navigation/JsAndCss.jsp" %>
		<link href="${path }/css/glDatePicker.default.css" rel="stylesheet" />
		<script src="/js/html5.js"></script>
		<script src="/datePicker/WdatePicker.js"></script>
		<style>
.performance_msg {
	font-size: 20px;
}

div.tabs
{
    width:940px;
	height:35px;
	overflow:hidden;
	padding-left:10px;
	margin-top:10px;
}
div.tabs ul li
{
	float:left;
	padding:0 5px;
}
div.tabs ul li a
{
	display:block;
	width:101px;
	height:36px;
	overflow:hidden;
	line-height:36px;
	text-align:center;
}
div.fee_type input, div.fee_type label
{
    border-width: 0px;
    display: block;
    height: 30px;
    line-height: 27px;
    float: left;
    margin-left: 5px;
}
div.fee_type label
{
    margin-left: 3px;
    margin-right: 5px;
}
div.input_info
{
    width: 580px;
    text-align: left;
    margin-left: 10px;
    float: left;
    height: 40px;
}
div.input_info span.info
{
    display:inline-block;
    width:50px;
}
</style>
<script type="text/javascript">
	function getProductCommissionByAmount(){
		var id = $("#flag option:selected").val();
		$.post("findProductCommissionByAmount.do",{"id":id},function(data){
			if(data!=null){
				$("#amount").val(data.amount);
				$("#commission").val(data.commission);
				$("#description").val(data.description);
				$("#sortId").val(data.sortId);
				
			}
		});
	}
	function deleteCommission(productId){
		var id = $("#flag").val();
		$.post("deleteProductCommission.do",{"id":id},function(data){
			if(data!=null){
				alert("删除成功!");
				setTimeout(function(){
					location.href="?toProductCommission.do?productId=";
				}, 1000);
				
			}
		});
	}
</script>
</head>
<body>
	<div class="container">
		<div class="navbar">
			<div class="navbar-inner">
				<%@include file="../navigation/menu.jsp"%>
			</div>
		</div>
		<div class="row">
			<%@include file="../navigation/navigation.jsp"%>
			<div class="span9">
			
				<div class="tabs">
					<ul style="list-style-type: none">
						
						<li><span class="performance_msg">产品返佣</span></li>
					</ul>
				</div>
				<form id="edit-profile" class="form-horizontal" name="form" method="post" action="addOrModifyProductCommission.do?productId=${productId }">
					<legend style="margin-top:15px"></legend>
					<div class="control-group">
								<label class="control-label" for="flag">已有返佣金额范围</label>
								<div class="controls">
									<select id="flag" name="flag" onchange="getProductCommissionByAmount()">
									<option value="0">--新增返佣金额范围--</option>
									<c:forEach items="${commissions }" var="commissions">
										<option value="${commissions.id }">${commissions.amount }</option>
									</c:forEach>									
										
									</select>
								</div>
							</div>
					<div id="product_commission">
						<div class="control-group">
							<label class="control-label" for="amount">金额范围</label>
							<div class="controls">
								<input type="text" class="input-xlarge" id="amount"
									name="amount" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="commission">佣金费率</label>
							<div class="controls">
								<input type="text" class="input-xlarge" id="commission"
									name="commission" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="description">产品返佣说明</label>
							<div class="controls">
								<textarea type="text" class="input-xlarge" id="description"
									name="description"></textarea>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="sortId">排列顺序</label>
							<div class="controls">
								<input type="text" class="input-xlarge" id="sortId"
									name="sortId" />
							</div>
						</div>
						<div class="form-actions">
							<button type="submit" class="btn btn-primary">提交</button>
							<button class="btn" type="reset" onclick="location.href='toModifyProduct.do?productId=${productId}'">返回</button>
							<button class="btn" type="button" onclick="deleteCommission(${productId})">删除佣金</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
