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

'导出回款信息到Excel开始
Response.Buffer = True 
Response.ContentType = "application/vnd.ms-excel" 
SaveFilename=replace(replace(replace(now,":","")," ",""),"/","")
Thead="Payment_"
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=""5%""><b>创建时间</b></td>")
Response.Write("<td width=""10%""><b>状态</b></td>")
Response.Write("<td width=""10%""><b>实收金额</b></td>")
Response.Write("<td width=""10%""><b>实收日期</b></td>")
Response.Write("<td width=""10%""><b>实收方式</b></td>")
Response.Write("<td width=""10%""><b>开票否</b></td>")
Response.Write("<td width=""10%""><b>开票类别</b></td>")
Response.Write("<td width=""10%""><b>征收税点</b></td>")
Response.Write("<td width=""10%""><b>票据单号</b></td>")
Response.Write("<td width=""10%""><b>开票日期</b></td>")
Response.Write("<td width=""10%""><b>收款说明</b></td>")
Response.Write("<td width=""10%""><b>财务人员</b></td>")
Response.Write("</tr>"&VBCrlf)

if F("id")="" then
Set RS = Server.CreateObject("ADODB.Recordset")
sql="select * from SK_Payment where SK_Del=0"
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)
'-----------------------------------------
Response.Write("<td align=left>"&Rs("SK_PaymentNo")&"</td>")

set rsClient=server.createobject("adodb.recordset")
sqlClient="select * from SK_Client where ClientID="&Rs("SK_ClientID")&""
rsClient.open sqlClient,conn,1,1
Response.Write("<td align=left>"&RsClient("SK_Wname")&"</td>")
RsClient.close
Set RsClient=Nothing

set rsOrders=server.createobject("adodb.recordset")
sqlOrders="select * from SK_SalesOrders where OrdersID="&Rs("SK_OrderID")&""
rsOrders.open sqlOrders,conn,1,1
Response.write"<td align=left>"&RsOrders("SK_OrdersNo")&"</td>"
RsOrders.close
RsOrders=Nothing

set RsPay=server.createobject("adodb.recordset")
SqlPay="select * from SK_SystemCategory where SK_Di=141 and CategoryID="&Rs("SK_Pay")&""
RsPay.open SqlPay,conn,1,1
Response.write"<td align=left>"&RsPay("SK_Name")&"</td>"
RsPay.close
Set RsPay=Nothing

Response.write"<td align=center>"&formatnumber(Rs("SK_Amount1"),2)&"</td>"
Response.write"<td align=center>"&Rs("SK_ATime1")&"</td>"
Response.Write("<td align=left>"&Rs("SK_Pcontent")&"</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>")
if Rs("SK_Feet")=0 then
Response.Write("<td align=left>未到款</td>")
else
Response.Write("<td align=left>已到款</td>")
end if

Response.write"<td align=center>"&formatnumber(Rs("SK_Amount2"),2)&"</td>"
Response.write"<td align=center>"&Rs("SK_ATime2")&"</td>"

set RsaPay=server.createobject("adodb.recordset")
SqlaPay="select * from SK_SystemCategory where SK_Di=141 and CategoryID="&Rs("SK_APay")&""
RsaPay.open SqlaPay,conn,1,1
Response.write"<td align=left>"&RsaPay("SK_Name")&"</td>"
RsaPay.close
Set RsaPay=Nothing

if Rs("SK_ABill")=0 then
Response.Write("<td align=left>否</td>")
else
Response.Write("<td align=left>是</td>")
end if

set RsABillType=server.createobject("adodb.recordset")
SqlABillType="select * from SK_SystemCategory where SK_Di=143 and CategoryID="&RS("SK_ABillType")&""
RsABillType.open SqlABillType,conn,1,1
Response.Write("<td align=left>"&RsABillType("SK_Name")&"</td>")
RsABillType.close
Set RsABillType=Nothing

Response.Write("<td align=left>"&Rs("SK_ABillSd")&"</td>")
Response.Write("<td align=left>"&Rs("SK_ABillNo")&"</td>")
Response.Write("<td align=left>"&Rs("SK_ABillTime")&"</td>")
Response.Write("<td align=left>"&Rs("SK_AContent")&"</td>")

set RsFinUID=server.createobject("adodb.recordset")
SqlFinUID="select * from SK_SystemUsers where UsersID="&Rs("SK_FinUID")&""
RsFinUID.open SqlFinUID,conn,1,1
Response.Write("<td align=left>"&RsFinUID("SK_OName")&"</td>")
RsFinUID.close
set RsFinUID=Nothing
'------------------------------------------
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")
sql="select * from SK_Payment where SK_Del=0 and PaymentID="&trim(str2(i))
RS.Open Sql,Conn,1,1
Response.Write("<tr bgcolor=FFFFFF>"&VBCrlf)
'-----------------------------------------
Response.Write("<td align=left>"&Rs("SK_PaymentNo")&"</td>")

set rsClient=server.createobject("adodb.recordset")
sqlClient="select * from SK_Client where ClientID="&Rs("SK_ClientID")&""
rsClient.open sqlClient,conn,1,1
Response.Write("<td align=left>"&RsClient("SK_Wname")&"</td>")
RsClient.close
Set RsClient=Nothing

set rsOrders=server.createobject("adodb.recordset")
sqlOrders="select * from SK_SalesOrders where OrdersID="&Rs("SK_OrderID")&""
rsOrders.open sqlOrders,conn,1,1
Response.write"<td align=left>"&RsOrders("SK_OrdersNo")&"</td>"
RsOrders.close
RsOrders=Nothing

set RsPay=server.createobject("adodb.recordset")
SqlPay="select * from SK_SystemCategory where SK_Di=141 and CategoryID="&Rs("SK_Pay")&""
RsPay.open SqlPay,conn,1,1
Response.write"<td align=left>"&RsPay("SK_Name")&"</td>"
RsPay.close
Set RsPay=Nothing

Response.write"<td align=center>"&formatnumber(Rs("SK_Amount1"),2)&"</td>"
Response.write"<td align=center>"&Rs("SK_ATime1")&"</td>"
Response.Write("<td align=left>"&Rs("SK_Pcontent")&"</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>")
if Rs("SK_Feet")=0 then
Response.Write("<td align=left>未到款</td>")
else
Response.Write("<td align=left>已到款</td>")
end if

Response.write"<td align=center>"&formatnumber(Rs("SK_Amount2"),2)&"</td>"
Response.write"<td align=center>"&Rs("SK_ATime2")&"</td>"

set RsaPay=server.createobject("adodb.recordset")
SqlaPay="select * from SK_SystemCategory where SK_Di=141 and CategoryID="&Rs("SK_APay")&""
RsaPay.open SqlaPay,conn,1,1
Response.write"<td align=left>"&RsaPay("SK_Name")&"</td>"
RsaPay.close
Set RsaPay=Nothing

if Rs("SK_ABill")=0 then
Response.Write("<td align=left>否</td>")
else
Response.Write("<td align=left>是</td>")
end if

set RsABillType=server.createobject("adodb.recordset")
SqlABillType="select * from SK_SystemCategory where SK_Di=143 and CategoryID="&RS("SK_ABillType")&""
RsABillType.open SqlABillType,conn,1,1
Response.Write("<td align=left>"&RsABillType("SK_Name")&"</td>")
RsABillType.close
Set RsABillType=Nothing

Response.Write("<td align=left>"&Rs("SK_ABillSd")&"</td>")
Response.Write("<td align=left>"&Rs("SK_ABillNo")&"</td>")
Response.Write("<td align=left>"&Rs("SK_ABillTime")&"</td>")
Response.Write("<td align=left>"&Rs("SK_AContent")&"</td>")
set RsFinUID=server.createobject("adodb.recordset")
SqlFinUID="select * from SK_SystemUsers where UsersID="&Rs("SK_FinUID")&""
RsFinUID.open SqlFinUID,conn,1,1
Response.Write("<td align=left>"&RsFinUID("SK_OName")&"</td>")
RsFinUID.close
set RsFinUID=Nothing
'------------------------------------------
Response.Write("</tr>"&VBCrlf)
next
end if '当选择有ID时输出数据结束

Response.Write("</table>")

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