<!--#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"), "|7,") = 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
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 KehuView()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  
    <tr>
      <th height="22" sytle="line-height:150%">【<%=kCompany%>-详细信息】</th>
    </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==4)
    {
     document.getElementById("gback").style.display="none"; 
    }
  else
    {
     document.getElementById("gback").style.display="";
	 document.getElementById("showid").value=ID;
    }
}
//点击修改按钮跳转至对应的Tab 2012-1-6 add by qiJun zhang
function goview(){
    var showid=document.getElementById("showid").value;
	window.location.href="KehuEdit.Asp?Result=Modify&ID=<%=ID%>&showid="+showid;
}
</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)">联系人<%
			If attribute1 <>"" Then
	           attribute1_1 = Split(attribute1, "§§§")
	           cnum=UBound(attribute1_1)+1
	        else
	           cnum=0
	       end if
			%>(<font color="#FF0000"><%=cnum%></font>)
			</td>
            <td id="TabTitle" class="title5" onclick="ShowTabs(2)">合作意向</td>
            <td id="TabTitle" class="title5" onclick="ShowTabs(3)">其 它</td>
			<td id="TabTitle" class="title5" onclick="ShowTabs(4)">跟进(<font color="#FF0000"><%KHRe(ID)%></font>)</td>
            <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"><%=genjinText(session("UserName"))%></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">公司名称：</td>
      <td class="forumRowHighlight"><%=kCompany%>
	  [<font color="#FF6600"><%=SortName%></font>]	  </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"><%=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">邮政编码：</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"><%=kCname%></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">
	  <%=kMobile%></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"></td>
    </tr>
<tr>
      <td align="right" class="forumRow" valign="top">联系人：</td>
      <td class="forumRowHighlight">
	  <%
	  If attribute1 <>"" Then
         attribute1_1 = Split(attribute1, "§§§")
         attribute1_value_1 = Split(attribute1_value, "§§§")
		 attribute1_value_2 = Split(attribute1_value2, "§§§")
		 attribute1_value_3 = Split(attribute1_value3, "§§§")
         For i = 0 To UBound(attribute1_1)
      %>
                    <font color="#0033CC">姓名：</font><%=attribute1_1(i)%>  
					<font color="#0033CC">手机：</font><%=attribute1_value_1(i)%> 
					<font color="#0033CC">QQ：</font><%=attribute1_value_2(i)%> 
					<font color="#0033CC">E-mail：</font><%=attribute1_value_3(i)%><br />
      <%
         Next
	   else
	   response.Write("<font color=""#FF6600""> 无</font>")
	   
      End If
     %>	  </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="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
  </tbody>
<tbody id="Tabs" style="display:none">
    <tr>
      <td colspan="2" class="forumRowHighlight">
	  
	    <form action="../DelContent.Asp?Result=KehuRe&fromID=<%=ID%>" method="post" name="formDel">
  <% KehuReList(ID) %>
        </form>
  
	  </td>
      </tr>
  </tbody>
  </table>
</td>
</tr>
</table>
	  </td>
    </tr>
    	
    <tr>
      <td class="forumRowHighlight" align="center"><input type="hidden" id="showid" value="0" />
       <input type="button" id="gback" onclick="history.back(-1)" value="返回上一页" style="display:"></td>
    </tr>
  
  
</table>


<%

Sub KehuView()
    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")
            kAddress = rs("Address")
            kZipCode = rs("ZipCode")
            kTelephone = rs("Telephone")
            kFax = rs("Fax")
            kMobile = rs("Mobile")
            kEmail = rs("Email")
            kHomepage = rs("Homepage")
			KCQQ=rs("CQQ")
			SortName = SortText(rs("SortID"))
            SortID = rs("SortID")
            SortPath = rs("SortPath")
			'联系人（姓名、手机、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
				  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)

'End Function
Function KehuReList(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_KehuRe"
    Dim datawhere
	    datawhere = "where KehuId="&KehuID&" and ViewFlag "
    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=4&"
    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="100" height="25" align="center"><strong><%=rs("RealName")%></strong></td>
              <td><font class="gjtime"><%=rs("Retime")%></font></td>
              <td width="50" align="center">&nbsp;</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""> </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"">无跟进记录...</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
    rs.Open sql,conn,1,1
    max=rs.recordcount
	Response.Write max
    rs.Close
    Set rs = Nothing
End Function
%>