<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/config.asp"-->
<!--#include file="../md5.asp"-->

<script language=javascript src=../include/mouse.js></script>
   <%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("04")%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
<script language=javascript>
<!--
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}
-->
</script>
</head>
<BODY bgcolor="#D9EAFC">

<%
action = request("action")
if action="" then call order_index()
if action="恢复订单" then call huifu()
if action="彻底删除" then call orderdel()


sub order_index()
%>

<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;定单回收站</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30><font color="#000000"></font></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
<form action=order3.asp method=post name=orderlist>
<%pages = 20
set rs = server.createobject("adodb.recordset")
sql = "select a.ID,a.OrderNum,a.del,a.OrderSum,a.PayType,a.RecName,a.UserID,a.OrderTime,b.Status,b.StatusDefine from bOrderList a,type b where a.del=true and a.Status=b.Status "
sql= sql+" order by OrderTime desc"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<tr bgcolor=#FFFFFF><td colspan=7 align=center height=50>回收站是空的</td></tr>"
response.end 
rs.close
set rs=nothing
end if
totalrs=rs.RecordCount
rs.pageSize = pages
allPages = rs.pageCount
page = Request("page")
If not isNumeric(page) then page=1
if isEmpty(page) or int(page) <= 1 then
page = 1
elseif int(page) > allPages then
page = allPages 
end if
rs.AbsolutePage = page
%>

<tr bgcolor="#f4f5fd">
<td width=5% align=center>选</td>
<td width='15%' align=center>订单号</td>
<td width='15%' align=center>金额</td>
<td width='15%' align=center>会员ID</td>
<td width='12%' align=center>收货人姓名</td>
<td width='20%' align=center>下单时间</td>
<td width='18%' align=center>订单状态</td>
</tr>
<%
Do While Not rs.eof and pages>0
response.write "<tr bgcolor=#FFFFFF><td><input type='checkbox' value='"&rs("ID")&"' name=id></td>"
response.write "<td align=center>"&rs("OrderNum")&"</td><td align=right>"&formatnum(csng(rs("OrderSum")),2)&"&nbsp;</td><td>"
response.write rs("userid")&"</td><td>"&rs("RecName")&"</td><td >"&rs("OrderTime")&"</td><td align=center>"
if rs("Status")="0" then
response.write "<font color=red>"&rs("StatusDefine")&"</font>"
elseif rs("Status")="99" then 
response.write "<font color=blue>"&rs("StatusDefine")&"</font>"
elseif rs("Status")="88" then 
response.write "<font color=blue>"&rs("StatusDefine")&"</font>"
else
response.write "<font color=darkgray>"&rs("StatusDefine")&"</font>"
end if
response.write "</td></tr>"

pages = pages - 1
rs.movenext
if rs.eof then exit do
loop
%>	
<tr bgcolor="#FFFFFF"><td colspan=7>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>
<input type="submit" name="action" value="彻底删除" onClick="{if(confirm('提示：该操作不可恢复，您确实要删除所选订单吗？')){this.document.orderlist.submit();return true;}return false;}"> 	
<input type="submit" name="action" value="恢复订单" onClick="{if(confirm('提示：确认要恢复此订单吗？')){this.document.orderlist.submit();return true;}return false;}"> 	
</td></tr>
</form>
</table>
		  <table height="5"><tr><td></td></tr></table>
<%
rs.close
set rs=nothing
'if allpages<=1 then exit sub
response.write "<br>总订单数<font color=red>"&totalrs&"</font> &nbsp; 每页<font color=red>20</font>&nbsp; "
if page = 1 then
response.write "<font color=darkgray>首页 前页</font>"
else
response.write "<a href=order3.asp?keywords="&keywords&"&page=1>首页</a> <a href=order3.asp?keywords="&keywords&"&page="&page-1&">前页</a>"
end if
if page = allpages then
response.write "<font color=darkgray> 下页 末页</font>"
else
response.write " <a href=order3.asp?keywords="&keywords&"&page="&page+1&">下页</a> <a href=order3.asp?keywords="&keywords&"&page="&allpages&">末页</a>"
end if

end sub



sub orderdel()
delid=request("id")
if Delid="" or isnull(Delid) then
response.write "<script language='javascript'>"
response.write "alert('操作失败，您什么也没有选择。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bOrderList where id in ("&Delid&")"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('出错了，该订单不存在或者已经被删除。');"		
response.write "</script>"			
response.end 
else
Do while not rs.eof
rs.delete
rs.update
rs.movenext
loop
rs.close
set rs=nothing
response.write "<script language='javascript'>"
response.write "alert('操作成功，所选订单已被彻底删除。');"
response.write "location.href='order3.asp';"			
response.write "</script>"
end if
end sub



sub huifu()
id=request("id")
if id="" or isnull(id) then
response.write "<script language='javascript'>"
response.write "alert('操作失败，您什么也没有选择。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from bOrderList where id in ("&id&")"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('出错了，该订单不存在或者已经被删除。');"		
response.write "</script>"			
response.end 
else
Do while not rs.eof
rs("del")=false
rs.update
rs.movenext
loop
rs.close
set rs=nothing
response.write "<script language='javascript'>"
response.write "alert('操作成功，所选订单已被恢复。');"
response.write "location.href='order3.asp';"			
response.write "</script>"
end if
end sub

%>
</body>
</html>