<%@ LANGUAGE = VBScript.Encode %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>会员钱包</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Script/Admin.js"></script>
</HEAD>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="CheckAdmin.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<BODY>

<%
if Instr(session("AdminPurview"),"|33,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end If
'管理员操作财务==============
If request("financial")="yes" Then
If  request("username")="" Or request("total")="" Or request("type")="" Then
response.Write "<script language=javascript>alert('请正确选择会员名/金额/类型!');location.replace('Member_purse.asp');</script>"
response.end
End if
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select wallet from TianTianCMS_Members where MemName='"&request("username")&"'"
rs.open sql,conn,1,3
If rs.eof and rs.bof  Then
response.Write "<script language=javascript>alert('不存在此会员!');location.replace('Member_purse.asp');</script>"
Call CloseRs(rs)
response.end
Else
If request("type")="1" Then rs("wallet")=rs("wallet")+Formatnumber(request("total"),2,-1,-1,0)'充值
rs.update
If request("type")="0" Then
If Formatnumber(rs("wallet"),2,-1,-1,0)>Formatnumber(request("total"),2,-1,-1,0) Then
rs("wallet")=rs("wallet")-Formatnumber(request("total"),2,-1,-1,0)'扣款
rs.update
Else
response.Write "<script language=javascript>alert('此会员钱包不足扣款!');location.replace('Member_purse.asp');</script>"
Call CloseRs(rs)
response.end
End If
End if
End If
Call CloseRs(rs)
shijian=now()
ddhm="zz"&year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select wallet from TianTianCMS_financiallog"
rs.open sql,conn,1,3
If Not (rs.eof and rs.bof)  Then
rs.addnew
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_financiallog"
rs.open sql,conn,1,3
rs.addnew
rs("members")=trim(request("username"))
rs("ddhm")=ddhm
If request("type")="1" Then rs("OrderName")="站长充值"
If request("type")="0" Then rs("OrderName")="站长扣款"
If request("type")="1" Then rs("income")=Formatnumber(request("total"),2,-1,-1,0)
If request("type")="0" Then rs("spending")=Formatnumber(request("total"),2,-1,-1,0)
rs("operator")=session("AdminName")
rs("audit")=DN_True
rs("Operatingtime")=now()
rs("audittime")=now()
rs.update
End If
response.Write "<script language=javascript>alert('操作成功!');location.replace('Member_purse.asp');</script>"
Call CloseRs(rs)
response.end
End if
'管理员操作财务END===========
dim Result,Keyword
Result=request.QueryString("Result")
Keyword=request.QueryString("Keyword")

function PlaceFlag()
  if Result="Search" then
	If Keyword<>"" Then
		Response.Write "会员：列表 -> 检索 -> 关键字：<font color='red'>"&Keyword&"</font>"
	Else
		Response.Write "会员：列表 -> 检索 -> 关键字为空(显示全部会员)"
	End If
  else
    if SortPath<>"" then
      Response.Write "会员：列表 -> <a href='Member_purse.asp'>全部</a>"
	  TextPath(SortID)
	else
      Response.Write "会员：列表 -> 全部"
	end if
  end if
end function
%>
<br>
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <th>网站会员管理：会员财务流水</th>
  </tr>
  <tr>
    <td height="24" align="center" nowrap="nowrap"  class="forumrow"><a href="Member_purse.asp" onclick='changeAdminFlag(&quot;查看所有会员财务流水&quot;)'>查看所有会员财务流水</a></td>
  </tr>
</table>
<br>
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
<form name="formSearch" method="post" action="Search.asp?Result=purse">
  <tr>
    <th height="22">【会员财务检索及分类查看】</th>
  </tr>
  <tr>
    <td class="forumRow">关键字：<input name="Keyword" type="text" value="<%=Keyword%>" size="20"> <input name="submitSearch" type="submit" value="搜索会员"></td> </form><form name="formadmin" method="post" action="?financial=yes"><td class="forumRow">给会员充值或扣款：会员登录号<input name="username" type="text" value="" size="10"> &nbsp;&nbsp;金额<input name="total" type="text" value="" size="10" onKeyUp="if(isNaN(value)){alert('金额只允许输入数字');value='';}"   onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d|^\.]/g,''))">元&nbsp;&nbsp;类型<SELECT size=1 name="type">
<OPTION value="" selected>选择类型</OPTION>
<OPTION value="1">充值</OPTION>
<OPTION value="0">扣款</OPTION>
</select>&nbsp;&nbsp;<input name="submitSearzz" type="submit" value="确认"></td>
  </tr></form>
  <tr>
    <td class="forumRow" colspan='2'><%PlaceFlag()%></td>
  </tr>
 
</table>
<br>
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
<form action="DelContent.asp?Result=purse" method="post" name="formDel">
  <tr>
    <td align="center" width="20">ID</td>
    <td align="center" width="100">订单号</td>
	<td align="center" width="50">项目</td>
	<td align="center" width="60">收入</td>
	<td align="center" width="60">支出</td>
	<td align="center" width="80">操作人</td>
	<td align="center" width="150">操作时间</td>
	<td align="center" width="50">审核</td>
	<td align="center" width="150">审核时间</td>
	<td width="50" align="center" class="title"><input onClick="CheckAll(this.form)" name="buttonAllSelect" type="button" id="submitAllSearch" value="全选"> <input onClick="CheckOthers(this.form)" name="buttonOtherSelect" type="button" id="submitOtherSelect" value="反选"></td>
  </tr>
  <% MemList() %>
  </form>
</table>
</BODY>
</HTML>
<%
function MemList()
  dim idCount
  dim pages
      pages=20
  dim pagec
  dim page
      page=clng(request("Page"))
  dim pagenc
      pagenc=2
  dim pagenmax
  dim pagenmin
  dim datafrom
      datafrom="TianTianCMS_financiallog"
  dim datawhere
      if Result="Search" then
	     datawhere="where members like '%" & Keyword &_
		           "%' or ddhm like '%" & Keyword &_
		           "%' or OrderName like '%" & Keyword &_
		           "%' or channel like '%" & Keyword &_
		           "%' or operator like '%" & Keyword &_
		           "%' "
	  else
	     datawhere=""
	  end if
  dim sqlid
  dim Myself,PATH_INFO,QUERY_STRING
      PATH_INFO = request.servervariables("PATH_INFO")
	  QUERY_STRING = request.ServerVariables("QUERY_STRING")'
      if QUERY_STRING = "" or Instr(PATH_INFO & "?" & QUERY_STRING,"Page=")=0 then
	    Myself = PATH_INFO & "?"
	  else
	    Myself = Left(PATH_INFO & "?" & QUERY_STRING,Instr(PATH_INFO & "?" & QUERY_STRING,"Page=")-1)
	  end if
  dim taxis
      taxis="order by id desc"
  dim i
  dim rs,sql
  sql="select count(ID) as idCount from ["& datafrom &"]" & datawhere
  set rs=server.createobject("adodb.recordset")
  rs.open sql,conn,0,1
  idCount=rs("idCount")
  if(idcount>0) then
    if(idcount mod pages=0)then
	  pagec=int(idcount/pages)
   	else
      pagec=int(idcount/pages)+1
    end if
    sql="select id from ["& datafrom &"] " & datawhere & taxis
    set rs=server.createobject("adodb.recordset")
    rs.open sql,conn,1,1
    rs.pagesize = pages
    if page < 1 then page = 1
    if page > pagec then page = pagec
    if pagec > 0 then rs.absolutepage = page  
    for i=1 to rs.pagesize
	  if rs.eof then exit for  
	  if(i=1)then
	    sqlid=rs("id")
	  else
	    sqlid=sqlid &","&rs("id")
	  end if
	  rs.movenext
    next
  end if
  if(idcount>0 and sqlid<>"") then
    sql="select * from ["& datafrom &"] where id in("& sqlid &") "&taxis
    set rs=server.createobject("adodb.recordset")
    rs.open sql,conn,0,1
    while(not rs.eof)
	  Response.Write "<tr>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("ID")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("ddhm")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("OrderName")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("income")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("spending")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("operator")&"</td>" & vbCrLf
      Response.Write "<td nowrap class=""forumRow"">"&rs("Operatingtime")&"</td>" & vbCrLf
      if rs("audit") then
        Response.Write "<td nowrap align='center' class=""forumRow""><font color='green'>√</font></td>" & vbCrLf
      else
        Response.Write "<td nowrap align='center' class=""forumRow""><font color='red'>×</font></td>" & vbCrLf
	  end If
      Response.Write "<td nowrap class=""forumRow"">"&rs("Operatingtime")&"</td>" & vbCrLf
 	  Response.Write "<td nowrap align='center' class=""forumRow""><input name='selectID' type='checkbox' value='"&rs("ID")&"'></td>" & vbCrLf
      Response.Write "</tr>" & vbCrLf
	  rs.movenext
    wend
    Response.Write "<tr>" & vbCrLf
    Response.Write "<td colspan='13' nowrap align=""right"" class=""forumRow""><input type=""submit"" name=""batch"" value=""批量通过审核"" onClick=""return test();""> <input type=""submit"" name=""batch"" value=""批量取消审核"" onClick=""return test();"">  <input name='batch' type='submit' value='删除所选' onClick=""return del();""></td>" & vbCrLf
    Response.Write "</tr>" & vbCrLf
  else
    response.write "<tr><td nowrap align='center' colspan='12' class=""forumRow"">暂无记录</td></tr>"
  end if
  Response.Write "<tr>" & vbCrLf
  Response.Write "<td colspan='13' nowrap class=""forumRow"">" & vbCrLf
  Response.Write "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
  Response.Write "<tr>" & vbCrLf
  Response.Write "<td class=""forumRow"">共计：<font color='red'>"&idcount&"</font>条记录 页次：<font color='red'>"&page&"</font></strong>/"&pagec&" 每页：<font color='red'>"&pages&"</font>条</td>" & vbCrLf
  Response.Write "<td align='right'>" & vbCrLf
  pagenmin=page-pagenc
  pagenmax=page+pagenc
  if(pagenmin<1) then pagenmin=1
  if(page>1) then response.write ("<a href='"& myself &"Page=1'><font style='font-size: 14px; font-family: Webdings'>9</font></a> ")
  if(pagenmin>1) then response.write ("<a href='"& myself &"Page="& page-(pagenc*2+1) &"'><font style='font-size: 14px; font-family: Webdings'>7</font></a> ")
  if(pagenmax>pagec) then pagenmax=pagec
  for i = pagenmin to pagenmax
	if(i=page) then
	  response.write (" <font color='red'>"& i &"</font> ")
	else
	  response.write ("[<a href="& myself &"Page="& i &">"& i &"</a>]")
	end if
  next
  if(pagenmax<pagec) then response.write (" <a href='"& myself &"Page="& page+(pagenc*2+1) &"'><font style='font-size: 14px; font-family: Webdings'>8</font></a> ")
  if(page<pagec) then response.write ("<a href='"& myself &"Page="& pagec &"'><font style='font-size: 14px; font-family: Webdings'>:</font></a> ")
  Response.Write "第<input name='SkipPage' onKeyDown='if(event.keyCode==13)event.returnValue=false' onchange=""if(/\D/.test(this.value)){alert('请输入需要跳转到的页数并且必须为整数！');this.value='"&Page&"';}"" style='width: 28px;' type='text' value='"&Page&"'>页" & vbCrLf
  Response.Write "<input name='submitSkip' type='button' onClick='GoPage("""&Myself&""")' value='转到'>" & vbCrLf
  Response.Write "</td>" & vbCrLf
  Response.Write "</tr>" & vbCrLf
  Response.Write "</table>" & vbCrLf
  rs.close
  set rs=nothing
  Response.Write "</td>" & vbCrLf
  Response.Write "</tr>" & vbCrLf
end Function
Call CloseDB(conn)%>