<!--#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>
<%
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,ch_name,ch_kehuname,ch_kehuID,ch_amount,ch_MemName,ch_RealName,ch_memo,ch_addtime,ch_modytime,ch_status
Dim KehuReID,rekehu,set_state
ID = request.QueryString("ID")
set_state=trim(request.QueryString("set_state"))
   
Call MychancesView()
%>
<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">
	<img src="../Images/chances_1.png" />
	</td>
    <td valign="top"><font style="font-size:14px; font-weight:600; color:#ff6600">
	<a href="../Kehu/My_KehuView.Asp?Result=Modify&showid=0&ID=<%=ch_kehuID%>"><font color="#4579b9"><%=ch_kehuname%></font></a>
	<%if ch_kehuname<>"" then response.Write "<font color=""#4579b9"">：</font>" end if%>
	<%=ch_name%>
	</font>
	<div style="padding:10px 0px;color:#999999; font-size:14px">
	<%if ch_amount=0 then
	      response.Write "没有设置金额. "
	  else
	      response.Write "￥"&ch_amount
	  end if	  
	%>
	</div>
	
	<div class="change_state_container">
	     <%
			Select Case ch_status
                Case "C"
				     response.Write "<span class=""span_C"">C</span>"
				     response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=B"">B</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=A"">A</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=O"">O</a>"
				Case "B"
				     response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=C"">C</a>"
				     response.Write "<span class=""span_B"">B</span>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=A"">A</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=O"">O</a>"
				Case "A"
				     response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=C"">C</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=B"">B</a>"
				     response.Write "<span class=""span_A"">A</span>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=O"">O</a>"
				Case "O"
				     response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=C"">C</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=B"">B</a>"
					 response.Write "<a href=""?Result=Modify&ID="&ID&"&set_state=A"">A</a>"
				     response.Write "<span class=""span_O"">O</span>"
					 
				Case else
			  End Select
		%>  
	</div>
	</td>
	<td width="100" valign="top">
	<a href="My_chances_Edit.Asp?Result=Modify&ID=<%=ID%>"><font color="#4579b9">编辑机会</font></a>|<a href="../DelContent.Asp?Result=My_chances&fromID=<%=ID%>" onClick="return confirm('您确定要删除这个机会吗？\n所有与这个机会相关的事件， 文件都将被删除。\n删除后不能再恢复。')" title="删除这个机会"><img src="../Images/del_1.png" border="0"/></a> </td>
  </tr>
</table>

	  </td>
      <td rowspan="2" width="250" bgcolor="#E5E5E5" valign="top">
<script language="javascript">
//点击显示添加任务        2012-3-7 by qijun zhang
function Show_tasksadd(ID){
	if (ID==1)
	{
         document.getElementById("addtasks").style.display="";
		 document.getElementById("bt_tasksadd").style.display="none";
	}
	else
	{
		document.getElementById("addtasks").style.display="none";
		document.getElementById("bt_tasksadd").style.display="";
	}
 }
function checktasksadd(){
if (document.taskadd.TDemo.value.replace(/^\s*/g,"")=="") {
    alert("工作或任务不能为空,请认真填写!");
    document.taskadd.TDemo.focus();
    return false;
 }
}
function show_d241()
{
	if (document.getElementById("Task_frame").value=="calendar"){
	document.getElementById("d241").style.display="";
	}
	else
	{
		document.getElementById("d241").style.display="none";
		}
	
}
</script>
 <div style="padding-bottom:10px" id="bt_tasksadd"><a href="javascript:Show_tasksadd(1)"><img src="../Images/tasks_add.png" /></a></div>
      <form action="My_chances_Taskseadd.asp?Result=Modify&ID=<%=ID%>" method="post" name="taskadd" onSubmit="return checktasksadd()">
      <div style="border-width:5px; border-color:#CACFD5; border-style:solid; margin:5px; float:left; width:98%;display:none;" id="addtasks">
      <table width="100%" border="0" align="center" cellspacing="5" style="background-color:#F0F5F8; ">
  <tr>
    <td><font style="font-weight:bold;font-size:14px">添加一个任务</font>
    <input name="TChancesID" type="hidden" value="<%=ID%>">
    </td>
  </tr>
  <tr>
    <td><textarea name="TDemo" rows="2" style="width:100%"></textarea></td>
  </tr>
  <tr>
    <td class="fontdan">到期时间?</td>
  </tr>
  <tr>
    <td><select name="Task_frame" onchange="javascript:show_d241()">
     <option value="today" <%if Task_frame="today" then response.Write"selected"%>>今天</option>
     <option value="tomorrow" <%if Task_frame="tomorrow" then response.Write"selected"%>>明天</option>
     <option value="aftertomorrow" <%if Task_frame="aftertomorrow" then response.Write"selected"%>>后天</option>
     <option value="this_week" <%if Task_frame="this_week" then response.Write"selected"%>>本周</option>
     <option value="next_week" <%if Task_frame="next_week" then response.Write"selected"%>>下周</option>
     <option value="later" <%if Task_frame="later" then response.Write"selected"%>>以后</option>
     <option value="calendar" <%if Task_frame="calendar" then response.Write"selected"%>>设置时间 ...</option>
	   
	 </select>
     <input name="d241" type="text" class="Wdate" id="d241" style="width:150px;
	 <%if Task_frame="calendar" then 
	      response.Write " display:"
	   else
	      response.Write " display:none"
	   end if	  
	 %>
     " onfocus="WdatePicker({skin:'blueFresh',dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<%=TEtime%>"/>
     </td>
  </tr>
  <tr>
    <td class="fontdan">选择一个分类</td>
  </tr>
  <tr><td>
  <select name="TasksSort">
     <option value='0'>无</option>
	   <% call SelectTasksSort() %>
	 </select>
  </td></tr>
  <tr>
    <td><hr />
</td>
  </tr>
  <tr>
    <td>&nbsp;<input name="submitSavetasks" type="submit" id="submitSavetasks" value="添加这个任务"> <font class="fontdan">或</font> <a href="javascript:Show_tasksadd(0)">取消</a></td>
  </tr>
</table>
      </div>
      </form>
      <table width="96%" border="0" align="center" cellspacing="5" style="background-color:#F0F5F8; ">
  <tr>
    <td>
    <% Tasks_overdue(ID)%>
	<% Tasks_today(ID) %>
    <% Tasks_tomorrow(ID)%>
    <% Tasks_aftertomorrow(ID)%>
    <% Tasks_this_week(ID)%>
    <% Tasks_next_week(ID)%>
    <% Tasks_later(ID)%>
    
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
      </td>
	</tr>
	<tr>
      <td class="forumRowHighlight">
  <script language="javascript">
var rID=1;

//点击显示隐藏添加修改          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="1" class="border"><tr class="tdbg"><td valign="top">
    <table width="100%" align="center" cellpadding="2" cellspacing="1">
  <tbody id="Tabs">
    <tr>
      <td colspan="2" class="forumRowHighlight">
        <form action="?reAction=SaveEdit&Result=Modify&ID=<%=ID%>" 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="center" width="150" bgcolor="#FFFFFF"><img src="../Images/add_1.png" /> <a href="javascript:Showre()">添加修改当天事件</a></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>
      
      </table>
  </td>
  </tr>
  </table>
      </td>
    </tr>
</table>


<%

Sub MychancesView()
    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_chances where ch_MemName='"&session("UserName")&"' and ID="& ID
            rs.Open sql,conn,1,3
			if rs.bof and rs.eof then
			   response.Write "<script language='javascript'>alert('参数错误！');history.back(-1);</script>"
			   response.End
			else
			   if set_state<>"" and (set_state="C" or set_state="B" or set_state="A" or set_state="O") then
			      rs("ch_status")=set_state
			   end if
			ch_name=rs("ch_name")
			ch_kehuname=rs("ch_kehuname")
			ch_kehuID=rs("ch_kehuID")
			ch_amount=rs("ch_amount")
			ch_MemName=rs("ch_MemName")
			ch_RealName=rs("ch_RealName")
			ch_memo=rs("ch_memo")
			ch_addtime=rs("ch_addtime")
			ch_modytime=rs("ch_modytime")
			ch_status=rs("ch_status")
            
			end if
			rs.update
            rs.Close
            Set rs = Nothing
			'--------------------保存跟进及读取跟进记录开始------------------------------
			if reAction="SaveEdit" then '保存跟进记录
			   Set rs = server.CreateObject("adodb.recordset")
			   sql = "select * from Zqj_KehuRe where chancesID="&ID&" and Retime=#"&date()&"#"
               rs.Open sql, conn, 1, 3
			   if rs.bof and rs.eof then
			      rs.addnew
				  rs("MemName")=ch_MemName
				  rs("RealName")=ch_RealName
				  rs("Re")=Request.Form("rekehu")
				  rs("Retime")=date()
				  rs("KehuId")=ch_kehuID
				  rs("KehuParentID")=0
				  rs("chancesID")=ID
				  rs("ViewFlag")=1
			      
			   else
			      rs("Re")=Request.Form("rekehu")
				  rs("RealName")=ch_RealName
			   end if
			   rs.update
			   rs.close
			   set rs=nothing
			   response.Redirect("?Result=Modify&ID="&ID)
			else '读取当天跟进记录
			   Set rs = server.CreateObject("adodb.recordset")
			   sql = "select * from Zqj_KehuRe where chancesID="&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 KehuReList(chancesID)
    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 chancesID="&chancesID&" 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="&chancesID&"&"
    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=""../Kehu/My_KehuView.Asp?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 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

Sub SelectTasksSort() '任务分类
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from Zqj_TasksSort where ViewFlag order by ID asc"
    rs.Open sql, conn, 1, 1
    If rs.bof And rs.EOF Then
        response.Write("未设置")
    End If
    While Not rs.EOF
        response.Write("<option value='"&rs("ID")&"'")
		 if rs("ID")=TasksSortID then
		 response.Write " selected"
		 end if
        response.Write(">"&rs("SortName")&"</option>")
        rs.movenext
    Wend
    rs.Close
    Set rs = Nothing
End Sub
%>
<!--#include file="My_chances_Tasksshow.asp" -->