<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<%if Not (Getconfig("SK_Finance")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK700000000") AND JudgePopedomTF(Session("UserName"),"SK700000500")))) then Call ReturnError()%>
<%
Dim i,str2

'导出付款信息到Excel开始
Response.Buffer = True 
Response.ContentType = "application/vnd.ms-excel" 
SaveFilename=replace(replace(replace(now,":","")," ",""),"/","")
Thead="ProcureFund_"
Response.AddHeader "content-disposition", "inline; filename = "&Thead&SaveFilename&".xls"

Response.Write("<table width=""100%"" align=""center"" cellpadding=""3"" cellspacing=""1"" border=""1"">"&VBCrlf)
Response.Write("<tr bgcolor=""#E8E8E8"">"&VBCrlf)
Response.Write("<td width=""12%""><b>类别</b></td>")
Response.Write("<td width=""9%""><b>采购订单</b></td>")
Response.Write("<td width=""9%""><b>收款单位</b></td>")
Response.Write("<td width=""9%""><b>付款账户</b></td>")
Response.Write("<td width=""9%""><b>付款金额</b></td>")
Response.Write("<td width=""9%""><b>付款日期</b></td>")
Response.Write("<td width=""9%""><b>经办人员</b></td>")
Response.Write("<td width=""9%""><b>财务人员</b></td>")
Response.Write("<td width=""10%""><b>创建时间</b></td>")
Response.Write("<td width=""5%""><b>描述</b></td>")
Response.Write("</tr>"&VBCrlf)

if F("id")="" then
Set RS = Server.CreateObject("ADODB.Recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="select * from SK_Accounts where SK_Di=1 and SK_ProcureOrders<>0 and SK_ProcureVend<>0 and SK_Del=0"
elseif Session("Manager")=3 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&""
elseif Session("Manager")=4 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&""
elseif Session("Manager")=5 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&""
elseif Session("Manager")=6 then
sql="select * from SK_Accounts where SK_Di=1 and SK_ProcureOrders<>0 and SK_ProcureVend<>0 and SK_Del=0 and SK_SalesID="&Session("UID")&""
end if
RS.Open Sql,Conn,1,1
if rs.bof and rs.eof then Call ReturnError4()
K=0
while not Rs.eof
K=K+1
Response.Write("<tr bgcolor=FFFFFF>"&VBCrlf)
'-----------------------------------------
if Rs("SK_Di")=0 then
Response.Write("<td align=left><font color=red>收入</font></td>")
else
Response.Write("<td align=left><font color=blue>支出</font></td>")
end if
set RsOrders=server.createobject("adodb.recordset")
SqlOrders="select * from SK_ProcureOrders where OrdersID="&Rs("SK_ProcureOrders")&""
RsOrders.open SqlOrders,conn,1,1
Response.Write("<td align=left>"&RsOrders("SK_OrdersNo")&"</td>")
RsOrders.close
Set RsOrders=Nothing

set RsVend=server.createobject("adodb.recordset")
SqlVend="select * from SK_ProcureVend where VendID="&Rs("SK_ProcureVend")&""
RsVend.open SqlVend,conn,1,1
Response.Write("<td align=left>"&RsVend("SK_Wname")&"</td>")
RsVend.close
Set RsVend=Nothing

set rsBanks=server.createobject("adodb.recordset")
sqlBanks="select * from SK_Banks where BanksID="&Rs("SK_BanksID")&""
rsBanks.open sqlBanks,conn,1,1
Response.Write("<td align=left>"&RsBanks("SK_BankName")&"</td>")
RsBanks.close
Set RsBanks=Nothing
if Rs("SK_Di")=0 then
Response.write"<td align=center><font color=red>"&formatnumber(Rs("SK_Amount"),2)&"</font></td>"
else
Response.write"<td align=center><font color=blue>"&formatnumber(Rs("SK_Amount"),2)&"</font></td>"
end if
Response.Write("<td align=left>"&Rs("SK_Atime")&"</td>")
Response.Write("<td align=left>"&Rs("SK_Aname")&"</td>")

set RsSales=server.createobject("adodb.recordset")
SqlSales="select * from SK_SystemUsers where UsersID="&RS("SK_SalesID")&""
RsSales.open SqlSales,conn,1,1
Response.Write("<td align=left>"&RsSales("SK_OName")&"</td>")
RsSales.close
Set RsSales=Nothing
Response.Write("<td align=left>"&Rs("SK_Time")&"</td>")
Response.Write("<td align=left>"&Rs("SK_Content")&"</td>")
'------------------------------------------
Response.Write("</tr>"&VBCrlf)
rs.movenext
wend

elseif F("id")<>"" then '当选择有ID时输出数据开始
str2=split(F("id"),",")
for i=0 to ubound(str2)
Set Rs = Server.CreateObject("ADODB.Recordset")
if Session("Manager")=1 or Session("Manager")=2 then
sql="select * from SK_Accounts where SK_Di=1 and SK_ProcureOrders<>0 and SK_ProcureVend<>0 and SK_Del=0 and AccountsID="&trim(str2(i))
elseif Session("Manager")=3 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and  SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_Accounts.AccountsID="&trim(str2(i))
elseif Session("Manager")=4 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_Accounts.AccountsID="&trim(str2(i))
elseif Session("Manager")=5 then
sql="select * from SK_Accounts INNER JOIN SK_SystemUsers ON SK_Accounts.SK_SalesID=SK_SystemUsers.UsersID where SK_Accounts.SK_Di=1 and SK_Accounts.SK_ProcureOrders<>0 and SK_Accounts.SK_ProcureVend<>0 and SK_Accounts.SK_Del=0 and SK_SystemUsers.SK_Dept1="&Session("Dept1")&" and SK_SystemUsers.SK_Dept2="&Session("Dept2")&" and SK_SystemUsers.SK_Dept3="&Session("Dept3")&" and SK_Accounts.AccountsID="&trim(str2(i))
elseif Session("Manager")=6 then
sql="select * from SK_Accounts where SK_Di=1 and SK_ProcureOrders<>0 and SK_ProcureVend<>0 and SK_Del=0 and SK_SalesID="&Session("UID")&" and AccountsID="&trim(str2(i))
end if
RS.Open Sql,Conn,1,1
Response.Write("<tr bgcolor=FFFFFF>"&VBCrlf)
'-----------------------------------------
if Rs("SK_Di")=0 then
Response.Write("<td align=left><font color=red>收入</font></td>")
else
Response.Write("<td align=left><font color=blue>支出</font></td>")
end if

set RsOrders=server.createobject("adodb.recordset")
SqlOrders="select * from SK_ProcureOrders where OrdersID="&Rs("SK_ProcureOrders")&""
RsOrders.open SqlOrders,conn,1,1
Response.Write("<td align=left>"&RsOrders("SK_OrdersNo")&"</td>")
RsOrders.close
Set RsOrders=Nothing

set RsVend=server.createobject("adodb.recordset")
SqlVend="select * from SK_ProcureVend where VendID="&Rs("SK_ProcureVend")&""
RsVend.open SqlVend,conn,1,1
Response.Write("<td align=left>"&RsVend("SK_Wname")&"</td>")
RsVend.close
Set RsVend=Nothing

set rsBanks=server.createobject("adodb.recordset")
sqlBanks="select * from SK_Banks where BanksID="&Rs("SK_BanksID")&""
rsBanks.open sqlBanks,conn,1,1
Response.Write("<td align=left>"&RsBanks("SK_BankName")&"</td>")
RsBanks.close
Set RsBanks=Nothing
if Rs("SK_Di")=0 then
Response.write"<td align=center><font color=red>"&formatnumber(Rs("SK_Amount"),2)&"</font></td>"
else
Response.write"<td align=center><font color=blue>"&formatnumber(Rs("SK_Amount"),2)&"</font></td>"
end if
Response.Write("<td align=left>"&Rs("SK_Atime")&"</td>")
Response.Write("<td align=left>"&Rs("SK_Aname")&"</td>")

set RsSales=server.createobject("adodb.recordset")
SqlSales="select * from SK_SystemUsers where UsersID="&RS("SK_SalesID")&""
RsSales.open SqlSales,conn,1,1
Response.Write("<td align=left>"&RsSales("SK_OName")&"</td>")
RsSales.close
Set RsSales=Nothing
Response.Write("<td align=left>"&Rs("SK_Time")&"</td>")
Response.Write("<td align=left>"&Rs("SK_Content")&"</td>")
'------------------------------------------
Response.Write("</tr>"&VBCrlf)
next
end if '当选择有ID时输出数据结束

Response.Write("</table>")

Call CloseDB()
'导出付款到Excel结束
%>