<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<script type="text/javascript">		
	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-0)+'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-0) +'px': (st.offsetTop - st.clientHeight)+'px';
		}
	}
    function display(display,indexID){
           document.getElementById(indexID).style.display=display;
}
function Show_bt(btID,rid){
		 document.getElementById(btID).style.display="";
		 document.getElementById(rid).style.width="250px";
		 //document.getElementById(rid).style.height="30px";
 }
function Ushow_bt(btID,rid)
{
	//document.getElementById(btID).style.display="none";
	document.getElementById(rid).style.width="";
	document.getElementById(rid).style.height="";
}
function checkkhreedit(checkid,forms)
{
  if (document.getElementById(checkid).value.replace(/^\s*/g,"")==""){
	   alert("事件不能为空,请认真填写!");
	   document.getElementById(checkid).focus();
	   return false;
	   }
   
}
</script>
<%
Dim Result,TDemo,TEtime,TasksSortID,TKehuID,TChancesID,Task_frame,TSortID,datafrom,s
Result = request.QueryString("Result")
ID = request.QueryString("ID")
TSortID=trim(request.QueryString("TSortID"))
datafrom="Zqj_Tasks"
s=1

%>
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">

    <tr>
      <td class="forumRowHighlight"><img src="../Images/img.gif" width="20" height="20">
      <font style=" font-size:16px;">待办事项</font><br><br>
      <font color="#0000FF">分类为</font>
      <select name="TasksSort" onChange="window.location='Tasks_todo_list.asp?TSortID=' + this.value">
      <option value="">所有</option>
      <% call SelectTasksSort() %>
   </select>
        <% Tasks_overdue()%>
        <% Tasks_today() %>
        <% Tasks_tomorrow() %>
        <% Tasks_aftertomorrow()%>
        <% Tasks_this_week()%>
        <% Tasks_next_week()%>
        <% Tasks_later()%>
      </td>
    </tr>
    

</table>
</body>
</html>
<%
Function Tasks_overdue() '过期
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
       sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TasksSortID="&TSortID&" and Completed=false and Etime is not null and DATEDIFF('s',Etime,'"&now()&"')>0 order by ID desc"
	else
	   sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and DATEDIFF('s',Etime,'"&now()&"')>0 order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write "<div class=""dashed_line""><font color=""#FF0000"">已过期</font></div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"" >"
    While Not rs.EOF
		Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
		response.Write "</td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_today() '今天

    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TasksSortID="&TSortID&" and Completed=false and Etime is not null and DATEDIFF('d',Etime,'"&date()&"')=0 and DATEDIFF('s',Etime,'"&now()&"')<0 order by ID desc"
	else
	    sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and DATEDIFF('d',Etime,'"&date()&"')=0 and DATEDIFF('s',Etime,'"&now()&"')<0 order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write " <div class=""dashed_line"">今日</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"
    While Not rs.EOF
	    Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc&" "
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	    response.Write " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_tomorrow() '明天
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TasksSortID="&TSortID&" and Completed=false and Etime is not null and DATEDIFF('d',Etime,'"&date()+1&"')=0 order by ID desc"
	else
	   sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and DATEDIFF('d',Etime,'"&date()+1&"')=0 order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write "<div class=""dashed_line"">明日</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"
    While Not rs.EOF
	    Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		 response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		 response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	    response.Write " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_aftertomorrow() '后天
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
         sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TasksSortID="&TSortID&" and Etime is not null and DATEDIFF('d',Etime,'"&date()+2&"')=0 order by ID desc"
	else
	    sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and DATEDIFF('d',Etime,'"&date()+2&"')=0 order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write " <div class=""dashed_line"">后天</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"
    While Not rs.EOF
	    Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		 response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		 response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	    response.Write " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
	
End Function

Function Tasks_this_week() '本周
    n1t=date()+3 '大后天
	n2t=dateadd("d",date+1,7-weekday(date)) '本周六
	if n1t<=n2t then
	   Dim rs, sql
       Set rs = server.CreateObject("adodb.recordset")
	   if TSortID<>"" and IsNumeric(TSortID) then
          sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TasksSortID="&TSortID&" and Etime is not null and Etime between #"&n1t&"# and #"&n2t&"# order by ID desc"
	   else
	      sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and Etime between #"&n1t&"# and #"&n2t&"# order by ID desc"
	   end if
       rs.Open sql, conn, 1, 1
       If not(rs.bof And rs.EOF) Then
          response.Write "<div class=""dashed_line"">本周</div>"
	      response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"	
         While Not rs.EOF
	      Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		  delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		  response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		   response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		   response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	      response.Write " </td></tr>"
		  s=s+1
          rs.movenext
        Wend
	      response.Write "</table>"
	   End If
          rs.Close
       Set rs = Nothing
	end if
End Function

Function Tasks_next_week() '下周
    n1t=date()+3 '大后天
	nt=dateadd("d",date,8-weekday(date)) '周日
	n2t=DateAdd("d",+8,dateadd("d",date,7-weekday(date))) '下周六
	 if n1t<=nt then
	    n1t=nt
	 else
	    n1t=n1t
	 end if
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TasksSortID="&TSortID&" and Etime is not null and Etime between #"&n1t&"# and #"&n2t&"# order by ID desc"
	else
	    sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is not null and Etime between #"&n1t&"# and #"&n2t&"# order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
    response.Write "<div class=""dashed_line"">下周</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"	
    While Not rs.EOF
	    Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		 response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		 response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	    response.Write " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_later() '以后
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TSortID<>"" and IsNumeric(TSortID) then
	   sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TasksSortID="&TSortID&" and Etime is null order by ID desc"
	else
       sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and Etime is null order by ID desc"
	end if
    rs.Open sql, conn, 1, 1
    If not(rs.bof And rs.EOF) Then
	response.Write "<div class=""dashed_line"">以后</div>"
	response.Write "<table width=""100%"" border=""0"" bgcolor='#F0F8FF' cellpadding=""2"">"
    While Not rs.EOF
	    Response.Write "<tr onMouseOver=""this.style.backgroundColor='#DEB887'"" onMouseOut=""this.style.backgroundColor=''""><td>"
		delc="<a href=""../DelContent.Asp?Result=Tasks&fromID="&rs("ID")&""" onClick=""return confirm('这个任务未完成，您确定要删除吗？相关的跟进记录也将一同被删除\n删除后不能再恢复。')"" title=""删除""><img src=""../Images/del_1.png"" width=""13"" height=""12""></a>"
		response.Write TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
		 response.Write " </td><td align=""center"" valign=""bottom"" width=""80"">"
		 response.Write "<a href='Tasks_do.Asp?id="&rs("ID")&"&LX="&datafrom&"&Operation=up&TSortID="&TSortID&"' title='完成'><img src=""../Images/resource_go.gif"" width=""15"" height=""13""></a> <a href=""Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&""" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> "&delc
		   'call Formkhre(s,rs("TKehuID"),rs("TChancesID"),rs("ID"))
	    response.Write " </td></tr>"
		s=s+1
        rs.movenext
    Wend
	response.Write "</table>"
	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("未设置")
    else
    While Not rs.EOF
	
        response.Write("<option value='"&rs("ID")&"'")
		 if TSortID<>"" and IsNumeric(TSortID) then
		    if int(TSortID)=rs("ID") then
		           response.Write " selected"
		    end if
		 end if
        response.Write(">"&rs("SortName")&"</option>")
        rs.movenext
    Wend
	End If
    rs.Close
    Set rs = Nothing
End Sub

Function TasksSortText(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_TasksSort where ID="&ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	else
	    TasksSortText = "<span style="" padding:0px 5px;height:20px; background-color:"&rs("T_color")&"; text-align:center; color:#FFFFFF;"">"&rs("SortName")&"</span>"	
	end if
    rs.Close
    Set rs = Nothing
End Function



Function Formkhre(s,khID,TChancesID,Tasksid) 's,表单控件结尾标识;khID联系人ID,Tasksid任务ID
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_KehuRe where TasksID="&Tasksid
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	   Re = ""
	else
	   Re=rs("Re")
	   ReId=rs("ID")
	end if
    rs.Close
    Set rs = Nothing
%>
<form action="Tasks_do.asp?Operation=modiy&s=<%=s%>" method="post" name="form<%=s%>" onSubmit="return checkkhreedit('ReKehu<%=s%>','form<%=s%>')">
<!--事件-->
  <input name="ReKehu<%=s%>" type="text" id="ReKehu<%=s%>" onFocus="javascript:Show_bt('reSaveEdit<%=s%>','ReKehu<%=s%>')" onBlur="javascript:Ushow_bt('reSaveEdit<%=s%>','ReKehu<%=s%>')" value="<%=Re%>">
<!--客户ID-->
  <input name="ReKehuID<%=s%>" type="hidden" id="ReKehuID<%=s%>" value="<%=khID%>" >
<!--机会ID-->
  <input name="TChancesID<%=s%>" type="hidden" id="TChancesID<%=s%>" value="<%=TChancesID%>" >
<!--事件记录表ID-->
  <input name="ReID<%=s%>" type="hidden" id="ReID<%=s%>" value="<%=ReId%>" >
<!--任务ID-->
  <input name="Tasksid<%=s%>" type="hidden" id="Tasksid<%=s%>" value="<%=Tasksid%>" >
<input name="reSaveEdit<%=s%>" type="submit" id="reSaveEdit<%=s%>" value="保存" style="display:none"></form>
<%
End Function

%>
 