<%@ Language=VBScript %>
<%
If session("username")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
If session("HOSTAUID")<>"" Then ec="主机面板中不能操作用户区的内容，请您先登陆用户区。"
If session("EmailAUID")<>"" Then ec="邮箱面板中不能操作用户区的内容，请您先登陆用户区。"
If session("SQLAUID")<>"" Then ec="数据库面板中不能操作用户区的内容，请您先登陆用户区。"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
  Set dsreg = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&session("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsreg.Open Sql,conn,1,1
If dsreg.Eof Then
		ef=True
		ec="会员名不存在或密码出错了！"
end if
end if

if not ef then
session("usermoney")=dsreg("usermoney")
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>　财务记录
<%=htmlwrite("html3")%>
<br>
<%=session("username")%>，<%If session("AgnRunasUser")=false then%>
您当前的可用金额：<font face="Arial, Helvetica, sans-serif">
<%=FormatNumber(dsreg("usermoney"),2,-1)%> </font>元 　等待入帐金额：<font face="Arial, Helvetica, sans-serif">
<%=FormatNumber(dsreg("waitmoney"),2,-1)%> </font>元<%Else'代理进入用户区

  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&session("username")&"'"
		dsagent.Open Sql,conn,1,1

%>
您是代理，您的代理角色的可用金额：<font face="Arial, Helvetica, sans-serif" color=red><%=FormatNumber(dsagent("usermoney"),2,-1)%> </font>元，等待入帐金额：<font face="Arial, Helvetica, sans-serif" color=red><%=FormatNumber(dsagent("waitmoney"),2,-1)%> </font>元，用户角色可用金额：<font face="Arial, Helvetica, sans-serif"><%=FormatNumber(dsreg("usermoney"),2,-1)%> </font>元，等待入帐金额：<font face="Arial, Helvetica, sans-serif"><%=FormatNumber(dsreg("waitmoney"),2,-1)%> </font>元，您在用户区所有的消费价格为代理成本价。


<%end if%>
<a href="moneyana.asp">消费统计&gt;&gt;</a><br>
<%Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsmoney = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_moneylog where norusername='"&session ("username")&"' and isuser='y' and isnew='y' and isdel is null order by id desc"
If session("AgnRunasUser") then	Sql="Select * from FreeHost.FreeHost_moneylog where (opusername='"&session("agentname")&"' or agnusername='"&session("agentname")&"' or agent1='"&session("agentname")&"' or agent2='"&session("agentname")&"') and isnew='y' and isdel is null order by id desc"

If IsDate(Request("starttime")) And IsDate(Request("endtime")) Then sql=Replace(sql," order by id desc"," and attime>'"&Request("starttime")&"' and attime<'"&Request("endtime")&"' order by id desc")

If Request("isadd")="y" Then sql=Replace(sql," order by id desc"," and isadd='y' order by id desc")
If Request("isadd")="n" Then sql=Replace(sql," order by id desc"," and isadd='n' order by id desc")

			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsmoney.PageSize = 25
If Request("PageSize")<>"" and isnumeric(Request("PageSize")) then dsmoney.PageSize =Request("PageSize")
	dsmoney.Open Sql,conn,1,1
if dsmoney.Eof then
%>
<br>
数据库中不存在此类款项操作记录。
<%
else
if Request.ServerVariables("QUERY_STRING")<>"" then
ask=Split(Request.ServerVariables("QUERY_STRING"), chr(38)&"pn")
else
ask=Split("freehost=1", "")
ask(0)="freehost=lsoft"
end if
	pn=1
if Request.QueryString ("pn")<>"" then pn=Request.QueryString ("pn")
If dsmoney.RecordCount <> 0 Then dsmoney.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsmoney.PageCount<=10 then
       endini=dsmoney.PageCount 
       else
       endini=10
      end if
    end if
%><br>

<%if clng(pn)<=10 then%>最新 <%for i=begini to endini
    if clng(pn)=i then%><font color=red>[<%=i%>]</font><%else%><a href="?<%=ask(0)%>&pn=<%=i%>"><font color="#000000">[<%=i%>]</font></a><%end if%>　<%next%> 
        <%else%>　<a href="?<%=ask(0)%>&pn=1"><font color="#000000">最新[1]--[10]</font></a>　　现在是第<font color=red>[<%=pn%>]</font>页 
        　共<%=dsmoney.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>">上一页</a><%End If%>|<%If Clng(pn)<dsmoney.PageCount Then%><a href="?<%=ask(0)%>&pn=<%=pn+1%>"><font color="#000000">下一页</font></a>
        <%End If%>
        <br>
        <br>        
<table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#EEEEEE">
            <td width="13%" height="30" align="center">时间</td>
            <td width="12%" height="30" align="center">增加</td>
            <td width="11%" height="30" align="center">减少</td>
            <td width="12%" height="30" align="center">余额</td>
            <td width="52%" align="center">原因</td>
          </tr>
<%
addcount=0
decount=0					
For N=1 To dsmoney.PageSize 
					If dsmoney.RecordCount=0 Then Exit For
%>
<%If session("AgnRunasUser")=false then%>
<%if not instr(dsmoney("forwhat"),"代理收入")>0 or not instr(dsmoney("forwhat"),"子代理返回的收入")>0 or not instr(dsmoney("forwhat"),"扣除代理资金")>0 then%>
          <tr bgcolor="#FFFFFF">
            <td width="13%" height="25" align="center" bgcolor="#FFFFFF"><%=formatdatetime(dsmoney("attime"),2)%></td>
            <td width="12%" align="center"><%if dsmoney("isadd")="y" then
			addcount=addcount+abs(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(abs(dsmoney("usermoney")),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td width="11%" align="center"><%if not dsmoney("isadd")="y" then
			decount=decount+abs(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(abs(dsmoney("usermoney")),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td align="center"><%=replace(formatCurrency(dsmoney("norEndmoney"),2,-1),".00","")%> 元</td>
            <td align="center"><a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=dsmoney("forwhat")%></a></td>
          </tr>
<%End if%>
<%else'代理进入用户区%>

<%if not (instr(dsmoney("forwhat"),"子代理返回的收入")>0 and dsmoney("opusername")=session("agentname")) then%>
<%if not (instr(dsmoney("forwhat"),"子代理返回的收入")>0 and dsmoney("username")<>session("agentname") and dsmoney("opusername")<>dsmoney("agent1") ) then%>
<%if not isnull(dsmoney("agnEndmoney")) Or dsmoney("norusername")=session("username") then '2009-6-9%>
          <tr bgcolor="#FFFFFF">
            <td width="13%" height="25" align="center" bgcolor="#FFFFFF"><%=formatdatetime(dsmoney("attime"),2)%></td>
            <td width="12%" align="center"><%if dsmoney("isadd")="y" then
			addcount=addcount+abs(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(abs(dsmoney("usermoney")),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td width="11%" align="center"><%if not dsmoney("isadd")="y" then
						decount=decount+abs(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(abs(dsmoney("usermoney")),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td align="center"><%if not isnull(dsmoney("agnEndmoney")) then%><%=replace(formatCurrency(dsmoney("agnEndmoney"),2,-1),".00","")%><%else%><%=replace(formatCurrency(dsmoney("norEndmoney"),2,-1),".00","")%><%End if%> 元</td>
            <td align="center"><a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=dsmoney("forwhat")%></a></td>
          </tr>
<%end if%>
<%end if%>
<%end if%>

<%end if
If clng(pn)=dsmoney.PageCount Then
I = dsmoney.RecordCount - (dsmoney.PageCount-1) * dsmoney.PageSize
If N=I Then Exit For
End If
dsmoney.movenext
Next
%>
          <tr bgcolor="#F6F6F6">
            <td width="13%" height="25" align="center" bgcolor="#F6F6F6">本页总计</td>
            <td width="12%" align="center"><%=replace(formatCurrency(abs(addcount),2,-1),".00","")%> 元</td>
            <td width="11%" align="center"><%=replace(formatCurrency(abs(decount),2,-1),".00","")%> 元</td>
            <td colspan="2" align="center">&nbsp;</td>
  </tr>
</table>
<%end if
dsmoney.close
set dsmoney=nothing%><br>

<form action="moneylist.asp" method="get" name="form1">
<%
t1=Year(now)&"-"&Month(now)&"-1"
If IsDate(Request("starttime")) Then t1=Request("starttime")
t2=DateAdd("d",1,date)
If IsDate(Request("endtime")) Then t2=Request("endtime")
pagesize=25
If Request("PageSize")<>"" and isnumeric(Request("PageSize")) then PageSize =Request("PageSize")
isadd=Request("isadd")
%>
  <table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
    <tr bgcolor="">
      <td>查询指定时间段的财务流水：</td>
    </tr>
  </table>
  <table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td width="9%" height="30" rowspan="2" bgcolor="#FFFFFF"><p>　起始时间：
              <input name="starttime" type="text" id="starttime" value="<%=t1%>" size="11">
　结束时间：
<input name="endtime" type="text" id="endtime" value="<%=t2%>" size="11">
 　每页记录数：
 <input name="pagesize" type="text" id="pagesize" value="<%=pagesize%>" size="3">　
 分类：
 <select name="isadd" id="isadd">
   <option <%if isadd="" then%>selected<%end if%>>全部</option>
   <option value="y" <%if isadd="y" then%>selected<%end if%>>入款</option>
   <option value="n" <%if isadd="n" then%>selected<%end if%>>消费</option>
 </select>
          <input type="submit" name="Submit" value="查找">
      </p></td>
    </tr>
  </table>
</form>
<%=htmlwrite("html4")%>
<%
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
