<!--#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" src="../JavaScript/select_date.js"></script>
<%
'If InStr(session("GroupPurview"), "|2,") = 0 Then
    'response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    'response.End
'End If
Response.Buffer=True    
Response.ExpiresAbsolute =Now()-1    
Response.Expires=0    
Response.CacheControl="no-cache"    
Response.AddHeader "Pragma","No-Cache"
Dim Result,reResult
Result = request.QueryString("Result")
reResult = request.QueryString("reResult")
Dim ID,showid, mMemName, mRealName,kCompany,kabout,kDemo,SortName,SortID,SortPath
Dim kAddress, kZipCode, kTelephone, kFax, kCname,kMobile, kEmail, kHomepage,kCQQ, kWorking,AddTime,kUpdatime,Kclass,kposition,kParentID
Dim attribute1,attribute1_value,attribute1_value2,attribute1_value3
Dim KehuReID,rekehu
ID = request.QueryString("ID")
'初始tab
showid=request.QueryString("showid")
 response.Write "<script language='javascript' for='window' event='onload'>ShowTabs("&showid&");</script>"
Call MyKehuView()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
	<tr>
      <td class="forumRowHighlight" align="center">
	  <table width="100%" border="0">
  <tr>
    <td width="70" valign="top">
	<%
	if Kclass=1 then
	   response.Write "<img src=""../Images/Companies_1.png"" />"
	else
	   response.Write "<img src=""../Images/peploe_1.png"" />"
	end if
	%>
	</td>
    <td valign="top"><font style="font-size:18px; font-weight:bold;">
	<%if Kclass=1 then%>
	  <%=kCompany%>
	<%else%>
	  <%=kCname%>
	<%end if%>
	</font>
	<div style="padding:10px 0px">
	<%if Kclass=2 then%>
	   <%=kposition%> － <a href="?Result=Modify&ID=<%=kParentID%>&showid=0"><font color="#4579b9"><%=kCompany%></font></a><br />
	<%end if%>
	
	<font color="#FF6600"><%=SortName%></font>
	</div>
	
	</td>
  </tr>
</table>

	  </td>
	</tr>
	<tr>
      <td class="forumRowHighlight">
<script language="javascript">
var tID=0;
var rID=1;
function ShowTabs(ID){
  if(ID!=tID){
    TabTitle[tID].className="title5";
    TabTitle[ID].className="title6";
    Tabs[tID].style.display="none";
    Tabs[ID].style.display="";
    tID=ID;
  }
  if(ID==2 || ID==3 || ID==4)
    {
     document.getElementById("gback").style.display="none";
     document.getElementById("submitSaveEdit").style.display="none";  
    }
  else
    {
     document.getElementById("gback").style.display="";
     document.getElementById("submitSaveEdit").style.display="";
	 document.getElementById("showid").value=ID;
    }
}
//点击修改按钮跳转至对应的Tab 2012-1-6 add by qiJun zhang
function goview(){
    var showid=document.getElementById("showid").value;
	<%if Kclass=1 then%>
	window.location.href="My_Companies_KehuEdit.Asp?Result=Modify&ID=<%=ID%>&showid="+showid;
	<%else%>
	window.location.href="My_people_KehuEdit.Asp?Result=Modify&ID=<%=ID%>&showid="+showid;
	<%end if%>
}
//点击显示隐藏添加修改          2012-1-12 by qijun zhang
function Showre(){
    if(rID==1)
	   {
         document.getElementById("rekehuSaveEdit").style.display="";
	     document.getElementById("rekehu").style.display="";
		 rID=rID-1;
		} 
     else
	    {
         document.getElementById("rekehuSaveEdit").style.display="none";
	     document.getElementById("rekehu").style.display="none";
		 rID=rID+1;
		}
 }
function checkreedit(){
if (document.reform1.rekehu.value.replace(/^\s*/g,"")=="") {
    alert("请认真填写!事件可以保存日常工作中的点点滴滴。比如每一次电话，会议或者任何想法。");
    document.reform1.rekehu.focus();
    return false;
 }
}
</script>
	  <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr align="center">
            <td id="TabTitle" class="title6" onclick="ShowTabs(0)">基本信息</td>
           
            <td id="TabTitle" class="title5" onclick="ShowTabs(1)">合作意向</td>
            <td id="TabTitle" class="title5" onclick="ShowTabs(2)">业务机会(<font color="#FF0000"><%chances(ID)%></font>)</td>
			<td id="TabTitle" class="title5" onclick="ShowTabs(3)">事件(<font color="#FF0000"><%KHRe(ID)%></font>)</td> 
			<%if Kclass=1 then%>
			<td id="TabTitle" class="title5" onclick="ShowTabs(4)">联系人(<font color="#FF0000"><%cnum(ID)%></font>)</td>
            <%end if%>
			<td>&nbsp;</td>
        </tr>
</table>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" class="border"><tr class="tdbg"><td valign="top">
  <table width="100%" align="center" cellpadding="2" cellspacing="1">
  <tbody id="Tabs" style="display:">
  <tr>
      <td width="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
	
        <tr>
      <td align="right" class="forumRow">电 话：</td>
      <td class="forumRowHighlight"><%=kTelephone%></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">手机号码：</td>
      <td class="forumRowHighlight">
	  <%=kMobile%></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">传真号码：</td>
      <td class="forumRowHighlight"><%=kFax%></td>
    </tr>
	
	<tr>
      <td align="right" class="forumRow">电子信箱：</td>
      <td class="forumRowHighlight"><%=kEmail%></td>
    </tr>

	<tr>
      <td align="right" class="forumRow">地 址：</td>
      <td class="forumRowHighlight"><%=kAddress%></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">Q Q：</td>
      <td class="forumRowHighlight"><%=kCQQ%></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">邮政编码：</td>
      <td class="forumRowHighlight">
	  <%=kZipCode%>	 </td>
    </tr>
    <tr>
      <td align="right" class="forumRow">网 址：</td>
      <td class="forumRowHighlight"><a href="<%=kHomePage%>" target="_blank"><%=kHomePage%></a></td>
    </tr>
	
	
    
    <tr>
      <td align="right" class="forumRow">背景信息：</td>
      <td class="forumRowHighlight">
	    <%=kabout%></td>
    </tr>
  </tbody>
  
  <tbody id="Tabs" style="display:none">
    <tr>
      <td width="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">合作意向：</td>
      <td width="80%" class="forumRowHighlight">
	  <%
	  if kDemo<>"" then
	  else
	  response.Write("<font color=""#FF6600"">未录入或无</font>")
	  end if
	  %>
	  <%=kDemo%>	  </td>
    </tr>
  </tbody>
  <tbody id="Tabs" style="display:none">
    <tr>
      <td width="100%" class="forumRowHighlight" colspan="2">
	  <table border="0" align="center" cellpadding="0" cellspacing="0" width="98%" class="bordergj">
  <tr valign="top" bgcolor="#F8F8FA" >
    <td align="left" bgcolor="#D7E4F7">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25" align="left" width="150" bgcolor="#FFFFFF"> &nbsp; 
              <%
			        if Kclass=1 then
			            ch_kehuname=kCompany
			         else
			            ch_kehuname=kCname
			         end if
			  if mMemName=session("UserName") then
			  %>
                 <img src="../Images/add_1.png" /> <a href="../chances/My_chances_Edit.Asp?Result=Add&ch_kehuname=<%=ch_kehuname%>">添加机会</a>
              <%
			  else
			  %>
                   <img src="../Images/current.jpg" /> 机会列表
              <%
			  end if
			  %>
            </td>
              <td align="left">&nbsp;</td>
              <td width="50" align="center">&nbsp;</td>
            </tr>
          </table> </td>
  </tr>
</table>
      <form action="#" method="post" name="formDel">
 <%ChancesList(ID)%>
        </form>
	  </td>
    </tr>
  </tbody>
<tbody id="Tabs" style="display:none">
    <tr>
      <td colspan="2" class="forumRowHighlight">
	  <form action="?reAction=SaveEdit&Result=Modify&ID=<%=ID%>&showid=3" method="post" name="reform1" onSubmit="return checkreedit()">
	  <table border="0" align="center" cellpadding="0" cellspacing="0" width="98%" class="bordergj">
  <tr valign="top" bgcolor="#F8F8FA" >
    <td align="left" bgcolor="#D7E4F7">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25" align="left" width="150" bgcolor="#FFFFFF"> &nbsp; 
              <%
			  if mMemName=session("UserName") then
			  %>
                <img src="../Images/add_1.png" /> <a href="javascript:Showre()">添加修改当天事件</a>
              <%
			  else
			  %>
                 <img src="../Images/current.jpg" /> 事件列表
              <%
			  end if
			  %>
              </td>
              <td align="left">&nbsp;</td>
              <td width="50" align="center"><input name="rekehuSaveEdit" type="submit" id="rekehuSaveEdit" value="保存" style="display:none"></td>
            </tr>
          </table> </td>
  </tr>
  <tr bgcolor="#F8F8FA" >
    <td align="left">&nbsp;<textarea name="rekehu" rows="8" style="width:99%; margin-bottom:8px;display:none"><%=rekehu%></textarea></td>
  </tr>
</table>
      </form>
	    <form action="#" method="post" name="formDel">
  <% KehuReList(ID) %>
        </form>
  
	  </td>
      </tr>
  </tbody>
  <tbody id="Tabs" style="display:none">
  <tr>
      <td width="100%" class="forumRowHighlight"></td>
    </tr>
<tr>
      <td class="forumRowHighlight" colspan="2">
	  
	 <table border="0" align="center" cellpadding="0" cellspacing="0" width="98%" class="bordergj">
  <tr valign="top" bgcolor="#F8F8FA" >
    <td align="left" bgcolor="#D7E4F7">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25" align="left" width="150" bgcolor="#FFFFFF"> &nbsp; 
              <%
			  if mMemName=session("UserName") then
			  %>
                <img src="../Images/add_1.png" /> <a href="My_people_KehuEdit.Asp?Result=Add&showid=0&Company=<%=kCompany%>">添加联系人</a>
              <%
			  else
			  %>
              <img src="../Images/current.jpg" /> 联系人列表
              <%
			  end if
			  %>
              </td>
              <td align="left">&nbsp;</td>
              <td width="50" align="center">&nbsp;</td>
            </tr>
          </table> </td>
  </tr>
  
  
  <tr bgcolor="#F8F8FA" >
    <td align="center">
	<% peopleList(ID)%> 
	
	<table width="100%" border="0">
  <tr>
    <td></td>
    <td>&nbsp;</td>
  </tr>
</table>
</td>
  </tr>
</table>
	 </td>
    </tr>
  </tbody>
  </table>
</td>
</tr>
</table>
	  </td>
    </tr>
    	
    <tr>
      <td class="forumRowHighlight" align="center"><input type="hidden" id="showid" value="0" />
      <%if mMemName=session("UserName") then%>
      <input name="submitSaveEdit" type="button" id="submitSaveEdit" value="修改信息" onClick="goview()" style="display:">   <%end if%>
       <input type="button" id="gback" onclick="history.back(-1)" value="返回上一页" style="display:"></td>
    </tr>
</table>
<%

Sub MyKehuView()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
	reAction=request.QueryString("reAction")
        If Result = "Modify" Then
            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 "<script language='javascript'>alert('参数错误！');history.back(-1);</script>"
			response.End
			else
            mMemName = rs("MemName")
            mRealName = rs("RealName")
            kCompany = rs("Company")
            kabout = rs("about")
            kDemo = rs("Demo")
			kCname=rs("Cname")
			kposition=rs("position")
            kAddress = rs("Address")
            kZipCode = rs("ZipCode")
            kTelephone = rs("Telephone")
            kFax = rs("Fax")
            kMobile = rs("Mobile")
            kEmail = rs("Email")
            kHomepage = rs("Homepage")
			KCQQ=rs("CQQ")
			Kclass=rs("class")
			SortName = SortText(rs("SortID"))
            SortID = rs("SortID")
            SortPath = rs("SortPath")
			kParentID=rs("ParentID")
			'联系人（姓名、手机、QQ、EMAIL)
			attribute1=rs("attribute1")
            attribute1_value=rs("attribute1_value")
			attribute1_value2=rs("attribute1_value2")
			attribute1_value3=rs("attribute1_value3")
			end if
            rs.Close
            Set rs = Nothing
			'--------------------保存跟进及读取跟进记录开始------------------------------
			if reAction="SaveEdit" then '保存跟进记录
			   Set rs = server.CreateObject("adodb.recordset")
			   sql = "select * from Zqj_KehuRe where KehuId="&ID&" and Retime=#"&date()&"#"
               rs.Open sql, conn, 1, 3
			   if rs.bof and rs.eof then
			      rs.addnew
				  rs("MemName")=mMemName
				  rs("RealName")=mRealName
				  rs("Re")=Request.Form("rekehu")
				  rs("Retime")=date()
				  rs("KehuId")=ID
				  if Kclass=1 then
				     rs("KehuParentID")=0
				  else
				     rs("KehuParentID")=kParentID
				  end if
				  rs("ViewFlag")=1
			      
			   else
			      rs("Re")=Request.Form("rekehu")
				  rs("RealName")=mRealName
			   end if
			   rs.update
			   rs.close
			   set rs=nothing
			   response.Redirect("?Result=Modify&ID="&ID&"&showid="&showid)
			else '读取当天跟进记录
			   Set rs = server.CreateObject("adodb.recordset")
			   sql = "select * from Zqj_KehuRe where KehuId="&ID&" and Retime=#"&date()&"#"
               rs.Open sql, conn, 1, 1
			   if rs.bof and rs.eof then
			   else
			       rekehu=rs("Re")
				   KehuReID=rs("ID")
			   end if
			end if
			'-------------------保存跟进及读取跟进记录结束------------------------------
        End If
End Sub


Function SortText(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_KehuSort where ID="& ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	SortText="未分类"
	else
    SortText = rs("SortName")
	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 KehuReList(KehuID)
    Dim idCount
    Dim pages
    pages = 20
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 2
    Dim pagenmax
    Dim pagenmin
    Dim datafrom
    datafrom = "Zqj_KehuRe"
    Dim datawhere
	    if Kclass=1 then
		   datawhere = "where (KehuId="&KehuID&" or KehuParentID="&KehuID&") and ViewFlag "
		else
	       datawhere = "where KehuId="&KehuID&" and ViewFlag "
		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 & "?Result=Modify&ID="&KehuID&"&showid=3&"
    Else
        Myself = Left(PATH_INFO & "?" & QUERY_STRING, InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") -1)
    End If
    Dim taxis
    taxis = "order by Retime 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="50" height="25" align="center"><img src="../Images/bag_2.png" /></td>
              <td>
			  <%
			  if rs("KehuParentID")<>0 then
			  response.Write "<a href=""?Result=Modify&ID="&rs("KehuId")&"&showid=0""><font color=""#4579b9"">"&Kehucname(rs("KehuId"))&"</font></a><br />"
			  end if
			  %>
			  
			  		  
			  <%=rs("RealName")%> 添加 于 <font class="gjtime"><%=rs("Retime")%></font></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"><%=rs("Re")%></div>
	  </td>
  </tr>
</table>

<%
noli=noli+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 KHRe(ID)
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	sql = "select * from Zqj_KehuRe where ViewFlag and KehuId="&ID&" or KehuParentID="&ID
    rs.Open sql,conn,1,1
    max=rs.recordcount
	Response.Write max
    rs.Close
    Set rs = Nothing
End Function

Function chances(ID) '业务机会条数
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	sql = "select * from Zqj_chances where ch_kehuID="&ID
    rs.Open sql,conn,1,1
    chancesnum=rs.recordcount
	Response.Write chancesnum
    rs.Close
    Set rs = Nothing
End Function

Function cnum(ID) '联系人数
    Dim rs,sql
    Set rs = server.CreateObject("adodb.recordset")
	sql = "select * from Zqj_Kehu where class=2 and ParentID="&ID
	
    rs.Open sql,conn,1,1
    maxnum=rs.recordcount
	Response.Write maxnum
    rs.Close
    Set rs = Nothing
End Function

Function peopleList(ID) '联系人列表
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from Zqj_Kehu where class=2 and ParentID="&ID&" order by AddTime desc"
    rs.Open sql,conn,1,1
    if rs.eof and rs.bof then
		response.Write "<font color=red></li>"
	else
	While(Not rs.Eof)
	  AutoLink = ""
	Response.Write "<div class=""peoplelist""><img src=""../Images/peploe_2.png"" /> " & vbCrLf
	Response.Write " <a href=""My_team_KehuView.Asp?Result=Modify&ID="&rs("ID")&"&showid=0""><font class=""peoplelist_f14"">"&rs("Cname")&"</font></a>" & vbCrLf
	Response.Write "<font color=""#999999"">"&rs("position")&"</font>" & vbCrLf
	Response.Write "</div>" & vbCrLf
	 rs.MoveNext
	 Wend
	end if
    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 ChancesList(KehuID)
    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
	       datawhere = "where ch_kehuID="&KehuID
    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 & "?Result=Modify&ID="&KehuID&"&showid=2&"
    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="../chances/My_team_chancesView.Asp?Result=Modify&ID=<%=rs("ID")%>"><font style="font-size:14px; font-weight:400; color:#ff6600"><%=rs("ch_name")%></font></a>
			   添加 于 <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
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
%>