<!--#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" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
<!--
function checktasksseach()
{
   if (tasks.st.value.replace(/[ ]/g,"")=="")
   {
	  alert("请选择开始日期！");
	  return false;
   }
  if (tasks.et.value.replace(/[ ]/g,"")=="")
   {
	  alert("请选择结束日期！");
	  return false;
   }
}
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-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>
<%
Dim Result,TDemo,TEtime,TasksSortID,TKehuID,TChancesID,Task_frame,TSortID,st,et,s
Result = request.QueryString("Result")
ID = request.QueryString("ID")
TSortID=trim(request.QueryString("TSortID"))
Action = request.QueryString("Action")
st=trim(request("st")) '开始时间
et=trim(request("et")) '结束时间
    If Action = "seach" Then
	   st=trim(request.Form("st"))
	   et=trim(request.Form("et"))
	      if st="" and et="" then '查询分页时
	         st=trim(request("st"))
             et=trim(request("et"))
	      end if
	end if
if st="" and et="" then
   st=year(date())&"-"&month(date())&"-1"
   et=date()
end if
s=1
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="tasks" method="post" action="?Action=seach&TSortID=<%=TSortID%>&st=<%=st%>&et=<%=et%>&Page=1" onSubmit="return checktasksseach()">
    <tr>
      <td class="forumRowHighlight"><img src="../Images/finish.gif" width="15" height="15" />
      <font style=" font-size:16px;">已完成的事项</font><br><br>
      分类为
      <select name="TasksSort" onchange="window.location='?TSortID=' + this.value">
      <option value="">所有</option>
      <% call SelectTasksSort() %>
   </select>
   &nbsp;&nbsp;选择日期：<input name="st" id="st" class="Wdate" type="text" onFocus="WdatePicker({skin:'blueFresh',maxDate:'#F{$dp.$D(\'et\')||\'2020-10-01\'}'})" value="<%=st%>"/> 
   至 
   <input name="et" id="et" class="Wdate" type="text" onFocus="WdatePicker({skin:'blueFresh',minDate:'#F{$dp.$D(\'st\')}',maxDate:'2020-10-01'})" value="<%=et%>"/>
   <input name="submit" type="submit" id="submit" value="显示" />
         <% TcompletedList() %>
      </td>
    </tr>
    
  </form>
</table>
<%

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 TcompletedList()
    Dim idCount
    Dim pages
    pages = 20
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 2
    Dim pagenmax
    Dim pagenmin
    Dim datafrom
    datafrom = "Zqj_Tasks"
    Dim datawhere
	if TSortID<>"" and IsNumeric(TSortID) then
        datawhere="where MemName='"&session("UserName")&"' and ViewFlag and TasksSortID="&TSortID&" and Completed and Completed_time between #"&st&"# and #"&dateadd("d",+1,et)&"# "
	else
	    datawhere="where MemName='"&session("UserName")&"' and ViewFlag and Completed and Completed_time between #"&st&"# and #"&dateadd("d",+1,et)&"# "
	end if
	
    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 & "?TSortID="&TSortID&"&"
    Else
        Myself = Left(PATH_INFO & "?" & QUERY_STRING, InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") -1)
    End If
    Dim taxis
    taxis = "order by Completed_time 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
response.Write "<div class=""dashed_line""></div><br>"
While(Not rs.EOF)
%>

<table width="100%" border="0" cellpadding="4" cellspacing="1">
    <tr <%if (noli mod 2)=1 then%>bgcolor='#F0F8FF'<%end if%> onMouseOver="this.style.backgroundColor='#DEB887'" onMouseOut="this.style.backgroundColor=''"><td>&nbsp;
         <%=TasksSortText(rs("TasksSortID"))%>  &nbsp;<%=rs("Demo")%>
        <%
		   call Formkhre(rs("ID"))
		%>
	 </td>
     <td width="132" align="center">
	 <%
	 if DATEDIFF("d",rs("Completed_time"),date())=0 then
	 response.Write "<font color=""#FF0000"">"&rs("Completed_time")&"</font>"
	 else
	 response.Write rs("Completed_time")
	 end if
	 %>
     <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>
     </td>
     </tr>
</table>

<%
noli=noli+1
s=s+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""> </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 Formkhre(Tasksid) 'Tasksid任务ID
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select top 1 * From Zqj_KehuRe where TasksID="&Tasksid
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	   Re = ""
	else
	   response.Write " <font color=""#999999"">"&rs("Re")&"</font>"
	end if
    rs.Close
    Set rs = Nothing
End Function
%>
