<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Task/TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%
Dim KSCls
Set KSCls = New Admin_TaskManage
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_TaskManage
        Private KS,KSCls
		Private totalPut,rs, Page, MaxPerPage,DomainStr,SearchType,SQLParam
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KSCls=Nothing
		End Sub
	
	Sub DoDel()		'删除任务
	Dim RSObj, ID ,Total_Point
	ID = KS.G("ID")
	IF KS.CheckOuterUrl()=False Then
		If ID <> "" Then
			Conn.Execute("Delete From CollectJie Where ID IN("& ID & ")")
			KS.AlertHintScript("删除成功！")
		Else
			KS.AlertHintScript("提交参数有误！")
		End If
	End If
	End Sub
	
		Public Sub HSK_Run()
	    If Not (KS.ReturnPowerResult(0, "KMUA10007") or KS.ReturnPowerResult(5,"M510014"))Then
			  Call KS.ReturnErr(1, "")
		End If
		SearchType=KS.ChkClng(KS.G("SearchType"))
		Dim begindate:begindate=request("begindate")
		Dim enddate:enddate=request("enddate")

		Dim ID,Action : Action=KS.S("Action")
		IF Action="Del" And KS.G("ID") <>"" then
			Call DoDel()
			Exit Sub
		ElseIF Action="del" then	'暂时没用到
			Dim Param
			Select Case KS.ChkClng(KS.G("DelType"))
				Case 1 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>11"
				Case 2 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>31"
				Case 3 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>61"
				Case 4 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>91"
				Case 5 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>181"
				Case 6 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>366"
			End Select
			If Param<>"" Then
				Conn.Execute("Delete From CollectJie Where 1=1 and " & Param)
				KS.AlertHintScript "已按所选的条件，删除了已接手收藏任务的相关记录！"
			End IF
			Exit Sub
		End If
		%>
<html>
<head><title>收藏任务管理</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="include/Admin_Style.css" type=text/css rel=stylesheet>
<script src="../HSK_JS/jquery.js" type="text/javascript"></script>
<script src="../HSK_JS/common.js" language="JavaScript"></script>
</head>
<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
  <div class="topdashed" style="padding:4px;">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td style="color:red"><strong>已接手收藏任务管理：</strong></td>
<FORM name="form2" action="?" method="post">
      <td style="border:1px #cccccc dashed">高级查询： 
<Select id=Field name=Field class='textbox'> 
  <Option value=3<%=KS.IIF(KS.ChkClng(KS.G("Field"))=3," selected","")%>>发布人</Option> 
  <Option value=4<%=KS.IIF(KS.ChkClng(KS.G("Field"))=4," selected","")%>>接手人</Option> 
  <Option value=1<%=KS.IIF(KS.ChkClng(KS.G("Field"))=1," selected","")%>>ID号</Option> 
  <Option value=2<%=KS.IIF(KS.ChkClng(KS.G("Field"))=2," selected","")%>>任务编号</Option>
</Select> 关键字：
  <Input id=Keyword class='textbox' maxLength=30 name=Keyword value="<%=KS.G("KeyWord")%>"> 
  <Input class='button' type=submit value=" 查 询 " name=Submit2> 
        <Input id=SearchType type=hidden value=5 name=SearchType> </td></FORM>
    </tr>
  </table>
  </div>

  <div style="border:1px #cccccc dashed;overflow:hidden"></div>
  
   <table width="100%" border="0">
<form action="?action=search&SearchType=100&Field=4" method=post name="myform">
   
   <tr>
     <td width="12%"><strong>按时间段查询</strong></td>
     <td width="48%">
       
       <table width="100%"  align="center" border=0 cellPadding=0 cellSpacing=0>
         <tr>
           <td nowrap="nowrap" class=form-left>起始日期：
             <%if isdate(begindate) then%>
             <input type="text" name="begindate" value="<%=begindate%>" size="12" class="form-input">
             <%else%>
             <input type="text" name="begindate" value="<%=year(now)&"-"&month(now)&"-1"%>" size="12" class="form-input">
             <%end if%>
            </td>    
		    <td  class=form-left>终止日期：  
		      <%if isdate(enddate) then%>            
		      <input type="text" name="enddate" value="<%=enddate%>" size="12" class="form-input">
		      <%else%>
		      <input type="text" name="enddate" value="<%=formatdatetime(now,2)%>" size="12" class="form-input">
		      <%end if%>
		      </td>    
			</tr>
        </table>	 </td>
     <td width="40%">接手人用户名：
      <input type="text" class='textbox' name="keyword" size="10" value="<%If KS.ChkClng(KS.G("Field"))=4 Then KS.Echo Request("keyword")%>" /> &nbsp;
      <input name="submit2" type="submit" value="按日期查找" class='button' />
      </td>
    </tr>
</form>
 </table>
<table width="100%">
    <tr>
      <td align=left>
	  <%
	  if begindate<>"" and enddate<>"" then
	   response.write "<br><div align=center style='font-size:14px'>"
	 response.write "查询时间段 <font color=red>" & begindate & "</font> 至 <font color=red>" & enddate & "</font><br></div>"
	  end if
	  %></td>
    </tr>
  </table>
  
  
  
  <table width="100%">
    <tr>
      <td align=left>您现在的位置：<a href="CollectSubTaskManage.asp">已接手收藏任务管理</a>&nbsp;&gt;&gt;&nbsp;
	  <%Dim SearchTypeStr,SQLStr,TotalPages
	    Dim KeyWord:KeyWord=Trim(KS.G("KeyWord"))
	  Select Case SearchType
		 Case 5 
		    Select Case KS.ChkClng(KS.G("Field"))
			  Case 1:SearchTypeStr="ID号含有<font color=red>""" & KeyWord & """</font>"
			  Case 2:SearchTypeStr="任务编号含有<font color=red>""" & KeyWord & """</font>"
			  Case 3:SearchTypeStr="发布人含有<font color=red>""" & KeyWord & """</font>"
			  Case 4:SearchTypeStr="接手人含有<font color=red>""" & KeyWord & """</font>"
			End Select
		Case 100:SearchTypeStr="时间段查询结果"
	  End Select
	  Response.Write SearchTypeStr%></td>
    </tr>
  </table>
    <div style="border:1px #cccccc dashed;overflow:hidden"></div>

  <table cellSpacing=0 cellPadding=0 width="100%" border=0>
  <form name="selform" method="post" action="?action=Del">
    <tr class=sort align=middle>
	  <td width="4%" nowrap>选择</th>
      <td width="8%" height="25">ID号</td>
      <td width="12%">主任务编号</td>
      <td width="12%">发布人</td>
      <td width="12%">接手人</td>
      <td width="10%">收藏类型</td>
      <td width="20%">收藏时间</td>
      <td width="10%">状态</td>
      <td width="">操作</td>
    </tr>
	<%
			MaxPerPage=20
			Page = KS.ChkClng(KS.G("page"))
			If Page<=0 Then  Page = 1
			SqlParam="1=1"
            If SearchType<>"0" Then
			  Select Case SearchType

			  Case 5
			      Select Case KS.ChkClng(KS.G("Field"))
				   Case 1
				   	 If KS.IsNul(Keyword) Then Keyword = 0
				     SqlParam=SqlParam &" And ID=" & Keyword
				   Case 2
				     SqlParam=SqlParam &" And TaskID Like '%" & Keyword & "%'"
				   Case 3
				     SqlParam=SqlParam &" And Inputer Like '%" & Keyword & "%'"
				  Case 4
				     SqlParam=SqlParam &" And UserName Like '%" & Keyword & "%'"
				  End Select
			  Case 100
			  		If Keyword <> "" Then
				  		SqlParam=SqlParam &" And UserName Like '%" & Keyword & "%'"
					End If
			  End Select
			End If
			If CInt(DataBaseType) = 1 Then         'Sql
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>='" & begindate & "'"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<='" & enddate & "'"
			else
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>=#" & begindate & "#"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<=#" & enddate & "#"
			end if


    If DataBaseType=1 Then
					Dim Cmd : Set Cmd = Server.CreateObject("ADODB.Command")
					Set Cmd.ActiveConnection=conn
					Cmd.CommandText="KS_GetPageRecords"
					Cmd.CommandType=4	
					CMD.Prepared = true 
					Cmd.Parameters.Append cmd.CreateParameter("@tblName",202,1,200)
					Cmd.Parameters.Append cmd.CreateParameter("@fldName",202,1,200)
					Cmd.Parameters.Append cmd.CreateParameter("@pagesize",3)
					Cmd.Parameters.Append cmd.CreateParameter("@pageindex",3)
					Cmd.Parameters.Append cmd.CreateParameter("@ordertype",3)
					Cmd.Parameters.Append cmd.CreateParameter("@strWhere",202,1,1000)
					Cmd.Parameters.Append cmd.CreateParameter("@fieldIds",202,1,1000)
					Cmd("@tblName")="CollectJie"
					Cmd("@fldName")= "ID"
					Cmd("@pagesize")=MaxPerPage
					Cmd("@pageindex")=page
					Cmd("@ordertype")=1
					Cmd("@strWhere")=SqlParam
					Cmd("@fieldIds")="*"
					Set Rs=Cmd.Execute
					Set Cmd = Nothing
	 Else
			SQLStr=KS.GetPageSQL("CollectJie","ID",MaxPerPage,Page,1,SqlParam,"*")
			Set RS = Server.CreateObject("AdoDb.RecordSet")
			RS.Open SQLStr, conn, 1, 1
	 End If
	If RS.Eof AND RS.Bof Then
	 Response.WRITE "<tr class=list onmouseover=""this.className='listmouseover'"" onmouseout=""this.className='list'""><td colspan=9 align=center height='25'>找不到" & SearchTypeStr & "!</td></tr></table>"
	Else
		totalPut = Conn.Execute("Select Count(0) From CollectJie Where " & SqlParam)(0)
		Call showContent()
	End If
	RS.Close:Set RS=Nothing
   %>
<br/>
	<br/>
<div class="attention">
<strong>特别提醒：</strong>
发布的收藏任务或要求收藏数量比较多时，接手表的数据增长得比较快，会给数据查询造成一定资源消耗，所以建议删除二三个月前的收藏记录，以释放资源。
<br />

<iframe src='about:blank' style='display:none' name='_hiddenframe' id='_hiddenframe'></iframe>
<form action="?action=del" target="_hiddenframe" method=post onSubmit="return(confirm('确实要删除有关记录吗？请慎重!'))">
删除范围：<input name="deltype" type="radio" value=1 disabled>
10天前 
    <input name="deltype" type="radio" value="2" />
    1个月前
    <input name="deltype" type="radio" value="3" />
    2个月前
    <input name="deltype" type="radio" value="4" checked="checked" />
    3个月前
    <input name="deltype" type="radio" value="5" />
    6个月前
    <input name="deltype" type="radio" value="6" />
    1年前
    <input type="submit" value="执行删除" class="button">
	</form>

	<br/>
</body>
</html>
   <%
   End Sub
  
  Sub ShowContent()
     on error resume next
     Dim I
     Do While Not rs.eof 
	%>
    <tr class=list onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'">
	  <td align="center" class="splittd"><input type="checkbox" name="ID" value="<%=rs("id")%>"></td>
      <td  class="splittd" align=middle onClick="$('#C<%=rs("id")%>').toggle()" style="cursor:pointer"><%=rs("ID")%></td>
      <td  class="splittd" align=middle><a href="javascript:;" onClick="if(confirm('选“确定”查看接手该任务的用户！\n\n选“取消”查看主任务状态信息！')){self.location.href='?SearchType=5&Field=2&KeyWord=<%=Rs("TaskID")%>';}else{self.location.href='CollectTaskManage.asp?SearchType=5&Field=2&KeyWord=<%=Rs("TaskID")%>';}"><%=rs("TaskID")%></a></td>
      <td  class="splittd" align=middle><a href="?SearchType=5&Field=3&KeyWord=<%=Rs("Inputer")%>" title="掌柜名：<%=rs("ShopName")%>"><%=rs("Inputer")%></a></td>
      <td  class="splittd" align=middle><a href="?SearchType=5&Field=4&KeyWord=<%=Rs("UserName")%>" title="小号名：<%=rs("JieShopName")%>"><%=rs("UserName")%></a></td>
	  <td  class="splittd" align=middle><%If KS.ChkClng(Rs("CollectType"))=1 Then KS.Echo "<span style=""color:green;"">收藏店铺<span>" Else KS.Echo "<span style=""color:#FF5500;"">收藏商品</span>"%></td>
      <td  class="splittd" align=center><%=rs("AddDate")%></td>
      <td  class="splittd" align=middle onClick="$('#C<%=rs("id")%>').toggle()" style="cursor:pointer"><%
			  Select Case KS.ChkClng(rs("Status"))
					Case 0
						KS.Echo "<span style=""color:blue"">刚刚接手</span>"
					Case 1
						KS.Echo "<span style=""color:green"">收藏成功</span>"
					Case 2
						KS.Echo "<span style=""color:#FF5500"" title=""无法访问或访问超时等,还有一次机会重复执行收藏"">访问失败</span>"
					Case 3
						KS.Echo "<span style=""color:red"" title=""重复收藏或收藏夹已满等(同时也包含“无法访问”等情况)"">收藏失败</span>"
			  End Select
		  %></td>
      <td  class="splittd" align=center><a href="?Action=Del&ID=<%=rs("ID")%>" onClick="return confirm('您确定要删除吗？')" title="删除任务">删除</a></td>
    </tr>
    <tr id="C<%=rs("id")%>" bgcolor="#EEEEEE" style="display:none;">
      <td class="splittd" align=center colSpan=10>店铺/商品网址：<%=rs("ProductUrl")%><%if Not KS.IsNul(rs("EndDate")) Then KS.Echo " &nbsp; &nbsp; 完成时间：" & rs("EndDate")%> &nbsp; &nbsp; 用户IP：<%=rs("UserIP")%></td>
    </tr>
	<%
	I = I + 1
	RS.MoveNext
	If I >= MaxPerPage Then Exit Do
	loop
	%>
<tr>
	<td class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" height='25' colspan=10>
	&nbsp;&nbsp;<input id="chkAll" onClick="CheckAll(this.form)" type="checkbox" value="checkbox"  name="chkAll">全选
    <input class="button" type="submit" name="Submit2" value=" 删除选中的任务 " onClick="{if(confirm('确定要删除选中的记录吗?')){this.document.selform.submit();return true;}return false;}"></td>
</tr>
</form>
<tr>
	<td  colspan=10 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "", True, "条", Page, KS.QueryParam("page"))
	%></td>
</tr>
</table>
		<%
		End Sub
		
End Class
%> 
