<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<title><%=webname%>--订单管理</title>
<!--#include file="include/header.asp"--> 
<%

if request.cookies("sundxshop")("username")="" then
response.Write "<script language='javascript'>alert('请先登陆！');location.href='index.asp';</script>"
response.End
end if
%>

<%dim state,namekey

state=sqlCheckstr(request.form("state"))
if state="" then 
state=SafeRequest("state",0)
end if

%><TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
  <tr> 
    <td align="center"><font color="#FFFFFF">管理商品订单</font></td>
  </tr>
  </table>
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
 
  <tr> 
       <td  valign="top" bgcolor="#FFFFFF" WIDTH="210">
 <!--#include file="include/user_left.asp"--> 
</td>
    <td height="167" valign="top" bgcolor="#FFFFFF"> 
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr> 
          <td align="right">
             <select name="state" onChange="var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!='') {window.location=jmpURL;} else {this.selectedIndex=0 ;}" > 
            <option value="dan.asp?action=goods&state=0" selected>--请选择查询状态--</option> 
            <option value="dan.asp?action=goods&state=0" >全部订单状态</option> 
            <option value="dan.asp?action=goods&state=2" >未作任何处理</option> 
            <option value="dan.asp?action=goods&state=3" >用户已划出款</option> 
            <option value="dan.asp?action=goods&state=3" >服务商已收到款</option> 
            <option value="dan.asp?action=goods&state=4" >服务商已发货</option> 
            <option value="dan.asp?action=goods&state=5" >用户已经收到货</option> 
</select>
            </td>
        </tr>
      </table>

  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr align="center" bgcolor=#ffffff> 
              <td width="14%" height="25"><FONT color=#000000>订单号</font></td>
              <td width="9%"><FONT color=#000000>合计金额</font></td>
              <td width="4%"><FONT color=#000000>积分</font></td>
              <td width="7%"><FONT color=#000000>订货人</font></td>
              <td width="14%"><FONT color=#000000>付款方式</font></td>
              <td width="20%"><FONT color=#000000>收货方式</font></td>
              <td width="16%"><FONT color=#000000>订单日期</font></td>
              <td width="17%"><FONT color=#000000>订单状态</font></td>
           
            </tr>
           </table>
      <%                    Const MaxPerPage=20 
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(SafeRequest("page",1)) then
      				currentPage=Cint(SafeRequest("page",1))
   				else
      				currentPage=1
   				end if 



				
set rs=server.CreateObject("adodb.recordset")

  state=SafeRequest("state",1)
  if state=0 or state="" then
  select case state
  case "0"
  rs.open "select distinct(goods),realname,actiondate,deliverymethord,paymethord,state,postcode,comment,receipt,useremail,usertel,usermobile,address  from orders where username='"&strUserName&"' and state<6 order by actiondate desc",conn,1,1
  case ""
  rs.open "select distinct(goods),realname,actiondate,deliverymethord,paymethord,state,postcode,comment,receipt,useremail,usertel,usermobile,address  from orders where username='"&strUserName&"' and state<6 order by actiondate desc",conn,1,1
  end select
  else
  rs.open "select distinct(goods),realname,actiondate,deliverymethord,paymethord,state,postcode,comment,receipt,useremail,usertel,usermobile,address  from orders where username='"&strUserName&"' and state="&state&" order by actiondate",conn,1,1
  end if

                  
		


     
				if err.number<>0 then
				response.write ""
				end if
				
  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' class='contents'> 对不起，您选择的状态目前还没有订单！</p>"
   				else
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"dan.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookbrand
            				bookbrand=rs.bookbrand
            				showContent
             				showpage totalput,MaxPerPage,"dan.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"dan.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0
   
			%>
      
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
      <% do while not rs.eof%>
        <tr bgcolor="#FFFFFF" align="center"> 
			

                         <%  dim shop,rs2 
			set shop=server.CreateObject("adodb.recordset")
			shop.open "select sum(paid) as paid,sum(score) as score from orders where goods='"&trim(rs("goods"))&"' ",conn,1,1
				%>
              <td  width="14%"><a href=# onClick="javascript:window.open('chkorder.asp?dan=<%=trim(rs("goods"))%>&score=<% = trim(shop("score")) %>','','width=710,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"><FONT color=#999999><%=trim(rs("goods"))%></a></td>
              <td width="9%"> 
			  <%   dim sumx
				set rs2=server.CreateObject("adodb.recordset")
				rs2.open "select * from delivery where deliveryid="&rs("deliverymethord"),conn,1,1
				Dim LngFee
				
		  IF webbj5 = 0 Then
		  LngFee = rs2("fee")
                  
		  Else
		  		If shop("paid") >= webbj5 Then
				LngFee = 0
				Else
				LngFee = rs2("fee")
				End IF
		  End IF
                  sumx=Round((shop("paid")+LngFee),2)
	response.write "<FONT color=#999999>"&Round((shop("paid")+LngFee),2)&"元</font>" 
	rs2.close
	set rs2=nothing %>
              </td>
              <td width="4%">
                <FONT color=#999999><% = shop("score") %></font>
                <%
	shop.close
	set shop=nothing
	%>
              </td>
              <td width="7%"><FONT color=#999999><%=trim(rs("realname"))%></font></td>
              <td width="14%"><FONT color=#999999> 
                <%set rs2=server.CreateObject("adodb.recordset")
        rs2.open "select * from delivery where deliveryid="&rs("paymethord"),conn,1,1
        response.Write trim(rs2("subject"))
        rs2.close
        set rs2=nothing%></font>
              </td>
              <td align="center" width="20%"><FONT color=#999999>
                <%set rs2=server.CreateObject("adodb.recordset")
        rs2.open "select * from delivery where deliveryid="&rs("deliverymethord"),conn,1,1
        response.Write trim(rs2("subject"))
        rs2.close
        set rs2=nothing
        %></font>
              </td>
              <td width="16%"><FONT color=#999999><%=trim(rs("actiondate"))%></font></td>
              <td width="17%">
               <FONT color=#999999> <%select case rs("state")
	case "1"
	response.write "未作任何处理"
	case "2"
	response.write "订单处理中"
	case "3"
	response.write "服务商收到款"
	case "4"
	response.write "服务商已发货"
	case "5"
	response.write "用户已收到货"
	end select%></font>
              </td>
             
            </tr>
        <%i=i+1
			if i>=MaxPerPage then Exit Do
			rs.movenext
		loop
		rs.close
		set rs=nothing%>
</table>
     
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <tr align="center" bgcolor=#ffffff> 
   <td  bgcolor="#FFFFFF">
      <%  
				End Sub   
				
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				if namekey="" then
				Response.Write "<form method=Post action="&filename&"?state="&state&">"  
				else
				Response.Write "<form method=Post action="&filename&"?state="&state&"&namekey="&namekey&">" 
				end if
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>首 页 上一页</font> "  
				Else  
					if namekey="" then
					Response.Write "<a href="&filename&"?page=1&state="&state&" class='contents'>首 页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&state="&state&" class='contents'>上一页</a> "  
					ELSE
					Response.Write "<a href="&filename&"?page=1&state="&state&"&namekey="&namekey&" class='contents'>首 页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&state="&state&"&namekey="&namekey&" class='contents'>上一页</a> "
					end if  
				End If
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>下一页 末 页</font>"  
				Else 
				if namekey="" then
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&state="&state&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&state="&state&" class='contents'>末 页</a>"
					else
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&state="&state&"&namekey="&namekey&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&state="&state&"&namekey="&namekey&" class='contents'>末 页</a>" 
					end if 
				End If  
					Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
					Response.Write "<font class='contents'> 共有"&totalnumber&"笔订单 "&maxperpage&"笔订单/页</font> " 
					Response.Write "<font class='contents'>转到：</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"  
					Response.Write "&nbsp;<input type='submit'  class='contents' value='跳转' name='cndok'></form>"  
				End Function  
				
			%></td></tr></table></td></tr></table>
     


<!--#include file="include/footer.asp"--> 