<!--#include file="Include/Const.Asp" -->
<!--#include file="Include/ConnSiteData.Asp" -->
<!--#include file="Include/Version.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<%
If Request("Act") = "ClsCache" Then
    Call ClsCache()
End If

Dim Result,MemName,MemNameList,MemName_Pre,st,et,t
Result = request.QueryString("Result")
st=trim(request("st")) '开始时间
et=trim(request("et")) '结束时间
if st="" and et="" then
   st=date()
   et=date()
end if
Action = request.QueryString("Action")
    If Action = "seach" Then
	st=trim(request.Form("st"))
	et=trim(request.Form("et"))
	end if
t=trim(request("t"))

%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="Images/Admin_style.css">
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
<!--
function Checkstet()
{
   if (seach1.st.value.replace(/[ ]/g,"")=="")
   {
	  alert("请选择开始日期！");
	  return false;
   }
  if (seach1.et.value.replace(/[ ]/g,"")=="")
   {
	  alert("请选择结束日期！");
	  return false;
   }
}
-->
</script>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tr>
    <td class="forumRow">
	<div class="datelist"><form action="?Action=seach" method="post" id="seach1" onsubmit="return Checkstet()">
    <a href="?st=<%=GetNow(0)%>&et=<%=GetNow(0)%>">今日</a> 
    <a href="?st=<%=GetNow(1)%>&et=<%=GetNow(1)%>">昨日</a> 
    <a href="?st=<%=GetNow(7)%>&et=<%=GetNow(0)%>&t=7">最近7天</a>
    <a href="?st=<%=GetNow(30)%>&et=<%=GetNow(0)%>&t=30">最近30天</a>
    <a href="?st=<%=year(date())&"-"&month(date())&"-1"%>&et=<%=GetNow(0)%>&t=month">本月</a>
    &nbsp;&nbsp;
    选择日期： <input name="st" id="st" class="Wdate" type="text" onFocus="WdatePicker({skin:'blueFresh',maxDate:'#F{$dp.$D(\'et\')||\'2020-10-01\'}'})" value="<%=st%>"/> 
   至 
   <input name="et" id="et" class="Wdate" type="text" onFocus="WdatePicker({skin:'blueFresh',minDate:'#F{$dp.$D(\'st\')}',maxDate:'2020-10-01'})" value="<%=et%>"/>
    <input name="submit" type="submit" id="submit" value="查询" /></form></div>
  
	</td>
  </tr>
  <tr>
    <td class="forumRow">&nbsp;
	 <img src="Images/question.gif" width="18" height="18" />
     您
   <font color="#FF0000">
    <%
	select case t
	     case "7"
		     response.Write "最近7天"
		 case "30"
		     response.Write "最近30天"
		 case "month"
		      response.Write "本月" 	 
		 case else
		      if datediff("d",st,date())=0 then
			     response.Write "今日"
			  elseif datediff("d",st,date())=1 then
			     response.Write "昨日"
			  else
			     response.Write st&"<font color=""#0033FF""> 至 </font>"&et
			  end if
    end select		 
	%></font>
    客户及机会情况<br /><br />
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cedced">
      <tr bgcolor="#e9f1fa">
        <td width="200"><div align="center"><strong>日 期</strong></div></td>
        <td width="80"><div align="center"><strong>客 户</strong></div></td>
        <td width="80"><div align="center"><strong>业务机会</strong></div></td>
        <td><div align="center"><strong>&nbsp;</strong></div></td>
      </tr>
  <%
   strToday=date() '今日 
  Select Case t
  'st,et
     case "7"
	    for i=0 to t-1
		  response.Write "<tr bgcolor=""#FFFFFF"">"
	      response.Write "<td nowrap align='center'>"&dateadd("d",-i,strToday)&"</td>"
          Response.Write "<td nowrap align='center'>"&thisday(dateadd("d",-i,strToday))&"</td>"
		  Response.Write "<td nowrap align='center'>"&thisdaychances(dateadd("d",-i,strToday))&"</td>"
		  Response.Write "<td nowrap >&nbsp;</td>"
	      Response.Write "</tr>"
	   next
	 case "30"
	    for i=0 to t-1
		  response.Write "<tr bgcolor=""#FFFFFF"">"
	      response.Write "<td nowrap align='center'>"&dateadd("d",-i,strToday)&"</td>"
          Response.Write "<td nowrap align='center'>"&thisday(dateadd("d",-i,strToday))&"</td>"
		  Response.Write "<td nowrap align='center'>"&thisdaychances(dateadd("d",-i,strToday))&"</td>"
		  Response.Write "<td nowrap >&nbsp;</td>"
	      Response.Write "</tr>"
	   next
	'case "month"
	      
		   'date1=date()-day(date()-1) 
		   'response.Write date1
    case else
	      t=datediff("d",st,et) '相隔天数
		  'response.Write t
		for i=0 to t
		'response.Write st
		  response.Write "<tr bgcolor=""#FFFFFF"">"
	      response.Write "<td nowrap align='center'>"&dateadd("d",-i,et)&"</td>"
          Response.Write "<td nowrap align='center'>"&thisday(dateadd("d",-i,et))&"</td>"
		  Response.Write "<td nowrap align='center'>"&thisdaychances(dateadd("d",-i,et))&"</td>"
		  Response.Write "<td nowrap >&nbsp;</td>"
	      Response.Write "</tr>"
		next  
  End Select
  %>

</table>
    </td>
  </tr>
  </form>
</table>
<br />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
</table>
<br />
<%
Function thisday(thist) 
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from Zqj_Kehu where MemName='"&session("UserName")&"' and year(AddTime)="&year(thist)&" and month(AddTime)="&month(thist)&" and day(AddTime)="&day(thist)&" order by AddTime desc"
	rs.Open sql,conn,1,3
	thisday=rs.recordcount
    rs.Close
    Set rs = Nothing
End Function

Function thisdaychances(thist2)
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	sql = "select * from Zqj_chances where ch_MemName='"&session("UserName")&"' and year(ch_addtime)="&year(thist2)&" and month(ch_addtime)="&month(thist2)&" and day(ch_addtime)="&day(thist2)&" order by ch_addtime desc"
	rs.Open sql,conn,1,3
	thisdaychances=rs.recordcount
    rs.Close
    Set rs = Nothing
End Function
%>