<%@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" %>
					<script src="/js/html5.js"></script>
					<script src="/js/quant.js"></script>
					<script>
function change(){
	status = $("#status").val();
	location.href="/operation/product/findSimpleProduct.do?status="+status;
}
function changeSort(productId,obj){
	var a = $(obj).prev();
	var sortId = $(a).val();
	//if(sortId===null||sortId===""||sortId===undefined){
	//	sortId = 0;
	//}
	$.ajax({
		url:'/operation/product/modifySort.do',
		data:{
			productId:productId,
			sortId:sortId
		},
		success:function(obj){
			if(obj==1){
				alert("修改成功");
			}else{
				alert("修改失败，请重试");
			}
		}
	});
}

</script>
	<style type="text/css">
		.current_page{border:solid 1px;padding:0 3px;}
	</style>
</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">
				<h1>产品列表</h1>
				<table class="table table-bordered table-striped">
					<thead>
						<tr>
							<th>产品名称</th>
							<th><div>产品状态<select id="status" style="padding-top:5px;width:100px" onchange="change(this)">
							<option value="100"  <c:if test="${status==100 }">selected</c:if>>全部</option>
							<option value="0"  <c:if test="${status==0 }">selected</c:if>  >已清盘</option>
							<option value="1"  <c:if test="${status==1 }">selected</c:if>>热销中</option>
							<option value="2"  <c:if test="${status==2 }">selected</c:if>>运行中</option>
							</select></div></th>
							<th>前台显示</th>
							<th>操作</th>
							<th>排序<font style="font-size: 12px;font-style:normal;">(数值越大越靠前)</font></th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${products }" var="product">
							<tr>
								<td>${product.shorterName }</td>
								<td>
									<c:if test="${product.status==0 }">已清盘</c:if> 
									<c:if test="${product.status==1 }">热销中</c:if> 
									<c:if test="${product.status==2 }">运行中</c:if> 
								</td>
								<td>
									<c:if test="${product.showStatus==0 }">不显示</c:if> 
									<c:if test="${product.showStatus==1 }">显示</c:if> 
									
								</td>
								<td class="td_modi">
									<a href="toModifyProduct.do?productId=${product.productId}">编辑</a>
								</td>
								<td class="td_modi">
									<input type="text" name="sortId" id="sortId" value="${product.sortId }" style="width:50px"/>
									<input type="button" value="确定" style="margin-bottom:10px" onclick="changeSort(${product.productId},this )" />
								</td>

							</tr>
						</c:forEach>
						<tr>
							<td colspan="4">
							<%@include file="../navigation/page.jsp"%>
							</td>
							</tr>
					</tbody>
				</table>
				<a class="toggle-link" href="toAddProduct.do"><i
					class="icon-plus"></i>添加产品</a>

			</div>
		</div>
	</div>
</body>
</html>
