<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>资金明细记录管理</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
</head>
<body>
	<%	
	Private totalPut,rs, CurrentPage, MaxPerPage,DomainStr,SearchType,SQLParam
	SearchType=ChkNumeric(request("SearchType"))
	%>
		<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 资金明细记录管理 >>	  <%Dim SearchTypeStr
	    Dim KeyWord:KeyWord=request("KeyWord")
	  Select Case SearchType
	     Case 0 :SearchTypeStr="所有资金明细记录"
		 Case 1 :SearchTypeStr="最近10天内的新资金明细记录"
		 Case 2 :SearchTypeStr="最近一月内的新资金明细记录"
		 Case 3 :SearchTypeStr="所有收入记录"
		 Case 4 :SearchTypeStr="所有支出记录"
		 Case 5 
		    Select Case ChkNumeric(request("Field"))
			  Case 1:SearchTypeStr="客户姓名含有<font color=red>""" & KeyWord & """</font>"
			  Case 2:SearchTypeStr="用户名含有<font color=red>""" & KeyWord & """</font>"
			  Case 3:SearchTypeStr="交易时间含有<font color=red>""" & KeyWord & """</font>"
			End Select
	  End Select
	  echo SearchTypeStr%>
	  </div>
    <div class="opers">
    	<FORM name=form2 action=? method=post><a href="?" class="btn">资金明细首页</a>
    	<a href="?SearchType=0" class="btn  <%If SearchType="0" Then echo " btn_primary" %>">所有资金明细记录</a>
    	<a href="?SearchType=1" class="btn  <%If SearchType="1" Then echo " btn_primary" %>">10天内的新资金明细记录</a>
    	<a href="?SearchType=2" class="btn  <%If SearchType="2" Then echo " btn_primary" %>">一月内的新资金明细记录</a>
    	<a href="?SearchType=3" class="btn  <%If SearchType="3" Then echo " btn_primary" %>">所有收入记录</a>
    	<a href="?SearchType=4" class="btn  <%If SearchType="4" Then echo " btn_primary" %>">所有支出记录</a>
   
	
	
	
	 高级查询： 
	<Select id=Field name=Field class='textbox'> 
	<Option value=1 selected>客户姓名</Option> 
	<Option value=2>用户名</Option> 
	<Option value=3>交易时间</Option> 
	</Select> 
	<Input id=Keyword class='Ainput' maxLength=30 name=Keyword> 
	<Input class="btn btn_primary" type=submit value=" 查 询 " name=Submit2> 
	<Input id=SearchType type=hidden value=5 name=SearchType></FORM>
 
 	
	</div>




 
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>交易时间</th>
	  <th>用户名</th>
	  <th>客户姓名</th>
	  <th>交易方式</th>
	  <th>币种</th>
	  <th>收入金额</th>
	  <th>支出金额</th>
	  <th>摘要</th>
	  <th>备注/说明</th>
	  </tr>
    </thead>


	<%
			MaxPerPage=20
			If request("page") <> "" Then
				  CurrentPage = ChkNumeric(request("page"))
			Else
				  CurrentPage = 1
			End If
			SqlParam="1=1"
            If SearchType<>"0" Then
			  Select Case SearchType
			   Case 1
					SqlParam=SqlParam &" And datediff('d',Logtime," & NowString & ")<=10"
			   Case 2
					SqlParam=SqlParam &" And datediff('d',Logtime," & NowString & ")<=30"
			  Case 3 : SqlParam = SqlParam & "And IncomeFlag=1"
			  Case 4 : SqlParam = SqlParam & "And IncomeFlag=2"
			  Case 5
			      Select Case ChkNumeric(request("Field"))
				   Case 1
				     SqlParam=SqlParam &" And ClientName Like '%" & Keyword & "%'"
				   Case 2
				     SqlParam=SqlParam &" And UserID Like '%" & Keyword & "%'"
				   Case 3
				     SqlParam=SqlParam &" And logtime Like '%" & Keyword & "%'"
				  End Select
			  End Select
			End If
	Set RS=Server.CreateObject("ADODB.RECORDSET")
 	
	RS.Open "Select * From Money_Log_fy Where " & SqlParam & " Order By ID Desc",Conn,1,1
	If RS.Eof AND RS.Bof Then
	 echo "<tr  lass='td_bg' ><td colspan=9 align=center height='25'>找不到" & SearchTypeStr & "!</td></tr>"
   Else
                          totalPut = RS.RecordCount
							If CurrentPage < 1 Then	CurrentPage = 1
							If (CurrentPage - 1) * MaxPerPage > totalPut Then
								If (totalPut Mod MaxPerPage) = 0 Then
									CurrentPage = totalPut \ MaxPerPage
								Else
									CurrentPage = totalPut \ MaxPerPage + 1
								End If
							End If
							If CurrentPage = 1 Then
								Call showContent()
							Else
								If (CurrentPage - 1) * MaxPerPage < totalPut Then
									RS.Move (CurrentPage - 1) * MaxPerPage
									Call showContent()
								Else
									CurrentPage = 1
									Call showContent()
								End If
							End If
   End If
   RS.Close:Set RS=Nothing
   %>
	
	
	</table>
    <div class="pagelist">
      <%
		   	  '显示分页信息
			  Call ShowPagePara(totalPut, MaxPerPage, "", True, "条记录", CurrentPage, "SearchType=" & SearchType & "&Field=" & request("Field") & "&KeyWord=" & KeyWord)
		
		   %>
   </div>
</div>


   <%
  
	Public Function ShowPagePara(totalnumber, MaxPerPage, FileName, ShowAllPages, strUnit, CurrentPage, ParamterStr)
		  Dim N, I, PageStr
				Const Btn_First = "第一页"'样式定义
				Const Btn_Prev = "上一页" 
				Const Btn_Next = "下一页" 
				Const Btn_Last = "最后一页" 
				  PageStr = ""
					If totalnumber Mod MaxPerPage = 0 Then
						N = totalnumber \ MaxPerPage
					Else
						N = totalnumber \ MaxPerPage + 1
					End If
				If N > 1 Then
					PageStr = PageStr & ("页次：<font color=red>" & CurrentPage & "</font>/" & N & "页 共有:" & totalnumber & strUnit & " 每页:" & MaxPerPage & strUnit & " ")
					If CurrentPage < 2 Then
						PageStr = PageStr & Btn_First & " " & Btn_Prev & " "
					Else
						PageStr = PageStr & ("<a href=" & FileName & "?page=1" & "&" & ParamterStr & ">" & Btn_First & "</a> <a href=" & FileName & "?page=" & CurrentPage - 1 & "&" & ParamterStr & ">" & Btn_Prev & "</a> ")
					End If
					
					If N - CurrentPage < 1 Then
						PageStr = PageStr & " " & Btn_Next & " " & Btn_Last & " "
					Else
						PageStr = PageStr & (" <a href=" & FileName & "?page=" & (CurrentPage + 1) & "&" & ParamterStr & ">" & Btn_Next & "</a> <a href=" & FileName & "?page=" & N & "&" & ParamterStr & ">" & Btn_Last & "</a> ")
					End If
					If ShowAllPages = True Then
						PageStr = PageStr & ("GO:<select  onChange='location.href=this.value;' style='width:55;' name='select'>")
				   For I = 1 To N
					 If Cint(CurrentPage) = I Then
						PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & " selected>NO." & I & "</option>")
					 Else
						 PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & ">NO." & I & "</option>")
					 End If
				   Next
				  PageStr = PageStr & "</select>"
				  End If
			 End If
			 ShowPagePara = PageStr
			 echo ShowPagePara
	End Function
  Sub ShowContent()
     Dim I,intotalmoney,outtotalmoney
     Do While Not rs.eof 
	%>
    <tr class=tdbg  >
      <td align=middle width=150 class="td_bg"><%=rs("LogTime")%></td>
      <td align=middle width=80 class="td_bg"><%=fycms.UserM(rs("UserID"))%></td>
	  <td align=middle width=80 class="td_bg"><%=rs("clientname")%></td>
      <td align=middle width=60 class="td_bg">
	  <% Select Case rs("MoneyType")
	      Case 1:echo "现金"
		  Case 2:echo "银行汇款"
		  Case 3:echo "在线支付"
		  Case 4:echo "资金余额"
		 End Select
	 %>
	  </td>
      <td align=middle width=50 class="td_bg">人民币</td>
      <td width=80 > 
	  <%If rs("IncomeFlag")=1 Then
	     echo formatnumber(rs("money"),2)
		 intotalmoney=intotalmoney+rs("money")
	    End If
		%></td>
      <td align=right width=80 class="td_bg">
	  <%If rs("IncomeFlag")=2 Then
	     echo formatnumber(rs("money"),2)
		 outtotalmoney=outtotalmoney+rs("money")
	    End If
		%></td>
      <td align=center width=40 class="td_bg">
	  <% If rs("IncomeFlag")=1 Then
	      echo "<font color=red>收入</font>"
		 Else
		  echo "<font color=green>支出</font>"
		 End If
		 %></td>
      <td align=middle class="td_bg"><%=rs("Remark")%></td>
    </tr>
	<%
	            
				I = I + 1
				RS.MoveNext
				If I >= MaxPerPage Then Exit Do

	 loop
	%>
    <tr >
      <td>本页合计：</td>
      <td colSpan=5 ><%=formatnumber(intotalmoney,2)%></td>
      <td ><%=formatnumber(outtotalmoney,2)%></td>
      <td colSpan=3 class="td_bg">&nbsp;</td>
    </tr>
    <tr >
      <td colSpan=5 >总计金额：</td>
	  <%intotalmoney=Conn.execute("Select Sum(Money) From Money_Log_fy Where "& SqlParam & " And IncomeFlag=1")(0)
	    outtotalmoney=Conn.execute("Select Sum(Money) From Money_Log_fy Where "& SqlParam & " And IncomeFlag=2")(0)
	    if not isnumeric(intotalmoney) then intotalmoney=0
		if not isnumeric(outtotalmoney) then outtotalmoney=0
	  %>
      <td ><%=formatnumber(intotalmoney,2)%></td>
      <td ><%=formatnumber(outtotalmoney,2)%></td>
      <td align=middle colSpan=3 class="td_bg">资金余额：<%=formatnumber(intotalmoney-outtotalmoney,2)%></td>
    </tr>
  </table>
		<%
		End Sub

%>




</body>
</html>
