<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%If session("agentusername")="" Then
	ef=True
	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_AGENT where username='"&session("agentusername")&"'"
		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("agentusermoney")=dsreg("usermoney")
	Set dsmoney = Server.CreateObject("ADODB.Recordset")	
'	Sql="Select * from FreeHost.FreeHost_moneylog where norusername='"&session("agentusername")&"' or agnusername='"&session("agentusername")&"' or agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"' order by id desc"
	Sql="Select * from FreeHost.FreeHost_moneylog where (opusername='"&session("agentusername")&"' or agnusername='"&session("agentusername")&"' or agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and isnew='y' and isdel is null order by id desc"
'if Request.QueryString ("op") ="all" then Sql="Select * from FreeHost.FreeHost_Product_Host order by id desc"
'if Request.QueryString ("op") ="pause" then Sql="Select * from FreeHost.FreeHost_Product_Host where endtime<'"&now&"' order by endtime desc"
'if Request.QueryString ("op") ="del" then Sql="Select * from FreeHost.FreeHost_Product_Host where endtime<'"&dateadd("d",-30,now)&"' order by endtime 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")

	dsmoney.PageSize = 25
If Request("PageSize")<>"" and isnumeric(Request("PageSize")) then dsmoney.PageSize =Request("PageSize")	
	dsmoney.Open Sql,conn,1,1
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>
　财务管理
<%=htmlwrite("html6")%>
<br>
您当前的可用金额：<%if session("agentusermoney")<1 and session("agentusermoney")>0 then%>0<%end if%><%=session("agentusermoney")%> 元
<form action="money-sub.asp" method="post" name="moneyform" target="_blank" id="Form1">
 
<table width="100%" height="108"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
  <tr bgcolor="#eeeeee">
    <td height="67" valign="middle" bgcolor="#F6F6F6"> <br>　
      <select name="usertype" id="usertype">
        <option value="用户或代理名">用户或代理名</option>
        <option value="用户名">用户名</option>
        <option value="代理名">代理名</option>
      </select>      
      <input name="username" type="text" id="username" size="14" value="<%=Request.QueryString("username")%>">
  　
  <input type="submit" name="Submit" value="查询用户信息">
  <br>  
  　 金额
  <input name="usermoney" type="text" id="usermoney" size="4" maxlength="7" value="<%=Request.QueryString("usermoney")%>">
  元
  <br>
  　
  [加]
  <input name="add" type="radio" value="入款" >
  入款
　
<span class="style1">   　　　
[减]
<input type="radio" name="add" value="直接扣款" >
直接扣款</span><br>
  　原因：
  <input name="forwhat" type="text" id="forwhat" size="60" maxlength="200" value="<%=Request.QueryString("forwhat")%>">
  <br>
  　
  <input type="submit" name="Submit" value="执行">
  <br>
  <br>
</td>
    </tr>
</table> 
</form>
<%
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
%>
<%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%>">下一页</a><%End If%>
        <table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#EEEEEE">
            <td width="13%" height="29" align="center" bgcolor="#EEEEEE">时间</td>
            <td width="11%" align="center" bgcolor="#EEEEEE">增加</td>
            <td width="11%" align="center" bgcolor="#EEEEEE">减少</td>
            <td width="11%" align="center" bgcolor="#EEEEEE">余额</td>
            <td width="13%" align="center" bgcolor="#EEEEEE">用户/代理</td>
            <td width="13%" align="center" bgcolor="#EEEEEE">类别/操作人</td>
            <td align="center">原因</td>
          </tr>
          <%
addcount=0
decount=0
For N=1 To dsmoney.PageSize 
					If dsmoney.RecordCount=0 Then Exit For
%>
<%if not (instr(dsmoney("forwhat"),"子代理返回的收入")>0 and dsmoney("opusername")=session("agentusername")) then%>
<%if not (instr(dsmoney("forwhat"),"子代理返回的收入")>0 and dsmoney("username")<>session("agentusername") and dsmoney("opusername")<>dsmoney("agent1") ) then%>
<%if not isnull(dsmoney("agnEndmoney")) then'2009-6-8%>
          <tr bgcolor="#FFFFFF">
            <td width="13%" align="center" bgcolor="#FFFFFF"><%=dsmoney("attime")%></td>
            <td width="11%" align="center" bgcolor="#FFFFFF"><%if dsmoney("isadd")="y" then
						addcount=addcount+(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(dsmoney("usermoney"),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td width="11%" align="center" bgcolor="#FFFFFF"><%if not dsmoney("isadd")="y" then
						decount=decount+(dsmoney("usermoney"))
			%>
                <a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=replace(formatCurrency(dsmoney("usermoney"),2,-1),".00","")%> 元</font></a>
            <%end if%></td>
            <td width="11%" align="center" bgcolor="#FFFFFF"><%=dsmoney("agnEndmoney")%> 元</td>
            <td width="13%" align="center" bgcolor="#FFFFFF"><a href="searchuser.asp?username=<%=dsmoney("norusername")%>"><font color="black"><%=dsmoney("norusername")%></font></a>
                <%if dsmoney("isagn")="y" then%>
                <a href="searchagent.asp?username=<%=dsmoney("agnusername")%>"><font color="black">(<%=dsmoney("agnusername")%>)</font></a>
                <%end if%><%if session("agenttype")="子代理" and dsmoney("agent1")<>session("agentusername") then%>/UP<%else%>
            <%if dsmoney("agent1")<>"" and dsmoney("agent1")<>session("agentusername") then%><a href="searchagent.asp?username=<%=dsmoney("agent1")%>"><font color="black">(<%=dsmoney("agent1")%>)</font></a><%end if%><%end if%></td>
            <td width="13%" align="center" bgcolor="#FFFFFF"><a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black">
            <%if session("agenttype")="子代理" and dsmoney("agent1")<>session("agentusername") then%>UP<%else%><%=dsmoney("atspace")%><%end if%><%if dsmoney("ishand")="y" then%>手工<%end if%></font></a></td>
            <td align="center"><a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black"><%=dsmoney("forwhat")%></font></a></td>
          </tr>
<%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="28" align="center">本页总计</td>
            <td width="11%" height="28" align="center"><%=replace(formatCurrency(abs(addcount),2,-1),".00","")%> 元</td>
            <td width="11%" height="28" align="center"><%=replace(formatCurrency(abs(decount),2,-1),".00","")%> 元</td>
            <td height="28" colspan="4" align="center" bgcolor="#F6F6F6"><a href="moneyshow.asp?id=<%=dsmoney("id")%>"><font color="black">
            </font></a><a href="moneyshow.asp?id=<%=dsmoney("id")%>"></a></td>
          </tr>
</table>
          <%
end if
dsmoney.close
set dsmoney=nothing%>
          <br>
          <form action="money.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>        
<%If Application("agentcannetpay")=True And dsreg("canusenetpay")=true Then%>
<table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td width="9%" height="30" rowspan="2" bgcolor="#FFFFFF">		  <form name="form1" method="post" action="setnetpay.asp">
<br>　
您可以设置自己的网上支付接口，设置后就不需要使用主站管理员的接口，<br>
　当您的名下用户通过您的接口支付时，钱会直接到您的财付通或支付宝帐上，<br>
　如果您在主机系统中的金额足够，系统就会自动将您在主机系统中的钱转移给名下用户，<br>
　如果您主机系统中的金额不足，系统就会在将此金额显示为＂等待入帐＂的金额，您可以手工再为用户入帐．<br>
　如果您设置后想恢复用主站管理员的接口，只需要将下面所有的参数都设置为空就可以了．<br>
		    <br>　 
　 <strong>支付宝网上支付部分，支付网址为：http://服务域名/netpay/alipay/</strong><br>
</strong>　 支付宝账户：
<input name="NP_ali_ShopID" type="text" value="<%=dsreg("NP_ali_ShopID")%>" size="20"><!--
<a href="http://act.life.alipay.com/systembiz/7i24/" target="_blank">使用支付宝前<font color="#FF0000">必须</font>先登陆支付宝<font color="#FF0000">确认</font>IDC实时到帐条款&gt;&gt;&gt;</a>-->
<br>
<br>
			
　　　<strong>财付通网上支付部分，支付网址为：http://服务域名/netpay/tenpay/</strong><br />
          　 商户号：
          <input name="tenpayid" type="text" value="<%=dsreg("tenpayid")%>" size="20" />
         <!-- (<a href="http://union.tenpay.com/mini_xingwai/index.html" target="_blank">申请财付通可以快速通过,同时有特殊优惠&gt;&gt;&gt;&gt;</a>)--><br />
　 支付密钥：
<input name="tenpaykey" type="password" value="<%=dsreg("tenpaykey")%>" size="20" />
<br>
<br>
<br>
<%if Request.ServerVariables("HTTP_FreeHostAPI")<>"7i24.com" Then%>
　 <strong>ChinaBank网上支付部分，支付网址为：http://服务域名/netpay/chinabank/</strong><br>
　 网银店铺编号：
<input name="NP_ChinaBank_ShopID" type="text" value="<%=dsreg("NP_ChinaBank_ShopID")%>" size="20">
<br>
　 网银私　　钥：
<input name="NP_ChinaBank_Key" type="password" value="<%=dsreg("NP_ChinaBank_Key")%>" size="20">
<br>
<br>
<%End if%>
  　　
  <input type="submit" name="Submit" value="提交">
</form></td>
  </tr>
</table>

<%end if%>		  
<br>
<br>
<br>

<%=htmlwrite("html7")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
