<html xmlns="http://www.w3.org/1999/xhtml">
<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<!--#include file="../Inc/SK.PageClass.asp" -->
<%if Not (Getconfig("SK_Sales")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK300000000") AND JudgePopedomTF(Session("UserName"),"SK300000700")))) then Call ReturnError()%>
<%
Dim i,Bid

'Delete begin
if F("id")<>"" and RQ("Action")="Del" and (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000703")) then
Bid=split(F("id"),",")
for i=0 to ubound(Bid)
set rs=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=0 and ReturnsID="&trim(Bid(i))
elseif Session("Manager")=3 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SalesOrders.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=4 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=5 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=6 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=0 and SK_SalesID="&Session("UID")&" and ReturnsID="&trim(Bid(i))
end if
rs.open sql,Conn,1,3
rs("SK_Del")=1
rs("SK_DelTime")=Now
rs("SK_DelUser")=Session("UID")
rs.Update
rs.close
Set rs=Nothing
next

'Event Begin
if getconfig("SK_Event")=0 then
set rsEvent=server.createobject("adodb.recordset")
sqlEvent="select * from SK_SystemEvent"
rsEvent.open sqlEvent,conn,1,3
rsEvent.AddNew
rsEvent("SK_Title")="将产品销售退货放入回收站"
rsEvent("SK_User")=Session("UserName")
rsEvent("SK_Time")=Now()
rsEvent("SK_IP")=request.ServerVariables("Remote_Addr")
rsEvent.Update
rsEvent.Close 
set rsEvent=Nothing
end if
'Event End
Call Returnokback()
end if
'Delete End

'YTG begin
if F("id")<>"" and RQ("Action")="YTG" and (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000708")) then
Bid=split(F("id"),",")
for i=0 to ubound(Bid)
set rs=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=0 and ReturnsID="&trim(Bid(i))
elseif Session("Manager")=3 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SalesOrders.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=4 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=5 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=0 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=6 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=0 and SK_SalesID="&Session("UID")&" and ReturnsID="&trim(Bid(i))
end if
rs.open sql,Conn,1,3
rs("SK_ShFeet")="1"
rs("SK_SHContent")="审核已通过"
rs("SK_ShUID")=Session("UID")
rs("SK_SHTime")=Now()
rs.Update
rs.close
Set rs=Nothing
next

'Event Begin
if getconfig("SK_Event")=0 then
set rsEvent=server.createobject("adodb.recordset")
sqlEvent="select * from SK_SystemEvent"
rsEvent.open sqlEvent,conn,1,3
rsEvent.AddNew
rsEvent("SK_Title")="审核产品退货已通过"
rsEvent("SK_User")=Session("UserName")
rsEvent("SK_Time")=Now()
rsEvent("SK_IP")=request.ServerVariables("Remote_Addr")
rsEvent.Update
rsEvent.Close 
set rsEvent=Nothing
end if
'Event End
Call Returnokback()
end if
'YTG End

'YTG begin
if F("id")<>"" and RQ("Action")="WTG" and (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000708")) then
Bid=split(F("id"),",")
for i=0 to ubound(Bid)
set rs=server.createobject("adodb.recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=1 and ReturnsID="&trim(Bid(i))
elseif Session("Manager")=3 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SalesOrders.SK_Del=0 and SK_SalesReturns.SK_ShFeet=1 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=4 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=1 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=5 then
sql="select * from SK_SalesReturns INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID where SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_SalesReturns.SK_Del=0 and SK_SalesReturns.SK_ShFeet=1 and SK_SalesReturns.ReturnsID="&trim(Bid(i))
elseif Session("Manager")=6 then
sql="select * from SK_SalesReturns where SK_Del=0 and SK_ShFeet=1 and SK_SalesID="&Session("UID")&" and ReturnsID="&trim(Bid(i))
end if
rs.open sql,Conn,1,3
rs("SK_ShFeet")="0"
rs("SK_SHContent")="审核未通过"
rs("SK_ShUID")=Session("UID")
rs("SK_SHTime")=Now()
rs.Update
rs.close
Set rs=Nothing
next

'Event Begin
if getconfig("SK_Event")=0 then
set rsEvent=server.createobject("adodb.recordset")
sqlEvent="select * from SK_SystemEvent"
rsEvent.open sqlEvent,conn,1,3
rsEvent.AddNew
rsEvent("SK_Title")="审核产品退货未通过"
rsEvent("SK_User")=Session("UserName")
rsEvent("SK_Time")=Now()
rsEvent("SK_IP")=request.ServerVariables("Remote_Addr")
rsEvent.Update
rsEvent.Close 
set rsEvent=Nothing
end if
'Event End
Call Returnokback()
end if
'WTG End

Set Page = new MyPages				'创建对象
Set Page.Conn = conn				'得到数据库连接对象
With Page
if Cint(F("PNum"))="" then
.PageSize=20		             '每页记录条数
else
.PageSize=Cint(F("PNum"))		'每页记录条数
end if
.PageParm = "P"					'页参数
'.PageIndex = 10				'当前页，可选参数，一般是生成静态时需要
.Database = "mssql"				'数据库类型,AC为access,MSSQL为sqlserver2000存储过程版,MYSQL为mysql,PGSQL为PostGreSql
.Table="SK_SalesReturns INNER JOIN SK_SalesOrders ON SK_SalesOrders.OrdersID=SK_SalesReturns.SK_OrderID INNER JOIN SK_Client ON SK_SalesReturns.SK_ClientID=SK_Client.ClientID INNER JOIN SK_SystemUsers ON SK_SalesReturns.SK_SalesID=SK_SystemUsers.UsersID"				'表名
.Pkey="ReturnsID"						'主键
.Field="SK_SalesReturns.ReturnsID,SK_SalesReturns.SK_ClientID,SK_SalesReturns.SK_OrderID,SK_SalesReturns.SK_Di,SK_SalesReturns.SK_Atime,SK_SalesReturns.SK_Feet,SK_SalesReturns.SK_SalesID,SK_SalesReturns.SK_ShUID,SK_SalesReturns.SK_ShFeet,SK_SalesReturns.SK_ShTime,SK_SalesReturns.SK_ShContent"	'字段

'//搜索关键字开始
STime=F("STime")&" 00:00:00"
Etime=F("ETime")&" 23:59:59"

if F("AA")="1" AND F("Akey")<>"" then srt1=" AND SK_SalesOrders.SK_OrdersNo Like '%"&F("Akey")&"%'"
if F("AA")="2" AND F("Akey")<>"" then srt1=" AND (SK_Client.SK_Wname Like '%"&F("Akey")&"%' OR SK_Client.SK_Jname Like '%"&F("Akey")&"%')"
if F("AA")="3" AND F("Akey")<>"" then srt1=" AND SK_SalesReturns.SK_ReContent Like '%"&F("Akey")&"%'"
if F("AA")="4" AND F("Akey")<>"" then srt1=" AND SK_SystemUsers.SK_Oname Like '%"&F("Akey")&"%'"

if F("Feet")<>"" then srt2=" AND SK_SalesReturns.SK_Feet="&F("Feet")&""
if F("Di")<>"" then srt4=" AND SK_SalesReturns.SK_Di="&F("Di")&""
if F("STime")<>"" AND F("ETime")<>"" then srt3=" AND SK_SalesReturns.SK_Atime Between '"&STime&"' AND '"&Etime&"'"

'//搜索关键字结束

'//权限判断开始
if Session("Manager")=1 or Session("Manager")=2 then
.Condition="SK_SalesReturns.SK_Del=0 AND SK_SalesReturns.SK_SalesID<>0"&srt1&""&srt2&""&srt3&""&srt4&""
elseif Session("Manager")=3 then
.Condition="SK_SalesReturns.SK_Del=0 AND SK_SalesReturns.SK_SalesID<>0 AND SK_SystemUsers.SK_Dept1="&Session("Dept1")&""&srt1&""&srt2&""&srt3&""&srt4&""
elseif Session("Manager")=4 then
.Condition="SK_SalesReturns.SK_Del=0 AND SK_SalesReturns.SK_SalesID<>0 AND SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&""&srt1&""&srt2&""&srt3&""&srt4&""
elseif Session("Manager")=5 then
.Condition="SK_SalesReturns.SK_Del=0 AND SK_SalesReturns.SK_SalesID<>0 AND SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&""&srt1&""&srt2&""&srt3&""&srt4&""
elseif Session("Manager")=6 then
.Condition="SK_SalesReturns.SK_Del=0 AND SK_SalesReturns.SK_SalesID<>0 AND SK_SalesOrders.SK_SalesID="&Session("UID")&""&srt1&""&srt2&""&srt3&""&srt4&""
end if
'//权限判断结束

'//指定排序条件开始
.OrderBy="SK_SalesReturns.ReturnsID Desc"

if F("BB")="0" AND F("PX")="1" then
.OrderBy="SK_SalesOrders.SK_OrdersNo Asc"
elseif F("BB")="0" AND F("PX")="2" then
.OrderBy="SK_SalesOrders.SK_OrdersNo Desc"
end if

if F("BB")="1" AND F("PX")="1" then
.OrderBy="SK_SalesReturns.SK_Atime Asc"
elseif F("BB")="1" AND F("PX")="2" then
.OrderBy="SK_SalesReturns.SK_Atime Desc"
end if

if F("BB")="2" AND F("PX")="1" then
.OrderBy="SK_SystemUsers.SK_Oname Asc"
elseif F("BB")="2" AND F("PX")="2" then
.OrderBy="SK_SystemUsers.SK_Oname Desc"
end if

'//指定排序条件结束

.RecordCount = 0	'总记录数，可以外部赋值，0不保存（适合搜索），-1存为session，-2存为cookies，-3存为applacation
.NumericJump = 3 '数字上下页个数，可选参数，默认为3，负数为跳转个数，0为显示所有
.Template = "总记录数：{$RecordCount} 总页数：{$PageCount} 每页记录数：{$PageSize} 当前页数：{$PageIndex} {$FirstPage} {$PreviousPage} {$NumericPage} {$NextPage} {$LastPage} {$InputPage} {$SelectPage}" '整体模板，可选参数，有默认值
.FirstPage = "首页" '可选参数，有默认值
.PreviousPage = "上一页" '可选参数，有默认值
.NextPage = "下一页" '可选参数，有默认值
.LastPage = "尾页" '可选参数，有默认值
.NumericPage = " {$PageNum} " '数字分页部分模板，可选参数，有默认值
End With
rs = Page.ResultSet() '记录集
rc = Page.RowCount() '可选，输出总记录数
nav = Page.Nav() '分页样式
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>产品销售退货</title>
<META http-equiv=Page-Enter content=SKCRM>
<META http-equiv=Page-Exit content=SKCRM>
<META content="MSHTML 6.00.3790.2858" name=GENERATOR>
<LINK href="../images/style.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="../Inc/Check.js"></script>
<script type="text/javascript" src="../Inc/Calendar.js"></script>
<script type="text/javascript">
function sh(id)
{
 if (id==1)
 {
 {
 thisForm.target='_self';
 thisForm.action="?Action=Del";
 thisForm.submit();
 }
 }
 if (id==2)
 {
 {
 thisForm.target='_self';
 thisForm.action="SK.ExcelProReturned.asp";
 thisForm.submit();
 }
 }
 if (id==5)
 {
 {
 thisForm.target='_self';
 thisForm.action="?Action=YTG";
 thisForm.submit();
 }
 }
 if (id==6)
 {
 {
 thisForm.target='_self';
 thisForm.action="?Action=WTG";
 thisForm.submit();
 }
 }
}
function AdSearch(t_id,b_id){
	var targetTR =eval("document.all.followTR" + t_id);
	var targetDiv =eval("document.all.follow" + t_id);
	
	if ("object"==typeof(targetTR)){
		if (targetDiv.style.display!='block'){
			targetDiv.style.display="block";
			
		}else{
			targetDiv.style.display="none";
		}
	}
}
function OpenDetails(de_id,ta_id){
	var taTd =eval("document.all.DetailsTD" + de_id);
	var taDiv =eval("document.all.Details" + de_id);
	
	if ("object"==typeof(taTd)){
		if (taDiv.style.display!='block'){
			taDiv.style.display="block";
			
		}else{
			taDiv.style.display="none";
		}
	}
}
</script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x:hidden;
overflow-y:auto;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<TBODY>
  <tr>
    <td class="SK_Td_Top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="25"><img src="../images/tab_03.gif" width="12" height="25" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" valign="middle">产品销售退货</td>
<td width="54%">
<table border="0" align="right" cellpadding="0" cellspacing="0">
 <tr>
 <td>
<%if Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000701") then%>
<a href="javascript:void(0)" onClick="javascript:var win=window.open('SK.AddProReturned.asp','Add','width=820,height=400,top=170,left=161,center:yes,status:no,help:no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes'); win.focus()"><img src="../images/SK_Add.gif" title="新建信息" /></a>
<%end if%>
</td>
 </tr>
</table>
</td>
</tr>
</table></td>
        <td width="16"><img src="../images/tab_07.gif" width="16" height="25" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form method="Get">
<tr>
<td background="../images/tab_12.gif"></td>
<td>
<select name="AA" size="1">
<option value="1" <%if RQ("AA")=1 OR RQ("AA")="" then Response.Write("selected=""selected""")%>>关联订单</option>
<option value="2" <%if RQ("AA")=2 then Response.Write("selected=""selected""")%>>关联客户</option>
<option value="3" <%if RQ("AA")=3 then Response.Write("selected=""selected""")%>>退货备注</option>
<option value="4" <%if RQ("AA")=4 then Response.Write("selected=""selected""")%>>业务人员</option>
</select> 
<input name="Akey" type="text" value="<%=F("Akey")%>" size="20">
 排序
<select name="BB" size="1">
<option value="0" <%if RQ("BB")=0 OR RQ("BB")="" then Response.Write("selected=""selected""")%>>关联订单</option>
<option value="1" <%if RQ("BB")=1 then Response.Write("selected=""selected""")%>>退货日期</option>
<option value="2" <%if RQ("BB")=2 then Response.Write("selected=""selected""")%>>业务人员</option>
</select>
<select name="PX" size="1">
<option value="1" <%if RQ("PX")=1 then Response.Write("selected=""selected""")%>> 升序</option>
<option value="2" <%if RQ("PX")=2 then Response.Write("selected=""selected""")%>> 降序</option>
</select>
 每页显示
<select name="PNum" size="1">
<option value="20" <%if RQ("PNum")=20 then Response.Write("selected=""selected""")%>>20</option>
<option value="25" <%if RQ("PNum")=25 then Response.Write("selected=""selected""")%>>25</option>
<option value="30" <%if RQ("PNum")=30 then Response.Write("selected=""selected""")%>>30</option>
<option value="40" <%if RQ("PNum")=40 then Response.Write("selected=""selected""")%>>40</option>
<option value="50" <%if RQ("PNum")=50 then Response.Write("selected=""selected""")%>>50</option>
<option value="60" <%if RQ("PNum")=60 then Response.Write("selected=""selected""")%>>60</option>
<option value="80" <%if RQ("PNum")=80 then Response.Write("selected=""selected""")%>>80</option>
<option value="100" <%if RQ("PNum")=100 then Response.Write("selected=""selected""")%>>100</option>
<option value="120" <%if RQ("PNum")=120 then Response.Write("selected=""selected""")%>>120</option>
<option value="150" <%if RQ("PNum")=150 then Response.Write("selected=""selected""")%>>150</option>
<option value="200" <%if RQ("PNum")=200 then Response.Write("selected=""selected""")%>>200</option>
<option value="300" <%if RQ("PNum")=300 then Response.Write("selected=""selected""")%>>300</option>
<option value="400" <%if RQ("PNum")=400 then Response.Write("selected=""selected""")%>>400</option>
<option value="500" <%if RQ("PNum")=500 then Response.Write("selected=""selected""")%>>500</option>
<option value="600" <%if RQ("PNum")=600 then Response.Write("selected=""selected""")%>>600</option>
<option value="800" <%if RQ("PNum")=800 then Response.Write("selected=""selected""")%>>800</option>
<option value="1000" <%if RQ("PNum")=1000 then Response.Write("selected=""selected""")%>>1000</option>
<option value="2000" <%if RQ("PNum")=2000 then Response.Write("selected=""selected""")%>>2000</option>
<option value="5000" <%if RQ("PNum")=5000 then Response.Write("selected=""selected""")%>>5000</option>
<option value="10000" <%if RQ("PNum")=10000 then Response.Write("selected=""selected""")%>>10000</option>
</select>
<input type="submit" name="go" value="查询" class="button1" />  
<span id="followTR1" style="CURSOR: hand" onClick="AdSearch(1,5)">高级查询</span>
</td>
<td background="../images/tab_15.gif"></td>
</tr>
<tr style="display:none" id="follow1">
<td background="../images/tab_12.gif"></td>
<td>
<select name="Feet">
<option value="" <%if RQ("Feet")="" then Response.Write("selected=""selected""")%>>--可选择--</option>
<option value="0" <%if RQ("Feet")="0" then Response.Write("selected=""selected""")%>>计划退货</option>
<option value="1" <%if RQ("Feet")="1" then Response.Write("selected=""selected""")%>>已经退货</option>
<option value="2" <%if RQ("Feet")="2" then Response.Write("selected=""selected""")%>>申请入库</option>
<option value="3" <%if RQ("Feet")="3" then Response.Write("selected=""selected""")%>>已经入库</option>
</select>  

<select name="Di">
<option value="" <%if RQ("Di")="" then Response.Write("selected=""selected""")%>>--可选择--</option>
<%
Set rs1=Server.CreateObject("ADODB.RecordSet") 
sql1="SELECT * from SK_SystemCategory where SK_Di=46 order by CategoryID asc" 
rs1.Open sql1,conn,1,1
do while not rs1.eof
%><option value="<%=rs1("CategoryID")%>" <%if RQ("Di")=""&rs1("CategoryID")&"" then Response.Write("selected=""selected""")%>><%=rs1("SK_Name")%></option>
<%
rs1.movenext
loop
rs1.close
set rs1=Nothing
%></select>

退货日期：
<input name="STime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=RQ("STime")%>" readOnly /> 至 <input name="ETime" type="text" size="12" onClick="new Calendar().show(this);" value="<%=RQ("ETime")%>" readOnly />   
</td>
<td background="../images/tab_15.gif"></td>
</tr>
</form>

<tr>
<td width="8" background="../images/tab_12.gif"></td>
<td>

<%
If IsNull(Rs) Then
response.write"对不起，没有你要的信息!"
else
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<form name="thisForm" id="form1" method="post" action="">	  
<tr><td width="2%" class="SK_Title"><input name="chkall" type="checkbox" id="chkall" value="select" onClick="CheckAll(this.form)" style="border:0" /></td>
<td width="14%" class="SK_Title">关联订单</td>
<td width="14%" class="SK_Title">关联客户</td>
<td width="8%" class="SK_Title">退款金额</td>
<td width="8%" class="SK_Title">已退金额</td>
<td width="8%" class="SK_Title">应退金额</td>
<td width="6%" class="SK_Title">状态</td>
<td width="6%" class="SK_Title">退货原因</td>
<td width="6%" class="SK_Title">审核</td>
<td width="7%" class="SK_Title">退货日期</td>
<td width="6%" class="SK_Title">业务人员</td>
<td width="4%" class="SK_Title">修改</td>
</tr>
<%For i=0 To Ubound(Rs,2)%>
<tr onMouseOver="changeto()" onMouseOut="changeback()">
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><input type="checkbox" name="ID" value="<%=Rs(0,i)%>" style="border:0"></td>
<td <%if i mod 2 = 0 then%>class="SK_Text1"<%else%>class="SK_Text1two"<%end if%>>
<%
set rsOrder=server.createobject("adodb.recordset")
sqlOrder="select * from SK_SalesOrders where OrdersID="&Rs(2,i)&""
rsOrder.open sqlOrder,conn,1,1
if rsOrder.eof and rsOrder.bof then Call ReturnError21()
Response.write"<a href=""javascript:void(0)"" onClick=""javascript:var win=window.open('SK.ReProOrder.asp?id="&rsOrder("OrdersID")&"','Read','width=820,height=400,top=170,left=161,center:yes,status:no,help:no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes'); win.focus()"">"&RsOrder("SK_OrdersNo")&"</a>"
RsOrder.close
Set RsOrder=Nothing
%> <span id="DetailsTD<%=i%>" style="CURSOR: hand" onClick="OpenDetails(<%=i%>,5)" title="展开产品列表">+</span></td>
<td <%if i mod 2 = 0 then%>class="SK_Text1"<%else%>class="SK_Text1two"<%end if%>><%
set rsClient=server.createobject("adodb.recordset")
sqlClient="select * from SK_Client where ClientID="&Rs(1,i)&""
rsClient.open sqlClient,conn,1,1
if rsClient.eof and rsClient.bof then Call ReturnError12()
Response.write"<a href=""javascript:void(0)"" onClick=""javascript:var win=window.open('../Client/SK.ReClient.asp?id="&rsClient("ClientID")&"','Read','width=820,height=400,top=170,left=161,center:yes,status:no,help:no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes'); win.focus()"" title=""客户全称:"&RsClient("SK_Wname")&"""><font color=red>"&left(RsClient("SK_Wname"),14)&"</font></a>"
RsClient.close
Set RsClient=Nothing
%></td>

<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsAG=server.createobject("adodb.recordset")
AGSql="select sum(SK_Total*SK_Price) as AG from SK_SalesReturnsDetail where SK_ReturnsID="&Rs(0,i)&""
RsAG.open AGSql,Conn,1,1
if RsAG("AG")<>"" then
Response.write"<font color=blue>"&formatnumber(RsAG("AG"),2)&"</font>" 
else 
Response.write"<font color=blue>0</font>"
end if
Dim JAG
if RsAG("AG")<>"" then
JAG=RsAG("AG")
else
JAG="0"
end if
RsAG.close
set RsAG=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsYS=server.createobject("adodb.recordset")
SqlYS="select sum(SK_Amount) as YS from SK_Accounts where SK_Di=1 and SK_Feet=1 and SK_SalesOrders="&Rs(2,i)&""
RsYS.open SqlYS,Conn,1,1
if RsYS("YS")<>"" then 
Response.write"<font color=blue>"&formatnumber(RsYS("YS"),2)&"</font>"
else
Response.write"<font color=blue>0</font>"
end if
Dim JYS
if RsYS("YS")<>"" then
JYS=RsYS("YS")
else
JYS="0"
end if
RsYS.close
set RsYS=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
if (JAG-JYS)>0 then
Response.write"<font color=red>"&formatnumber((JAG-JYS),2)&"</font>"
else
Response.write"<font color=red>0</font>"
end if
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><% 
Response.write"<font color=blue>"
if Rs(5,i)=0 then
Response.write"计划退货"
elseif Rs(5,i)=1 then
Response.write"已经退货"
elseif Rs(5,i)=2 then
Response.write"申请入库"
elseif Rs(5,i)=3 then
Response.write"已经入库"
end if
Response.write"</font>"
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsClass=server.createobject("adodb.recordset")
SqlClass="select * from SK_SystemCategory where SK_Di=46 and CategoryID="&Rs(3,i)&""
RsClass.open SqlClass,conn,1,1
Response.write"<font color=""#999999"">"&RsClass("SK_Name")&"</font>"
RsClass.close
set RsClass=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsShUID=server.createobject("adodb.recordset")
SqlShUID="select * from SK_SystemUsers where UsersID="&Rs(7,i)&""
RsShUID.open SqlShUID,conn,1,1
if Rs(8,i)=0 then 
Response.write"<font color=""#009999"">未审核</font>"
elseif Rs(8,i)=1 then
Response.write"<span style=""CURSOR: hand"" title=""审核时间:"&Rs(9,i)&"&#13;审核人员:"&RsShUID("SK_OName")&"&#13;审核备注:"&Rs(10,i)&"""><font color=""#0066FF"">已通过</font></span>"
elseif Rs(8,i)=2 then
Response.write"<span style=""CURSOR: hand"" title=""审核时间:"&Rs(9,i)&"&#13;审核人员:"&RsShUID("SK_OName")&"&#13;审核备注:"&Rs(10,i)&"""><font color=""red"">未通过</font></span>"
end if
RsShUID.close
Set RsShUID=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%=Rs(4,i)%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>><%
set RsFuser=server.createobject("adodb.recordset")
SqlFuser="select * from SK_SystemUsers where UsersID="&Rs(6,i)&""
RsFuser.open SqlFuser,conn,1,1
Response.write""&RsFuser("SK_OName")&""
RsFuser.close
Set RsFuser=Nothing
%></td>
<td <%if i mod 2 = 0 then%>class="SK_Text"<%else%>class="SK_Texttwo"<%end if%>>
<%
if (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000702")) and Rs(6,i)<>"3" then
Response.write"<a href=""javascript:void(0)"" onClick=""javascript:var win=window.open('SK.ModProReturned.asp?id="&Rs(0,i)&"','Mod','width=820,height=400,top=170,left=161,center:yes,status:no,help:no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes'); win.focus()""><img src=""../images/mod.gif"" /></a>"
else
Response.write"<img src=""../images/nomod.gif"">"
end if
%></td>
</tr>
<TR style="display:none" id="Details<%=i%>">
<td colspan="12" class="SK_Text">
<!--产品列表开始-->
<%
set RsDetail=Server.createobject("adodb.recordset")
sqlDetail="select * from SK_SalesReturnsDetail where SK_ReturnsID="&Rs(0,i)&" order by ReturnsDetailID asc"
RsDetail.open sqlDetail,conn,1,1
if RsDetail.bof and RsDetail.eof then 
Call ReturnError8()
else
%>
<TABLE width="100%" border=1 align="center" cellPadding=1 cellSpacing=0 borderColor=#ffffff borderColorLight=#dfdfdf borderColorDark=#ffffff>
<tr>  
<td width="25%" class="Pheadtd">产品名称</td>
<td width="21%" class="Pheadtd">产品编码</td>  
<td width="21%" class="Pheadtd">产品规格</td>  
<td width="11%" class="Pheadtd">数量</td>
<td width="11%" class="Pheadtd">单价</td>  
<td width="11%" class="Pheadtd">金额</td>
</tr>
<%
For J = 1 To RsDetail.recordcount
set rsProduct=server.createobject("adodb.recordset")
sqlProduct="select * from SK_Product where ProID="&RsDetail("SK_ProID")&""
rsProduct.open sqlProduct,conn,1,1
set RsUnit=server.createobject("adodb.recordset")

SqlUnit="select * from SK_SystemCategory where SK_Di=161 and CategoryID="&rsProduct("SK_Unit")&""
RsUnit.open SqlUnit,conn,1,1
%>
<tr>
<td class="Ptetd"><%=RsProduct("SK_ProName")%></td>
<td class="Ptetd"><%=RsProduct("SK_ProNo")%></td>
<td class="Ptetd"><%=RsProduct("SK_ProNum")%></td>
<td class="Ptetd"><%=RsDetail("SK_Total")%> / <%=RsUnit("SK_Name")%></td>
<td class="Ptetd"><%=formatnumber(RsDetail("SK_Price"),2)%></td>
<td class="Ptetd"><%=formatnumber(RsDetail("SK_Total")*RsDetail("SK_Price"),2)%></td>
</tr>
<%
RsUnit.close
Set RsUnit=Nothing
rsProduct.close

RsDetail.movenext
next
%>
<tr>
  <td colspan="5" class="Ptetd">合计</td>
  <td class="Ptetd"><%
set RsAG=server.createobject("adodb.recordset")
SqlAG="select sum(SK_Total*SK_Price) as AG from SK_SalesReturnsDetail where SK_ReturnsID="&Rs(0,i)&""
RsAG.open SqlAG,Conn,1,1
Response.write"<font color=blue>"&formatnumber(RsAG("AG"),2)&"</font>"
RsAG.close
set RsAG=Nothing
%></td>
  </tr>
</table>
<%
end if
RsDetail.close
Set RsDetail=Nothing
%>
<!--产品列表结束--></td>
</tr>
<%next%>
</form>
<%if Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000703") OR JudgePopedomTF(Session("UserName"),"SK300000704") then%>
<tr>
<td colspan="12" class="SK_Text">
<%if Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000703") then%>
<input type="button" name="Del" value="删除" class="button1" onClick="if (confirm('温馨提示:删除后的数据将放入回收站,审核通过的单不能删除,是否要继续?')){sh(1)}" />
<%end if%>

<%if Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000704") then%>
<input type="button" name="Exl" value="导出" class="button1" onClick="if (confirm('温馨提示:将数据导出到EXCEL表格,是否要继续?')){sh(2)}" />
<%end if%>

<%if Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK300000708") then%>
<input type="button" name="F5" value="已通过" class="button1" onClick="if (confirm('温馨提示:将退货设为已通过,已通过的可以进入退款,是否要继续?')){sh(5)}" />

<input type="button" name="F6" value="未通过" class="button1" onClick="if (confirm('温馨提示:将退货设为未通过,是否要继续?')){sh(6)}" />
<%end if%></td>
</tr>
<%end if%>
<tr>
<td colspan="12" class="SK_Text"><%Response.Write nav%></td>
</tr>
</table>
<%end if%>
</td>
<td width="8" background="../images/tab_15.gif"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="SK_Td_Foot">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" height="20"><img src="../images/tab_18.gif" width="12" height="20" /></td>
<td width="98%" class="SK_Td_Page"></td>
<td width="1%"><img src="../images/tab_20.gif" width="16" height="20" /></td>
</tr>
</table>

</td>
</tr>
</TBODY>
</table>
</body>
<%
Page = Null
Set Page = Nothing
Call CloseDB()
%>
</html>