<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="inc/Page_cls.asp"-->
<!--#include file="../Include/Lebi_config.asp"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_product_select.asp
'* 最后更新 2013-05-25 by 56770.kingdge
'*****************************************
Dim admin_flag
admin_flag=",1.10,"
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_order.inc"
CurrentId = 2
CurrentUrl = "admin_order_quick.asp"
LB_Head()
Response.Write("<style>BODY {BACKGROUND: #fff}</style>")
Response.Write("<div class=""mainbody"" style=""width:930px"">")
Response.Write("<div class=""mainbody2"" style=""width:930px"">")
If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
		adminflag()
Else
		If OutSubmit = 1 Then CheckOutSubmit()
		Select Case Request("action")
			   Case Else
					product()
		End Select
End If
Response.Write("</div>")
Response.Write("</div>")

Sub product()
        Dim list_type
        list_type = CheckNum(request("list_type"),0)
        sort_id=CheckNum(request("sort_id"),0)
        page = CheckNum(request("page"),1)
	    pagecount=page
		dis_grade = checknum(request("dis_grade"),1)
		keyword = safereplace(Trim(request("keyword")))
		LangTxt = safereplace(request("LangTxt"))
		Dim ors
		Set ors=new Cls_vbsPage
		Set ors.Conn=conn
		With ors
		.PageSize=10
		.PageName="Page"
		If IsSqlDataBase = 0 Then
				.DbType="AC"
		Else
				.DbType="MSSQL"
		End If
		.RecType=0
		.Pkey="p.id"
		.Field="p.id,p.bianhao,p.product_name"& LangTxt &",p.sprice,p.stj,p.ytj,p.zhuangtai,p.cx,p.cprice,p.kucun,p.buys,p.views,p.pic,p.P_SpecificationName,p.P_SpecificationValue,s.price as buyprice,p.P_SpecificationPic"
		.Table="[Lebi_product] as p,[Lebi_product_price] as s"
		sql = "s.product_id=p.id and s.grade_id="& dis_grade &" and p.zhuangtai=1"
		if keyword<>"" then sql=sql + " and (p.product_name"& LangTxt &" like '%"&keyword&"%' or p.bianhao like '%"& keyword &"%' or p.brand"& LangTxt &" like '%"& keyword &"%')"
		If sort_id<>"0" And IsSqlDataBase = 1 Then sql=sql + " and charindex(',"&sort_id&",',p.categoryid)>0"
		If sort_id<>"0" And IsSqlDataBase = 0 Then sql=sql + " and instr(p.categoryid,',"&sort_id&",')>0"
		if request("type")="3" then sql=sql + " and p.cx=1"
		if request("type")="4" then sql=sql + " and (p.stj=1 or p.ytj=1)"
		.Condition=sql
		if request("type")="" then sqlorder = "p.sj desc,p.id desc"
		if request("type")="1" then sqlorder = "p.views desc"
		if request("type")="2" then sqlorder = "p.buys desc"
		if request("type")="3" then sqlorder = "p.sj desc,p.id desc"
		if request("type")="4" then sqlorder = "p.sj desc,p.id desc"
		if request("type")="5" then sqlorder = "p.p_order desc,p.id desc"
		.OrderBy=sqlorder
		End With
		DataCount=ors.RecCount()
		DataList=ors.ResultSet()
%>
<script language="javascript" type="text/javascript" src="inc/js/js_link.js"></script>
<script language="javascript" type="text/javascript" src="inc/js/order_quick.js"></script>
<script type="text/javascript">
function addtoorder(id,listcode,product_type,isValid,bianhao){  
	var pro_num = 1;
	var selectover = 1;
	var formBuy = document.forms['LEBI_FORMBUY_'+listcode];
	if (formBuy)
	{
		var pro_num = formBuy.elements['pro_num_'+listcode+'_'+id].value;
		var price = formBuy.elements['price_'+listcode+'_'+id].value;
		list_hid=document.getElementsByName("hidv_"+listcode+"_"+id);
		var spname="";var spvalue="";
		for(var j=0;j<list_hid.length;j++){
			if (list_hid[j].value != "")
			{
				spname+=list_hid[j].value.split("|")[0];
				spvalue+=list_hid[j].value.split("|")[1];
				if (j<list_hid.length-1)
				{
					spname+=",";
					spvalue+=",";
				}
			}
		}
		for(var j=0;j<list_hid.length;j++){
			if (spvalue.split(",")[j] =="")
			{
				selectover = 0
			}
		}
	}
	if (selectover == 0)
	{
		fixedtooltip(formBuy.elements['button_'+listcode+'_'+id+''], "<span style='font-weight:bold;color:#ff0000'>请先选择商品属性！</span><br /><a href='#'  onclick=\"this.parentNode.style.display=\'none\';return false;\">关闭</a>", null, null)
	}else{
		window.parent.document.getElementById('b_pro_id').value=bianhao;window.parent.document.getElementById('b_pro_num').value=pro_num;window.parent.document.getElementById('b_pro_price').value=price;window.parent.document.getElementById('b_pro_spname').value=spname;window.parent.document.getElementById('b_pro_spvalue').value=spvalue;parent.$('#windownbg').remove();parent.$('#windown-box').fadeOut('slow',function(){parent.$(this).remove();});
	}
}
function select_sp(id,i,ib,values,price,listcode){
	var selectover = 1;
	list=document.getElementsByName("sv_n_"+id+"_"+i);
	for(var j=0;j<list.length;j++){
		if (list[j].className == "spva-img"||list[j].className == "spva-imgon"){list[j].className="spva-img";}else{list[j].className="spva";}
		list[j].style.background="#fff";
	}
	if (document.getElementById("sv_"+id+"_"+i+"_"+ib).className=="spva-img"||document.getElementById("sv_"+id+"_"+i+"_"+ib).className=="spva-imgon"){document.getElementById("sv_"+id+"_"+i+"_"+ib).className="spva-imgon";}else{document.getElementById("sv_"+id+"_"+i+"_"+ib).className="spvaon";}
	document.getElementById("hidv_"+listcode+"_"+id+"_"+i).value=values;
	document.getElementById("sv_"+id+"_"+i+"_"+ib).style.background="url(images/select-on.gif) no-repeat right bottom";
	list_hid=document.getElementsByName("hidv_"+listcode+"_"+id);
	var spvalue="";
	for(var j=0;j<list_hid.length;j++){
		if (list_hid[j].value != "")
		{
			spvalue+=list_hid[j].value.split("|")[1];
			if (j<list_hid.length-1)
			{
				spvalue+=",";
			}
		}
	}
	for(var j=0;j<list_hid.length;j++){
		if (spvalue.split(",")[j] =="")
		{
			selectover = 0
		}
	}
	if (selectover == 1)
	{
		 var url=AdminPath +"Ajax_data.asp?action=getspinfoorder&id="+id+"&name="+escape(spvalue)+"&price="+price+"&LangTxt=<%=LangTxt%>&t="+Math.random();
		 $.ajax({
		 type:"POST",
		 url:url,
		 data:"",
		 success:function(returntxt){
			var mes = returntxt.split("|")[0];
			var price = returntxt.split("|")[1];
			if(returntxt.length > 0)
			{
				$("#result_"+listcode+"_"+id+"").html(mes);
				$("#price_"+listcode+"_"+id+"").val(price);
				$("#spvalue_"+listcode+"_"+id+"").val(spvalue);
			}
			else
			{
				$("#result_"+listcode+"_"+id+"").html("");
				$("#price_"+listcode+"_"+id+"").val(mes);
				$("#spvalue_"+listcode+"_"+id+"").val(mes);
			}
		 }
		})	
	}
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable-top">
<tbody>
<tr>
<form method="get" action="?">
<td height="30" align="left" class="classhead">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<select name="sort_id">
<option value="0" selected>┌ <%=Lang_Order(85)%></option>
<script language="javascript" type="text/javascript" src="../include/Lebi_Html/CategoryOption.js"></script>
</select>
</td>
<td style="padding-left:5px;">
<input name="keyword" id="keyword" type="text" class="form_query" size="15" autocomplete="off" onkeyup="search_suggest('keyword','Lebi_product','')"><input name="Submit" type="submit" value="" title="<%=Lang_sys(25)%>" align="absmiddle" class="btn_query"><input type="hidden" name="action" value="product"><input type="hidden" name="kucun" value="<%= kucun %>"><input type="hidden" name="LangTxt" value="<%= LangTxt %>"><input type="hidden" name="type" value="<%= request("type") %>"><br /><div id="search_suggest_keyword" class="search_suggest" style="display:none"></div>
</td>
</tr>
</table>
</td>
</form>
<td align="right" class="classhead">
<select name="anclassid" onChange="var jmpURL=this.options[this.selectedIndex].value ;if(jmpURL!='') {window.location=jmpURL; }else{ this.selectedIndex=0; }">
<option selected>┌ <%=Lang_Order(90)%></option>
<option value="?action=product&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(91)%></option>
<option value="?action=product&type=3&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(92)%></option>
<option value="?action=product&type=4&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(93)%></option>
<option value="?action=product&type=1&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(94)%></option>
<option value="?action=product&type=2&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(95)%></option>
<option value="?action=product&type=5&LangTxt=<%=LangTxt%>">├ <%=Lang_Order(96)%></option>
</select></td>
</tr>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="productlist" class="classtable2">
<thead>
<tr>
<td class="classtop" width="6%" height="30"><%=Lang_Order(43)%></td>
<td class="classtop" width="54%"><%=Lang_Order(50)%></td>
<td class="classtop" width="12%"><%=Lang_Order(49)%></td>
<td class="classtop" width="8%"><%=Lang_Order(98)%></td>
<td class="classtop" width="8%"><%=Lang_Order(99)%></td>
<td class="classtop" width="6%"><%=Lang_Order(100)%></td>
<td class="classtop" width="6%"><%=Lang_Order(101)%></td>
</tr>
</thead>
<tbody>
<form action="" method="post" name="LEBI_FORMBUY_0001" id="LEBI_FORMBUY_0001">
<%
If DataCount >0 Then
		For i = 0 To Ubound(DataList,2)
				P_SpecificationName=DataList(13,i)
				P_SpecificationValue=DataList(14,i)
				P_SpecificationPic=DataList(16,i)
				If InStr(P_SpecificationPic,"|")=0 Then P_SpecificationPic = "||||||||||||||||||||||||||||||||||||||||"
				If DataList(7,i) = 1 Then
						price = DataList(8,i)
				Else
						price = DataList(15,i)
				End If
%>
<tr class="classrow">
<td height="30" rowspan="2" class="classrow"><div class="pro-pic"><a href="<%If Config_Lebi_Eshop(16) = 0 Then
response.write("../showproduct.asp")
Else
response.write("../product/")
End If
%>?id=<%=DataList(0,i)%>" target="_blank"><img src='../<%= PicPath %>/<%=trim(DataList(12,i))%>' width="60" height="60" align='absmiddle' onMouseover="javascript:ddrivetip('<table cellspacing=0 cellpadding=6 width=100% align=center><tr><Td width=<%=pic_xw%>><img src=../<%= PicPath %>/<%=trim(DataList(12,i))%> width=<%=pic_xw%> height=<%=pic_xh%></td><td valign=top><%= productinfo %></td></tr></table>', '#ffffff', '300')" onMouseout="hideddrivetip()" border="0"></a></div></td>
<td class="classrow"><%=DataList(2,i)%><%if DataList(7,i)=1 then%><font color=red>[<%=Lang_Order(104)%>]</font><%end if%></td>
<td class="classrow"><%=DataList(1,i)%></td>
<td class="classrow"><%=formatnumber2(DataList(3,i))%></td>
<td class="classrow"><%=formatnumber2(price)%></td>
<td class="classrow"><%if DataList(4,i)=1 then response.write"<font color=red>√</font>" else response.write"×" end if %></td>
<td class="classrow"<%If DataList(13,i) <> "" Then%>onMouseOver="GetStockTips('<%=DataList(2,i)%>','<%=DataList(0,i)%>','<%=DataList(13,i)%>','2');" onMouseOut="RemoveTips(null,true);"<%End If%>><%if DataList(9,i)<10 then response.write"<font color=red><strong>"&DataList(9,i)&"</strong></font>" else  response.write DataList(9,i) end if%></td>
</tr>
<tr class="classrow">
<td colspan="9" class="classrow">
<div class="choosesp">
<%
If P_SpecificationName <> "" Then 
		If InStr(P_SpecificationName,",") = 0 Then 
				n = 0
				P_SpecificationValue = Replace(P_SpecificationValue,"|",",")
				If Right(P_SpecificationValue,1) = "|" Then P_SpecificationValue = cut_Right(P_SpecificationValue)
				If Right(P_SpecificationValue,1) = "," Then P_SpecificationValue = cut_Right(P_SpecificationValue)
				Set rs = conn.execute("select s_name"& LangTxt &" from [Lebi_SelectName] where s_id = "& checknum(P_SpecificationName,0) &"")
				If Not rs.eof Then 
						SName = rs(0)
						response.write("<dl class='size'><dt>"& SName &"</dt>")
				End If 
				rs.close : Set rs = Nothing
				Set rs = conn.execute("select s_value"& LangTxt &",id from [Lebi_SelectValue] where s_id = "& checknum(P_SpecificationName,0) &" and id in("& P_SpecificationValue &")")
				If Not rs.eof Then 
				j = 0
				response.write("<dd>")
				Do While Not rs.eof 
						p = getN(Replace(P_SpecificationValue,"|",","),rs(1),",")
						if Split(P_SpecificationPic,"|")(p) <> "" Then
								response.write("<div><a id=""sv_"& DataList(0,i) &"_"& n &"_"& j &""" name=""sv_n_"& DataList(0,i) &"_"& n &""" class=""spva-img"" title="""& rs(0) &""" onclick=""select_sp('"& DataList(0,i) &"','"& n &"','"& j &"','"& SName &"|"& rs(0) &"','"& price &"','0001');""><img src="""&Eshop_url&PicPath&"/"&Split(P_SpecificationPic,"|")(p)&""" /><span></span></a></div>")
						Else 
								response.write("<div><a id=""sv_"& DataList(0,i) &"_"& n &"_"& j &""" name=""sv_n_"& DataList(0,i) &"_"& n &""" class=""spva"" onclick=""select_sp('"& DataList(0,i) &"','"& n &"','"& j &"','"& SName &"|"& rs(0) &"','"& price &"','0001');"">"& rs(0) &"</a></div>")
						End If 
				rs.movenext
				j = j + 1
				Loop
				response.write("</dd>")
				End If 
				rs.close : Set rs = Nothing
				response.write("<input type=""hidden"" name=""hidv_0001_"& DataList(0,i) &""" id=""hidv_0001_"& DataList(0,i) &"_0""></dl>")
		Else
				For n = 0 To UBound(Split(P_SpecificationName,","))
				Set rs = conn.execute("select s_name"& LangTxt &" from [Lebi_SelectName] where s_id = "& checknum(Split(P_SpecificationName,",")(n),0) &"")
				If Not rs.eof Then 
						SName = rs(0)
						response.write("<dl class='size'><dt>"& SName &"</dt>")
				End If 
				rs.close : Set rs = Nothing
				Set rs = conn.execute("select s_value"& LangTxt &",id from [Lebi_SelectValue] where s_id = "& checknum(Split(P_SpecificationName,",")(n),0) &" and id in("& Split(P_SpecificationValue,"|")(n) &")")
				If Not rs.eof Then 
				j = 0
				response.write("<dd>")
				Do While Not rs.eof 
						p = getN(Replace(P_SpecificationValue,"|",","),rs(1),",")
						if Split(P_SpecificationPic,"|")(p) <> "" Then
								response.write("<div><a id=""sv_"& DataList(0,i) &"_"& n &"_"& j &""" name=""sv_n_"& DataList(0,i) &"_"& n &""" class=""spva-img"" title="""& rs(0) &""" onclick=""select_sp('"& DataList(0,i) &"','"& n &"','"& j &"','"& SName &"|"& rs(0) &"','"& price &"','0001');""><img src="""&Eshop_url&PicPath&"/"&Split(P_SpecificationPic,"|")(p)&""" /><span></span></a></div>")
						Else 
								response.write("<div><a id=""sv_"& DataList(0,i) &"_"& n &"_"& j &""" name=""sv_n_"& DataList(0,i) &"_"& n &""" class=""spva"" onclick=""select_sp('"& DataList(0,i) &"','"& n &"','"& j &"','"& SName &"|"& rs(0) &"','"& price &"','0001');"">"& rs(0) &"</a></div>")
						End If 
				rs.movenext
				j = j + 1
				Loop
				response.write("</dd>")
				End If 
				rs.close : Set rs = Nothing
				response.write("<input type=""hidden"" name=""hidv_0001_"& DataList(0,i) &""" id=""hidv_0001_"& DataList(0,i) &"_"& n &"""></dl>")
				Next 
		End If 
End If 
response.write(""& Lang_Order(107) &"<input type=""text"" name=""pro_num_0001_"& DataList(0,i) &""" id=""pro_num_0001_"& DataList(0,i) &""" value=""1"" size=""3"" class=""form"">")
response.write("&nbsp;<input type=""button"" name=""button_0001_"& DataList(0,i) &""" id=""button_0001_"& DataList(0,i) &""" value="""& Lang_Order(190) &""" onClick=""javascript:addtoorder('"& DataList(0,i) &"','0001','',1,'"& DataList(1,i) &"')"" class=""button""> <span id=""result_0001_"& DataList(0,i) &""" class=""result""></span><input type=""hidden"" name=""price_0001_"& DataList(0,i) &""" id=""price_0001_"& DataList(0,i) &""" value="""& price &"""><input type=""hidden"" name=""spvalue_0001_"& DataList(0,i) &""" id=""spvalue_0001_"& DataList(0,i) &""" value="""">")
%>
</div>
</td>
</tr>
<%
        Next
End If
%>
</form>
</tbody>
<tfoot>
<tr>
	<td height="30" class="classfooter" align="right" colspan="10"><%=ors.ShowPageFoot(page)%></td>
</tr>
</tfoot>
</table>
<script>tdshow("productlist");</script>
<%
end Sub
%>