<!--#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 type="text/javascript">
function checktasksedit(){
if (document.edittasks.TDemo.value.replace(/^\s*/g,"")=="") {
    alert("工作或任务不能为空,请认真填写!");
    document.edittasks.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";
		}
	
}
function changePos(thisID){
		var st=document.getElementById(thisID);
		if(document.body.clientWidth+document.body.scrollLeft-st.offsetLeft>=st.clientWidth){
			st.style.left=document.body.scrollLeft+250+'px';
			//st.style.left=st.offsetLeft+50+'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>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<%
Dim Result,TDemo,TEtime,TasksSortID,TKehuID,TChancesID,Task_frame,TCompleted,SelectID,s
Result = request.QueryString("Result")
SelectID=request.QueryString("SelectID")
s=1
    Call TasksEdit()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="edittasks" method="post" action="?Action=SaveEdit&Result=<%=Result%>" onSubmit="return checktasksedit()">
    <tr>
      <td colspan="2" align="left" class="forumRowHighlight">
      <% ShowSelect_chances(SelectID) %>
      </td>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRowHighlight">请输入工作或任务内容
      
      <input name="TChancesID" type="hidden" value="<%=SelectID%>">
      </td>
      <td width="80%" class="forumRowHighlight"><textarea name="TDemo" rows="8" style="width:80%; margin-bottom:8px"><%=TDemo%></textarea> </td>
    </tr>
    <tr>
      <td align="right" class="forumRowHighlight">到期时间?</td>
      <td class="forumRowHighlight">
	 <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 align="right" class="forumRowHighlight">选择一个分类</td>
      <td class="forumRowHighlight"> 
     <select name="TasksSort">
     <option value='0'>无</option>
	   <% call SelectTasksSort() %>
	 </select>
		
      </td>
    </tr>    
    <tr>
      <td align="right" class="forumRowHighlight"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="确认保存"> <input type="button" value="重新选择" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
Sub TasksEdit()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
	    Taskframe=trim(request.Form("Task_frame"))
		select case Taskframe
		      case "today"
			       TEtime=date()&" 23:59:59"
			  case "tomorrow"
			       TEtime=DateAdd("d",+1,Date())&" 23:59:59"
			  case "aftertomorrow"
			       TEtime=DateAdd("d",+2,Date())&" 23:59:59"
			  case "this_week"
			       TEtime=dateadd("d",date,7-weekday(date))&" 23:59:59"
			  case "next_week"
			       TEtime=DateAdd("d",+7,dateadd("d",date,7-weekday(date)))&" 23:59:59"
			  case "later"
			  case "calendar"
			       TEtime=trim(Request.Form("d241"))
			  case else
		end select	  
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Add" Then
		    sql = "select * from Zqj_Tasks"
            rs.Open sql, conn, 1, 3
            
		'判断及循环所选联系人--------------------------------
		   TChancesID=request.Form("TChancesID")
		   if not(IsNull(trim(TChancesID))) then
	             TChancesID=Split(TChancesID,",")
	          For i = 0 To UBound(TChancesID)
			      rs.addnew
			      rs("Demo")=Request.Form("TDemo")
			      rs("TasksSortID")=Request.Form("TasksSort")
			      rs("MemName")=session("UserName")
			      rs("TChancesID")=trim(TChancesID(i))
			      rs("TKehuID")=0
			      rs("Etime")=TEtime
			      rs("Task_frame")=trim(request.Form("Task_frame"))
			      rs.update
			  next
		   end if
		 '------------------------------------------------
            rs.Close
            Set rs = Nothing
            response.Write "<script language='javascript'>alert('设置成功！');location.replace('Tasks_todo_list.asp');</script>"
        End If
        If Result = "Modify" Then
		    '修改
        End If
        
    Else
        If Result = "Modify" Then
            '其它
        End If
    End If
End Sub


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

Function ShowSelect_chances(formSelectID) '显示已选机会列表
  if formSelectID<>"" then
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
       sql = "select * from Zqj_chances where ch_MemName='"&session("UserName")&"' and ID in ("&formSelectID&")"
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write "<div class=""dashed_line""><font color=""#FF0000"">已选择的业务机会列表</font>&nbsp;&nbsp;(<a href=""javascript:history.go(-1)"">重新选择</a>)</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"
    While Not rs.EOF
		Response.Write "<tr onMouseOver=""this.style.backgroundColor='#FFF8DC'"" onMouseOut=""this.style.backgroundColor=''""><td id="""&s&""">"
		response.Write " &nbsp;"&rs("ch_name")&""
		
%>
<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 " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
  else
	response.Write "<script language='JavaScript'>alert('未选择任何机会，无法继续下一步操作!');" & "history.back()" & "</script>"
    response.End
  end if	
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
%>