<!--#include file="Conn.asp"--><%Checklogin("产品管理")%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理区域</title>
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
<script>
$(document).ready(function(){

//var allPlugin={addproduct:{c:'tools_pro',t:'插入产品模板',e:function(){var _this=this;var jTest=$('<div>插入产品模块</div><div><textarea id="xheTestInput" style="width:260px;height:100px;display:none"><h1 class="p1_title"><!--产品名称--></h1><div class="p1_img"><a href="<!--图片地址-->" title="<!--产品名称-->" class="p1_showimg"><img src="<!--图片地址-->" alt="<!--产品名称-->" /></a><span>点击上图查看大图和更多...</span></div><dl class="p1_dl"><dt>型 号：</dt><dd>输入型号</dd></dl><dl class="p1_dl"><dt>品 牌：</dt><dd>输入品牌</dd></dl><dl class="p1_dl"><dt>产 地：</dt><dd>输入产地</dd></dl><dl class="p1_dl"><dt>产品简介：</dt><dd>输入简介</dd></dl><h2 class="p1_title1">产品介绍</h2><div class="p1_content">输入介绍</div><div class="p1_copyright">该<!--产品名称-->产品信息由Taber公司独家提供，严禁转载。</div></textarea></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>');var jTestInput=$('#xheTestInput',jTest),jSave=$('#xheSave',jTest);jSave.click(function(){var cptitle = document.getElementById("cptitle").value,cpimgurl=document.getElementById("cpimgurl").value;if(cptitle==''){alert('请先填写信息标题');return false;}if(cpimgurl==''){alert('请上传缩略图');return false;}_this.loadBookmark();var insertval = jTestInput.val().replace(/<!--产品名称-->/g,document.getElementById("cptitle").value).replace(/<!--图片地址-->/g,document.getElementById("cpimgurl").value);_this.pasteHTML(insertval);_this.hidePanel();return false;});_this.saveBookmark();_this.showDialog(jTest);}}}
$('.txt2').xheditor({
tools:'full',hoverExecDelay:-1,urlType:'root',//plugins:allPlugin,
upLinkUrl:"upload.asp",upLinkExt:"zip,rar,txt,pdf",
upImgUrl:"upload.asp",upImgExt:"jpg,jpeg,gif,png",
upFlashUrl:"upload.asp",upFlashExt:"swf",
upMediaUrl:"upload.asp",upMediaExt:"wmv,avi,wma,mp3,mid",loadCSS:'../css/layout2.css'
});
});
</script>
</head>

<body>
<div id="man_zone">
<%
Act = Request.QueryString("act")



If act = "save" Then

id = Request.Form("id")
If id="" Or Not IsNumeric(id) Then Response.Write "<script>alert('言论已被删除');history.back();</script>":Conn.Close:Set Conn=Nothing:Response.End


email = TextEnCode(Request.Form("email"))
q = HTMLEnCode(Request.Form("q"))
a = HTMLEnCode(Request.Form("a"))


Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.Open "Select * From qa Where id="&id,Conn,1,3
If Not Rs.Bof And Not Rs.Eof Then


	Rs("email") = email
	Rs("q") = q
	If a<>"" Then
	Rs("a") = a
	Rs("atime")=Now()
	Rs("state")=2
	End If
	Rs.Update:Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing
	Page = Request.QueryString("Page")
	Keys=Server.UrlEnCode(Request.QueryString("Keys"))
	Ord=Server.UrlEnCode(Request.QueryString("Ord"))
	Response.Redirect "?keys="&Keys&"&Ord="&Ord&"&Page="&Page
Else
	Response.Write "<script>alert('言论已被删除');history.back();</script>":Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing:Response.End
End If


Conn.Close:Set Conn=Nothing

End If 'end save

If Act = "edit" Then
id = Request.QueryString("id")
If id<>"" And IsNumeric(id) Then
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "Select * From qa Where id="&id,Conn,1,3
	If Not Rs.Bof And Not Rs.Eof Then
		email=Rs("email"):cpid=Rs("cpid"):q=Rs("q"):a=Rs("a"):addip=Rs("addip"):qtime=Rs("qtime"):atime=Rs("atime"):state=Rs("state")
		If Rs("state") = 0 Then Rs("state")=1:Rs.Update
		
	Else
		Response.Write "<script>alert('咨询已被删除');history.back();</script>"
		Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing:Response.End
	End If
	Rs.Close:Set Rs=Nothing
End If

Page = Request.QueryString("Page")
Keys=Server.UrlEnCode(Request.QueryString("Keys"))
Ord=Server.UrlEnCode(Request.QueryString("Ord"))
hrefstr = "?keys="&Keys&"&Ord="&Ord&"&Page="&Page
%>
	<form name="form1" method="post" action="<%=hrefstr%>&act=save">
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<tbody>
			<tr>
				<th width="8%">言论来自</th>
				<td><%
Set Rstt=Server.CreateObject("ADODB.RecordSet")
Rstt.Open "Select cpmc From cp Where id="& cpid,Conn,1,1
If Not Rstt.Bof And Not Rstt.Eof Then
	Response.Write "<a href=""/p"& cpid &".html"" target=""_blank"">"&Rstt(0)&"</a>"
Else
	Response.Write "无"
End If
Rstt.Close
%><input type="hidden" name="id" value="<%=id%>" /></td>
			</tr>
			<tr>
				<th width="8%">Email</th>
				<td><input type="text" name="email" value="<%=email%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">言论内容</th>
				<td><textarea id="cq" name="q" class="txt2"><%=q%></textarea></td>
			</tr>
			<tr>
				<th width="8%">回复内容</th>
				<td><textarea id="ca" name="a" class="txt2"><%=a%></textarea></td>
			</tr>
			<tr>
				<th width="8%">咨询时间</th>
				<td><%=qtime%></td>
			</tr>
			<tr>
				<th width="8%">IP</th>
				<td><%=addip%></td>
			</tr>
			<tr>
				<th width="8%">回复时间</th>
				<td><%=atime%></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="submit" name="save" id="save" value="确定" class="btn1" /> <input type="button" value="返回" class="btn1" onClick="location.href='<%=hrefstr%>'" /></td>
			</tr>
		</tbody>
	</table>
	</form>
</div>
</body>
</html>
<%
Response.End
End If 'End add


If Act="postchk" Then

Keys = Server.UrlEnCode(Request.QueryString("Keys"))
Ord = Server.UrlEnCode(Request.QueryString("Ord"))
Page = Request.QueryString("Page")
chkact = Request.Form("chkact")
SqlStr = ""
For i = 1 To Request.Form("chkbox").Count
	If SqlStr<>"" Then
		SqlStr = SqlStr & " Or id="&Request.Form("chkbox")(i)
	Else
		SqlStr = " Where id="&Request.Form("chkbox")(i)
	End If
Next

Select Case chkact
Case "0":SqlStr = "Update qa Set state="&chkact&SqlStr
Case "1":SqlStr = "Update qa Set state="&chkact&SqlStr
Case "2":SqlStr = "Update qa Set state="&chkact&SqlStr
Case Else:SqlStr = "Delete From qa"&SqlStr
End Select

Conn.Execute(SqlStr):Conn.Close:Set Conn=Nothing
Response.Redirect "?Keys="&Keys&"&Ord="&Ord&"&Page="&Page
Response.End
End If	'End postchk



Keys=Request.QueryString("Keys")
Keyscode=TextEnCode(Keys)
Ord=Request.QueryString("Ord")
Page = Request.QueryString("Page")
If Ord="cq" Or Ord="ca Desc" Or Ord="addip" Or Ord="addip Desc" Or Ord="uid" Or Ord="uid Desc" Or Ord="addtime" Or Ord="addtime Desc" Or Ord="pcstate" Or Ord="pcstate Desc" Then
	OrdStr=Ord&","
Else
	OrdStr=""
End If


Set Rs=Server.CreateObject("ADODB.RecordSet")
Rs.Open "Select * From qa Where q like '%"&Keyscode&"%' Or a like '%"&Keyscode&"%' Or addip like '%"&Keyscode&"%' Order By "&OrdStr&"id Desc",Conn,1,1
Keys=Server.UrlEnCode(Keys)
Ord=Server.UrlEnCode(Ord)
hrefstr = "?keys="&Keys
%>	
	<form id="form1" method="post" action="?act=postchk&Keys=<%=keys%>&Ord=<%=Ord%>&Page=<%=Page%>" onSubmit="return false" />
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<thead>
			<tr>
				<th width="4%"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></th>
				<th width="6%">序号</th>
				<th width="15%"><a href="<%=hrefstr%><%If ord="q" Then Response.Write "&ord=q+Desc" Else Response.Write "&ord=q"%>">咨询<%If Ord="q" Then Response.Write "↓" Else If Ord="q+Desc" Then Response.Write "↑"%></a></th>
				<th width="19%"><a href="<%=hrefstr%><%If ord="a" Then Response.Write "&ord=a+Desc" Else Response.Write "&ord=a"%>">回复<%If Ord="a" Then Response.Write "↓" Else If Ord="a+Desc" Then Response.Write "↑"%></a></th>
				<th width="15%"><a href="<%=hrefstr%><%If ord="addip" Then Response.Write "&ord=addip+Desc" Else Response.Write "&ord=addip"%>">IP<%If Ord="addip" Then Response.Write "↓" Else If Ord="addip+Desc" Then Response.Write "↑"%></a></th>
				<th width="15%"><a href="<%=hrefstr%><%If ord="qtime" Then Response.Write "&ord=qtime+Desc" Else Response.Write "&ord=qtime"%>">咨询时间<%If Ord="qtime" Then Response.Write "↓" Else If Ord="qtime+Desc" Then Response.Write "↑"%></a></th>
				<th width="8%"><a href="<%=hrefstr%><%If ord="state" Then Response.Write "&ord=state+Desc" Else Response.Write "&ord=state"%>">状态<%If Ord="state" Then Response.Write "↓" Else If Ord="state+Desc" Then Response.Write "↑"%></a></th>
				<th width="8%">操作</th>
			</tr>
		</thead>
		<tbody>
<%
If Not Rs.Bof And Not Rs.Eof Then
	Rs.PageSize = 10
	If Page = "" Then Page = 1
	If Page = "end" Then Page = Rs.PageCount
	If Not IsNumeric(Page) Or Page < 1 Then Page = 1
	Page = Cint(Page)
	If Page > Rs.PageCount Then Page = Rs.PageCount
	Rs.AbsolutePage = Page
	TempNum = Rs.PageSize * (Page - 1)
	
	Set Rs1=Server.CreateObject("ADODB.RecordSet")

	For i=1 To Rs.PageSize
		If Rs.Bof Or Rs.Eof Then Exit For
		TempNum=TempNum+1
%>

			<tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
				<td align="center"><input type="checkbox" name="chkbox" value="<%=Rs(0)%>" /></td>
				<td align="center"><%=TempNum%></td>
				<td align="center"><%=Left(RemoveHTML(HTMLUnCode(Rs("q"))),200)%></td>
				<td align="center"><%=Left(RemoveHTML(HTMLUnCode(Rs("a"))),200)%></td>
				<td align="center"><%=Rs("addip")%></td>
				<td align="center"><%=Rs("qtime")%></td>
				<td align="center"><%If Rs("state")=2 Then Response.Write "<span style=""color:green"">通过审核</span>" Else If Rs("state")=1 Then Response.Write "已读" Else Response.Write "<span style=""color:red"">未读</span>" End If%></td>
				<td align="center"><a href="?Keys=<%=keys%>&Ord=<%=Ord%>&Page=<%=Page%>&act=edit&id=<%=Rs("id")%>" class="ico_magnifier">查看详细</a></td>
			</tr>
<%
		Rs.MoveNext
	Next
Else
	If Keys="" Then
%>
			<tr>
				<td align="center" colspan="9">Sorry，当前暂无言论</td>
			</tr>
<%
	Else
%>
			<tr>
				<td align="center" colspan="9"><a href="?">Sorry，没有找到“<%=Keyscode%>”相关的言论，点击返回</a></td>
			</tr>
<%
	End If
End If
%>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="9">
					<div class="showpagebox">
<%
If Rs.PageCount > 1 Then
	PageName="?Keys="&Keys&"&Ord="&Ord&"&"
	Pagelen=3
	If Page>1 Then
		Response.Write "<a href="""&PageName&"Page=1"">首页</a>"
		Response.Write "<a href="""&PageName&"Page="&Page-1&""">上一页</a>"
	End If

	If Pagelen*2+1 >= Rs.PageCount Then
		StartPage=1:EndPage=Rs.PageCount
	Else
		If Page<=Pagelen+1 Then
			StartPage=1
			EndPage=Pagelen*2+1
		Else
			StartPage=Page-Pagelen
			EndPage=Page+Pagelen
		End If
		If Page+Pagelen>Rs.PageCount Then StartPage=Rs.PageCount-Pagelen*2:EndPage=Rs.PageCount
	End If

	For i = StartPage To EndPage
		If i = Page Then
			Response.Write "<a class=""current"">"&i&"</a>"
		Else
			Response.Write "<a href="""&PageName&"Page="&i&""">"&i&"</a>"
		End If
	Next

	If Page<Rs.PageCount Then
		If Rs.PageCount - Page > Pagelen Then Response.Write "<a href="""&PageName&"Page="&Rs.PageCount&""">..."&Rs.PageCount&"</a>"
		Response.Write "<a href="""&PageName&"Page="&Page+1&""">下一页</a>"
		Response.Write "<a href="""&PageName&"Page="&Rs.PageCount&""">尾页</a>"
	End If

	Response.Write "<input type=""text"" id=""Pagego"" value="""&Page&""" onFocus=""if(this.value == '"&Page&"'){this.value='';}"" onBlur=""if(this.value == ''){this.value='"&Page&"';}"" onKeyUp=""this.value=this.value.replace(/\D/g,'')"" onKeyDown=""if(event.keyCode==13){location.href='"&PageName&"Page='+document.getElementById('Pagego').value}"" />"
End If
%>					</div>
					<div class="searchbox"><input type="text" id="keys" value="<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>" onFocus="if(this.value == '<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>'){this.value='';}" onBlur="if(this.value == ''){this.value='<%If Keyscode="" Then Response.Write "请输入搜索关键词" Else Response.Write Keyscode%>';}" onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)}" /><input type="button" id="searchgo" value="go" onClick="location.href='?Keys='+escape(document.getElementById('keys').value)" /></div>
					<div class="postchkbox">
						<select id="chkact" name="chkact">
							<option value="2">通过审核</option>
							<option value="1">已读</option>
							<option value="0">未读</option>
							<option value="-1">删除</option>
						</select>
						<input type="button" value="执行" onClick="postchk(3)" class="btn1" />
					</div>
				</td>
			</tr>
		</tfoor>
	</table>
	</form>
<%Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing%>
</div>
</body>
</html>
