<!--#include file="../include/hf_conn.asp"-->
<!--#include file="checkadmin.asp"-->
<script language=javascript src=../include/mouse_on_title.js></script>
<%call checkmanage("10")%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
</script>
</head>
<BODY background="../images/admin/back.gif">

<%
action=request("action")
if action="" then%>

<table width="98%" border="1" cellpadding="3" bordercolor="#333333" style="border-collapse: collapse;" style="word-break:break-all">
	<tr class=backs><td colspan=6 class=td height=18>商品评论管理 &nbsp;</td></tr>
	<form name=Prodlist action=book2.asp method=post><tr>	
	<td align=center width=5%>选</td>
	<td align=center width=7%>商品</td>
	<td align=center width=18% height=15>姓名</td> 
	<td align=center width=45%>内容</td>
	<td align=center width=15%>日期</td>
	<td align=center width=10%>审核</td>
	</tr>
<%
dim rs,msg_per_page
dim sql
msg_per_page = 10 '每页显示记录数
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from hfvip_pinglun order by adddate desc"

rs.cursorlocation = 3 
rs.pagesize = msg_per_page '每页显示记录数
rs.open sql,conn,1,1 

	if rs.eof and rs.bof then
	response.write "<tr><td colspan=6 align=center><BR>暂时没有商品评论<BR><BR></td></tr>"
	end if

	if not (rs.eof and rs.bof) then '检测记录集是否为空
	totalrec = RS.RecordCount '总记录条数
	if rs.recordcount mod msg_per_page = 0 then '计算总页数,recordcount:数据的总记录数
	n = rs.recordcount\msg_per_page 'n:总页数
	else 
	n = rs.recordcount\msg_per_page+1 
	end if 

	currentpage = request("page") 'currentpage:当前页
	If currentpage <> "" then
		currentpage = clng(currentpage)
		if currentpage < 1 then 
			currentpage = 1
		end if 
		if err.number <> 0 then 
			err.clear
			currentpage = 1
		end if
	else
		currentpage = 1
	End if 
	if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then 
		currentPage=1
	end if
	rs.absolutepage = currentpage 'absolutepage：设置指针指向某页开头
	rowcount = rs.pagesize 'pagesize：设置每一页的数据记录数
	dim i
	dim k

	Do while not rs.eof and rowcount>0
	content=rs("nr")	
	name=rs("name")

	Response.write "<tr><td align=center><input type='checkbox' value='"&rs("ID")&"' name=id></td>"
	Response.write "<td align=center><a target='_blank' href=../list.asp?prodid="&rs("prodid")&"><img alt='查看该评论相关商品' border=0 src='../images/admin/goto.gif'></td><td>"&name&"</td><td><a href='book2.asp?action=replay&id="&rs("ID")&"'>"
	response.write lleft(server.htmlencode(content),50)
	response.write "</a></td><td  align=center>"&split(rs("adddate"))(0)&"</td><td  align=center>"
	if rs("view")="0" then
 	  response.write "<font color=red>隐藏</font>"
	else
	  response.write "公开"
	end if
	response.write "</td></tr>"
	rowcount=rowcount-1
	rs.movenext		
	loop
	end if

	rs.close
	conn.close
	set rs=nothing
	set conn=nothing
%>
<tr><td colspan=6><input type='checkbox' name=chkall onclick='CheckAll(this.form)'> 全选 
	<input type="submit" name="action" value="删除" onClick="{if(confirm('该操作不可恢复！\n\n确实删除选定的评论？')){this.document.Prodlist.submit();return true;}return false;}"> 	
	</td></tr></form></table>
<%
call listPages()
end if

if action="删除" then
	delid=replace(request("id"),"'","")
	call delfeedback()
end if

if action="replay" then
	id=request("id")
	call detailfeedback()

end if

%>                     
</td></tr></table>   
</td></tr>
</table>

</body></html>

<%
sub delfeedback()
	if delid="" or isnull(delid) then

	response.write "<script language='javascript'>"
	response.write "alert('操作失败，没有选择合适参数，请单击“确定”返回！');"
	response.write "location.href='book2.asp';"
	response.write "</script>"
	response.end

	else
		conn.execute("delete from hfvip_pinglun where ID in ("&delid&")")
		conn.close
		set conn=nothing

	response.write "<script language='javascript'>"
	response.write "alert('评论删除成功，请单击“确定”返回！');"
	response.write "location.href='book2.asp';"
	response.write "</script>"
	response.end

	end if
end sub

sub detailfeedback()
if id="" then
	response.write "<script language='javascript'>"
	response.write "alert('无此评论编号，请单击“确定”返回！');"
	response.write "location.href='book2.asp';"
	response.write "</script>"
	response.end
end if

	'修改评论资料
if request("send")="ok" then
	set rs=server.createobject("adodb.recordset")
	sql = " select * from hfvip_pinglun where ID="&id
	rs.open sql,conn,1,3

		if not (rs.eof and rs.bof) then
		rs("nr")=request.form("nr")
		rs("view")=request("view")
'		rs("jibie")=request("jibie")
		rs.update
		end if

	rs.close

	response.write "<script language='javascript'>"
	response.write "alert('评论已经修改成功，请单击“确定”返回！');"
	response.write "location.href='book2.asp';"
	response.write "</script>"
	response.end
end if

	'显示详细资料
	set rs = server.createobject("adodb.recordset")
	sql = "select * from hfvip_pinglun where ID="&id
	rs.open sql,conn,1,1

		if rs.eof and rs.bof then 
		response.write "<script language='javascript'>"
		response.write "alert('无此评论，请单击“确定”返回！');"
		response.write "location.href='book2.asp';"
		response.write "</script>"
		response.end
		end if

		if not (rs.eof and rs.bof) then 
			nr=replace(rs("nr"),"<BR>",vbCRLF)
		%>
   <table width="98%" border="1" cellpadding="3" bordercolor="#333333" style="border-collapse: collapse;">
	<tr class=backs><td colspan=2 class=td height=18>评论信息管理</td></tr>
		 <form name="repl" method="post" action='book2.asp?action=replay&id=<%=id%>'>
		 <tr><TD align="right" WIDTH=20% height=15>评论人IP地址</TD><td><a href='tj.asp?ip=<%=rs("ip")%>' target=_blank alt=查看来源><%=rs("IP")%></a></td></tr>
		 <tr><TD align="right" >评论日期</TD><td><%=rs("adddate")%></td></tr>		 
		 <tr><TD align="right" >评论人姓名</TD><td><%=rs("name")%></td></tr>
		<tr><TD align="right" >电子邮箱</TD><td><%=rs("Mail")%></td></tr>
		<tr><TD align="right" >评 级</TD><td>
	<%for i=1 to clng(rs("jibie"))
	response.write "<font color=orange>☆</font>"
	next
	%> 
		</td></tr>
		 <tr><TD align="right" >评论内容</TD><td><textarea style="overflow:auto" name="nr" cols="60" rows="8"><%=nr%></textarea></td></tr>
		<tr><TD align="right" >是否隐藏</TD><td><input type="radio" name="view" value="0" <%if rs("view")="0" then%>checked<%end if%>>
			  隐藏<input type="radio" name="view" value="1" <%if rs("view")="1" then%>checked<%end if%>>
			  公开 </td></tr>
			<TR><TD align="right" >&nbsp;<INPUT TYPE="hidden" name=send value=ok></TD><TD>
				<input type="submit" name="action" value=" 提 交 "></TD></TR>
			</form></TABLE>
		<%
		end if	

	rs.close
	set rs=nothing

end sub


sub listPages() 
if n <= 1 then exit sub 
%>
<p> >> 
<%if currentpage = 1 then%>
<font color=darkgray>首页 前页</font>
<%else%> 
<font color=black face="arial"><a href="<%=request.ServerVariables("script_name")%>?page=1">
首页</font></a>
 <a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage-1%>">
<font color=black face="arial" >前页</a></font>
<%end if%>
<%if currentpage = n then%> 
<font color=darkgray face="arial" >下页 末页</font>
<%else%> 
<font color=black face="arial" ><a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage+1%>">下页</a>
 <a href="<%=request.ServerVariables("script_name")%>?page=<%=n%>">末页</a></font>
<%end if%>
<font color=black face="arial" >
  总:<%=currentpage%>/<%=n%>页&nbsp;&nbsp;总共:<%=totalrec%>条评论 [<%=msg_per_page%>条/页]</font></p>

<%end sub%>