<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
else
if request.cookies("timesshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
end if
end if
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权查看商品订单！');window.close();</script>"
response.End
end if
%>
<title>查看订单</title>
<%
dim goods,username,rs2,strTitle,LngUserID,YourPrice
goods=SafeRequest("dan",1)
username=SafeRequest("username",0)
LngUserID=SafeRequest("UserID",1)

set rs2=server.CreateObject("adodb.recordset")
rs2.open "select [User].UserID,TimesGrp.GrpName,TimesGrp.GrpID from [User] Inner Join TimesGrp On [User].GrpID = TimesGrp.GrpID where UserID="&LngUserID,conn,1,1
strTitle = rs2("GrpName")
LngGrpID = rs2("GrpID")
rs2.close
LstPrice = "Price2"
Select Case LngGrpID
Case "" 
LstPrice = "Price1"

Case 4
LstPrice = "Price2"

Case 30
LstPrice = "Price3"

Case 31
LstPrice = "Price4"

Case 32
LstPrice = "Price5"

End Select
dim webbj5
rs2.Open "select webbj5 from config",conn,1,1
webbj5=CLng(trim(rs2("webbj5")))
rs2.Close

set rs=server.CreateObject("adodb.recordset")
rs.open "select product.id,product.name,product.amount,product.price1,product.price2,product." & LstPrice & ",product.vipprice,orders.actiondate,orders.UserSex,orders.ActionID,orders.remarks,orders.realname,orders.receipt,orders.goods,orders.postcode,orders.comments,orders.paymethord,orders.deliverymethord,orders.state,orders.paid,orders.score,orders.useremail,orders.usertel,orders.paid,orders.userid,orders.address,orders.productnum from product inner join orders on product.id=orders.id where orders.username='"&username&"' and goods='"&goods&"' ",conn,1,1
if rs.eof and rs.bof then
rs.Close
Set rs = Nothing
conn.close
set Conn = Nothing
response.write "<center>此订单中已有商品被管理员删除，无法处理，请手动删除此订单！ "
response.write "<input type=button name=Submit3 value=删除订单 onClick=""location.href='save.asp?action=del&dan="&goods&"&username="&username&"'""> </center>"
response.End
end if
%> <table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006699"> 
<tr> 
    <td><table width="100%" align="center" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
        <tr> 
          <td colspan="2" align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="90%" align="center">订单号：<%=goods%> ，详细资料：</td>
                <td width="10%" align="center"> <input type="button" name="Submit4" value="打 印" onClick="javascript:window.print()"> 
                </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td>订单状态：</td>
          <td width="80%"> <table width="98%" align="center" border="0" cellspacing="1" cellpadding="0" bgcolor="#006699">
              <form name="orderstate" method="post" action="save.asp?dan=<%=goods%>&action=save&username=<%=username%>">
                <tr bgcolor="#FFFFFF">
                  <td > 
                    <% grade() %>&nbsp;<input type="submit" name="Submit" value="修改订单状态"></td>
                </tr>
              </form>
            </table></td>
        </tr>
        <tr> 
          <td width="12%" valign="top">商品列表：</td>
          <td> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6699cc">
              <tr align="center" bgcolor="#6699cc" height="20"> 
                <td WIDTH="40%"><font color="#FFFFFF">商品名称</font></td>
                <td WIDTH="5%"><font color="#FFFFFF">数量</font></td>
                <td WIDTH="8%"><font color="#FFFFFF">市场价</font></td>
                <td WIDTH="8%"><font color="#FFFFFF">会员价格</font></td>
                <td WIDTH="8%"><font color="#FFFFFF">成交价</font></td>
				<td WIDTH="6%"><font color="#FFFFFF">邮 费</font></td>
				<td WIDTH="6%"><font color="#FFFFFF">积分</font></td>
                <td WIDTH="10%"><font color="#FFFFFF">金额小计</font></td>
              </tr>
              <%dim iii,jjj
		do while not rs.eof
		YourPrice =  Round(rs("" & LstPrice & ""),2)
%>
              <tr bgcolor="#FFFFFF" align="center" height="20"> 
                <td align="left">&nbsp;<a href=../product.asp?id=<%=rs("id")%> target=_blank><%=trim(rs("name"))%></a></td>
                <td><%=rs("productnum")%></td>
                <td><%=rs("price1")%>元</td>
                <td><%=rs("price2")%>元</td>
                <td><%=Round(YourPrice,2) %>元</td>
				<td><%=rs("vipprice")%>元</td>
				<td><%=rs("score")%>分</td>
                <td><%=Round(rs("paid"),2)%>元</td>
              </tr>
              <%
			  iii=rs("paid")+iii
			  jjj=rs("score")+jjj
		rs.movenext
		loop
		rs.movefirst%>
              <tr> 
                <td colspan="8" bgcolor="#FFFFFF" align="right" height="20">此会员等级：<%=strTitle %>，&nbsp;<br>送货方式： 
                  <%'
          set rs2=server.CreateObject("adodb.recordset")
          rs2.Open "select * from delivery where deliveryid="&int(rs("deliverymethord")),conn,1,1
		  if rs2.eof and rs2.bof then
		  response.write "方式以被删除"
		  response.write "&nbsp;附加费用：0元"
		  response.write "&nbsp;&nbsp;金额总计："& Round(iii,2) &"元"
		  else
		  response.write trim(rs2("subject"))
		  iii = iii*(1+ rs2("payfee")/100)
		  Dim LngFee
		  IF webbj5 = 0 Then
		  LngFee = rs2("fee")
		  Else
		  If iii >=webbj5 then
		  LngFee = 0
		  Else
		   LngFee = rs2("fee")
		  End If
		  End IF
		  
		  response.write "&nbsp;附加邮费：<font color=red>"&rs2("fee")&"</font>&nbsp;元，方式加收：<font color=red>"&rs2("payfee")&"％</font>"
		  response.write "&nbsp;金额总计：<font color=red>"&Round((iii+LngFee),2)&"</font>&nbsp;元，获得积分：<font color=red>"&jjj&"</font>&nbsp;分&nbsp;"
		  end if
		  rs2.Close
		  set rs2=nothing
		  %>
                 </td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td height="10"></td>
        </tr>
        <tr> 
          <td nowrap>订货人姓名：</td>
          <td><%=trim(rs("realname"))%></td>
        </tr>
        <tr> 
          <td>收货人姓名：</td>
          <td><%=trim(rs("receipt"))%>
		  <% 
		   if trim(rs("UserSex")) = 0 then
    response.Write "&nbsp;(先生)"
    else
    response.Write "&nbsp;(女士)"
    end if%>
	</td>
        </tr>
        <tr> 
          <td>收货地址：</td>
          <td><%=trim(rs("address"))%></td>
        </tr>
        <tr> 
          <td>邮政编码：</td>
          <td><%=trim(rs("postcode"))%></td>
        </tr>
        <tr> 
          <td>联系电话：</td>
          <td><%=trim(rs("usertel"))%></td>
        </tr>
        <tr> 
          <td>电子邮件：</td>
          <td><%=trim(rs("useremail"))%></td>
        </tr>
        <tr> 
          <td>送货方式：</td>
          <td> 
          <%set rs2=server.CreateObject("adodb.recordset")
    rs2.Open "select * from delivery where deliveryid="&rs("deliverymethord"),conn,1,1
     if rs2.eof and rs2.bof then
		  response.write "方式已被删除"
		  else
		  response.Write trim(rs2("subject"))
          end if
    rs2.Close
    %>
          </td>
        </tr>
        <tr> 
          <td>支付方式：</td>
          <td> 
            <%
          rs2.Open "select * from delivery where deliveryid="&int(rs("paymethord")),conn,1,1
          if rs2.eof and rs2.bof then
		  response.write "方式已被删除"
		  else
		  response.Write trim(rs2("subject"))
          end if
		  rs2.close
          set rs2=nothing %>
          </td>
        </tr>
        <tr> 
          <td>用户留言：</td>
          <td><%=trim(rs("comments"))%></td>
        </tr>
        <tr> 
          <td>下单日期：</td>
          <td><%=rs("actiondate")%></td>
        </tr>
		<tr> 
          <td>管理员评论：</td>
          <td><%=rs("remarks")%></td>
        </tr>
        <tr> 
          <td height="32" colspan="2" align="center"> <input type="button" name="Submit3" value="删除订单" onClick="if(confirm('您确定要删除吗?')) location.href='save.asp?action=del&dan=<%=goods%>&username=<%=username%>';else return;"> 
            &nbsp;&nbsp; <input type="button" name="Submit2" value="关闭窗口" onClick=javascript:window.close()> 
          </td>
        </tr>
		<tr><td colspan="2" align="center"><br><br>
		<form action="save.asp?action=orders&dan=<%=goods%>" method="post" name="remarks">
		<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><textarea name="remarks" cols="50" rows="5"></textarea></td>
  </tr>
  <tr>
    <td><input name="submitorders" type="submit" value="评 论"></td>
  </tr>
</table></form>
</td></tr>
      </table> </td>
  </tr> </table>
<%sub grade()
select case rs("state")
case "1"%> 
<input type="checkbox" name="checkbox1" value="2" DISABLED checked>未作任何处理<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox2" value="3">服务商已收到款<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox3" value="4" DISABLED>服务商已发货<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox4" value="5" DISABLED>用户已收到货 
<%case "2"%> 
<input type="checkbox" name="checkbox1" value="2" DISABLED checked>未作任何处理<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="state" value="3">服务商已收到款<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox3" value="4" DISABLED>服务商已发货<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox4" value="5" DISABLED>用户已收到货 
<%case "3"%> 
<input type="checkbox" name="checkbox1" value="2" DISABLED checked>未作任何处理<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox2" value="3" checked DISABLED>服务商已收到款<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="state" value="4" >服务商已发货<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox4" value="5" DISABLED>用户已收到货 
<%case "4"%> 
<input type="checkbox" name="checkbox1" value="2" DISABLED checked>未作任何处理<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox2" value="3" DISABLED checked>服务商已收到款<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox3" value="4" DISABLED checked>服务商已发货<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="state" value="5" >用户已经收到货 
<%case "5"%> 
<input type="checkbox" name="checkbox1" value="2" checked DISABLED>未作任何处理<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox2" value="3" checked DISABLED>服务商已收到款<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox3" value="4" checked DISABLED>服务商已发货<span style='font-family:Wingdings;'>à</span> 
<input type="checkbox" name="checkbox4" value="5" checked DISABLED>用户已收到货 
<%end select
end sub%>