<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]-->
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/respond.min.js"></script>
<!--[endif]-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/admin/static/h-ui.admin/css/page.css" />
<!--[if IE 6]-->
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<!--[endif]-->
<title>Formula Project</title>
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<body class="pos-r">

<div>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> Home Page
		<span style="text-align: center;padding-left: 600px;"><b>${product.name}</b></span>
		<a class="btn btn-success radius r" 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="page-container">

		
		<div class="mt-20">
			<h4>The Discount Range</h4>
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="480">Product Name</th>
						<th colspan="6" >Product Discount</th>
						<th width="200">Operation</th>
					</tr>
				</thead>
				<tbody>
							<tr class="text-c va-m">
								<td class="td-status">${product.name}</td>
								<td class="td-status" id="cou${1}Id${product.id }">${product.num1}</td>
								<td class="td-status" id="cou${2}Id${product.id }">${product.num2}</td>
								<td class="td-status" id="cou${3}Id${product.id }">${product.num3}</td>
								<td class="td-status" id="cou${4}Id${product.id }">${product.num4}</td>
								<td class="td-status" id="cou${5}Id${product.id }">${product.num5}</td>
								<td class="td-status" id="cou${6}Id${product.id }">${product.num6}</td>
								<td class="td-manage"> 
									<a style="text-decoration:none" class="ml-5" onClick="updataCount('${product.id }')" title="Compile"><i class="Hui-iconfont">&#xe6df;</i></a> 
									<a style="text-decoration:none" class="ml-5" onClick="submitCount('${product.id }')" title="Compile"><i class="Hui-iconfont"><img width="15" height="20" class="product-thumb" src="${pageContext.request.contextPath}/admin/101.png"></i></a>
							</tr>
					</tbody>
			</table>
		</div>
		
		<br/><br/>
		
		<div class="mt-20">
			<h4>Discount Price</h4>
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="60">ID</th>
						<th width="100">Printing </th>
						<th width="100">Thickness </th>
						<th width="100">Product Price</th>
						<th width="100">Decreased Base</th>
						<th width="100">Decreasing rate</th>
						<th width="80" id="finds1">${product.num1}-${product.num2}</th>
						<th width="80" id="finds2">${product.num2}-${product.num3}</th>
						<th width="80" id="finds3">${product.num3}-${product.num4}</th>
						<th width="80" id="finds4">${product.num4}-${product.num5}</th>
						<th width="80" id="finds5">${product.num5}-${product.num6}</th>
						<th width="80" id="finds6">>${product.num6}</th>
						<th width="100">Operation</th>
					</tr>
				</thead>
				<tbody>
						<c:forEach items="${list}" var="p" varStatus="s">
								<tr class="text-c va-m">
									<td >${s.count}</td>
									<td class="td-status">${p.size}</td>
									<td class="td-status">${p.name}</td>
									<td class="td-status" id="num${0}Id${p.id }">${p.price}</td>
									<td class="td-status" id="num${1}Id${p.id }">${p.orders}</td>
									<td class="td-status" id="num${2}Id${p.id }">${p.orderss}</td>
									<td class="td-status" id="num${3}Id${p.id }">${p.num1}</td>
									<td class="td-status" id="num${4}Id${p.id }">${p.num2}</td>
									<td class="td-status" id="num${5}Id${p.id }">${p.num3}</td>
									<td class="td-status" id="num${6}Id${p.id }">${p.num4}</td>
									<td class="td-status" id="num${7}Id${p.id }">${p.num5}</td>
									<td class="td-status" id="num${8}Id${p.id }">${p.num6}</td>
									<td class="td-manage">
										<a style="text-decoration:none" class="ml-5" onClick="updataDiscount('${p.id }')" title="Compile"><i class="Hui-iconfont">&#xe6df;</i></a>
										<a style="text-decoration:none" class="ml-5" onClick="submitDiscount('${p.id }')" title="Compile"><i class="Hui-iconfont"><img width="15" height="20" class="product-thumb" src="${pageContext.request.contextPath}/admin/101.png"></i></a>
								</tr>
						</c:forEach>
					</tbody>
			</table>
		</div>


	</div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>

<script type="text/javascript">

	var jj = 0;
	function updataDiscount(id){
	    if(jj==0){
            for(var i=0;i<=8;i++){
                var price=$("#"+"num"+i+"Id"+id).text();
                var input=$('<input type="text" id="num'+i+'Idd'+id+'" style="width:70px;" class="price" value="'+price+'">');
                $("#"+"num"+i+"Id"+id).html(input);
                $('input').click(function(){
                    return false;
                }); //阻止表单默认点击行为
            }
		}
		jj++;

	}
	function submitDiscount(id){
		var checkValue = ""; //定义一个数组
		for(var i=0;i<=8;i++){
			var price = $("#"+"num"+i+"Idd"+id).val();
			checkValue += price+",";
			$("#"+"num"+i+"Id"+id).html(price);
		}
		 $.ajax({  
	    		url : 'submit-discount11.html',
	            type : "POST",   
	            data : {"pid":id,"prices":checkValue},// 序列化表单值  
	            async : false,
				dataType : 'text', 
	            success : function(data) {  //成功
	                if(data == 'ok'){
	                    jj=0;
	                	alert("Modify Successfully");
	                }else{
	                	alert("Fail to Modify");
	                }
	            },  
	            error : function(request) {  //失败的话
	                /* alert("Connection error");  */
	            } 
	         });
		}
	
	var zz = 0;
	function updataCount(id){
	    if(zz==0){
            for(var i=1;i<=6;i++){
                var price=$("#"+"cou"+i+"Id"+id).text();
                var input=$('<input type="text" id="cou'+i+'Idd'+id+'" style="width:70px;" class="price" value="'+price+'">');
                $("#"+"cou"+i+"Id"+id).html(input);
                $('input').click(function(){
                    return false;
                }); //阻止表单默认点击行为
            }
		}
		zz++;
	}
	function submitCount(id){
		var checkValue = ""; //定义一个数组
		for(var i=1;i<=6;i++){
			var price = $("#"+"cou"+i+"Idd"+id).val();
			checkValue += price+",";
			$("#"+"cou"+i+"Id"+id).html(price);
		}
		 $.ajax({  
	    		url : 'submit-count11.html',
	            type : "POST",   
	            data : {"pid":id,"prices":checkValue},// 序列化表单值  
	            async : false,
				dataType : 'text', 
	            success : function(data) {  //成功
	                if(data == 'ok'){
	                    zz=0;
                        $.ajax({
                            url : 'replace_count.html',
                            type : "POST",
                            data : {"pid":11},// 传给后端产品的id编号
                            async : false,
                            dataType : 'json',
							success : function(obj){
                                $("#finds1").html(obj.f1+"-"+obj.f2);
                                $("#finds2").html(obj.f2+"-"+obj.f3);
                                $("#finds3").html(obj.f3+"-"+obj.f4);
                                $("#finds4").html(obj.f4+"-"+obj.f5);
                                $("#finds5").html(obj.f5+"-"+obj.f6);
                                $("#finds6").html(">"+obj.f6);
                            }
                        });


                            alert("Modify Successfully");
	                }else{
	                	alert("Fail to Modify");
	                }
	            },  
	            error : function(request) {  //失败的话
	                /* alert("Connection error");  */
	            } 
	         });
		}
	
	

	
	
</script>
</body>
</html>