<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%

Dim KSCls
Set KSCls = New Admin_TaskTemplate
KSCls.HSK_Run()
Set KSCls = Nothing

Class Admin_TaskTemplate
        Private KS,Param,KSCls
		Private Action,i,strClass,sFileName,RS,SQL,maxperpage,CurrentPage,totalPut,TotalPageNum
        Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
  		  maxperpage = 20 '###每页显示数
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		End Sub

		Public Sub HSK_Run()
		 With KS
					If Not KS.ReturnPowerResult(0, "KSMS20000") Then          '检查是权限
					 Call KS.ReturnErr(1, "")
					 Response.End()
					 End If
'              .echo "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">" & vbcrlf
'			  .echo "<html xmlns=""http://www.w3.org/1999/xhtml"">"
			  .echo "<html>"
			  .echo"<head>"
			  .echo"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .echo"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .echo "<script src=""../HSK_JS/common.js"" language=""JavaScript""></script>"
			  .echo "<script src=""../HSK_JS/jquery.js"" language=""JavaScript""></script>"
			  .echo "<script type=""text/javascript"" src=""../HSK_JS/HSK.box.js""></script>"
			  .echo "<script type=""text/javascript"" src=""../editor/ckeditor.js"" mce_src=""../editor/ckeditor.js""></script>"
			  .echo"</head>"
			  .echo"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"
			  .echo "<div class='topdashed sort'>任务模板管理</div>"
		
		If Not IsNumeric(Request("page")) And Len(Request("page")) <> 0 Then
			.echo ("错误的系统参数!请输入整数")
			Response.End
		End If
		If Not IsEmpty(Request("page")) And Len(Request("page")) <> 0 Then
			CurrentPage = CInt(Request("page"))
		Else
			CurrentPage = 1
		End If
		If CInt(CurrentPage) = 0 Then CurrentPage = 1
		
		Param=" where 1=1"
		If KS.G("KeyWord")<>"" Then
		  If KS.G("condition")="1" Then
		   Param= Param & " And Inputer like '%" & KS.G("KeyWord") & "%'"
		  ElseIf KS.G("condition")="2" Then
		   Param= Param & " And TemplateName like '%" & KS.G("KeyWord") & "%'"
		  End If
		End If
		
		totalPut = Conn.Execute("Select Count(id) From TaskTemplate " & Param)(0)
		TotalPageNum = CInt(totalPut / maxperpage)  '得到总页数
		If TotalPageNum < totalPut / maxperpage Then TotalPageNum = TotalPageNum + 1
		If CurrentPage < 1 Then CurrentPage = 1
		If CurrentPage > TotalPageNum Then CurrentPage = TotalPageNum
		Select Case KS.S("action")
		 Case "Del"  Call DoDel()
		 Case Else
				Call ShowList()
		End Select
	End With	
End Sub

Private Sub ShowList()
%>
<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0">
<tr height="25" align="center" class='sort'>
	<td width='5%' nowrap>选择</td>
	<td nowrap>ID号</td>
	<td nowrap width='60'>任务区</td>
	<td nowrap width='100'>模板名称</td>
	<td nowrap>用户名</td>
	<td nowrap>掌柜名</td>
	<td>商品地址</td>
	<td nowrap>价格</td>
	<td nowrap>发布点</td>
    <td nowrap>好评时限</td>
    <td nowrap width='80'>添加时间</td>
	<td nowrap>操作</td>
</tr>
<%
	sFileName = "TaskTemplateManage.asp?"
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "select * from TaskTemplate " & Param & " order by id desc"
	If DataBaseType = 1 Then
		If CurrentPage > 100 Then
			Rs.Open SQL, Conn, 1, 1
		Else
			Set Rs = Conn.Execute(SQL)
		End If
	Else
		Rs.Open SQL, Conn, 1, 1
	End If
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td height=""25"" align=center bgcolor=""#ffffff"" colspan=12>还没有任何任务模板！</td></tr>"
	Else
		If TotalPageNum > 1 then Rs.Move (CurrentPage - 1) * maxperpage
		i = 0
%>
<form name=selform method=post action=?action=Del>
<%
	On Error Resume Next
	Do While Not Rs.EOF And i < CInt(maxperpage)
		If Not Response.IsClientConnected Then Response.End
		
%>
<tr height="25" 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 align="center" class="splittd"><%=Rs("ID")%></td>
	<td align="center" class="splittd"><%=KS.C_C(RS("tid"),1)%></td>
	<td align="center" class="splittd"><%=Rs("TemplateName")%></td>
	<td align="center" class="splittd"><%=Rs("Inputer")%></td>
	<td align="center" class="splittd"><%=Rs("KS_ShopName")%></td>
	<td align="center" class="splittd"><a href="javascript:void(0)" onclick='new KesionPopup("#fff",4,true,"font-size:12px;background:url(/style/images/w_b_2.gif) #1B76B7 0 -4px;color:#20537A;height:22px;").mousepopup("&nbsp; 商品地址","<p><%=replace(replace(Rs("KS_ProductUrl"),chr(10),"<br>"),chr(13),"<br>")%></p>",450);' title="点击查看详细"><%=KS.gotTopic(Rs("KS_ProductUrl"),23)%></a></td>
    <td align="center" class="splittd"><%=Rs("KS_Price")%></td>
	<td align="center" class="splittd"><%=rs("KS_Point")%></td>
    <td align="center" class="splittd"><%=ks_haopinglimit(RS("KS_HaoPingLimit"),RS("KS_ShopDynamic"),RS("KS_HaoPingContent")) %>
    </td>
	<td align="center" class="splittd"><%=KS.GetTimeFormat(RS("AddDate"))%></td>
    <td align="center" class="splittd"><a href="?Action=Del&ID=<%=rs("id")%>" onclick="return(confirm('确定要删除吗？'));">删除</a>
    </td>
</tr>
<%
		Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close:Set Rs = Nothing
%>
<tr>
	<td class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" height='25' colspan=12>
	&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=12 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "TaskTemplateManage.asp", True, "个", CurrentPage, KS.QueryParam("page"))
	%></td>
</tr>
</table>
<div>
<form action="TaskTemplateManage.asp" name="myform" method="get">
   <div style="border:1px dashed #cccccc;margin:3px;padding:4px">
      &nbsp;<strong>快速搜索=></strong>
	 &nbsp;关键字:<input type="text" class='textbox' name="keyword">&nbsp;类型:
	 <select name="condition">
	  <option value=1>按用户号搜索</option>
	  <option value=2>按任务模板名搜索</option>
	 </select>
	  &nbsp;<input type="submit" value="开始搜索" class="button" name="s1">
    </div>
</form>
</div>
</body>
</head>
</html>
<%
End Sub

Function ks_haopinglimit(HaoPingLimit,ShopDynamic,HaoPingContent)
	Dim Val,Val2,Val3,str,str2,str3
	Val = KS.ChkClng(HaoPingLimit)
	Val2 = KS.ChkClng(ShopDynamic)
	Val3 = HaoPingContent
	If Not KS.IsNul(Val3) Then str3 = "带字"
	If Val2 = 5 Then str2 = "和店评5分"
	If Val = 1 Then
		str = "<span title=""立即确认收货" & str3 & "好评"& str2 &""">立即确认</span>"
	ElseIF Val =2 Then
		str = "<span title=""24小时后确认收货" & str3 & "好评"& str2 &""">24小时</span>"
	ElseIF Val =3 Then
		str = "<span title=""48小时后确认收货" & str3 & "好评"& str2 &""">48小时</span>"
	ElseIF Val =4 Then
		str = "<span title=""72小时后确认收货" & str3 & "好评"& str2 &""">72小时</span>"
	Else
		str = "联系发布方"
	End If
	ks_haopinglimit = str
End Function

Sub DoDel()
Dim ID: ID=KS.G("ID")
IF KS.CheckOuterUrl()=False Then
	If ID <> "" Then
		Conn.Execute("Delete From TaskTemplate Where id In("& id & ")")
		KS.AlertHintScript("删除成功！")
	End If
End If
End Sub

End Class
%> 
