<!--#include file=conn.asp-->
<!-- #include file="inc/const.asp" -->
<!--#include file=bank_data.asp-->
<!-- #include file="bank/bank_const.asp" -->
<%
'=========================================================
' file: bank_clientevents.asp
' Version:2.1 for Dvbbs7.0
' date: 2004-1-7
' script modified by winriver from yaoyue Version
'=========================================================
' copyright (c) 2004 all rights reserved.
' web: http://www.paperbridge.net http://www.winriver.org
' email: huanghetv@163.com winriver2002@yahoo.com
'=========================================================
Dvbbs.LoadTemplates("")
If Not IsObject(Conn) Then ConnectionDatabase
dim sql,rs,founderr,i,errmsg
founderr=false


dim pcount,page,total,admin_flag,bankuser,Statsmsg_1,Statsmsg_2
admin_flag="26"
bankuser = Dvbbs.HTMLEncode(Dvbbs.CheckStr(trim(request("bankuser"))))
if not isnumeric(request("page")) or request("page")="" then
    page=1
else
    page=cint(request("page"))
end if
if bankid=0 then
    Statsmsg_1="钱庄"
    Statsmsg_2="bank_index.asp"
else
    Statsmsg_1=bankname
    Statsmsg_2="bank_main.asp?bankid="&bankid
end if
if not Dvbbs.FoundUser then
    founderr=true
    errmsg=errmsg+errmsg6+"您还没有登录或注册，请先<a href=login.asp>登录</a>或<a href=reg.asp>注册</a>。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
	call Dvbbs.ActiveOnline()
	call Dvbbs.Footer()
	response.end
end if
if not Dvbbs.master then
    if not foundbankuserid and not foundbankuser then
        founderr=true
        errmsg=errmsg+errmsg6+"你还没有在该钱庄开户，若想单查该钱庄的用户，请到该钱庄开户，若想查某用户在哪些钱庄开户，请选所有钱庄，然后输入用户名。"
    end if
    if bankid=0 and bankuser="" then
        founderr=true
        errmsg=errmsg+errmsg6+"不允许查询所有钱庄，请键入具体要查询的名字。"
    end if
    if founderr=true then
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
    end if
end if
if request("action")="events" and not openeventslog then
    if not isbankmaster and not Dvbbs.master then
        founderr=true
        errmsg=errmsg+errmsg6+"该钱庄没有开放事件记录。"
	    Dvbbs.Stats="钱庄错误信息"
	    call Dvbbs.Nav()
	call new_head()
	    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
    end if
end if
if request("action")="delevents" then
    Dvbbs.Stats="删除事件记录"
    call Dvbbs.Nav()
	call new_head()
    call delevents()
elseif request("action")="freezeuser" then
    Dvbbs.Stats="冻结用户"
    call Dvbbs.Nav()
	call new_head()
    call freezeuser()
elseif request("action")="events" then
    Dvbbs.Stats="客户事件"
    call Dvbbs.Nav()
	call new_head()
    call bankevents()
else
    Dvbbs.Stats="用户查询"
    call Dvbbs.Nav()
	call new_head()
    call search()
end if
call Dvbbs.ActiveOnline()

if founderr then
Dvbbs.Stats="钱庄错误信息"
Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
call Dvbbs.Footer()

sub bankevents()
  if Dvbbs.master and instr(session("flag"),admin_flag)>0 then
      csql="select * from bankevent order by eventid desc"
  elseif isbankmaster then
      csql="select * from bankevent where bankid="&bankid&" order by eventid desc"
  else
      csql="select * from bankevent where bankid="&bankid&" and name1='"&Dvbbs.MemberName&"' order by eventid desc"
  end if
  set crs=server.createobject("adodb.recordset")
  crs.open csql,cjconn,1,1
  if crs.bof and crs.eof then
      founderr=true
      errmsg=errmsg+errmsg6+"没有找到您要查询的内容。"
  else
%>
<table cellpadding=0 cellspacing=0 border=0  class=tableborder1><tr><td class=tablebody1>以下是您所查询到的记录。<%if Dvbbs.master and instr(session("flag"),admin_flag)>0 and bankid=0 then response.write "如果想知道事件属哪个钱庄，把址栏上的bankid=?改为该钱庄的ｉｄ，也可先进入所想查的钱庄，再点事件记录。"%></td></tr></table><br>
<form action=bank_clientevents.asp?bankid=<%=bankid%>&action=delevents method=post>
<table cellpadding=3 cellspacing=1 class=tableborder1 align=center>
<tr valign=middle>
<th height=25 width=60>事件id</th>
<th width=120>操作人</th>
<th width=120>接受人（钱庄）</th>
<th width=120>事件</th>
<th width=120>交易金</th>
<th width=*>操作时间</th>
<%if Dvbbs.master and instr(session("flag"),admin_flag)>0 then response.write "<th width=40>管理</th>"%>
</tr>
<%
      crs.pagesize = Dvbbs.Forum_setting(11)
      total = crs.recordcount
      pcount = crs.pagecount
      if page < 1 then page = 1
      if page > pcount then page = pcount
      crs.move (page-1)*crs.pagesize
      ii = 0
      do while not crs.eof and ii < crs.pagesize
%>
  <tr> 
    <td align=middle class=tablebody2 width=60><%=crs(0)%></td> 
    <td align=middle class=tablebody1 width=120><%=crs(2)%></td> 
    <td align=middle class=tablebody2  width=120><%=crs(3)%><%if crs(3)="" then response.write bankname%></td> 
    <td align=middle class=tablebody1 width=120><%=crs(4)%></td>
    <td align=middle class=tablebody2  width=120><%=crs(5)%></td> 
    <td align=middle class=tablebody1 width=*><%=crs(6)%></td>
    <%if Dvbbs.master and instr(session("flag"),admin_flag)>0 then response.write "<td align=middle class=tablebody2  width=40><input type=checkbox name=del value="&crs(0)&"></td>"%>
</tr> 
<%
          ii = ii+1
          crs.movenext
      loop
      response.write "</table>"
      call pagefooter
      if Dvbbs.master and instr(session("flag"),admin_flag)>0 then
          response.write "<br><table cellpadding=0 cellspacing=0 border=0  class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=删除 onclick=""return confirm('是否删除所选定的记录？');""> 清空该钱庄的记录：<input type=checkbox name=delall value=1>　</td></tr></table>"
      end if
      response.write "</form>"
  end if
  crs.close
  set crs = nothing
end sub

sub search()
  dim bank
  if Dvbbs.master and bankid=0 and bankuser="" then
      bank=""
  elseif bankid > 0 and bankuser<>"" then
      bank=" where u.bankid="&bankid&" and u.name='"&bankuser&"' "
  elseif bankid=0 and bankuser<>"" then
      bank=" where u.name='"&bankuser&"' "
  else
      bank=" where u.bankid="&bankid&" "
  end if
  if Dvbbs.master and instr(session("flag"),admin_flag)>0 and request("vt")="deluser" then
      csql="select b.bankname,u.bankuserid,u.name,u.currdeposit,u.timedeposit,u.paymentforgoods,u.freeze from bankuser u inner join bank b on b.bankid=u.bankid and b.bankmaster<>u.name "&bank&" order by u.bankuserid desc"
  else
      csql="select b.bankname,u.bankuserid,u.name,u.currdeposit,u.timedeposit,u.paymentforgoods,u.freeze from bankuser u inner join bank b on b.bankid=u.bankid "&bank&" order by u.bankuserid desc"
  end if
  set crs=server.createobject("adodb.recordset")
  crs.open csql,cjconn,1,1
  if crs.bof and crs.eof then
      founderr=true
      errmsg=errmsg+errmsg6+"没有找到您要查询的内容。"
  else
%>
<table cellpadding=0 cellspacing=0 border=0 class=tableborder1 align=center><tr><td class=tablebody1>以下是您所查询到的记录</td></tr></table><br>
<form action=bank_clientevents.asp?bankid=<%=bankid%>&action=freezeuser&vt=<%=request("vt")%> method=post>
<table cellpadding=3 cellspacing=1 class=tableborder1 align=center>
<tr valign=middle>
<th height=25 width=120>所在钱庄</th>
<th width=120>用户名称</th>
<th width=120>活期存款</th>
<th width=*>定期存款</th>
<th width=120>贷款</th>
<th width=100>是否被冻结</th>
<%if Dvbbs.master or isbankmaster then response.write "<th width=40>管理</th>"%>
</tr>
<%
      crs.pagesize = Dvbbs.Forum_setting(11)
      total = crs.recordcount
      pcount = crs.pagecount
      if page < 1 then page = 1
      if page > pcount then page = pcount
      crs.move (page-1)*crs.pagesize
      ii = 0
      do while not crs.eof and ii < crs.pagesize
%>
  <tr> 
    <td align=middle class=tablebody2 width=120><%=crs(0)%></td> 
    <td align=middle class=tablebody1 width=120><%=crs(2)%></td> 
    <td align=middle class=tablebody2  width=120><%=crs(3)%></td> 
    <td align=middle class=tablebody1 width=*><%=crs(4)%></td>
    <td align=middle class=tablebody2  width=120><%=crs(5)%></td> 
    <td align=middle class=tablebody1 width=100><%=crs(6)%></td>
    <%if Dvbbs.master or isbankmaster then response.write "<td align=middle class=tablebody2  width=40><input type=checkbox name=bfreeze value="&crs(1)&"></td>"%>
</tr> 
<%
          ii = ii+1
          crs.movenext
      loop
      response.write "</table>"
      call pagefooter
      if Dvbbs.master and instr(session("flag"),admin_flag)>0 then
          if request("vt")="unfreeze" then
              response.write "<table cellpadding=0 cellspacing=0 border=0  class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=解冻 onclick=""return confirm('是否解冻所选定的用户？');"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"';"">　<input type=button name=t value=切换到删除用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"&vt=deluser';""> 本操作为解冰结所选中的用户</td></tr></table>"
          elseif request("vt")="deluser" then
              response.write "<table cellpadding=0 cellspacing=0 border=0  class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=删除 onclick=""return confirm('是否删除所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"&vt=unfreeze';"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"';""> 本操作为删除所选中的用户</td></tr></table>"
          else
              response.write "<table cellpadding=0 cellspacing=0 border=0 class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=冻结 onclick=""return confirm('是否冻结所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"&vt=unfreeze';"">　<input type=button name=t value=切换到删除用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"&vt=deluser';""> 本操作为冻结所选中的用户（要注意别把自己也冻了）</td></tr></table>"
          end if
      elseif Dvbbs.master or isbankmaster then
          if request("vt")="unfreeze" then
              response.write "<table cellpadding=0 cellspacing=0 border=0  class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=解冻 onclick=""return confirm('是否解冻所选定的用户？');"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"';""> 本操作为解冰结所选中的用户</td></tr></table>"
          else
              response.write "<table cellpadding=0 cellspacing=0 border=0  class=tableborder1 align=center><tr><td class=tablebody1><input type=submit name=s value=冻结 onclick=""return confirm('是否冻结所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='bank_clientevents.asp?bankid="&bankid&"&vt=unfreeze';""> 本操作为冻结所选中的用户（要注意别把自己也冻了）</td></tr></table>"
          end if
      end if
      response.write "</form>"
  end if
  crs.close
  set crs = nothing
  call search1
end sub

sub pagefooter()
  dim bpage
  ii=0
  if request("action")="events" then
      bpage="action=events"
  elseif request("vt")<>"" then
      bpage="vt="&request("vt")&"&bankuser="&bankuser
  else
      bpage="bankuser="&bankuser
  end if
  response.write  "<table border=0 cellpadding=3 cellspacing=0  class=tableborder1 align=center>"&_
                  "<tr><td valign=middle class=tablebody1 nowrap>"&_
                  "页次：<font color=#ff0000><b>"&page&"</b></font>/<b>"&pcount&"</b>页"&_
			     " 每页<font color=#ff0000><b>"&Dvbbs.Forum_setting(11)&"</b></font>条记录 总共有<font color=#ff0000><b>"&total&"</b></font>条记录</td>"&_
			     "<td valign=middle class=tablebody1 nowrap><font color=blue><div align=right><p>分页： "
			if page > 4 then
			    response.write "<a href=bank_clientevents.asp?bankid="&bankid&"&"&bpage&"&page=1>[1]</a>..."
			end if
			if pcount>page+3 then
			    ii=page+3
			else
			    ii=pcount
			end if
			for i=page-3 to ii
			    if not i < 1 then
			        if i=cint(page) then
			            response.write "<font color=#ff000000>["&i&"]</font>"
			        else
			            response.write "<a href=bank_clientevents.asp?bankid="&bankid&"&"&bpage&"&page="&i&">["&i&"]</a>"
			        end if
			    end if
			next
			if page+3 < pcount then
			    response.write "...<a href=bank_clientevents.asp?bankid="&bankid&"&"&bpage&"&page="&pcount&">["&pcount&"]</a>"
			end if
			response.write "</p></div></font></td></tr></table>"
end sub
sub search1()
  response.write "<br><table border=0 cellpadding=0 cellspacing=3 width=""98%"" align=center>"&_
                 "<tr><td valign=middle align=center nowrap>"&_
                 "<form action=bank_clientevents.asp method=get>"&_
                 "选择钱庄：<select name=bankid><option value=0>所有钱庄</option>"
                 csql="select bankid,bankname from bank"
                 set crs=cjconn.execute (csql)
                 do while not crs.eof
                     response.write "<option value="&crs(0)&" "
                     if bankid=crs(0) then
                         response.write "selected"
                     end if
                     response.write ">"&crs(1)&"</option>"
                     crs.movenext
                 loop
                 set crs=nothing
  response.write "</select> 填入想找的用户名（选全部钱庄时必须查询具体的某用户）：<input type=text name=bankuser size=10> <input type=submit name=s value=查询></form></td></tr></table>"
end sub
'删除事件
sub delevents()
  dim del,delall
  del=request.form("del")
  delall=request.form("delall")
  if not Dvbbs.master or instr(session("flag"),admin_flag)<=0 then
      founderr=true
      errmsg=errmsg+errmsg6+"你不是管理员或还没有登录后台，但可以肯定你是非法操作。"
  end if
  if not foundbankid then
      founderr=true
      errmsg=errmsg+errmsg6+"找不到你所操作的钱庄。"
  end if
  if delall<>1 and del="" then
      founderr=true
      errmsg=errmsg+errmsg6+"你没有选择任何记录。"
  end if
  if not founderr then
      if delall=1 then
          cjconn.execute ("delete from bankevent where bankid="&bankid)
      else
          cjconn.execute ("delete from bankevent where eventid in ("&del&") and bankid="&bankid)
      end if
      call yaoyue_banksuc()
  end if
end sub
'用户管理
sub freezeuser()
  dim bfreeze,unfreeze
  bfreeze=request.form("bfreeze")
  if request("vt")="unfreeze" then
      unfreeze=0
  elseif request("vt")="deluser" then
      unfreeze=2
  else
      unfreeze=1
  end if
  if unfreeze=2 then
      if not Dvbbs.master or instr(session("flag"),admin_flag)=0 then
          founderr=true
          errmsg=errmsg+errmsg6+"你不是管理员或还没登录后台。"
      end if
  elseif not isbankmaster and not Dvbbs.master then
      founderr=true
      errmsg=errmsg+errmsg6+"你不是该行掌柜或管理员。"
  end if
  if bfreeze="" then
      founderr=true
      errmsg=errmsg+errmsg6+"你没有选择用户。"
  end if
  if not founderr then
      if unfreeze = 2 then
          csql="select bankid,name,currdeposit,timedeposit,paymentforgoods,bydetaincp from bankuser where bankuserid in("&bfreeze&")"
          set crs=cjconn.execute (csql)
          if crs.bof and crs.eof then
              founderr=true
              errmsg=errmsg+errmsg6+"操作后请不要刷新本页。"
              exit sub
          end if
          do while not crs.eof
              cjconn.execute ("update bank set alldeposit=alldeposit-"&(crs(2)+crs(3))&",paymentforgoods=paymentforgoods-"&crs(4)&",loveliness=loveliness+"&crs(5)&" where bankid="&crs(0))
              crs.movenext
          loop
          set crs=nothing
          cjconn.execute ("delete from timedeposit where bankuserid in ("&bfreeze&")")
          cjconn.execute ("delete from paymentforgoods where bankuserid in ("&bfreeze&")")
          cjconn.execute ("delete from bankuser where bankuserid in ("&bfreeze&")")
      else
          cjconn.execute ("update bankuser set freeze="&unfreeze&" where bankuserid in ("&bfreeze&")")
      end if
      call yaoyue_banksuc()
  end if
end sub
%>

<%
sub new_head()
Dvbbs.Head_var 3,0,"钱庄</a> → "&"<a href=bank_main.asp?bankid="&BankID&">"&bankname,"bank_index.asp"
end sub
%>