<!--#include file="conn.asp"-->
<!--#include file="public.asp"-->





<%

Dim DateQuery

 set Conn=Server.CreateObject("adodb.connection") 
    Conn.Open connstr2   
 set rs=Server.CreateObject("adodb.recordset") 
 
 
 
startdate=request("startdate")
enddate=request("enddate")

 
RecvUser=request("RecvUser")
 
 
if startdate<>"" then 
 'DateQuery=" and createdate between '"  & startdate  & " 00:01:01'  and '" &  enddate   & " 23:59:59'  "
 DateQuery=" and createdate between '"  & startdate  & "'  and '" &  enddate   & "'  "

end if 

if RecvUser<>"" then

  DateQuery=DateQuery & " and id in( select a.notifyid from  handdetail a,handmaster b where a.id=b.id and b.groupid=" & RecvUser  &"  )  "


end if 



refundstartdate=request("refundstartdate")

refundenddate=request("refundenddate")

'refundstartdate=refundstartdate+" 00:00:01 "
'refundenddate=refundenddate+" 23:59:59"

	'if refundstartdate<> "" then DateQuery=DateQuery & " and id in (select  b.notifyid as id from refundmaster a,refunddetail b where a.id=b.id and a.createdate between'" & refundstartdate &  " 00:01:01' and '" & refundenddate &  " 23:59:59 ') "
if refundstartdate<> "" then DateQuery=DateQuery & " and id in (select  b.notifyid as id from refundmaster a,refunddetail b where a.id=b.id and a.createdate between'" & refundstartdate &  " 00:00:01' and '" & refundenddate &  " 23:59:59') "



%>


<SCRIPT LANGUAGE=vbscript>
<!--
function query()

   if not isdate( myform.startdate.value) and myform.startdate.value<>"" then
    msgbox "Ҫѯȷʱ"
    exit function
  end if
  
  
  
   if not isdate( myform.enddate.value) and myform.startdate.value<>"" then
    msgbox "Ҫѯȷʱ"
    exit function
  end if
  
myform.sum.value="Sum"  
myform.submit()

end function
//-->
</SCRIPT>


<form name=myform method>

<input type=hidden name="sum">


ʱ:<input name=startdate size=10 value="<%=startdate%>" class="input_text" onfocus="setday(this)"> - <input name="enddate" size=10 value="<%=enddate%>" class="input_text" onfocus="setday(this)">
  صʱ:
<input class="input_text" name="refundstartdate" value="<%=refundstartdate%>" size=10 onfocus="setday(this)">
--
<input class="input_text" name="refundenddate" value="<%=refundenddate%>" size=10 onfocus="setday(this)">
&nbsp;


 ѡ:<select name=RecvUser>
       
  
             <%
              set urs=server.CreateObject("adodb.recordset") 
              set urs=conn.Execute("select * from [group] where grouptype=10") 
              %>
             <option value=""></option>
              <%
              do while not urs.EOF  
              %>
              <option value="<%=urs("id")%>" <%if cstr(urs("id"))=cstr(RecvUser) then Response.Write "selected"%>><%=urs("groupname")%>
              <%
              urs.MoveNext 
              loop
              urs.Close 
              set urs=nothing
             %>
           </select>
           
           
<input type=button value="ͳ  " onclick="query()" class=button id=button1 name=button1> 





<br>
<br>

<table border=0 width=100%>
 <tr><td  valign=top>
			<font color=blue>Ҫܶ </font><br>
			
			<table border=1 borderColorDark=white>
			  <tr>
			    <th>Դ
			    <th>Υܶ
			    <th>ܶ
			    <th>ܶ
			 <tr>
			   <td>
			  <% 
			  allwfmoney=0
			   		allsxmoney=0
			   		alltmpa=0
			   if Request("Sum")="Sum" then
			   Str=" select groupname,wfmoney,sxmoney,blmoney from (select groupid,sum(wfmoney)as wfmoney ,sum(sxmoney) as sxmoney,sum(blmoney) as blmoney from notifyinfo  where (prostate is null or prostate =0) and stateid=1 " &  DateQuery  &   " group by groupid) a,[group] b where a.groupid=b.[id] "
				
		

				'Response.Write str
				set rs=conn.Execute (str)
				if not rs.EOF  then
						do while not rs.EOF  
						%>
			     <tr>
			      <td><%=rs("groupname")%>
			      <td><%=rs("wfmoney")%>
			      <td><%=rs("sxmoney")%>
			      <td><% tmpa=rs("blmoney")
			             if tmpa="" or isnull(tmpa) then
			             tmpa=0
			             end if
			             Response.Write tmpa
			          %>
			   		<%
			   		
					allwfmoney=cdbl(rs("wfmoney"))+allwfmoney
					allsxmoney=cdbl(rs("sxmoney"))+allsxmoney
					alltmpa=cdbl(alltmpa)+cdbl(tmpa)
					
						rs.MoveNext 
						loop
				rs.Close() 
				end if
			  end if
			  %> 
			    <tr>
			      <th>
			      <th><%=allwfmoney%>
			      <th><%=allsxmoney%>
			      <th><%=alltmpa%>
			</table>

<td  valign=top>
		<font color=blue>Ҫ˿ܶ </font><br>
			
			<table border=1 borderColorDark=white>
			  <tr>
			    <th>Դ
			    <th>Υܶ
			    <th>ܶ
			
			 <tr>
			   <td>
			  <% 
			        allwfmoney=0
			   		allsxmoney=0
			   if Request("Sum")="Sum" then
			   Str=" select groupname,wfmoney,sxmoney from (select groupid,sum(wfmoney)as wfmoney ,sum(sxmoney) as sxmoney from notifyinfo  where (prostate is null or prostate=0) and stateid=2 "  & DateQuery & "  group by groupid) a,[group] b where a.groupid=b.[id] "
				set rs=conn.Execute (str)
				if not rs.EOF  then
						do while not rs.EOF  
						%>
			     <tr>
			      <td><%=rs("groupname")%>
			      <td><%=rs("wfmoney")%>
			      <td><%=rs("sxmoney")%>
			      
			      
			   		<%
			   		
					allwfmoney=cdbl(rs("wfmoney"))+allwfmoney
					allsxmoney=cdbl(rs("sxmoney"))+allsxmoney
						rs.MoveNext 
						loop
				rs.Close() 
				end if
			  end if
			  %> 
			    <tr>
			      <th>
			      <th><%=allwfmoney%>
			      <th><%=allsxmoney%>
			</table>

<tr><td  valign=top>
			<font color=blue>Ҫܶ </font><br>
			
			<table border=1 borderColorDark=white>
			  <tr>
			    <th>Դ
			    <th>Υ
			    <th>
			  
			    <th>
		
			 <tr>
			   <td>
			  <% 
			        allwfmoney=0
			   		allsxmoney=0
			   		allsum=0
			   
			   		
			   if Request("Sum")="Sum" then
			   Str="select * from (select groupid,wfmoney,sxmoney,count(*) as sumcount,sum(blmoney) as blmoney from notifyinfo where (prostate is null or prostate =0) and stateid=1 " & DateQuery  & " group by groupid,wfmoney,sxmoney) a,[group] b where a.groupid=b.[id] order by a.groupid,a.wfmoney,a.sxmoney"
		'Response.Write str
				set rs=conn.Execute (str)
				if not rs.EOF  then
			
						do while not rs.EOF  
				%>
			     
			     <tr>
			      <td><%=rs("groupname")%>
			      <td><%=rs("wfmoney")%>
			      <td><%=rs("sxmoney")%>
			  
			      <td><%=rs("sumcount")%>
			
			  		<%
			  		alltmpa=cdbl(alltmpa)+cdbl(tmpa)
			   		allwfmoney=cdbl(rs("wfmoney"))*cdbl(rs("sumcount"))+allwfmoney
					allsxmoney=cdbl(rs("sxmoney"))*cdbl(rs("sumcount")) +allsxmoney
					allsum=cdbl(rs("sumcount"))+allsum
						rs.MoveNext 
						loop
				rs.Close() 
				end if
			  end if
			  %> 
			    <tr>
			      <th>
			      <th><%=allwfmoney%>
			      <th><%=allsxmoney%>
			   
			      <th><%=allsum%>
			</table>
			
		<td  valign=top>
			<font color=blue>Ҫ˿ܶ </font><br>
			
			<table border=1 borderColorDark=white>
			  <tr>
			    <th>Դ
			    <th>Υ
			    <th>
			    <th>
		
			 <tr>
			   <td>
			  <% 
			        allwfmoney=0
			   		allsxmoney=0
			   		allsum=0
			   		
			   if Request("Sum")="Sum" then
			   Str="select * from (select groupid,wfmoney,sxmoney,count(*) as sumcount from notifyinfo where   (prostate is null or prostate =0) and  stateid=2 " & DateQuery  & " group by groupid,wfmoney,sxmoney) a,[group] b where a.groupid=b.[id] order by a.groupid,a.wfmoney,a.sxmoney"
			
				set rs=conn.Execute (str)
				if not rs.EOF  then
						do while not rs.EOF  
				%>
			     
			     <tr>
			      <td><%=rs("groupname")%>
			      <td><%=rs("wfmoney")%>
			      <td><%=rs("sxmoney")%>
			      <td><%=rs("sumcount")%>
			  
			
			  		<%
			   		allwfmoney=cdbl(rs("wfmoney"))*cdbl(rs("sumcount"))+allwfmoney
					allsxmoney=cdbl(rs("sxmoney"))*cdbl(rs("sumcount")) +allsxmoney
					allsum=cdbl(rs("sumcount"))+allsum
						rs.MoveNext 
						loop
				rs.Close() 
				end if
			  end if
			  %> 
			    <tr>
			      <th>
			      <th><%=allwfmoney%>
			      <th><%=allsxmoney%>
			      <th><%=allsum%>
			</table>

</table>





</form>


<%
set rs=nothing
Conn.Close() 
set Conn=nothing

%>    