<%
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 Tasks_overdue(TChancesID) '过期

    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TChancesID<>"" and IsNumeric(TChancesID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_today(TChancesID) '今天

    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TChancesID<>"" and IsNumeric(TChancesID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_tomorrow(TChancesID) '明天
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TChancesID<>"" and IsNumeric(TChancesID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_aftertomorrow(TChancesID) '后天
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TChancesID<>"" and IsNumeric(TChancesID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_this_week(TChancesID) '本周
    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 TChancesID<>"" and IsNumeric(TChancesID) then
          sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"	
         While Not rs.EOF
	      response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	      response.Write " </td></tr>"
          rs.movenext
        Wend
	      response.Write "</table>"
	   End If
          rs.Close
       Set rs = Nothing
	end if
End Function

Function Tasks_next_week(TChancesID) '下周
    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 TChancesID<>"" and IsNumeric(TChancesID) then
        sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"	
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function

Function Tasks_later(TChancesID) '以后
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
	if TChancesID<>"" and IsNumeric(TChancesID) then
	   sql = "select * from Zqj_Tasks where MemName='"&session("UserName")&"' and ViewFlag and Completed=false and TChancesID="&TChancesID&" 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=""80%"" border=""0"">"
    While Not rs.EOF
	    response.Write "<tr><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 "<a href=""../tasks/Tasks_Edit.asp?Result=Modify&ID="&rs("ID")&"&Referer=back"" title='编辑'><img src=""../Images/mod.png"" width=""15"" height=""13""></a> <a href='../tasks/Tasks_do.Asp?id="&rs("ID")&"&LX=Zqj_Tasks&Operation=up' title='完成'><font color='blue'>√</font></a> "&delc&" "&TasksSortText(rs("TasksSortID"))&"  &nbsp;"&rs("Demo")&""
	    response.Write " </td></tr>"
        rs.movenext
    Wend
	response.Write "</table>"
	End If
    rs.Close
    Set rs = Nothing
End Function
%>