<!--#include file="conn.asp"-->
<!--#include file="inc/cookies_check.asp"-->
<!--#include file="../include/Config.Inc"-->
<!--#include file="../include/Lebi_db_cls.asp"-->
<!--#include file="../include/Lebi_cache_cls.asp"-->
<!--#include file="../include/Lebi_email_cls.asp"-->
<!--#include file="../include/Lebi_cache.asp"-->
<!--#include file="../include/Lebi_function.asp"-->
<!--#include file="../qs/config.asp"-->
<!--#include file="../union/config.asp"-->
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 Admin_orders_v.asp
'* 最后更新 2013-09-25 by 56770.kingdge
'*****************************************
include "lang/"& LangFilePath &"/lang_sys.inc"
include "lang/"& LangFilePath &"/lang_menu.inc"
include "lang/"& LangFilePath &"/lang_order.inc"
include "lang/"& LangFilePath &"/lang_ship.inc"
include "lang/"& LangFilePath &"/lang_user.inc"
action = request("action")
CurrentId = 2
CurrentUrl = "admin_orders.asp"
LB_Head()
LB_Menu()%>
<div class="tabmenu mainwidth">
      <ul>
        <li><a href="admin_orders.asp"><span><%=Lang_Menu(89)%></span></a></li>
        <li <%If action = "" Or action = "profile" Or action = "upmark" Or action = "up_b_next" Or action = "del_b" Or action = "add_b" Then Response.Write("class=""current""") End If%>><a href="?id=<%=request("id")%>"><span><%=Lang_Order(157)%></span></a></li>
        <li <%If action = "price" Or action = "price_ok" Then Response.Write("class=""current""") End If%>><a href="?action=price&id=<%=request("id")%>"><span><%=Lang_Order(148)%></span></a></li>
        <li <%If action = "ship" Or action = "ship_ok" Then Response.Write("class=""current""") End If%>><a href="?action=ship&id=<%=request("id")%>"><span><%=Lang_Order(172)%></span></a></li>
      </ul>
</div>
<%
Response.Write("<div class=""tab-mainbody"">")
Response.Write("<div class=""tab-mainbody2"">")
Select Case action
	   Case "huangou" : huangou()
	   Case "up_b" : up_b()
	   Case "up_b_next" : up_b_next()
	   Case "del_b" : del_b()
	   Case "add_b" : add_b()
	   Case "sup" : sup()
	   Case "upmark" : upmark()
	   Case "price" : price()
	   Case "price_ok" : price_ok()
	   Case "ship" : ship()
	   Case "ship_ok" : ship_ok()
	   Case "profile" : profile()
	   Case Else
			order_main()
End Select
Response.Write("</div>")
Response.Write("</div>")
LB_Footer()

rem	<-{  捆绑产品子产品显示样式 2008-1-14 by 56770.WangLei
rem puid:捆绑促销产品ID; tp:返回字符串类型样式; fgf:分隔符
Function getUniteChild(puid,tp,fgf)
		Dim rs_u,zArr,sArr,j
		getUniteChild = ""
		set rs_u = conn.execute("select product_unite_info from [Lebi_product_unite] where id ="&puid&"")
		If not rs_u.eof then
				zArr = Split(rs_u("product_unite_info"),"||||")
				for j=0 to ubound(zArr)
						sArr = Split(zArr(j),"||")
						If UBound(sArr) > 3 Then
								Select Case tp
									   Case "0" :
										If getUniteChild<>"" Then
												getUniteChild=getUniteChild & fgf
										End If
										Set DPro = conn.execute("select product_name"& LangTxt &",p_filename from Lebi_Product where id = "& sArr(0) &"")
										If Not DPro.eof Then
												name = DPro(0)
										Else
												name = sArr(2)
										End If
										Select Case show_html
											   Case "1" : getUniteChild=getUniteChild&"<a href="""&Eshop_url & Folder(0) & DPro(1)&".1.html"" target='_blank'>"& name &"</a>"
											   Case "0" : getUniteChild=getUniteChild&"<a href="""& Eshop_url & PagePath(10) &"?id="& sArr(0) &""" target='_blank'>"& name &"</a> × "& sArr(4)
										End Select
								End Select
						End If
				Next
		End If
		rs_u.Close : set rs_u = nothing
End Function
rem	}->

Sub upmark()
		admin_flag=",1.1,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        id=CheckNum(request("id"),0)
        remark=safereplace(request("remark"))
		mark = CheckNum(request("mark"),0)
        orderzt=Safereplace(request("orderzt"))
        is_pay_advance=CheckNum(request("is_pay_advance"),0)
        f_jifen=CheckNum(request("f_jifen"),0)
        fuyan=safereplace(request("fuyan"))
		is_pay_usermoney=CheckNum(request("is_pay_usermoney"),0)
		IsSendMail = 0
		Set rs = server.CreateObject("adodb.recordset")
        rs.open "select jifen,user_id,dis_sum,fei,zt,is_jifen,packing_price,fapiao_money,coupon_price,LangTxt,order_number,orderzt,paidmoney,mark,remark,fuyan,lastmoney from [Lebi_orders] where id=" & id &"",conn,1,3
		order_number = rs("order_number")
        jifen = rs("jifen")
        user_id = rs("user_id")
	    order_state = rs("zt")
		dis_sum = rs("dis_sum")
		fei = rs("fei")
		packing_price = rs("packing_price")
		is_jifen = rs("is_jifen")
		fapiao_money = rs("fapiao_money")
		coupon_price = checknum(rs("coupon_price"),0)
		zt = rs("zt")
		LangTxt = rs("LangTxt")
		paidmoney = rs("paidmoney")
		lastmoney = rs("lastmoney")
		If CStr(orderzt) <> CStr(rs("orderzt")) Then IsSendMail = 1
		order_price = dis_sum + fei + packing_price + fapiao_money - coupon_price
		rs("mark") = mark
		rs("remark") = remark
		rs("fuyan") = fuyan
		rs.update()
        rs.close:set rs=Nothing
		Set shipdb = conn.execute("select s_name from Lebi_ShipMes where s_order_number = '"& order_number &"'")
		If Not shipdb.eof Then
				orderzt = orderzt &",3,"
		end If
		shipdb.close : Set shipdb = Nothing
		If is_pay_usermoney = 1 Then
				Set user = server.CreateObject("adodb.recordset")
				user.open "select usermoney,sumpay from [lebi_user] where user_id = '"& user_id &"'",conn,1,3
				If Not user.eof Then
						If CDbl(user(0)) >= CDbl(lastmoney) Then
								paymoney = lastmoney
								user(1) = user(1) + CDbl(lastmoney)
								orderzt = orderzt &",2"
						Else
								paymoney = user(0)
								user(1) = user(1) + user(0)
						End If
						user(0) = user(0) - paymoney
						user.update()
						Set rs = server.CreateObject("adodb.recordset")
						rs.open "select lastmoney,paidmoney from [Lebi_orders] where id = "& id &"",conn,1,3
						If Not rs.eof Then 
							rs(0) = rs(0) - paymoney
							rs(1) = rs(1) + paymoney
							rs.update 
						End If 
						rs.close : Set rs = Nothing 
						conn.execute("insert into [Lebi_money_log](m_user_id,m_order_num,m_sj,m_type,m_price,m_zt)values('"& user_id &"','"&order_number&"',"&sqlnowstring&",'"&Lang_Order(168)&"',-"& paymoney &",1)")
						conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& order_price &",1,'"& Lang_Order(168) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
				End If
				user.close : Set user = Nothing
		End If
		If is_pay_advance = 1 Or is_pay_usermoney = 2 Then 
				Set rs = server.CreateObject("adodb.recordset")
				rs.open "select lastmoney,paidmoney,is_pay_advance,advance_money from [Lebi_orders] where id = "& id &"",conn,1,3
				If Not rs.eof Then 
					If rs(2) = 0 Then 
					rs(0) = rs(0) - rs(3)
					rs(1) = rs(1) + rs(3)
					rs(2) = 1
					rs.update 
					If is_pay_usermoney = 2 Then 
						Set user = server.CreateObject("adodb.recordset")
						user.open "select usermoney,sumpay from [lebi_user] where user_id = '"& user_id &"'",conn,1,3
						If Not user.eof Then
								user(0) = user(0) - rs(3)
								user(1) = user(1) + rs(3)
								user.update()
								conn.execute("insert into [Lebi_money_log](m_user_id,m_order_num,m_sj,m_type,m_price,m_zt)values('"& user_id &"','"&order_number&"',"&sqlnowstring&",'"&Lang_Order(168)&"',-"& rs(3) &",1)")
						End If
						user.close : Set user = Nothing
					End If 
					conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& rs(3) &",1,'"& Lang_Order(185) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
					End If 
				End If 
				rs.close : Set rs = Nothing 
		End If 
        conn.execute "update [Lebi_orders] set orderzt='"&orderzt&"' where id="&id
        '将本订单金额加入会员总消费
        if InStr(request("orderzt"),"2")>0 And zt="0" Then
				If user_id <> "" Then
						If UnionApi = "1" Then
								Set rs = server.CreateObject("adodb.recordset")
								rs.open "select sumpay,u_parent from [Lebi_user] where user_id='"& user_id &"'",conn,1,3
								If Not rs.eof Then
										rs(0) = rs(0) + lastmoney
										rs.update
										Uparent = rs(1)
								Else
										Uparent = 0
								End If
								rs.close:Set rs=Nothing
						Else
								Set rs = server.CreateObject("adodb.recordset")
								rs.open "select sumpay from [Lebi_user] where user_id='"& user_id &"'",conn,1,3
								If Not rs.eof Then
										rs(0) = rs(0) + lastmoney
										rs.update
								End If
								rs.close:Set rs=Nothing
						End If 
				End If
				If UnionApi = "1" Then
						rem <-{更新联盟订单日志状态 2011-01-13 by 56770.kingdge
						If Uparent <> 0 Then
								conn.execute("update [Lebi_union_log] set l_state = 2 where order_number = '"& order_number &"'")
						End If
						rem }->
				End If 
				conn.execute "update [Lebi_orders] set paidmoney = paidmoney + "& lastmoney &",lastmoney = 0 where id="&id
				conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& lastmoney &",1,'"& Lang_Order(185) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
	    End If
        if Instr(orderzt,2)>0 Then
				If zt = 0 And Config_Lebi_Eshop(23) = 1 Then '付款后扣除库存 by 56770.kingdge 2012-05-16
					Set rsbasket = conn.execute("select id,basket_count,spvalue,product_type from [lebi_basket] where order_number = "& id &"")
					Do While Not rsbasket.eof 
					If rsbasket("product_type") = "unite" Then
						conn.execute("update [Lebi_product_unite] set buys = buys + "& rsbasket("basket_count")&",kucun = kucun - "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
					ElseIf rsbasket("product_type") = "groupon" Then
						conn.execute("update [Lebi_groupon_product] set buys = buys + "& rsbasket("basket_count")&",kucun = kucun - "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
					Else 
						conn.execute("update [Lebi_product] set buys = buys + "& rsbasket("basket_count")&",kucun = kucun - "& rsbasket("basket_count") &",html = 0 where id = " & rsbasket("id") &"")
						conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& rsbasket("basket_count") &",p_stock = p_stock - "& rsbasket("basket_count") &" where p_id = " & rsbasket("id") &" and s_value"& LangTxt &" = '"& rsbasket("spvalue") &"'")
					End If 
					rsbasket.movenext 
					Loop
					rsbasket.close : Set rsbasket = Nothing 
				End If 
				conn.execute "update [Lebi_orders] set zt=1,is_pay_advance=1 where id="&id
		End If
        if Instr(orderzt,2)=0 Then '如果订单取消支付状态，还原库存
				Set rsorder = server.CreateObject("adodb.recordset")
				rsorder.open "select zt,orderzt,lastmoney from [lebi_orders] where id = "& id &"",conn,1,3
				If Not rsorder.eof Then 
					If InStr(rsorder(1),2) > 0 And Config_Lebi_Eshop(23) = 1 Then
						Set rsbasket = conn.execute("select id,basket_count,spvalue,product_type from [lebi_basket] where order_number = "& id &"")
						Do While Not rsbasket.eof 
						If rsbasket("product_type") = "unite" Then
							conn.execute("update [Lebi_product_unite] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
						ElseIf rsbasket("product_type") = "groupon" Then
							conn.execute("update [Lebi_groupon_product] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
						Else 
							conn.execute("update [Lebi_product] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &",html = 0 where id = " & rsbasket("id") &"")
							conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys - "& rsbasket("basket_count") &",p_stock = p_stock + "& rsbasket("basket_count") &" where p_id = " & rsbasket("id") &" and s_value"& LangTxt &" = '"& rsbasket("spvalue") &"'")
						End If 
						rsbasket.movenext 
						Loop
						rsbasket.close : Set rsbasket = Nothing 
					End If 
					rsorder(0) = 0
					rsorder(1) = orderzt
					rsorder(2) = order_price
					rsorder.update()
				End If 
				rsorder.close : Set rsorder = Nothing 
				conn.execute "update [Lebi_orders] set lastmoney = "& order_price &",paidmoney = 0 where id="&id
				conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& order_price &",0,'"& Lang_Order(199) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
		End If
        if Instr(orderzt,5)>0 Then '如果订单无效状态，还原库存
				Set rsorder = server.CreateObject("adodb.recordset")
				rsorder.open "select zt,orderzt,lastmoney from [lebi_orders] where id = "& id &"",conn,1,3
				If Not rsorder.eof Then 
					If InStr(rsorder(1),3) > 0 And Config_Lebi_Eshop(23) = 2 Then
						Set rsbasket = conn.execute("select id,basket_count,spvalue,product_type from [lebi_basket] where order_number = "& id &"")
						Do While Not rsbasket.eof 
						If rsbasket("product_type") = "unite" Then
							conn.execute("update [Lebi_product_unite] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
						ElseIf rsbasket("product_type") = "groupon" Then
							conn.execute("update [Lebi_groupon_product] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &" where id = " & rsbasket("id") &"")
						Else 
							conn.execute("update [Lebi_product] set buys = buys - "& rsbasket("basket_count")&",kucun = kucun + "& rsbasket("basket_count") &",html = 0 where id = " & rsbasket("id") &"")
							conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys - "& rsbasket("basket_count") &",p_stock = p_stock + "& rsbasket("basket_count") &" where p_id = " & rsbasket("id") &" and s_value"& LangTxt &" = '"& rsbasket("spvalue") &"'")
						End If 
						rsbasket.movenext 
						Loop
						rsbasket.close : Set rsbasket = Nothing 
					End If 
					rsorder(0) = 0
					rsorder(1) = Replace(orderzt,",3","")
					rsorder(2) = order_price
					rsorder.update()
				End If 
				rsorder.close : Set rsorder = Nothing 
		End If
		If UnionApi = "1" Then 
				If InStr(orderzt,5)>0 Then
						conn.execute("update [Lebi_union_log] set l_state = 5 where order_number = '"& order_number &"'")
				End If
		End If 
        if request("f_jifen")="1" And is_jifen = 0 And user_id<>"" Then
				conn.execute "update [Lebi_user] set jifen=jifen+"& jifen &" where user_id='"& user_id &"'"
				LogInfo = LogInfo & Replace(Replace(Lang_Order(127),"[user]",user_id),"[num]",jifen)
				conn.execute "update [Lebi_orders] set is_jifen=1 where id="&id
		End If
        If jmail_cashoveron=1 And jmail_type<>0 And IsSendMail = 1 Then
		        Dim useremail,topic,mailbody,sendmsg
                Dim LoadMailInfo,linkurl,order_state_mes
				If LangTxt = "" Then 
						If IsSqlDataBase = 1 Then
								sql = "select l_file,l_rate from [lebi_Language] where (l_txt = '' or l_txt is null)"
						Else
								sql = "select l_file,l_rate from [lebi_Language] where (l_txt = '' or isnull(l_txt))"
						End If 
				Else
						sql = "select l_file,l_rate from [lebi_Language] where l_txt = '"& LangTxt &"'"
				End If 
				Set LangRs = conn.execute(sql)
				If Not LangRs.eof Then
						include "../include/Lebi_Lang/"& LangRs(0)
						moneyhl = LangRs(1)
				Else
						moneyhl = 1
				End If
				LangRs.close : Set LangRs = Nothing
				Set rs = conn.execute("select top 1 sitename"& LangTxt &" from [Lebi_system]")
				If Not rs.eof Then
						sitename = rs(0)
				End If
				rs.close : Set rs = Nothing
		        rem 增加自定义邮件内容 2008-1-21 by 56770.kingdge
		        LoadMailInfo = Replace(AdminLoadStyle("../include/Lebi_Data/E-mail"& LangTxt &".data"),"{$sitename}",sitename)
				If request.ServerVariables("SERVER_PORT") <> 80 Then
						linkurl = "http://"&Request.ServerVariables("SERVER_NAME")&":"&request.ServerVariables("SERVER_PORT")
				Else
						linkurl = "http://"&Request.ServerVariables("SERVER_NAME")
				End If
		        linkurl = linkurl & Eshop_url &"search/order.asp?order_number=[order_number]"
		        If InStr(orderzt,1)>0 Then order_state_mes=order_state_mes&""&Lebi_cart(114)&"&nbsp;&nbsp;"
		        If InStr(orderzt,2)>0 Then order_state_mes=order_state_mes&""&Lebi_cart(115)&"&nbsp;&nbsp;"
		        If InStr(orderzt,3)>0 Then order_state_mes=order_state_mes&""&Lebi_cart(116)&"&nbsp;&nbsp;"
		        If InStr(orderzt,4)>0 Then order_state_mes=order_state_mes&""&Lebi_cart(117)&"&nbsp;&nbsp;"
		        If InStr(orderzt,5)>0 Then order_state_mes=order_state_mes&""&Lebi_cart(118)&""
				Set shipdb = conn.execute("select s_name,s_no,s_date,s_fei1 from Lebi_ShipMes where s_order_number = '"& order_number &"'")
				If Not shipdb.eof Then
						ship_name = shipdb(0)
						ship_no = shipdb(1)
						ship_date = shipdb(2)
						ship_fei1 = dw & FormatNumber2(shipdb(3))
						order_state_mes=order_state_mes&"<br/>"& Lebi_cart(189) &"："& ship_name &"&nbsp;&nbsp;"& Lebi_cart(190) &"："& ship_no &"&nbsp;&nbsp;"& Lebi_cart(191) &"："& ship_date &"&nbsp;&nbsp;"& Lebi_cart(192) &"："& shipdb(3)
				end If
				shipdb.close : Set shipdb = Nothing
		        useremail=Request.Form("email")
		        topic=splits(Split(LoadMailInfo,"@@@")(4))
				ReplaceStyle "user_id",request.form("to_name"),topic
		        mailbody = Split(LoadMailInfo,"@@@")(5)
				ReplaceStyle "user_id",request.form("to_name"),mailbody
				ReplaceStyle "order_state",order_state_mes,mailbody
		        ReplaceStyle "order_number",Request.Form("order_number"),mailbody
				ReplaceStyle "order_price",dw & formatnumber2(dis_sum/moneyhl),mailbody
				ReplaceStyle "order_fei",dw & formatnumber2(fei/moneyhl),mailbody
				ReplaceStyle "packing_price",dw & formatnumber2(packing_price/moneyhl),mailbody
				ReplaceStyle "order_total",dw & formatnumber2(order_price/moneyhl),mailbody
				ReplaceStyle "order_url",Replace(linkurl,"[order_number]",Request.Form("order_number")),mailbody
				ReplaceStyle "admin_mes",fuyan,mailbody
		        Dim Email_Lebi
		        Set Email_Lebi = New Dv_SendMail
		        Email_Lebi.SendObject = jmail_type
		        Email_Lebi.ServerLoginName = jmail_sendmail
		        Email_Lebi.ServerLoginPass = jmail_sendpass
		        Email_Lebi.SendSMTP = jmail_smtp
		        Email_Lebi.SendFromEmail = jmail_frommail
		        Email_Lebi.SendFromName = jmail_sendname
		        If Email_Lebi.ErrCode = 0 Then
			            Email_Lebi.SendMail useremail,topic,splits(mailbody)
			            If jmail_sendmail<>"" And jmail_sendpass<>"" And jmail_smtp<>"" Then
				                sendmsg = Lang_Order(128)
			            Else
			                    sendmsg = Lang_Order(129)
			            End If
		        Else
		                sendmsg= Lang_Order(129)
		        End If
		        Set Email_Lebi = Nothing
        End If
		LogInfo = LogInfo & Lang_Order(130) &" ["& order_number &"]"
		If order_state_mes <> "" Then LogInfo = LogInfo & "["& order_state_mes &"]"
		ManageLog LogInfo
	    m_s="·"& Lang_sys(68)
'        If request("f_jifen")=1 Then
'                m_s=m_s&"<br>·此订单共返还会员积分 <font color=red>"&jifen&"</font> 点。"
'        End If
        If jmail_cashoveron=1 And jmail_type<>0 Then
                m_s=m_s&"<br />·"&sendmsg&""
        End If
		Call Up_mes(Lang_sys(69),m_s,0,"?id="& id,0,0,2,1)
End Sub

Sub price_ok()
		admin_flag=",1.11,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        id=CheckNum(request("id"),0)
		pricec = CheckNum(request("pricec"),0)
		pricef = CheckNum(request("pricef"),0)
		packing_price = CheckNum(request("packing_price"),0)
		discount = CheckNum(request("discount"),0)
		jifen = CheckNum(request("jifen"),0)
		order_number = safereplace(request("order_number"))
		paidmoney = CheckNum(request("paidmoney"),0)
		If discount <> 0 Then
				discount = discount / 100
                conn.execute("update [Lebi_orders] set dis_sum = totalcash * "& discount &",discount = "& discount &" where id = "& id &"")
				LogInfo = LogInfo & Replace(Lang_Order(131),"[str]",discount * 100)
		End If
		If pricec <> 0 Then
                conn.execute("update [Lebi_orders] set dis_sum = dis_sum + "& pricec &" where id = "& id &"")
				LogInfo = LogInfo & Replace(Lang_Order(132),"[str]",pricec)
		End If
		If pricef <> 0 Then
                conn.execute("update [Lebi_orders] set fei = fei + "& pricef &" where id = "& id &"")
				LogInfo = LogInfo & Replace(Lang_Order(132),"[str]",pricef)
		End If
		rem	<-{ 包装费调整 2008-3-23 by 56770.WangLei
		If packing_price <> 0 Then
                conn.execute("update [Lebi_orders] set packing_price = packing_price + "& packing_price &" where id = "& id &"")
				LogInfo = LogInfo & Replace(Lang_Order(132),"[str]",packing_price)
		End If
		If jifen <> 0 Then
                conn.execute("update [Lebi_orders] set jifen = jifen + "& jifen &" where id = "& id &"")
				LogInfo = LogInfo & Replace(Lang_Order(166),"[str]",jifen)
		End If
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select lastmoney,fei,dis_sum,packing_price,fapiao_money,coupon_price,paidmoney from [Lebi_orders] where id = "& id &"",conn,1,3
		If Not rs.eof Then 
			rs(0) = rs(1) + rs(2) + rs(3) + rs(4) - rs(5) - paidmoney
			If CDbl(paidmoney) <> CDbl(rs(6)) Then 
				LogInfo = LogInfo & Replace(Lang_Order(201),"[str]",paidmoney)
				If CDbl(paidmoney) - CDbl(rs(6)) > 0 Then 
					conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& CDbl(paidmoney) - CDbl(rs(6)) &",1,'"& Lang_Order(202) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
				Else
					conn.execute("insert into [Lebi_Orders_Paylog](p_price,p_type,p_content,p_time,oid,admin_name)values("& CDbl(paidmoney) - CDbl(rs(6)) &",0,'"& Lang_Order(202) &"',"& sqlnowstring &","& id &",'"& Eshop_Lebi_name &"')")
				End If 
				rs(6) = paidmoney
			End If 
			rs.update 
		End If 
		rs.close : Set rs = Nothing 
		conn.execute("insert into [Lebi_orders_log](l_name,l_order_number,l_time,l_content)values('"&Eshop_Lebi_name&"','"& order_number &"',"&sqlnowstring&",'"& LogInfo &"')")
		LogInfo = LogInfo & Lang_Order(130) &" ["& order_number &"]"
		ManageLog LogInfo
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?id="& id,0,0,2,1)
End Sub

Sub ship_ok()
		admin_flag=",1.11,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        id = CheckNum(request("id"),0)
		deliver_price = CheckNum(request("deliver_price"),0)
		sendtype = safereplace(request("sendtype"))
		order_number = safereplace(request("order_number"))
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select fei,sendtype,lastmoney,dis_sum,packing_price,fapiao_money,coupon_price,paidmoney from [Lebi_orders] where id = "& id &"",conn,1,3
		If Not rs.eof Then 
			rs(0) = deliver_price
			rs(1) = sendtype
			rs(2) = deliver_price + rs(3) + rs(4) + rs(5) - rs(6) - rs(7)
			rs.update 
		End If 
		rs.close : Set rs = Nothing 
		LogInfo = Replace(Lang_Order(179),"[order_number]","["& order_number &"]")
		LogInfo = Replace(LogInfo,"[sendtype]",sendtype)
		LogInfo = Replace(LogInfo,"[price]",formatnumber2(deliver_price) &" 元")
		ManageLog LogInfo
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?id="& id,0,0,2,1)
End Sub

Sub huangou
		admin_flag=",1.1,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        f_jifen=CheckNum(request("f_jifen"),0)
        orderzt=CheckNum(request("orderzt"),0)
        id=CheckNum(request("id"),0)
        fuyan=safereplace(request("fuyan"))
		pricef = CheckNum(request("pricef"),0)
		If pricef <> 0 Then
                conn.execute("update [Lebi_orders] set fei = fei + "& pricef &" where id = "& id &"")
		End If
        set rs=server.createobject("adodb.recordset")
        sql="select user_id,totalcash from [Lebi_orders] where id=" & id
        rs.open sql, conn, 1, 1
        user_id=rs("user_id")
		totalcash=rs("totalcash")
        rs.close:set rs=nothing
        set rs=server.createobject("adodb.recordset")
        sql="select * from [Lebi_user] where user_id='" & user_id &"'"
        rs.open sql, conn, 1, 1
        If CLng(rs("jifen"))<CLng(totalcash) Then
                response.write "<script language='javascript'>alert('"& Lang_Order(135) &"');javascript:history.back();</script>"
                Response.End
        End If
        rs.close:set rs=nothing
        conn.execute "update [Lebi_orders] set fuyan='"&fuyan&"',orderzt='"&orderzt&"' where id="&id
		if request("f_jifen")="1" then conn.execute "update [Lebi_user] set jifen=jifen-"& totalcash &" where user_id='"& user_id &"'"
		if request("f_jifen")="1" then conn.execute "update [Lebi_orders] set totalcash=0 where id="&id
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?id="& id,0,0,2,1)
'        If request("f_jifen")=1 Then
'                m_s=m_s&"<br>·此订单共扣除会员积分 <font color=red>"&totalcash&"</font> 点。"
'        End If
End Sub

Sub up_b ' WangLei 2008-1-20  增加捆绑促销产品库存更新
		admin_flag=",1.10,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        rem 更新订单 2006-3-14 56770.kingdge
	    id=CheckNum(request("id"),0)
	    b_id=CheckNum(request("b_id"),0)
	    p_id=CheckNum(request("p_id"),0)
        b_count=CheckNum(request("b_count"),1)
        Set rs = conn.execute("select LangTxt from [Lebi_orders] where id="& id &"")
        LangTxt = rs("LangTxt")
        rs.close : set rs = nothing
        sql = "select basket_id,id,price,basket_count,product_type,spvalue from [Lebi_basket] where order_number="& id &" and Isgift=0"
	    set Rs = conn.execute(sql)
	    do while not rs.eof
	    b_count = checknum(request("count_"&rs("basket_id")&""),1)
	    b_price = checknum(request("price_"&rs("basket_id")&""),0)
	    sum_b_prce = sum_b_prce + b_price*b_count
		If rs("product_type") = "unite" Then
				sql_s = "select kucun,buys from [Lebi_product_unite] where id = "& rs("id") &""
				set rs_s = server.CreateObject("Adodb.recordset")
				rs_s.open sql_s,conn,1,3
				If not rs_s.eof Then
						If clng(b_count)>clng(rs("basket_count")) Then
								If clng(b_count)-clng(rs("basket_count"))>clng(rs_s("kucun")) Then
										response.write"<script>alert('"& Lang_Order(35) &"');javascript:history.back();</script>"
										response.End()
								Else
										If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
											rs_s(0) = rs_s(0) - (clng(b_count)-clng(rs("basket_count")))
											rs_s(1) = rs_s(1) + (clng(b_count)-clng(rs("basket_count")))
											rs_s.update
										End If 
								End If
						Else
								If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
									rs_s(0) = rs_s(0) + (clng(rs("basket_count"))-clng(b_count))
									rs_s(1) = rs_s(1) - (clng(rs("basket_count"))-clng(b_count))
									rs_s.update
								End If 
						End If
				End If
				rs_s.close:set rs_S=Nothing
		ElseIf rs("product_type") = "groupon" Then
				sql_s = "select kucun,buys from [Lebi_groupon_product] where id = "& rs("id") &""
				set rs_s = server.CreateObject("Adodb.recordset")
				rs_s.open sql_s,conn,1,3
				If not rs_s.eof Then
						If clng(b_count)>clng(rs("basket_count")) Then
								If clng(b_count)-clng(rs("basket_count"))>clng(rs_s("kucun")) Then
										response.write"<script>alert('"& Lang_Order(35) &"');javascript:history.back();</script>"
										response.End()
								Else
										If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
											rs_s(0) = rs_s(0) - (clng(b_count)-clng(rs("basket_count")))
											rs_s(1) = rs_s(1) + (clng(b_count)-clng(rs("basket_count")))
											rs_s.update
										End If 
								End If
						Else
								If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
									rs_s(0) = rs_s(0) + (clng(rs("basket_count"))-clng(b_count))
									rs_s(1) = rs_s(1) - (clng(rs("basket_count"))-clng(b_count))
									rs_s.update
								End If 
						End If
				End If
				rs_s.close:set rs_S=nothing
		Else
				sql_s = "select kucun,buys from [Lebi_product] where id = "& rs("id") &""
				set rs_s = server.CreateObject("Adodb.recordset")
				rs_s.open sql_s,conn,1,3
				If not rs_s.eof Then
						If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
							conn.execute("update [Lebi_product] set buys = buys + "& b_count &",kucun = kucun - "& b_count &",html = 0 where id = " & rs("id") &"")
							conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& b_count &",p_stock = p_stock - "& rs("basket_count") &" where p_id = " & rs("id") &" and s_value"& LangTxt &" = '"& rs("spvalue") &"'")
						End If 
						If clng(b_count)>clng(rs("basket_count")) Then
								If clng(b_count)-clng(rs("basket_count"))>clng(rs_s("kucun")) Then
										response.write"<script>alert('"& Lang_Order(35) &"');javascript:history.go(-1);</script>"
										response.End()
								Else
										If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
											rs_s(0) = rs_s(0) - (clng(b_count)-clng(rs("basket_count")))
											rs_s(1) = rs_s(1) + (clng(b_count)-clng(rs("basket_count")))
											rs_s.update
											conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& (clng(b_count)-clng(rs("basket_count"))) &",p_stock = p_stock - "& (clng(b_count)-clng(rs("basket_count"))) &" where p_id = " & rs("id") &" and s_value"& LangTxt &" = '"& rs("spvalue") &"'")
										End If 
								End If
						Else
								If Config_Lebi_Eshop(23) = 0 Then '下单后扣除库存 by 56770.kingdge 2012-05-16
									rs_s(0) = rs_s(0) + (clng(rs("basket_count"))-clng(b_count))
									rs_s(1) = rs_s(1) - (clng(rs("basket_count"))-clng(b_count))
									rs_s.update
									conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys - "& (clng(rs("basket_count"))-clng(b_count)) &",p_stock = p_stock + "& (clng(rs("basket_count"))-clng(b_count)) &" where p_id = " & rs("id") &" and s_value"& LangTxt &" = '"& rs("spvalue") &"'")
								End If 
						End If
				End If
				rs_s.close:set rs_S=nothing
		End If
	    SQL = "update [Lebi_basket] set basket_count = "& b_count &",price = "& b_price &"  where basket_id = "& rs("basket_id") &""
	    conn.execute(SQL)
	    rs.movenext
	    loop
        rs.close:set rs=nothing
	    response.redirect"?action=up_b_next&id="& id &"&sum_b_prce="&sum_b_prce&""
	    response.End
End Sub

Sub up_b_next
		admin_flag=",1.10,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        rem 重新计算折扣
	    id=CheckNum(request("id"),0)
	    sum_b_prce=CheckNum(request("sum_b_prce"),0)
        set rs = conn.execute("select user_id,coupon_price,order_number from [Lebi_orders] where id=" & id &"")
        user_id = Trim(rs(0))
		coupon_price = CheckNum(rs(1),0)
		order_number = rs(2)
        rs.close:set rs=Nothing
		rem 获取会员等级 用来计算折扣和积分
		Dim usergrade
        Set rs=conn.execute("select user_grade from [Lebi_user] where user_id='"&user_id&"'")
		If rs.eof Then
		        dis_grade=1
		Else
		        dis_grade=rs(0)
		End If
		rs.close:Set rs=Nothing
		If IsSqlDataBase = 1 Then
	    Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(sum_b_prce)&" and charindex('"&dis_grade&"',z_flag)>0 order by z_id desc")
        Else
		Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(sum_b_prce)&" and instr(z_flag,"&dis_grade&")>0 order by z_id desc")
		End If
        If rss.eof Then
                z_price="0"
                z_discount="1.00"
        Else
                z_price=rss("z_price")
                z_discount=rss("z_discount")
        End if
        rss.close:Set rss=Nothing
		rem <-{重新计算购物积分 2011-2-3 by 56770.kingdge
		TotalPrice = 0 : jifen1 = 0 : jifen2 = 0 : cbprice = 0
		set rs = conn.execute("select b.price,b.basket_count,p.p_jifen,p.categoryid,p.cbprice from [lebi_basket] as b,[lebi_product] as p where order_number = "& id &" and b.id = p.id")
		if Not rs.eof then
				do While Not rs.EOF
				c_rate = GetCategoryRate(rs("categoryid"))
				TotalPrice = TotalPrice + (rs("price") * rs("basket_count"))
				cbprice = cbprice + (rs("cbprice") * rs("basket_count"))
				jifen1 = jifen1 + (rs("p_jifen") * rs("basket_count"))
				If InStr(c_rate,"|") = 0 Then c_rate = "1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1"
				If IsNumeric(Split(c_rate,"|")(dis_grade-1)) Then
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * Split(c_rate,"|")(dis_grade-1))
				Else
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * cache_buy_jifen(dis_grade))
				End If
				rs.MoveNext
		Loop
		End If
		rs.close : Set rs=Nothing
		jifen = Clng(jifen1 + (jifen2 * z_discount))
		rem }->
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select lastmoney,fei,dis_sum,packing_price,fapiao_money,coupon_price,paidmoney,totalcash,discount,jifen from [Lebi_orders] where order_number = '"& order_number &"'",conn,1,3
		If Not rs.eof Then 
			dis_sum = (sum_b_prce*z_discount)-CheckNum(coupon_price,0)
			rs(2) = dis_sum
			rs(0) = rs(1) + dis_sum + rs(3) + rs(4) - rs(5) - rs(6)
			rs(7) = sum_b_prce
			rs(8) = z_discount
			rs(9) = jifen
			rs.update 
		End If 
		rs.close : Set rs = Nothing 
		If UnionApi = "1" Then
				rem <-{更新联盟订单日志金额 2011-01-13 by 56770.kingdge
				conn.execute("update [Lebi_union_log] set l_price = "& sum_b_prce*z_discount &",l_price2 = "& (TotalPrice*z_discount)-cbprice &" where order_number = '"& order_number &"'")
				rem }->
		End If 
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?id="& id,0,0,2,1)
End Sub

Sub del_b  ' WangLei 2008-1-20  增加捆绑促销产品库存更新
		admin_flag=",1.10,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        On Error Resume Next
        rem 删除订单商品 2006-3-14 by 56770.kingdge
        b_id= Replace(safereplace(Trim(request("b_id"))),"，",",")
		If Right(b_id,1) = "," Then b_id = Left(b_id,Len(b_id)-1)
        if b_id="" then
                response.write"<SCRIPT language=JavaScript>alert('"& Lang_sys(41) &"');javascript:history.go(-1)</SCRIPT>"
                response.end
        end If
		id=CheckNum(request("id"),0)
        rem 重新计算折扣
        set rs=conn.execute("select totalcash,user_id,coupon_price,order_number,LangTxt from [Lebi_orders] where id=" & id &"")
        user_id = Trim(rs(1))
		strtotalcash = rs(0)
		coupon_price = rs(2)
		order_number = rs(3)
		LangTxt = rs(4)
        rs.close:set rs=Nothing
		rem 获取会员等级 用来计算折扣和积分
        Set rs=conn.execute("select user_grade from [Lebi_user] where user_id='"&user_id&"'")
		If rs.eof Then
		        dis_grade=1
		Else
		        dis_grade=Trim(rs(0))
		End If
		rs.close:Set rs=Nothing
        Set rs = server.CreateObject("adodb.recordset")
		rs.open "select id,basket_count,price,product_type,spvalue from [Lebi_basket] where basket_id in ("&b_id&")",conn,1,3
	    If Not rs.eof Then
				Do While Not rs.eof
		        sum_b_price = sum_b_price+ (rs("basket_count")*rs("price"))
		        rem 如果订单未处理 不对库存进行返还操作 2006-9-13 by 56770.kingdge
				If rs("product_type") = "unite" Then
'						If instr(orderzt,"3")=0 Then '如果没发货操作库存 2009-6-11 by 56770.kingdge
'								conn.execute("update [Lebi_product_unite] set kucun=kucun+"&rs("basket_count")&" where id="&rs("id")&"")
'						End If
						If Config_Lebi_Eshop(23) = 0 Then '若提交订单后扣除库存，删除后返回库存 by 56770.kingdge 2012-05-16
							conn.execute("update [Lebi_product_unite] set buys = buys - "& rs("basket_count") &",kucun = kucun + "& rs("basket_count") &" where id = " & rs(0) &"")
						End If 
				ElseIf rs("product_type") = "groupon" Then
						If Config_Lebi_Eshop(23) = 0 Then
							conn.execute("update [Lebi_groupon_product] set buys = buys - "& rs("basket_count") &",kucun = kucun + "& rs("basket_count") &" where id = " & rs(0) &"")
						End If 
				Else
'						If instr(orderzt,"3")=0 Then '如果没发货操作库存 2009-6-11 by 56770.kingdge
'								conn.execute("update [Lebi_product] set kucun=kucun+"&rs("basket_count")&" where id="&rs("id")&"")
'						End If
						If Config_Lebi_Eshop(23) = 0 Then '若提交订单后扣除库存，删除后返回库存 by 56770.kingdge 2012-05-16
							conn.execute("update [Lebi_product] set buys = buys - "& rs("basket_count") &",kucun = kucun + "& rs("basket_count") &" where id = " & rs(0) &"")
							conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys - "& rs("basket_count") &",p_stock = p_stock + "& rs("basket_count") &" where p_id = "& rs(0) &" and s_value"& LangTxt &" = '"& rs(4) &"'")
						End If 
				End If
		        rs.delete()
				rs.update()
				rs.movenext
				loop
	    End If
	    rs.close:Set rs=Nothing
	    If IsSqlDataBase = 1 Then
	            Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(strtotalcash-sum_b_price)&" and charindex('"&dis_grade&"',z_flag)>0 order by z_id desc")
        Else
		        Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(strtotalcash-sum_b_price)&" and instr(z_flag,"&dis_grade&")>0 order by z_id desc")
		End If
        If rss.eof Then
                z_price="0"
                z_discount="1.00"
        Else
                z_price=rss("z_price")
                z_discount=rss("z_discount")
        End if
        rss.close:Set rss=Nothing
		rem <-{重新计算购物积分 2011-2-3 by 56770.kingdge
		TotalPrice = 0 : jifen1 = 0 : jifen2 = 0 : cbprice = 0
		set rs = conn.execute("select b.price,b.basket_count,p.p_jifen,p.categoryid,p.cbprice from [lebi_basket] as b,[lebi_product] as p where order_number = "& id &" and b.id = p.id")
		if Not rs.eof then
				do While Not rs.EOF
				c_rate = GetCategoryRate(rs("categoryid"))
				TotalPrice = TotalPrice + (rs("price") * rs("basket_count"))
				cbprice = cbprice + (rs("cbprice") * rs("basket_count"))
				jifen1 = jifen1 + (rs("p_jifen") * rs("basket_count"))
				If InStr(c_rate,"|") = 0 Then c_rate = "1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1"
				If IsNumeric(Split(c_rate,"|")(dis_grade-1)) Then
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * Split(c_rate,"|")(dis_grade-1))
				Else
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * cache_buy_jifen(dis_grade))
				End If
				rs.MoveNext
		Loop
		End If
		rs.close : Set rs=Nothing
		jifen = Clng(jifen1 + (jifen2 * z_discount))
		rem }->
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select lastmoney,fei,dis_sum,packing_price,fapiao_money,coupon_price,paidmoney,totalcash,discount,jifen from [Lebi_orders] where id="& id &"",conn,1,3
		If Not rs.eof Then 
			dis_sum = Replace(formatnumber2(((strtotalcash-sum_b_price)*z_discount)-CheckNum(coupon_price,0)),",","")
			rs(2) = dis_sum
			rs(0) = rs(1) + dis_sum + rs(3) + rs(4) - rs(5) - rs(6)
			rs(7) = rs(7) - sum_b_price
			rs(8) = z_discount
			rs(9) = jifen
			rs.update 
		End If 
		rs.close : Set rs = Nothing 
		If UnionApi = "1" Then
				rem <-{更新联盟订单日志金额 2011-01-13 by 56770.kingdge
				conn.execute("update [Lebi_union_log] set l_price = "& Replace(formatnumber2(((strtotalcash-sum_b_price)*z_discount)-CheckNum(coupon_price,0)),",","") &",l_price2 = "& (TotalPrice * z_discount) - cbprice &" where order_number = '"& order_number &"'")
				rem }->
		End If 
		Call Up_mes(Lang_sys(43),"·"& Lang_sys(42),0,"?id="& id,0,0,2,1)
End Sub

Sub add_b
		admin_flag=",1.10,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        ' On Error Resume Next
        b_pro_id=Safereplace(request("b_pro_id"))
	    b_pro_num=CheckNum(request("b_pro_num"),1)
	    b_pro_price=CheckNum(request("b_pro_price"),0)
	    id=CheckNum(request("id"),0)
	    b_pro_spvalue = safereplace(trim(request("b_pro_spvalue")))
		b_pro_spname = safereplace(trim(request("b_pro_spname")))
		LangTxt = safereplace(request("LangTxt"))
        rem 重新计算折扣
	    sumprice=b_pro_price*b_pro_num
        set Rs = conn.execute("select totalcash,user_id,order_time,coupon_price,order_number from [Lebi_orders] where id=" & id &"")
	    If not rs.eof Then
                user_id=Trim(rs(1))
	            totalcash=rs(0)
	            order_time=rs(2)
				coupon_price = rs(3)
				order_number = rs(4)
	    End If
        rs.close:set rs=Nothing
	    rem 获取会员等级 用来计算折扣和积分
	    Dim dis_grade
        Set rs=conn.execute("select user_grade from [Lebi_user] where user_id='"&user_id&"'")
	    If rs.eof Then
		        dis_grade=1
	    Else
		        dis_grade=Trim(rs(0))
	    End If
	    rs.close:Set rs=Nothing
        Set rs=conn.execute("select id,product_name"& langtxt &",bianhao from [Lebi_product] where bianhao = '"&b_pro_id&"'")
	    If rs.eof Then
                response.write"<SCRIPT language=JavaScript>alert('"& Lang_Order(164) &"');javascript:history.go(-1);</SCRIPT>"
		        response.End
	    Else
		        Set rss=server.CreateObject("adodb.recordset")
				rss.open "select * from [Lebi_basket] where id="& rs(0) &" and order_number="& id &" and spvalue='"& b_pro_spvalue &"' and spname='"& b_pro_spname &"'",conn,1,3
		        If Not rss.eof Then
                        rss("basket_count") = b_pro_num
						rss("basket_date") = order_time
						rss("price") = b_pro_price
						rss("spvalue") = b_pro_spvalue
						rss("spname") = b_pro_spname
						rss.update
		        Else
						rss.addnew
						rss("id") = rs(0)
						rss("user_id") = user_id
						rss("product_name") = rs(1)
						rss("bianhao") = rs(2)
						rss("order_number") = id
                        rss("basket_count") = b_pro_num
						rss("basket_date") = order_time
						rss("price") = b_pro_price
						rss("spvalue") = b_pro_spvalue
						rss("spname") = b_pro_spname
						rss("father") = 1
						rss("isgift") = 0
						rss("is_booking") = 0
						rss("advance_money") = 0
						rss.update
		        End If
		        rss.close:Set rss=Nothing
				If Config_Lebi_Eshop(23) = 0 Then '提交订单后扣除库存 by 56770.kingdge 2012-05-14
					conn.execute("update [Lebi_product] set buys = buys + "& b_pro_num &",kucun = kucun - "& b_pro_num &",html = 0 where id = " & rs(0) &"")
					conn.execute("update [Lebi_Product_Stock] set p_buys = p_buys + "& b_pro_num &",p_stock = p_stock - "& b_pro_num &" where p_id = " & rs(0) &" and s_value"& LangTxt &" = '"& b_pro_spvalue &"'")
				End If 
	    End If
	    rs.close:Set rs=Nothing
	    If IsSqlDataBase = 1 Then
	            Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(totalcash+sumprice)&" and charindex('"&dis_grade&"',z_flag)>0 order by z_id desc")
        Else
		        Set rss=conn.execute("select top 1 * from [Lebi_discount] where z_price<="&CLng(totalcash+sumprice)&" and instr(z_flag,"&dis_grade&")>0 order by z_id desc")
	    End If
        If rss.eof Then
                z_price="0"
                z_discount="1.00"
        Else
                z_price=rss("z_price")
                z_discount=rss("z_discount")
        End if
        rss.close:Set rss=Nothing
		rem <-{重新计算购物积分 2011-2-3 by 56770.kingdge
		TotalPrice = 0 : jifen1 = 0 : jifen2 = 0
		set rs = conn.execute("select b.price,b.basket_count,p.p_jifen,p.categoryid,p.cbprice from [lebi_basket] as b,[lebi_product] as p where order_number = "& id &" and b.id = p.id")
		if Not rs.eof then
				do While Not rs.EOF
				c_rate = GetCategoryRate(rs("categoryid"))
				TotalPrice = TotalPrice + (rs("price") * rs("basket_count"))
				cbprice = cbprice + (rs("cbprice") * rs("basket_count"))
				jifen1 = jifen1 + (rs("p_jifen") * rs("basket_count"))
				If InStr(c_rate,"|") = 0 Then c_rate = "1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1"
				If IsNumeric(Split(c_rate,"|")(dis_grade-1)) Then
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * Split(c_rate,"|")(dis_grade-1))
				Else
						jifen2 = jifen2 + (rs("price") * rs("basket_count") * cache_buy_jifen(dis_grade))
				End If
				rs.MoveNext
		Loop
		End If
		rs.close : Set rs=Nothing
		jifen = Clng(jifen1 + (jifen2 * z_discount))
		rem }->
		Set rs = server.CreateObject("adodb.recordset")
		rs.open "select lastmoney,fei,dis_sum,packing_price,fapiao_money,coupon_price,paidmoney,totalcash,discount,jifen from [Lebi_orders] where id="& id &"",conn,1,3
		If Not rs.eof Then 
			dis_sum = Replace(formatnumber2(((totalcash+sumprice)*z_discount)-CheckNum(coupon_price,0)),",","")
			rs(2) = dis_sum
			rs(0) = rs(1) + dis_sum + rs(3) + rs(4) - rs(5) - rs(6)
			rs(7) = rs(7) + sumprice
			rs(8) = z_discount
			rs(9) = jifen
			rs.update 
		End If 
		rs.close : Set rs = Nothing 
		If UnionApi = "1" Then
				rem <-{更新联盟订单日志金额 2011-01-13 by 56770.kingdge
				conn.execute("update [Lebi_union_log] set l_price = "& Replace(formatnumber2(((totalcash+sumprice)*z_discount)-CheckNum(coupon_price,0)),",","") &",l_price2 = "& (TotalPrice * z_discount) - cbprice &" where order_number = '"& order_number &"'")
				rem }->
		End If 
		Call Up_mes(Lang_sys(45),"·"& Lang_sys(44),0,"?id="& id,0,0,2,1)
End Sub

Sub sup()
        If OnlyRead = 1 Then OnlyReadMessage()
        Dim Sup_conn, Sup_ConnStr
	    Sup_ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password="&pass&";Data Source = " & Server.MapPath(QS_ACData)
	    Set Sup_conn = Server.CreateObject("ADODB.Connection")
	    Sup_conn.open Sup_ConnStr
		On Error Resume Next
	    If Err Then
		        err.Clear
		        Set Eshop_conn = Nothing
		        Response.Write "Unable to connect database."
		        Response.End
	    End If
		id = checknum(request("id"),0)
        order_number = safereplace(request("order_number"))
		Set rs = conn.execute("select bianhao,product_name,basket_count,price,spvalue,spname from [Lebi_basket] where order_number = "& id &"")
		Do While Not rs.eof
                Set rss = Sup_conn.execute("select qs_id,cbprice from [Lebi_product_temp] where bianhao = '"& rs("bianhao") &"'")
				If Not rss.eof Then
				qs_id = rss("qs_id")
				cbprice = rss("cbprice")
				Else
				qs_id = 0
				cbprice = 0
				End If
				rss.close : Set rss = Nothing
				Set rss = server.CreateObject("adodb.recordset")
				sql = "select qs_id,o_no,p_bianhao,p_name,p_qty,p_price,spvalue,spname,o_state,o_pay,o_cash,o_reach,o_date from [56770_orders] where o_no = '"& order_number &"' and p_bianhao = '"& rs("bianhao") &"' and qs_id = "& qs_id &""
				rss.open sql,Sup_conn,1,3
				If rss.eof Then
				rss.addnew
					rss("qs_id") = qs_id
					rss("o_no") = order_number
					rss("p_bianhao") = rs("bianhao")
					rss("p_name") = rs("product_name")
					rss("p_qty") = rs("basket_count")
					rss("p_price") = cbprice
					rss("spvalue") = rs("spvalue")
					rss("spname") = rs("spname")
					rss("o_state") = 0
					rss("o_pay") = 0
					rss("o_cash") = 0
					rss("o_reach") = 0
					rss("o_date") = Date()
					rss.update
				Else
					rss("p_name") = rs("product_name")
					rss("p_qty") = rs("basket_count")
					rss("p_price") = cbprice
					rss("spvalue") = rs("spvalue")
					rss("spname") = rs("spname")
					rss("o_state") = 0
					rss("o_pay") = 0
					rss("o_cash") = 0
					rss("o_reach") = 0
					rss("o_date") = Date()
					rss.update
				End If
				rss.close : Set rss = Nothing
		rs.movenext
		Loop
		rs.close : Set rs = Nothing
		Call Up_mes(Lang_sys(45),"·"& Lang_sys(44),0,"?id="& id,0,0,2,1)
End Sub

Sub profile()
		admin_flag=",1.1,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
        If OnlyRead = 1 Then OnlyReadMessage()
        id=CheckNum(request("id"),0)
        to_name=safereplace(request("to_name"))
        to_mobile=Safereplace(request("to_mobile"))
        to_tel=safereplace(request("to_tel"))
        to_tel2=safereplace(request("to_tel2"))
        to_zip=Safereplace(request("to_zip"))
        to_adds=safereplace(request("to_adds"))
        to_other=safereplace(request("to_other"))
        from_name=Safereplace(request("from_name"))
        from_mobile=safereplace(request("from_mobile"))
        from_tel=safereplace(request("from_tel"))
        from_email=Safereplace(request("from_email"))
        from_zip=safereplace(request("from_zip"))
        from_adds=Safereplace(request("from_adds"))
        from_other=safereplace(request("from_other"))
        fapiao_company=safereplace(request("fapiao_company"))
        fapiao_adds=Safereplace(request("fapiao_adds"))
        fapiao_zip=safereplace(request("fapiao_zip"))
		from_adds2=Safereplace(request("from_adds2"))
        from_city=safereplace(request("from_city"))
        from_state=safereplace(request("from_state"))
        from_country=CheckNum(request("from_country"),0)
		Set rs = server.CreateObject("adodb.recordset")
        rs.open "select * from [Lebi_orders] where id=" & id &"",conn,1,3
		If sys_soft = 0 Then 
				rs("to_name") = to_name
				rs("to_mobile") = to_mobile
				rs("to_tel") = to_tel
				rs("to_tel2") = to_tel2
				rs("to_zip") = to_zip
				rs("to_adds") = to_adds
				rs("to_other") = to_other
		End If 
		rs("from_name") = from_name
		rs("from_mobile") = from_mobile
		rs("from_tel") = from_tel
		rs("from_email") = from_email
		rs("from_zip") = from_zip
		rs("from_adds") = from_adds
		rs("from_other") = from_other
		rs("fapiao_company") = fapiao_company
		rs("fapiao_adds") = fapiao_adds
		rs("fapiao_zip") = fapiao_zip
		If sys_soft = 1 Then 
				rs("from_adds2") = from_adds2
				rs("from_city") = from_city
				rs("from_state") = from_state
				rs("from_country") = from_country
		End If 
		rs.update()
        rs.close:set rs=Nothing
		ManageLog LogInfo
		Call Up_mes(Lang_sys(69),"·"& Lang_sys(68),0,"?id="& id,0,0,2,1)
End Sub

Sub order_main  'WangLei 2008-1-20
		admin_flag=",1.1,"
		If Eshop_Lebi_name="" Or instr(","&Eshop_Lebi_flag&",",admin_flag)=0 Then
				adminflag()
		End If
		OrderLock = 0
		id = CheckNum(request("id"),0)
		sql = "select * from [Lebi_orders] where id=" & id
		set Rs = conn.execute(sql)
		orderzt=rs("orderzt")
		totalcash=rs("totalcash")
		order_number=rs("order_number")
		order_time=rs("order_time")
		sendtype=rs("sendtype")
		paymenttype=rs("paymenttype")
		fei=rs("fei")
		jifen=rs("jifen")
		user_id=rs("user_id")
		to_name=rs("to_name")
		to_zip=rs("to_zip")
		to_tel=rs("to_tel")
		to_tel2=rs("to_tel2")
		to_adds=rs("to_adds")
		to_other=rs("to_other")
		to_mobile=rs("to_mobile")
		from_name=rs("from_name")
		from_zip=rs("from_zip")
		from_tel=rs("from_tel")
		from_adds=rs("from_adds")
		from_other=rs("from_other")
		from_email=rs("from_email")
		from_mobile=rs("from_mobile")
		fuyan=rs("fuyan")
		coupon_price = rs("coupon_price")
		If IsNull(coupon_price) Then coupon_price = 0
		zt=rs("zt")
		iffapiao=rs("iffapiao")
		fapiao_company=rs("fapiao_company")
		fapiao_adds=rs("fapiao_adds")
		fapiao_zip=rs("fapiao_zip")
		packing_name = ""
		packing_id = rs("packing_id")
		packing_price = rs("packing_price")
		is_jifen = rs("is_jifen")
		fapiao_money = rs("fapiao_money")
		If packing_id <> 0 Then
			Set rspk = conn.execute("select packing_name from [Lebi_packing] where id="&packing_id)
			If Not rspk.eof Then packing_name = rspk("packing_name")
			rspk.close:Set rspk = Nothing
		End If
		is_booking = rs("is_booking")
		advance_money = rs("advance_money")
		is_pay_advance = rs("is_pay_advance")
		z_discount=rs("discount")
		dis_sum=rs("dis_sum")
		mark=rs("mark")
		remark=rs("remark")
		LangName = rs("LangName")
		LangTxt = rs("LangTxt")
		paidmoney = rs("paidmoney")
		lastmoney = rs("lastmoney")
		from_adds2=rs("from_adds2")
		from_city=rs("from_city")
		from_state=rs("from_state")
		from_country=checknum(rs("from_country"),0)
		rs.close
		set rs=Nothing
		Dim usergrade
        Set rs = conn.execute("select user_grade from [Lebi_user] where user_id='"& user_id &"'")
		If rs.eof Then
		        dis_grade = 1
		Else
		        dis_grade = rs(0)
		End If
		rs.close:Set rs=Nothing
		set rs = conn.execute("select l_path from [Lebi_language] where l_txt = '"& LangTxt &"' and l_state = 1")
		If Not (rs.eof And rs.bof) Then
				LangPath = rs(0)
		End If
		rs.close : Set rs = Nothing
		If InStr(orderzt,"2")>0 Or InStr(orderzt,"3")>0 Then
				OrderLock = 1
		End If 
%>
<script>
function todel()
{
   var i = 0;
   var chkArr = document.getElementsByName("basket_id");
   var id = document.getElementById("id").value;
   var param = "";
   for (i=0;i<chkArr.length;i++)
   if (chkArr[i].checked)
   param+=chkArr[i].value +",";
   if (param.length == 0)
   {
       alert("<%=Lang_sys(41)%>");
   }else{
       if(window.confirm("<%=Lang_sys(64)%>")){
           document.location.href="?action=del_b&b_id="+param+"&id="+id;
       }else return;
   }
}
</script>
<script language="javascript" type="text/javascript" src="inc/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="inc/js/tipswindown.js"></script>
<script language="javascript" type="text/javascript" src="inc/js/js_link.js"></script>
<script language="javascript">
var $=jQuery;
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="classtable-top">
  <tr>
	<td height="30" align="left" class="classhead">
	<strong><%=order_number%></strong>
	</td>
	<td class="classhead" align="right">
	<input type="image" src="lang/<%=LangFilePath%>/images/bt_toword.gif" title=" <%=Lang_sys(30)%> " onclick="window.open('admin_orders_out.asp?action=toword&order_number=<%=order_number%>');return false;" align="absmiddle">
	<input type="image" src="lang/<%=LangFilePath%>/images/bt_toexcel.gif" title=" <%=Lang_sys(29)%> " onclick="window.open('admin_orders_out.asp?action=toexcel&order_number=<%=order_number%>');return false;" align="absmiddle">
	<input type="image" src="lang/<%=LangFilePath%>/images/bt_sendorder.gif" title=" <%=Lang_sys(28)%> " onclick="window.open('admin_sh.asp?action=save&s_type=1&lx=&sj=<%= date() %>&bh=<%= order_number%>','basket', 'scrollbars=yes,resizable=no,width=1,height=1,menubar=no');return false;" align="absmiddle">
	<%If QS_State = 1 Then%><input type="image" src="lang/<%=LangFilePath%>/images/bt_tosup.gif" title=" <%=Lang_sys(31)%> " onclick="location.href='?action=sup&id=<%=id%>&order_number=<%=order_number%>';return false;" align="absmiddle"><%End If%>
	<input type="image" src="lang/<%=LangFilePath%>/images/bt_invoice.gif" title=" <%=Lang_sys(19)%> " onclick="location.href='admin_invoice.asp?action=add&id=<%=id%>';return false;" align="absmiddle">
	<input type="image" src="lang/<%=LangFilePath%>/images/bt_print.gif" title=" <%=Lang_sys(24)%> " onclick="window.open('<%=Eshop_url & LangPath %>basket/print.asp?order_id=<%=id%>');return false;" align="absmiddle">
	<%=QuickMenu("","")%>
	</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderinfo" class="classtable2">
<tr>
<td height="30" colspan="4" class="classtop"><%=Lang_Order(157)%></td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(1)%></td>
<td width="35%" class="classrow"><%=order_number%>
<%If is_booking = 1 Then response.write("<FONT COLOR=red>["& Lang_Order(13) &"]</FONT>")%>
<%If IsDS = 1 Then response.write("<FONT COLOR=#669966>[代收款]</FONT>")%>
</td>
<td width="15%" class="classrow"><%=Lang_Order(4)%></td>
<td width="35%" class="classrow"><%=order_time%>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(169)%></td>
<td colspan="3" class="classrow"><span style="color:#FF0000;font-size:13px;font-weight:bold;" onMouseOver="GetOrderPayLogTips('<%=Lang_Order(182)%>','<%=id%>');" onMouseOut="RemoveTips(null,true);"><%
Response.write(LanguageMoney(1) & formatnumber2((dis_sum+fei+packing_price+fapiao_money)/LanguageRate(1)))
%></span> <em>(<%
For LangT = 1 To TotalLang
		Response.write(LanguageName(LangT) &"："& LanguageMoney(LangT) & formatnumber2((dis_sum+fei+packing_price+fapiao_money)/LanguageRate(LangT)))
		If LangT < TotalLang Then Response.write("&nbsp;&nbsp;")
Next
%>)</em> =
<%if hg=0 then%>
<%=Lang_Order(74) & formatnumber2(totalcash)%> × <%=Lang_Order(70)%><strong><%=z_discount*100%></strong>
<%else%>
<%=Lang_Order(78) & totalcash%>
<%end if%>
+ <%=Lang_Order(75) & formatnumber2(fei)%> + <%=Lang_Order(77) & formatnumber2(packing_price)%> + <%=Lang_Order(76) & formatnumber2(fapiao_money)%>
<%If coupon_price > 0 Then%><span style="color:#FF0000"> - <%=Lang_Order(126) & formatnumber2(coupon_price)%></span><%End If%>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(170)%></td>
<td colspan="3" class="classrow"><span style="color:#FF0000;font-size:18px;font-weight:bold;"><%
Response.write(LanguageMoney(1) & formatnumber2(LastMoney/LanguageRate(1)))
%></span> <em>(<%
For LangT = 1 To TotalLang
		Response.write(LanguageName(LangT) &"："& LanguageMoney(LangT) & formatnumber2(LastMoney/LanguageRate(LangT)))
		If LangT < TotalLang Then Response.write("&nbsp;&nbsp;")
Next
%>)</em>
<%If paidmoney > 0 Then%><span style="color:#FF0000"> - <%
Response.write(Lang_Order(25))
Response.write(LanguageMoney(1) & formatnumber2(paidmoney/LanguageRate(1)))
%></span> <em>(<%
For LangT = 1 To TotalLang
		Response.write(LanguageName(LangT) &"："& LanguageMoney(LangT) & formatnumber2(paidmoney/LanguageRate(LangT)))
		If LangT < TotalLang Then Response.write("&nbsp;&nbsp;")
Next
%>)</em><%End If%>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(78)%></td>
<td colspan="3" class="classrow"><%=jifen%></td>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(119)%></td>
<td width="35%" class="classrow"><%=paymenttype%>
</td>
<td width="15%" class="classrow"><%=Lang_Order(118)%></td>
<td width="35%" class="classrow"><%=sendtype%>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(160)%></td>
<td width="35%" colspan="3" class="classrow"><%=packing_name%>&nbsp;
</td>
</tr>
<%
Set shipdb = conn.execute("select s_name,s_no,s_date from [Lebi_ShipMes] where s_order_number = '"& order_number &"'")
If Not shipdb.eof Then
%>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Ship(19)%></td>
<td width="35%" align="left" class="classrow"><%=shipdb(0)%><em>(<%=shipdb(2)%>)</em>&nbsp;</td>
<td width="15%" align="left" class="classrow"><%=Lang_Ship(20)%></td>
<td width="35%" align="left" class="classrow"><%=shipdb(1)%>&nbsp;</td>
</tr>
<%
Set rsdeliver = conn.execute("select deliver_code from [Lebi_deliver] where deliver_name"& LangTxt &" = '"& shipdb(0) &"'")
If Not rsdeliver.eof Then 
	response.write"<tr class=""classrow""><td height=""30"" width=""15%"" align=""left"" valign=""top"" class=""classrow"">"& Lang_Order(195) &"</td><td class=""classrow"" colspan=""3"">"
	If InStr("|ems|,|shentong|,|shunfeng|,|youzhengguonei|","|"& rsdeliver(0) &"|") > 0 Then 
		response.write("<form>"& Lang_Order(196) &"<input name=""valicode"" type=""text"" id=""valicode"" size=""5"" class=""form"" /> <img src=""http://api.kuaidi100.com/verifyCode?id="& Split(sys_kuaidi100,"|")(1) &"&com="& rsdeliver(0) &""" align=""absmiddle"" /> <input type=""submit"" name=""submit"" value="""& Lang_Order(197) &""" class=""button"" /><input type=""hidden"" name=""id"" value="""& id &""" /><input type=""hidden"" name=""order_number"" value="""& order_number &""" /></form>")
	End If 
	response.write Kuadi100API(rsdeliver(0),shipdb(1),request("valicode")) &"</td></tr>"
End If 
rsdeliver.close : Set rsdeliver = Nothing
end If
shipdb.close : Set shipdb = Nothing 
%>
</table>
<script>tdshow("orderinfo");</script>
</div>
</div>
<div class="mainbody-block">
<div class="mainbody-block2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="profile" class="classtable">
<form action="Admin_orders_v.asp" method="post" name="orders">
<tr>
	<td height="30" colspan="4" align="left" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
 </tr>
<%If sys_soft = 0 Then%>
<tr class="classrow">
<td height="30" colspan="4" class="classtop"><%=Lang_Order(20)%></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(54)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_name" value="<%=to_name%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(120)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_mobile" value="<%=to_mobile%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(9)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_tel" value="<%=to_tel%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(56)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_tel2" value="<%=to_tel2%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(12)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_zip" value="<%=to_zip%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(11)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="to_adds" value="<%=to_adds%>" size="30" class="form" /></td>
</tr>
<%if to_other<>"" Then%>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(55)%></td>
<td colspan="3" width="85%" align="left" class="classrow">
<textarea name="to_other" rows="3" cols="60" class="text"><%=to_other%></textarea><br />
<a href="javascript:u_Size(-5,'to_other')"><img src="lang/<%=LangFilePath%>/images/tab/bt_close.gif" border='0'></a>
<a href="javascript:u_Size(5,'to_other')"><img src="lang/<%=LangFilePath%>/images/tab/bt_open.gif" border='0'></a>
</td>
</tr>
<%End If%>
<%End If%>
<tr>
<td height="30" colspan="4" class="classtop"><%=Lang_Order(19)%></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(7)%></td>
<td width="35%" align="left" colspan="3" class="classrow"><%
If user_id <> "" Then
		response.write user_id&"&nbsp;&nbsp;<a href=""admin_msg.asp?action=add&user_id="& server.urlencode(user_id) &""" target=""_blank""><img src=""images/message.gif"" width=""16"" height=""16"" border=""0"" title="""& Lang_Order(159) &""" align=""absmiddle""></a>"
End If
If Not IsNull(from_mobile) And Trim(from_mobile) <> "" Then 
	response.write("&nbsp;&nbsp;<a href=""admin_sms.asp?action=send&send_no="& from_mobile &""" target=""_blank""><img src=""images/icon_sms.gif"" width=""16"" height=""16"" border=""0"" title="""& Lang_User(167) &"""></a>")
End If 
Set rsplugin = conn.execute("select p_state from [lebi_plugin] where p_type = 3 and p_flag = '1'")
If Not rsplugin.eof Then 
	If rsplugin(0) = 1 And Not IsNull(from_email) And Trim(from_email) <> "" Then 
	response.write"&nbsp;&nbsp;<a href=""plugin/admin_mail.asp?action=sendmail&user_email="& from_email &"&user_name="& server.urlencode(from_name) &""" target=""_blank""><img src=""images/icon_email.gif"" width=""16"" height=""16"" border=""0"" title="""& Lang_Order(204) &""" align=""absmiddle""></a>"
	End If 
End If 
rsplugin.close : Set rsplugin = Nothing 
%></td>
</tr>
<%If sys_soft = 0 Then%>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(54)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_name" value="<%=from_name%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(120)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_mobile" value="<%=from_mobile%>" size="30" class="form" />
</td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(9)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_tel" value="<%=from_tel%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(10)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_email" value="<%=from_email%>" size="30" class="form" />
</td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(12)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_zip" value="<%=from_zip%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(11)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_adds" value="<%=from_adds%>" size="30" class="form" /></td>
</tr>
<%Else
If InStr(from_tel,",") = 0 Then from_tel = from_tel &",,"
%>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(54)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_name" value="<%=from_name%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(120)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_mobile" value="<%=from_mobile%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(9)%></td>
<td width="35%" align="left" class="classrow">(<input type="text" name="from_tel" value="<%=Trim(split(from_tel,",")(0))%>" size="3" class="form">).<input type="text" name="from_tel" value="<%=Trim(split(from_tel,",")(1))%>" size="3" class="form">.<input type="text" name="from_tel" value="<%=Trim(split(from_tel,",")(2))%>" size="5" class="form"></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(10)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_email" value="<%=from_email%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(11)%></td>
<td width="85%" align="left" colspan="3" class="classrow"><input type="text" name="from_adds" value="<%=from_adds%>" size="50" class="form" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="from_adds2" value="<%=from_adds2%>" size="50" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(186)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_city" value="<%=from_city%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(187)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_state" value="<%=from_state%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(12)%></td>
<td width="35%" align="left" class="classrow"><input type="text" name="from_zip" value="<%=from_zip%>" size="30" class="form" /></td>
<td width="15%" align="left" class="classrow"><%=Lang_Order(188)%></td>
<td width="35%" align="left" class="classrow"><select name="from_country">
<%
Set country = conn.execute("Select id,area_name from [lebi_deliver_area] order by area_order desc")
If Not country.eof Then
Do While Not country.eof
	Response.write("<option value="& Country(0) &" "& judge2(Country(0),from_country) &">"& Country(1) &"</option>")
country.movenext
Loop 
End If
country.close : Set country = Nothing
%></select>
</td>
</tr>
<%End If%>
<%if from_other<>"" Then%>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(55)%></td>
<td colspan="3" width="85%" align="left" class="classrow">
<textarea name="from_other" rows="3" cols="60" class="text"><%=from_other%></textarea><br />
<a href="javascript:u_Size(-5,'from_other')"><img src="lang/<%=LangFilePath%>/images/tab/bt_close.gif" border='0'></a>
<a href="javascript:u_Size(5,'from_other')"><img src="lang/<%=LangFilePath%>/images/tab/bt_open.gif" border='0'></a>
</td>
</tr>
<%End If%>
<%if fapiao_company <> "" then%>
<tr>
<td colspan="4" height="30" class="classtop"><%=Lang_Order(62)%></td>
</tr>
<tr class="classrow">
<td height="30" width="15%" align="left" class="classrow"><%=Lang_Order(64)%></td>
<td width="85%" colspan=3 class="classrow"><input type="text" name="fapiao_company" value="<%=fapiao_company%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" align="left" class="classrow"><%=Lang_Order(65)%></td>
<td colspan=3 class="classrow"><input type="text" name="fapiao_adds" value="<%=fapiao_adds%>" size="30" class="form" /></td>
</tr>
<tr class="classrow">
<td height="30" align="left" class="classrow"><%=Lang_Order(12)%></td>
<td colspan=3 class="classrow"><input type="text" name="fapiao_zip" value="<%=fapiao_zip%>" size="30" class="form" /></td>
</tr>
<%end if%>
<tr class="classfooter">
  <td height="30" align="left" colspan="2" class="classfooter"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	<input type="hidden" name="id" value="<%=id%>">
	<input type="hidden" name="order_number" value="<%=order_number%>">
	<input type="hidden" name="action" value="profile">
</td>
 </tr>
 </form>
</table>
<script>tdshow("profile");</script>
</div>
</div>
<div class="mainbody-block">
<div class="mainbody-block2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderstate" class="classtable">
<form action="Admin_orders_v.asp" method="post" name="orders">
<tr>
	<td height="30" colspan="2" align="left" class="classhead"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle"></td>
 </tr>
<tr>
<td colspan="2" height="30" class="classtop"><%=Lang_Order(136)%></td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(137)%></td>
<td colspan="3" class="classrow">
<input type="checkbox" name="orderzt" value="1" <%if Instr(orderzt, 1)>0 then response.write"checked" end if%>>
<%=Lang_Order(14)%>
<input type="checkbox" name="orderzt" value="2" <%if Instr(orderzt, 2)>0 then response.write"checked" end if%>>
<%=Lang_Order(15)%>
<input type="checkbox" name="orderzt" value="3" disabled <%if Instr(orderzt, 3)>0 then response.write"checked" end if%>>
<%=Lang_Order(16)%> <%
Set shipdb = conn.execute("select s_id from Lebi_ShipMes where s_order_number = '"& order_number &"'")
If Not shipdb.eof Then
		response.write"<a href=""Admin_ship.asp?action=edit&order_number="& order_number &"&order_id="& id &""" title=""查看发货通知"" target=""_blank""><img src=""images/icon_ship_r.gif"" border=""0"" align=""absmiddle""></a>"
Else
		response.write"<a href=""Admin_ship.asp?action=add&id="& id &""" title=""还没有添加发货通知，添加后订单状态更新为已发货"" target=""_blank""><img src=""images/icon_ship.gif"" border=""0"" align=""absmiddle""></a>"
end If
shipdb.close : Set shipdb = Nothing
%>
<input type="checkbox" name="orderzt" value="4" <%if Instr(orderzt, 4)>0 then response.write"checked" end if%>>
<%=Lang_Order(17)%>
<input type="checkbox" name="orderzt" value="5" <%if Instr(orderzt, 5)>0 then response.write"checked" end if%>>
<%=Lang_Order(18)%>
<!--<input type="checkbox" name="orderzt" value="6">
操作库存 <img src="images/help.gif" title="选择 [操作库存] ,系统将自动从商品库存中减去订购商品数,不能重复操作!">
</td>
</tr>
-->
<!--<tr class="classrow">
<td width="70">库存处理：</td>
<td>
<input type="checkbox" name="zt" <%if zt=1 then response.write"checked" end if%>>
已处理(请勿对库存进行重复操作!)</td>
</tr>-->
<%If is_booking = 1 Then %>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(138)%></td>
<td colspan="3" class="classrow">
<%=Lang_Order(139) & formatnumber2(advance_money)%> <input type="checkbox" name="is_pay_advance" value="1" <%if is_pay_advance="1"  then response.write"checked" end if%>> <%=Lang_Order(15)%>
</td>
</tr>
<%
End If
If user_id <> "" And (Instr(orderzt, 2) = 0 And LastMoney > 0) Then
Set user = conn.execute("Select usermoney from [lebi_user] where user_id = '"& user_id &"'")
If Not user.eof Then
If user(0) > 0 Then
%>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(167)%></td>
<td colspan="3" class="classrow">
<%=formatnumber2(user(0))%>
<%
If is_booking = 1 Then
If is_pay_advance = 1 Then
%>
<input type="checkbox" name="is_pay_usermoney" value="1"> <%=Lang_Order(193)%>
<%Else%>
<input type="checkbox" name="is_pay_usermoney" value="1">
<%
If CDbl(user(0)) >= CDbl(lastmoney) Then 
	Response.write(Lang_Order(168))
Else
	Response.write(Lang_Order(193))
End If 
If CDbl(user(0)) >= CDbl(advance_money) Then 
%>
<input type="checkbox" name="is_pay_usermoney" value="2"> <%=Lang_Order(192)%>
<%
End If 
End If
Else
%>
<input type="checkbox" name="is_pay_usermoney" value="1">
<%
If CDbl(user(0)) >= CDbl(lastmoney) Then 
	Response.write(Lang_Order(168))
Else
	Response.write(Lang_Order(193))
End If 
End If
%>
</td>
</tr>
<%
End If
End If
End If
%>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(78)%></td>
<td colspan="3" class="classrow">
<%if is_jifen=0 then%><input type="radio" name="f_jifen" value="1"> <%=Lang_Order(140)%>
<input type="radio" name="f_jifen" value="0" checked> <%=Lang_Order(141)%><%else%><font color=red><%=Lang_Order(142)%></font><%end if%>
</td>
</tr>
<tr class="classrow">
<td valign="top" width="15%" class="classrow" valign="top" style="padding-top:6px"><%=Lang_Order(143)%><br/><font color=gray><%=Lang_Order(144) & LangName %></font></td>
<td colspan="3" class="classrow">
<textarea name="fuyan" id="fuyan" rows="3" cols="60" class="text"><%=fuyan%></textarea>
<br /><a href="javascript:u_Size(-5,'fuyan')"><img src="lang/<%=LangFilePath%>/images/tab/bt_close.gif" border='0'></a>
<a href="javascript:u_Size(5,'fuyan')"><img src="lang/<%=LangFilePath%>/images/tab/bt_open.gif" border='0'></a>
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(145)%></td>
<td class="classrow">
<input type="radio" name="mark" value="1"<%If InStr(mark,"1")>0 Then response.write(" checked") End If%>><img src="images/mark/1.gif" title="" border="0" align="absmiddle">
<input type="radio" name="mark" value="2"<%If InStr(mark,"2")>0 Then response.write(" checked") End If%>><img src="images/mark/2.gif" title="" border="0" align="absmiddle">
<input type="radio" name="mark" value="3"<%If InStr(mark,"3")>0 Then response.write(" checked") End If%>><img src="images/mark/3.gif" title="" border="0" align="absmiddle">
<input type="radio" name="mark" value="4"<%If InStr(mark,"4")>0 Then response.write(" checked") End If%>><img src="images/mark/4.gif" title="" border="0" align="absmiddle">
<input type="radio" name="mark" value="5"<%If InStr(mark,"5")>0 Then response.write(" checked") End If%>><img src="images/mark/5.gif" title="" border="0" align="absmiddle">
</td>
</tr>
<tr class="classrow">
<td valign="top" width="15%" class="classrow" valign="top" style="padding-top:6px"><%=Lang_Order(146)%><br><font color=gray><%=Lang_Order(147)%></font></td>
<td class="classrow">
<textarea name="remark" id="remark" rows="3" cols="60" class="text"><%=remark%></textarea>
<br /><a href="javascript:u_Size(-5,'remark')"><img src="lang/<%=LangFilePath%>/images/tab/bt_close.gif" border='0'></a>
<a href="javascript:u_Size(5,'remark')"><img src="lang/<%=LangFilePath%>/images/tab/bt_open.gif" border='0'></a>
</td>
</tr>
<tr class="classfooter">
  <td height="30" align="left" colspan="2" class="classfooter"><input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
	<input type="hidden" name="id" value="<%=id%>">
	<input type="hidden" name="user_id" value="<%=user_id%>">
	<input type="hidden" name="email" value="<%=from_email%>">
	<input type="hidden" name="summoney" value="<%=dis_sum+fei%>">
	<input type="hidden" name="to_name" value="<%=from_name%>">
	<input type="hidden" name="postcode" value="<%=from_zip%>">
	<input type="hidden" name="tel" value="<%=from_tel%>">
	<input type="hidden" name="to_adds" value="<%=from_adds%>">
	<input type="hidden" name="jifen" value="<%=jifen%>">
	<input type="hidden" name="order_number" value="<%=order_number%>">
	<input type="hidden" name="action" value="upmark">
</td>
 </tr>
 </form>
</table>
<script>tdshow("orderstate");</script>
</div>
</div>
<%
sql="select * from [Lebi_basket] where order_number="&id&" and IsGift=1"
'If IsSqlDataBase = 1 Then sql=sql&" and datediff(s,basket_date,'"&order_time&"')<172800"
'If IsSqlDataBase = 0 Then sql=sql&" and datediff('h',basket_date,'"&order_time&"')<48"
set rs = conn.execute(sql)
If Not rs.eof Then
%>
<div class="mainbody-block">
<div class="mainbody-block2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="ordergift" class="classtable">
<tr><td colspan="6" class="classhead" height="25"><%=Lang_Order(42)%></td></tr>
<tr>
<td height="30" width="5%" align="center" class="classtop"><%=Lang_Order(43)%></td>
<td width="49%" class="classtop"><%=Lang_Order(44)%></td>
<td width="10%" align="center" class="classtop"><%=Lang_Order(45)%></td>
<td width="10%" align="center" class="classtop"><%=Lang_Order(46)%></td>
<td width="8%" align="center" class="classtop"><%=Lang_Order(47)%></td>
<td width="8%" align="center" class="classtop"><%=Lang_Order(48)%></td>
</td>
</tr>
<%Do While Not rs.eof
rem <-{增加缩图显示 2008-5-17 by 56770.kingdge
Set GetPic = conn.execute("select pic from [Lebi_vipproduct] where id = "& rs("id") &"")
If Not GetPic.eof Then
GiftPic = GetPic(0)
End If
GetPic.close : Set GetPic = Nothing
rem }->
%>
<tr class="classrow">
<td height="30" align="center" class="classrow"><div class="pro-pic"><img src='../<%=GiftPic%>' onMouseover="javascript:ddrivetip('<img src=../<%=GiftPic%> width=<%=pic_xw%> height=<%=pic_xh%>>', '#ffffff', '<%=pic_xh%>')" onMouseout="hideddrivetip()"></div></td>
<td class="classrow"><%=rs("product_name")%></td>
<td align="center" class="classrow"><%=rs("price")%></td>
<td align="center" class="classrow"><%=rs("basket_count")%></td>
<td align="center" class="classrow"><%=rs("price")*rs("basket_count")%></td>
<td align="center" class="classrow"><a href="?action=del_gift&b_id=<%=rs("basket_id")%>&id=<%=id%>" onClick="return ConfirmDel();"><img src="images/icon_del.gif" title="<%=Lang_sys(15)%>" border="0" align="absmiddle"></a></td>
</tr>
<%
rs.movenext
Loop
%>
</table>
<script>tdshow("ordergift");</script>
</div>
</div>
<%
End If
rs.close : Set rs = Nothing
sql="select * from [Lebi_basket] where order_number="&id&" and IsGift=0 and id > 0 order by id desc"
'If IsSqlDataBase = 1 Then sql=sql&" and datediff(s,basket_date,'"&order_time&"')<172800"
'If IsSqlDataBase = 0 Then sql=sql&" and datediff('h',basket_date,'"&order_time&"')<48"
set rs2 = conn.execute(sql)
If Not rs2.eof Then
%>
<div class="mainbody-block">
<div class="mainbody-block2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderproduct" class="classtable">
<%If OrderLock = 0 Then%>
<form name="form1" method="post" action="?">
<tr>
<td class="classhead" colspan="9" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">&nbsp;<input type="image" border="0" title=" <%=Lang_sys(15)%> " onclick="location.href='javascript:todel();';return false;" src="lang/<%=LangFilePath%>/images/bt_delete.gif" align="absmiddle">
</td>
</tr>
<%End If%>
<tr>
<%If OrderLock = 0 Then%><td class="classtop" height="30" width="4%" title="<%=Lang_sys(4)%>" style="cursor:pointer;" onclick="location.href='javascript:selectall();';return false;"><%=Lang_sys(50)%></td><%End If%>
<td height="30" width="5%" class="classtop"><%=Lang_Order(43)%></td>
<td width="12%" class="classtop"><%=Lang_Order(49)%></td>
<td width="*" class="classtop"><%=Lang_Order(50)%></td>
<td width="10%" class="classtop"><%=Lang_Order(46)%></td>
<td width="10%" class="classtop"><%=Lang_Order(53)%></td>
<td width="8%" class="classtop"><%=Lang_Order(47)%></td>
</td>
</tr>
<%
do while not rs2.eof  'WangLei 2008-1-14
        pro_bianhao = rs2("bianhao")
		pro_price = FormatNumber2(rs2("price"))
		pro_totalprice = FormatNumber2(rs2("price")*rs2("basket_count"))
		pro_product_type = rs2("product_type")
		If pro_product_type = "unite" Then
			rem <-{增加缩图显示 2008-5-17 by 56770.kingdge
			Set GetPic = conn.execute("select pic from [Lebi_product_unite] where id = "& rs2("id") &"")
			If Not GetPic.eof Then
			ProPic = GetPic(0)
			End If
			GetPic.close : Set GetPic = Nothing
			rem }->
			pro_viewurl = "../product/unite/show/?id="& rs2("id")
			pName = ""&rs2("product_name")&"<br/>("&Lang_Order(161) & getUniteChild(rs2("id"),0,"&nbsp;+&nbsp;")&")"
		ElseIf pro_product_type = "groupon" Then
			Set GetPic = conn.execute("select pic from [Lebi_groupon_product] where id = "& rs2("id") &"")
			If Not GetPic.eof Then
			ProPic = GetPic(0)
			End If
			GetPic.close : Set GetPic = Nothing
			pro_viewurl = "../groupon/detail/?id="& rs2("id")
			pName = "["& Lang_Order(203) &"]"&rs2("product_name")&""
		Else
			rem <-{增加缩图显示 2008-5-17 by 56770.kingdge
			Set GetPic = conn.execute("select pic from [Lebi_product] where id = "& rs2("id") &"")
			If Not GetPic.eof Then
			ProPic = GetPic(0)
			End If
			GetPic.close : Set GetPic = Nothing
			rem }->
			If Config_Lebi_Eshop(16) = 0 Then
				pro_viewurl = "../showproduct.asp?id="& rs2("id")
			Else
				pro_viewurl = "../product/?id="& rs2("id")
			End If
			pName = rs2("product_name")
			If rs2("spname") <> "" Then 
					spstr = "<br/>"
					If InStr(rs2("spname"),",") > 0 Then 
							arr_spname = Split(rs2("spname"),",")
							arr_spvalue = Split(rs2("spvalue"),",")
							For s = 0 To UBound(arr_spname)
									spstr = spstr & arr_spname(s) &"："& arr_spvalue(s)
									If s < UBound(arr_spname) Then spstr = spstr & "&nbsp;&nbsp;"
							Next 
					Else
							spstr = spstr & rs2("spname") &"："& rs2("spvalue")
					End If 
			Else
					spstr = ""
			End If 
		End If
%>
<input type="hidden" name="b_id" value="<%=rs2("basket_id")%>">
<input type="hidden" name="p_id" value="<%=rs2("id")%>">
<tr class="classrow">
<%If OrderLock = 0 Then%><td class="classrow" height="30"><input name="basket_id" type="checkbox" value="<%=rs2("basket_id")%>" title="<%=rs2("basket_id")%>"><%If rs2("is_booking")=1 Then response.write "<br /><span style=""color:#ff0000"">"& Lang_Order(13) &"</span>"%></td><%End If%>
<td class="classrow" height="30"><div class="pro-pic"><a href="<%=pro_viewurl%>" target="_blabk"><img src='../<%=PicPath%>/<%=ProPic%>' onMouseover="javascript:ddrivetip('<img src=../<%=PicPath%>/<%=ProPic%> width=<%=pic_xw%> height=<%=pic_xh%>>', '#ffffff', '<%=pic_xh%>')" onMouseout="hideddrivetip()"></a></td>
<td class="classrow"><%= pro_bianhao%></td>
<td class="classrow" style="line-height:160%"><a href="<%=pro_viewurl%>" target="_blabk"><%=pName%></a><em><%=spstr%></em></td>
<td class="classrow"><input type="text" name="count_<%=rs2("basket_id")%>" value="<%=rs2("basket_count")%>" size="5" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
<td class="classrow"><input type="text" name="price_<%=rs2("basket_id")%>" value="<%=Replace(FormatNumber(rs2("price"),2),",","")%>" size="5" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
<td class="classrow"><%=formatnumber2(rs2("price")*rs2("basket_count"))%></td>
</tr>
<%
rs2.movenext
b_num=b_num+1
loop
%>
<%
sql_t="select price,basket_count from [Lebi_basket] where order_number="&id&" and isgift=0 and id > 0"
set rss = conn.execute(sql_t)
b_num_s = 0
b_price = 0
do while not rss.eof
b_price=b_price+(rss("price")*rss("basket_count"))
b_num_s=clng(b_num_s+clng(rss("basket_count")))
rss.movenext
loop
rss.close:set rss=nothing
%>
<tr class="classfooter">
<%If OrderLock = 0 Then%>
<td class="classfooter" colspan="3" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">&nbsp;<input type="image" border="0" title=" <%=Lang_sys(15)%> " onclick="location.href='javascript:todel();';return false;" src="lang/<%=LangFilePath%>/images/bt_delete.gif" align="absmiddle"><input type="hidden" name="action" value="up_b"><input type="hidden" name="id" id="id" value="<%=id%>">
</form>
</td>
<%End If%>
<td class="classfooter" colspan="6" align="right" height="30"><%=Lang_Order(122) & b_num%>&nbsp;&nbsp;&nbsp;&nbsp;<%=Lang_Order(123) & b_num_s%>&nbsp;&nbsp;&nbsp;&nbsp;<%=Lang_Order(124) & FormatNumber(b_price,2)%></td>
</tr>
</table>
<script>tdshow("orderproduct");</script>
</div>
</div>
<%
End If
rs2.close : set rs2=Nothing
If OrderLock = 0 Then 
RanNum = Int(90000*rnd)+10000
%>
<div class="mainbody-block">
<div class="mainbody-block2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderadd" class="classtable">
<form name="add_b" method="post" action="?" onSubmit="return CheckAdd(this);">
<tr>
<td class="classhead" colspan="9" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
</td>
</tr>
<tr class="classrow">
<td height="30" width="15%" class="classtop"><%=Lang_Order(49)%></td>
<td height="30" width="10%" class="classtop"><%=Lang_Order(46)%></td>
<td height="30" width="10%" class="classtop"><%=Lang_Order(162)%></td>
<td height="30" width="65%" class="classtop">&nbsp;</td>
</td>
</tr>
<tr class="classrow">
<td height="30" class="classrow"><input type="text" name="b_pro_id" id="b_pro_id" value="" size="10" class="form" onclick="javascript:tipsWindown('<%=Lang_Order(189)%>','iframe:admin_product_select.asp?dis_grade=<%=dis_grade%>&LangTxt=<%=LangTxt%>&RanNum=<%=RanNum%>','1000','320','true','','true','text');"></td>
<td height="30" class="classrow"><input type="text" name="b_pro_num" id="b_pro_num" value="" size="5" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');" value="1"></td>
<td height="30" class="classrow"><input type="text" name="b_pro_price" id="b_pro_price" value="" size="5" class="form" onkeyup="value=value.replace(/[^\d\.]/g,'');"></td>
<td height="30" class="classrow"><input type="hidden" name="b_pro_spname" id="b_pro_spname" value="" /><input type="hidden" name="b_pro_spvalue" id="b_pro_spvalue" value="" /></td>
</td>
</tr>
<input type="hidden" name="action" value="add_b">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="LangTxt" value="<%=LangTxt%>">
</form>
</table>
<script language="JavaScript" type="text/JavaScript">
function CheckAdd(theform)
{
    if (!isEmpty(theform.b_pro_id,'<%=Lang_Order(163)%>')) return false;
}
tdshow("orderadd");
</script>
</div>
</div>
<%
End If 
%>
<div><div>
<%
End Sub

Sub price()
		id = CheckNum(request("id"),0)
		set Rs = conn.execute("select order_number,orderzt,paidmoney from [Lebi_orders] where id=" & id)
		order_number = rs(0)
		orderzt = rs(1)
		paidmoney = rs(2)
		rs.close : set rs=Nothing
		If InStr(orderzt,"2")>0 Then 
				Call Up_mes(Lang_sys(46),"·"& Lang_order(180),0,"javascript:history.back()",0,0,2,0)
		End If 
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderprice" class="classtable">
<form action="Admin_orders_v.asp" method="post" name="orders">
<tr>
<td class="classhead" colspan="3" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
</td>
<td class="classhead" align="right">
<%=QuickMenu("","")%>
</td>
</tr>
<tr class="classrow">
<td colspan="4" height="30" class="classtop"><%=Lang_Order(148)%></td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(149)%></td>
<td width="35%" class="classrow"><input type="text" name="discount" value="0" size="5" class="form"> <img src="images/help.gif" align="absmiddle" title="<%=Lang_Order(150)%>">
</td>
<td width="15%" class="classrow"><%=Lang_Order(151)%></td>
<td width="35%" class="classrow"><input type="text" name="pricec" value="0" size="5" class="form"> <img src="images/help.gif" align="absmiddle" title="<%=Lang_Order(152)%>">
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(153)%></td>
<td width="35%" class="classrow"><input type="text" name="pricef" value="0" size="5" class="form"> <img src="images/help.gif" align="absmiddle" title="<%=Lang_Order(152)%>">
</td>
<td width="15%" class="classrow"><%=Lang_Order(154)%></td>
<td width="35%" class="classrow"><input type="text" name="packing_price" value="0" size="5" class="form"> <img src="images/help.gif" align="absmiddle" title="<%=Lang_Order(152)%>">
</td>
</tr>
<tr class="classrow">
<td width="15%" height="30" class="classrow"><%=Lang_Order(165)%></td>
<td width="35%" class="classrow"><input type="text" name="jifen" value="0" size="5" class="form"> <img src="images/help.gif" align="absmiddle" title="<%=Lang_Order(152)%>">
</td>
<td width="15%" height="30" class="classrow"><%=Lang_Order(200)%></td>
<td width="35%" class="classrow"><input type="text" name="paidmoney" value="<%=paidmoney%>" size="5" class="form">
</td>
</tr>
<tr class="classfooter">
<td class="classfooter" colspan="4" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="order_number" value="<%=order_number%>">
<input type="hidden" name="action" value="price_ok">
</td>
</tr>
</form>
<%
Set lebi_log = conn.execute("select l_name,l_content,l_time from lebi_orders_log where l_order_number = '"& order_number &"'")
If Not lebi_log.eof Then
%>
<tr class="classrow">
<td colspan="4" height="30" class="classtop"><%=Lang_Order(155)%></td>
</tr>
<%
		Do While Not lebi_log.eof
%>
<tr class="classrow">
<td colspan="4" height="30" class="classrow"><%=Lang_Order(156) & lebi_log("l_name")%>&nbsp;&nbsp;<%=lebi_log("l_content")%>(<%=lebi_log("l_time")%>)</td>
</tr>
<%
		lebi_log.movenext
		Loop
End If
lebi_log.close : Set lebi_log = Nothing
%>
</table>
<script>
tdshow("orderprice");
</script>
<%End Sub

Sub ship()
		id = CheckNum(request("id"),0)
		Sum3 = 0
		p_weight = 0
		set Rs = conn.execute("select order_number,orderzt,LangTxt,LangName from [Lebi_orders] where id=" & id)
		order_number = rs(0)
		orderzt = rs(1)
		LangTxt = rs(2)
		LangName = rs(3)
		rs.close : set rs=Nothing
		If InStr(orderzt,"3")>0 Then 
				Call Up_mes(Lang_sys(46),"·"& Lang_order(181),0,"javascript:history.back()",0,0,2,0)
		End If 
		set rs = conn.execute("select p.p_weight,b.basket_count,b.price,b.isgift from [Lebi_basket] as b,[lebi_product] as p where b.id = p.id and b.order_number = "& id &"")
		do While Not rs.EOF
				If rs(3) = 0 Then
						Sum3 = Sum3 + (rs(2)*rs(1))
				End If
				p_weight = p_weight + (rs(0)*rs(1)/1000)
		rs.MoveNext
		loop
		rs.close : Set rs=Nothing
%>
<script language="JavaScript" type="text/JavaScript">
function CheckForm(theform)
{
	var updatefee = document.getElementById('updatefee');
	if (updatefee.checked){}else{ShowMessage('updatefee','<%=Lang_Order(178)%>');return false;}
}
</script>
<script language="javascript" type="text/javascript" src="inc/js/order_quick.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderprice" class="classtable">
<form action="Admin_orders_v.asp" method="post" name="orders" onSubmit="return CheckForm(this);">
<tr>
<td class="classhead" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
</td>
<td class="classhead" align="right">
<%=QuickMenu("","")%>
</td>
</tr>
<tr class="classrow">
<td colspan="2" height="30" class="classtop"><%=Lang_Order(172)%></td>
</tr>
<%
Set rs=conn.execute("SELECT id,area_name"& LangTxt &" FROM [Lebi_deliver_area] where parent_id=0 and ShowLang like '%"& LangName &"%' ORDER BY area_order desc,id asc")
area_list_num = 1
AreaId = rs("id")
do while not rs.eof
	area_list_str = area_list_str & "<option value="""&rs(0)&""""
	If area_list_num = 1 Then area_list_str = area_list_str & " selected"
	area_list_str = area_list_str & ">"&rs(1)&"</option>"
	rs.movenext
	area_list_num = area_list_num + 1
Loop
rs.close: Set rs = Nothing
Dim FirstDeliver,bw_price,b_weight,o_price,deliver_name
sql="SELECT a.id,a.deliver_id,a.is_end_pay,a.basic_weight_price,a.basic_weight,a.overstep_price, b.deliver_name"& LangTxt &",b.deliver_info"& LangTxt &",b.deliver_price,a.last_price,a.free_price FROM [Lebi_deliver_list] as a,[Lebi_deliver] as b where a.area_id="&areaid&" and a.deliver_id=b.id ORDER BY a.d_order desc"
Set rs= conn.execute(SQL)
If Not rs.eof Then
i = 0
Select Case Config_Lebi_Eshop(15)
Case "0" bw_price = rs("deliver_price")
Case "1" bw_price = rs("basic_weight_price")
End Select 
b_weight = rs("basic_weight")
o_price = rs("overstep_price")
deliver_name = rs("deliver_name"& LangTxt)
l_price = rs("last_price")
f_price = rs("free_price")
do while not rs.eof
	FirstDeliver = FirstDeliver &"<tr class='classrow'><td class='classrow' colspan='2'><input type='radio' value='"&rs("deliver_id")&"'  name='deliver_id' onclick='getDeliverPrice("&i&");'"
	If i = 0 Then FirstDeliver = FirstDeliver &" checked"
	FirstDeliver = FirstDeliver &"> "&rs("deliver_name"& LangTxt)&"</td></tr>"
	FirstDeliver = FirstDeliver &"<tr class='classrow'><td class='classrow' colspan='2'>"&rs("deliver_info"& LangTxt)&"</td></tr><INPUT TYPE=""hidden"" value="""&rs("is_end_pay")&""" name=""is_end_pay""><INPUT TYPE=""hidden"" value="""&rs("deliver_name"& LangTxt)&""" name=""deliver_name""><INPUT TYPE=""hidden"" value="""&rs("basic_weight")&""" name=""basic_weight""><INPUT TYPE=""hidden"" value="""&rs("overstep_price")&""" name=""overstep_price""><INPUT TYPE=""hidden"" value="""&rs("last_price")&""" name=""last_price""><INPUT TYPE=""hidden"" value="""&rs("free_price")&""" name=""free_price"">"
	If CInt(Config_Lebi_Eshop(15)) = 0 Then
		FirstDeliver = FirstDeliver &"<INPUT TYPE=""hidden"" value="""&rs("deliver_price")&""" name=""basic_weight_price"">"
	Else
		FirstDeliver = FirstDeliver &"<INPUT TYPE=""hidden"" value="""&rs("basic_weight_price")&""" name=""basic_weight_price"">"
	End If
	rs.movenext
	i = i+1
Loop
End If
rs.close:set rs=Nothing
%>
<tr class="classrow">
	<td class="classrow" width="15%" rowspan="2" valign="top"><%=Lang_Order(173)%></td>
	<td class="classrow" width="85%"><select size="1" name="area_id" onchange="ajaxSub(0,'Ajax_data.asp?action=getDeliverArea2&parentid='+this.value+'&LangTxt=<%=LangTxt%>&LangName=<%=LangName%>');ajaxSub1(1,'Ajax_data.asp?action=getDeliverList&areaid='+this.value+'&parentid=0&LangTxt=<%=LangTxt%>&LangName=<%=LangName%>');"><option value="0"><%=Lang_Order(174)%></option><%=area_list_str%></select>
	<span id="deliver_area_2">
	<%
	Set rs= conn.execute("SELECT id,area_name"& LangTxt &" FROM [Lebi_deliver_area] where parent_id="&AreaId&" and ShowLang like '%"& LangName &"%' ORDER BY area_order desc,id asc")
	If Not rs.eof Then
			Response.write("<select size=1 name=""area2_id"" onchange=""ajaxSub1(1,'Ajax_data.asp?action=getDeliverList&areaid='+this.value+'&parentid="& AreaId &"');""><option value=""0"">"&Lang_Order(174) &"</option>")
			do while not rs.eof
			Response.write("<option value="""&rs("id")&""">"&rs("area_name")&"</option>")
			rs.movenext
			Loop
			Response.write("</select>")
	End If
	rs.close:set rs=Nothing
	%>
	</span></td>
</tr>
<tr class="classrow">
	<td class="classrow" colspan="2"><span id="div_deliver_show"><table cellspacing=0 cellpadding=0 border=0 width=100%><%=FirstDeliver%></table></span></td>
</tr>
<%
	If (p_weight) <= b_weight Or Config_Lebi_Eshop(15) = 0 Then
			deliver_price = bw_price
	Else
			If b_weight = 0 Then
					deliver_price = bw_price
			Else
					basic_weight = (p_weight - b_weight) / b_weight
					If InStr(basic_weight,".") > 0 Then 
							If basic_weight < 1 Then 
									basic_weight = 1
							Else 
									basic_weight = Split(basic_weight,".")(0) + 1
							End If 
					End If 
					deliver_price = bw_price + (basic_weight * o_price)
			End If
			If l_price > 0 And CLng(deliver_price) >= CLng(l_price) Then deliver_price = l_price
	End If
	If f_price > 0 And CLng(Sum3) >= CLng(f_price) Then deliver_price = 0
%>
	<INPUT TYPE="hidden" NAME="p_weight" value="<%=p_weight%>"><INPUT TYPE="hidden" NAME="sendtype" value="<%=deliver_name%>"><INPUT TYPE="hidden" NAME="stype" value="<%=Config_Lebi_Eshop(15)%>"><input type="hidden" name="deliver_price" value="<%=deliver_price%>">
<tr class="classrow">
	<td class="classrow" width="15%" valign="top"><%=Lang_Order(175)%></td>
	<td class="classrow" width="85%"><span id="showweight" style="color:#ff0000"><%=formatnumber2(p_weight)%></span> Kg</td>
</tr>
<tr class="classrow">
	<td class="classrow" width="15%" valign="top"><%=Lang_Order(176)%></td>
	<td class="classrow" width="85%"><span id="showprice" style="color:#ff0000"><%=formatnumber2(deliver_price)%></span> 元</td>
</tr>
<tr class="classrow">
	<td class="classrow" width="15%" valign="top"><%=Lang_Order(177)%></td>
	<td class="classrow" width="85%"><input type="checkbox" name="updatefee" id="updatefee" value="1" /> <span id="mes_updatefee"></span></td>
</tr>
<tr class="classfooter">
<td class="classfooter" colspan="2" align="left" height="30">
<input name="submit" type="image" src="lang/<%=LangFilePath%>/images/bt_app.gif" title=" <%=Lang_sys(1)%> " align="absmiddle">&nbsp;<input type="image" src="lang/<%=LangFilePath%>/images/bt_res.gif" title=" <%=Lang_sys(2)%> " onclick="reset();return false;" align="absmiddle">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="order_number" value="<%=order_number%>">
<input type="hidden" name="action" value="ship_ok">
</td>
</tr>
</form>
</table>
<script>
tdshow("orderprice");
</script>
<script>
function getDeliverList() {
  if (xmlHttp1.readyState < 4) {
	document.getElementById('div_deliver_show').innerHTML="<span>loading...</span>";
  }
  if (xmlHttp1.readyState == 4) {
	var response = xmlHttp1.responseText;
	if (response == "")
	{
		var pweight = document.getElementsByName('p_weight')[0].value/1;
		document.getElementById('div_deliver_show').innerHTML="";
		document.getElementById('showprice').innerHTML = "0.00";
		document.getElementById('showweight').innerHTML = ""+(pweight).toFixed(2)+"";
		document.getElementsByName('deliver_price')[0].value = 0;
		document.getElementsByName('sendtype')[0].value = '-';
	}else
	{
		document.getElementById('div_deliver_show').innerHTML="<table cellspacing=0 cellpadding=0 border=0 width=100%>"+ response +"</table>";
		document.getElementById('showprice').innerHTML = "<%=Lang_Order(68)%>";
		document.getElementsByName('deliver_price')[0].value = '';
		document.getElementsByName('sendtype')[0].value = '';
	}
  }
}

function getDeliverPrice(i)
{
	var deliverPrice = 0
	var pweight = document.getElementsByName('p_weight')[0].value/1;
	var bw_price = document.getElementsByName('basic_weight_price')[i].value/1;
	var b_weight = document.getElementsByName('basic_weight')[i].value/1;
	var o_price = document.getElementsByName('overstep_price')[i].value/1;
	var d_name = document.getElementsByName('deliver_name')[i].value;
	var l_price = document.getElementsByName('last_price')[i].value/1;
	var f_price = document.getElementsByName('free_price')[i].value/1;
	var s_type = document.getElementsByName('s_type').value/1;
	if ((pweight <= b_weight) || (s_type==0))
	{
		deliverPrice = bw_price;
	}else
	{
		if (b_weight==0)
		{
			deliverPrice = bw_price/1;
		}else{
			deliverPrice = bw_price/1 + (Math.ceil((pweight-b_weight)/b_weight)) * o_price;
		}
		if (l_price >0 && deliverPrice >= l_price){deliverPrice = l_price}
	}
	if (f_price >0 && <%=sum3%> >= f_price){deliverPrice = 0}
	document.getElementById('showprice').innerHTML = ""+(deliverPrice).toFixed(2)+"";
	document.getElementById('showweight').innerHTML = ""+(pweight).toFixed(2)+"";
	document.getElementsByName('sendtype')[0].value = d_name;
	document.getElementsByName('deliver_price')[0].value = deliverPrice;
}
</script>
<%End Sub%>