<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<%
If InStr(session("GroupPurview"),"|10,") = 0 Then
    response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    response.End
End If
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<script language="javascript" src="../JavaScript/Admin.js"></script>
<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>
<%
Dim Result,MemName,MemNameList,MemName_Pre,st,et,t
Result = request.QueryString("Result")
MemName_Pre=request.QueryString("MemName_Pre") '获取成员
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"))
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tr>
    <td class="forumRow">
	<div class="team_list">按团队成员：&nbsp; <a href="?st=<%=st%>&et=<%=et%>&t=<%=t%>">全部</a> &nbsp; 
    
	<%teamlist(session("UserName"))%>
    </div>
	<div class="datelist"><form action="?Action=seach&MemName_Pre=<%=request("MemName_Pre")%>" method="post" id="seach1" onsubmit="return Checkstet()">
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(0)%>&et=<%=GetNow(0)%>">今日</a> 
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(1)%>&et=<%=GetNow(1)%>">昨日</a> 
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(7)%>&et=<%=GetNow(0)%>&t=7">最近7天</a> 
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(30)%>&et=<%=GetNow(0)%>&t=30">最近30天</a>
    <a href="?MemName_Pre=<%=MemName_Pre%>&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" />
     <%if MemName_Pre<>"" then%>
       <b><%=genjinText(MemName_Pre)%></b> 
    <%end if%> 
   <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>
    更新联系人
    <%
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	if MemName_Pre<>"" then
	sql = "SELECT Zqj_Contactperson.Cp_name,Zqj_Contactperson.Cp_updatime,Zqj_Contactperson.Memname, Zqj_Company.Co_name FROM Zqj_Contactperson LEFT JOIN Zqj_Company ON Zqj_Contactperson.Co_ID = Zqj_Company.Co_ID WHERE (((Zqj_Contactperson.Memname) in('"&MemName_Pre&"')) and Zqj_Contactperson.Cp_updatime between #"&st&"# and #"&dateadd("d",+1,et)&"#) order by Zqj_Contactperson.Cp_updatime desc"
	else
	sql = "SELECT Zqj_Contactperson.Cp_name,Zqj_Contactperson.Cp_updatime, Zqj_Contactperson.Memname, Zqj_Company.Co_name FROM Zqj_Contactperson LEFT JOIN Zqj_Company ON Zqj_Contactperson.Co_ID = Zqj_Company.Co_ID WHERE (((Zqj_Contactperson.Memname) in("&MemNameList&")) and Zqj_Contactperson.Cp_updatime between #"&st&"# and #"&dateadd("d",+1,et)&"#) order by Zqj_Contactperson.Cp_updatime desc"
	end if
    rs.Open sql,conn,1,3
	cpn=rs.RecordCount
  %>
     共 <font color="#0000FF"><%=cpn%></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><div align="left"><strong>公 司</strong></div></td>
        <td><div align="center"><strong></strong></div></td>
      </tr>
  <%	
	if rs.eof and rs.bof then
	      response.Write "<tr bgcolor=""#FFFFFF"">"
		  Response.Write "<td nowrap colspan=""4"">&nbsp;暂无相关信息!</td>"
	      Response.Write "</tr>"
	else
	    While Not rs.EOF
		  response.Write "<tr bgcolor=""#FFFFFF"">"
		  if DATEDIFF("d",rs("Cp_updatime"),date())=0 then
	         response.Write "<td nowrap align='center' style=""color:#F00"">"&rs("Cp_updatime")&"</td>"
		  else
		     response.Write "<td nowrap align='center'>"&rs("Cp_updatime")&"</td>"
		  end if
          Response.Write "<td nowrap align='center'>"&rs("Cp_name")&"</td>"
		  Response.Write "<td nowrap >"&rs("Co_name")&"</td>"
		  Response.Write "<td nowrap >&nbsp;</td>"
	      Response.Write "</tr>"
		rs.movenext
		Wend
	end if
    rs.Close
    Set rs = Nothing		 
  %>
</table>
    </td>
  </tr>
  </form>
</table>
<br />

<%


Function teamlist(MemName)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Members where MemName='"&MemName&"' and Working"
    rs.Open sql, conn, 1, 1
    If rs.eof and rs.bof  Then
        response.Write "<script language='javascript'>alert('参数错误！');history.back(-1);</script>"
        response.End
    else
        SortPath=rs("SortPath") '读取当前用户的部门
		SortID=rs("SortID")
    end if
    rs.Close
    Set rs = Nothing
	'列出团队成员
	Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Members where SortID="&SortID&" and Working"
    rs.Open sql, conn, 1, 1
	if rs.eof and rs.bof then
	    response.Write "无成员"
	else
	    While Not rs.EOF
        response.Write(" <img src='../Images/doing.gif' /> <a href='?MemName_Pre="&rs("MemName")&"&st="&st&"&et="&et&"&t="&t&"&Page=1'>"&rs("RealName")&"</a> &nbsp;")
		MemNameList=MemNameList+"'"+rs("MemName")+"'"
        rs.movenext
		if not rs.eof then
		   MemNameList=MemNameList+","
		end if		
        Wend
	end if
	rs.close
	set rs=nothing
End Function

Function genjinText(MemName)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Members where MemName='"&MemName&"'"
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	genjinText="无跟进人"
	else
    genjinText = rs("RealName")
	end if
    rs.Close
    Set rs = Nothing
End Function

Function thisday(MemName_Pre,thist) 
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	if MemName_Pre<>"" then
	sql = "select * from Zqj_Contactperson where Memname in('"&MemName_Pre&"') and year(Cp_updatime)="&year(thist)&" and month(Cp_updatime)="&month(thist)&" and day(Cp_updatime)="&day(thist)&" order by Cp_updatime desc"	
	else
	sql = "select * from Zqj_Contactperson where MemName in("&MemNameList&") and year(Cp_updatime)="&year(thist)&" and month(Cp_updatime)="&month(thist)&" and day(Cp_updatime)="&day(thist)&" order by Cp_updatime desc"
	end if
    rs.Open sql,conn,1,3
	thisday=rs.recordcount
    rs.Close
    Set rs = Nothing
End Function
%>