<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<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;
   }
}
function changePos(thisID){
		var st=document.getElementById(thisID);
		if(document.body.clientWidth+document.body.scrollLeft-st.offsetLeft>=st.clientWidth){
			st.style.left=st.offsetLeft+'px';
		}else{
			st.style.left=(document.body.clientWidth>=st.clientWidth)? (document.body.clientWidth-st.clientWidth+document.body.scrollLeft-10)+'px':document.body.scrollLeft+'px';
			}
		if (document.body.clientHeight + document.body.scrollTop - st.offsetTop - st.clientHeight < st.clientHeight){
			//st.style.top  = (st.offsetTop - document.body.scrollTop < st.clientHeight) ? (st.offsetTop + st.clientHeight) +'px': (st.offsetTop - st.clientHeight)+'px';
			st.style.top=(st.offsetTop - document.body.scrollTop < st.clientHeight) ? (document.body.clientHeight-st.clientHeight+document.body.scrollTop-10) +'px': (st.offsetTop - st.clientHeight)+'px';
		}
	}
function display(display,indexID){
        document.getElementById(indexID).style.display=display;
}
-->
</script>
<%
If InStr(session("GroupPurview"), "|11,") = 0 Then
    response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    response.End
End If
Dim Result,reResult,Keyword,st,et,MemName_Pre,MemNameList,s
Result = request.QueryString("Result")
reResult = request.QueryString("reResult")
Keyword = request.QueryString("Keyword")
MemName_Pre=request.QueryString("MemName_Pre") '获取团队成员用户名
'初始
st=trim(request("st")) '开始时间
et=trim(request("et")) '结束时间

Action = request.QueryString("Action")
    If Action = "seach" Then
	st=trim(request.Form("st"))
	et=trim(request.Form("et"))
	   if st="" and et="" then '查询分页时
	      st=trim(request("st"))
          et=trim(request("et"))
	   end if
	end if

t=trim(request("t"))
if st="" and et="" then
   st=date()
   et=date()
end if
s=1
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
	<tr>
    <td class="forumrowhighlight">
    <div class="datelist"><form action="?Action=seach&MemName_Pre=<%=MemName_Pre%>&st=<%=st%>&et=<%=et%>&Page=1" method="post" id="seach1" onsubmit="return Checkstet()">
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(0)%>&et=<%=GetNow(0)%>&Page=1">今日</a> &nbsp;
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(1)%>&et=<%=GetNow(1)%>&Page=1">昨日</a> &nbsp;
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(7)%>&et=<%=GetNow(0)%>&t=7&Page=1">最近7天</a> &nbsp;
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=GetNow(30)%>&et=<%=GetNow(0)%>&t=30&Page=1">最近30天</a> &nbsp;
    <a href="?MemName_Pre=<%=MemName_Pre%>&st=<%=year(date())&"-"&month(date())&"-1"%>&et=<%=GetNow(0)%>&t=month&Page=1">本月</a> &nbsp;
    &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>
    <div class="team_list">团队成员：&nbsp; <a href="?st=<%=st%>&et=<%=et%>&t=<%=t%>">全部</a> &nbsp; 	<%teamlist(session("UserName"))%>
    </div>
    <div style="margin-top:5px; padding-left:10px;"><img src="../Images/question.gif" width="18" height="18" /> 
    <%if MemName_Pre<>"" then%>
       <b><%=genjinText(MemName_Pre)%></b> 
    <%
	else
	    response.Write "<b>全部</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 and datediff("d",et,date())=1 then
			     response.Write "昨日"
			  else
			     response.Write st&"<font color=""#0033FF""> 至 </font>"&et
			  end if
    end select		 
	%></font> 业务机会列表
    </div>
    
    </td>
    </tr>
    <tr>
      <td class="forumRowHighlight">
<table width="100%" align="center" cellpadding="2" cellspacing="1">
    <tr>
      <td class="forumRowHighlight"><form action="#" method="post" name="formDel">
  <% ChancesList() %>
        </form>
	  </td>
      </tr>
    <tr>
      <td class="forumRowHighlight">&nbsp;</td>
    </tr>
  </table>
	  </td>
    </tr>
</table>
<%

'机会列表
Function ChancesList()
    Dim idCount
    Dim pages
    pages = 10
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 2
    Dim pagenmax
    Dim pagenmin
    Dim datafrom
    datafrom = "Zqj_chances"
    Dim datawhere
	If Result = "Search" Then
        datawhere = "where (ch_name like '%" & Keyword &_
        "%' or ch_kehuname like '%" & Keyword &_
        "%' or ch_memo like '%" & Keyword &_
        "%') and ch_MemName='"&session("UserName")&"' "
	else
	    if MemName_Pre<>"" then
	        datawhere = "where ch_MemName='"&MemName_Pre&"' and ch_addtime between #"&st&"# and #"&dateadd("d",+1,et)&"# "
		else
		    datawhere = "where ch_MemName in("&MemNameList&") and ch_addtime between #"&st&"# and #"&dateadd("d",+1,et)&"# "
		end if
		
	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 ch_addtime 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
noli=1
While(Not rs.EOF)
%>
<table border="0" align="center" cellpadding="3" cellspacing="0" width="98%" class="bordergj">
  <tr valign="top" bgcolor="#F8F8FA" >
    <td align="left" bgcolor="#d5e9ff">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="60" height="25" align="center"><img src="../Images/chances_2.png" width="42" height="35" /></td>
              <td>
			    <a href="My_team_chancesView.Asp?Result=Modify&ID=<%=rs("ID")%>"><font style="font-size:14px; font-weight:400; color:#ff6600"><%=rs("ch_name")%></font></a>
			  <%
			  if rs("ch_kehuID")<>0 then
			  response.Write "来自<span id="""&s&"""> <a href=""../Kehu/My_team_KehuView.Asp?Result=Modify&ID="&rs("ch_kehuID")&"&showid=0""><font color=""#4579b9"">"&rs("ch_kehuname")&"</font></a> <img src=""../Images/connet_1.png"" width=""14"" height=""12"" />"
			  %>
      <script type="text/javascript">
           document.getElementById("<%=s%>").onmouseover=function(){display('block','w<%=s%>');changePos('w<%=s%>');};
           document.getElementById("<%=s%>").onmouseout=function(){display('none','w<%=s%>')};
     </script>
     <%call CKehuText(rs("ch_kehuID"),s)%>
              <%
			  response.Write "</span>"
			  end if
			  %>
			  
			  <font class="gjtime"><%=rs("ch_addtime")%></font></td>
			  <td width="100">
			  <%
			  Select Case rs("ch_status")
                Case "C"
				     response.Write "<div class=""chances_c"">C</div>"
				Case "B"
				     response.Write "<div class=""chances_b"">B</div>"
				Case "A"
				      response.Write "<div class=""chances_a"">A</div>"
				Case "O"
				      response.Write "<div class=""chances_o"">O</div>"
				Case else
			  End Select		 
			  %>
			  </td>
              <td width="50" align="center"><input name="selectID" type="checkbox" value="<%=rs("ID")%>"></td>
            </tr>
          </table> </td>
  </tr>
  <tr bgcolor="#F8F8FA" >
    <td align="left">
      <div class="gjlist" style="color:#999999"><%=rs("ch_memo")%></div>
	  <div style=" font-weight:bold; padding:5px;">
	  <%
	  if rs("ch_amount")=0 then
	     response.Write("没有设置金额.")
	  else	 
	  %>
	  ￥<%=rs("ch_amount")%>
	  <%end if%>
	  </div>
	  </td>
  </tr>
</table>

<%
noli=noli+1
s=s+1
rs.movenext
Wend
Response.Write "<table width=""98%"" align=""center"" cellpadding=""5"" cellspacing=""1"" style=""margin-top:20px;"">" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td nowrap align=""right"" class=""forumRow""> <input onClick=""CheckAll(this.form)"" name=""buttonAllSelect"" type=""button"" id=""submitAllSearch"" value=""全选""> <input onClick=""CheckOthers(this.form)"" name=""buttonOtherSelect"" type=""button"" id=""submitOtherSelect"" value=""反选""> <input name='batch' type='submit' value='删除所选' onClick=""return test();"" disabled></td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Else
Response.Write "<table border=""0"" align=""center"" cellpadding=""3"" cellspacing=""0"" width=""98%"" class=""bordergj"" style=""margin-bottom:20px;"">" & vbCrLf
Response.Write "  <tr valign=""top"" bgcolor=""#F8F8FA"" >" & vbCrLf
Response.Write "    <td align=""left"" bgcolor=""#d5e9ff"">" & vbCrLf
Response.Write "          <table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbCrLf
Response.Write "            <tr>" & vbCrLf
Response.Write "              <td width=""100"" height=""25"" align=""center"">&nbsp;</td>" & vbCrLf
Response.Write "              <td>&nbsp;</td>" & vbCrLf
Response.Write "              <td width=""50"" align=""center"">&nbsp;</td>" & vbCrLf
Response.Write "            </tr>" & vbCrLf
Response.Write "          </table> </td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "  <tr bgcolor=""#F8F8FA"" >" & vbCrLf
Response.Write "    <td align=""left"">" & vbCrLf
Response.Write "      <div class=""gjlist""> <font color='#999999'>什么是机会？ 机会即业务机会或商业机会，比如一笔可能成交的业务或项目。机会通常跟一个联系人相关，您需要先将这个联系人添加到系统。</font></div>" & vbCrLf
Response.Write "    </td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
End If
Response.Write "<table width='98%' border='0' align='center' cellpadding='5' cellspacing='1' style=""margin-bottom:20px;"">" & vbCrLf
Response.Write "<tr>" & vbCrLf
Response.Write "<td class=""forumRow"">&nbsp; 共计：<font color='red'>"&idcount&"</font>条记录 页次：<font color='red'>"&page&"</font></strong>/"&pagec&" 每页：<font color='red'>"&pages&"</font>条</td>" & vbCrLf
Response.Write "<td align='right' class=""forumRow"">" & 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
End Function

Function Kehucname(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Kehu where ID="& ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	Kehucname=""
	else
    Kehucname = rs("Cname")
	end if
    rs.Close
    Set rs = Nothing
End Function

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 CKehuText(ID,s) '显示关联联系人信息
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Kehu where ID="&ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	response.Write ""
	else
%>
    <div class="dayPlanTable" id="w<%=s%>" onMouseOut="display('none','m<%=s%>')">
     <table width="100%" border="0">
  <tr>
    <td width="50" valign="top">
	<%
	if rs("class")=1 then
	   response.Write "<img src=""../Images/Companies_3.png"" />"
	else
	   response.Write "<img src=""../Images/peploe_3.png"" />"
	end if
	%>
	</td>
    <td valign="top"><font style="font-size:18px; font-weight:bold;">
	<%if rs("class")=1 then%>
	  <%=rs("Company")%>
	<%else%>
	  <%=rs("Cname")%>
	<%end if%>
	</font>
	<div style="padding:5px 0px">
	<%if rs("class")=2 then%>
	   <%=rs("position")%> － <font color="#4579b9"><%=rs("Company")%></font>
	<%end if%>
	</div>
	</td>
  </tr>
  <tr>
  <td colspan="2"><hr /></td>
  </tr>
  <tr>
  <td colspan="2" align="center"><div style="width:95%; margin:0 auto; text-align:left">
  <%if rs("Telephone")<>"" then%>
  电话：<%=rs("Telephone")%><br>
  <%end if%>
  <%if rs("Mobile")<>"" then%>
  手机：<%=rs("Mobile")%><br>
  <%end if%>
  <%if rs("Fax")<>"" then%>
  传真：<%=rs("Fax")%><br>
  <%end if%>
  <%if rs("Email")<>"" then%>
  邮箱：<%=rs("Email")%><br>
  <%end if%>
  <%if rs("CQQ")<>"" then%>
  Q  Q ：<%=rs("CQQ")%><br>
  <%end if%>
  </div></td>
  </tr>
</table>
    </div>
<%
       response.Write "<font style=""font-weight:bold;"">"
       if rs("Telephone")<>"" then
	      response.Write rs("Telephone")
	   else
	      response.Write rs("Mobile")
	   end if
	   response.Write "</font>"
	end if
    rs.Close
    Set rs = Nothing
End Function
%>