<!--#include file="admin_conn.asp"-->
<%
chkLogin
dim action : action = be("get","action")

select case action
	case "audit" : audit 
	case else : headAdmin "留言管理" : main
end select
dispseObj()

sub audit
	dim g_id : g_id = be("all","g_id")
	if not isN(g_id) then
		objdb.update "{pre}gbook",Array("g_audit"),Array("1") ,"g_id in ("& g_id & ")"
	end if
	writeA "审核完毕"
end sub

sub main
	dim pagenum : pagenum = be("all","page")
	if not isNum(pagenum) then pagenum = 1 else pagenum=cint(pagenum)
	if pagenum < 1 then pagenum = 1
	pagenum = clng(pagenum)
	Dim sql : sql = "SELECT g_id,g_vid,g_audit,g_name,g_content,g_ip,g_reply,g_time,g_replytime FROM {pre}gbook ORDER BY g_id DESC"
	Dim rs : Set rs = objdb.DB(sql,"rs1")
	dim i : i = 0
	%>
<script language="javascript">
$(document).ready(function(){
	$('#form1').form({
		onSubmit:function(){
			if(!$("#form1").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info',function(){
	        location.href=location.href;
	        });
	    }
	});
	$('#form2').form({
		onSubmit:function(){
			if(!$("#form2").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info');
	    }
	});
	$("#btnCancel").click(function(){
		location.href= location.href;
	});
	$("#btnDel").click(function(){
		if(confirm('确定要删除吗')){
			$("#form1").attr("action","admin_ajax.asp?action=del&flag=batch&tab={pre}gbook");
			$("#form1").submit();
		}
		else{return false}
	});
	$("#btnAudit").click(function(){
		$("#form1").attr("action","admin_gbook.asp?action=audit");
		$("#form1").submit();
	});
});
function reply(id)
{
	$('#form2').form('clear');
	$("#flag").val("edit");
	$('#win1').window('open');
	$('#form2').form('load','admin_ajax.asp?action=getinfo&tab={pre}gbook&col=g_id&val='+id);
}
</script>
<%
	if rs.eof then
	%>
	<div align="center">没有任何记录!</div>
	<%
		else
		Dim j,g_content
		rs.PageSize = app_pagenum
	    rs.AbsolutePage = pagenum
	  	for j = 1 to rs.PageSize
	  		if rs.eof then exit for
			i = i+1
			g_content = rs("g_content")
	  		g_content = regReplace(g_content, "\[em:(\d{1,})?\]", "<img src=""../images/face/$1.gif"" border=0/>")
%>
<form id="form1" name="form1" method="post">
 <div style="width:100%; border:1px solid #B5D6E6; margin-top:10px;">
	 <div style="width:100%; height:30px; line-height:30px; font-size:12px; background:#EEF7FE">
		 <span style="float:left;color:#185691;">
		 	<input type="checkbox" name="g_id" value="<%=rs("g_id")%>" class="checkbox">
		 	&nbsp;昵称:<strong><%=rs("g_name")%></strong>
		 	&nbsp;&nbsp;IP:<%=rs("g_ip")%>
		 	&nbsp;&nbsp;<%if rs("g_audit")=1 then %><font color=green>已审核</font><%else%><font color=red>未审核</font><%end if%>
		 </span>
		 <span style="float:right;text-align:right; font-size:12px;">
		 	发表于:<font color="red"><%=rs("g_time")%></font>
		 </span>
	 </div>
	 <div style="width:95%; margin:0 auto; height:60px; font-size:12px; line-height:20px; border-bottom:1px solid #CCC">
	 	留言内容：<%=g_content%>
	 	<br>
	 	<font color="red">回复内容：</font><%=rs("g_reply")%>
	 </div>
	 <div style="width:100%; height:20px; text-align:right;font-size:12px; line-height:20px;">
	 	&nbsp;&nbsp;[<a style="cursor:pointer" onclick="reply(<%=rs("g_id")%>)">
	 	回复</a>]&nbsp;&nbsp;[<a href="admin_ajax.asp?action=del&tab={pre}gbook&g_id=<%=rs("g_id")%>" onClick="return confirm('确定要删除吗?');">删除</a>]&nbsp;&nbsp;
	 </div>
 </div>
	<%
	rs.movenext
	next
	end if
	%>
<table class="tb" style="margin-top:5px;">
<tr><td>
全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'g_id');"/>&nbsp;
<input type="button" id="btnDel" value="批量删除" class="input">
<input type="button" id="btnAudit" value="批量审核" class="input">
</td></tr>
<tr align="center">
<td>
<%=pagelist_manage(rs.PageCount,pagenum,rs.RecordCount,app_pagenum,"admin_gbook.asp?page={p}")%>
</td>
</tr>
</table>
</form>

<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:400px;" closed="true" minimizable="false" maximizable="false">
<form action="admin_ajax.asp?action=save&tab={pre}gbook" method="post" name="form2" id="form2">
<table class="tb">
	<input id="g_id" name="g_id" type="hidden" value="">
	<input id="flag" name="flag" type="hidden" value="">
	<tr>
	<td width="20%" >回复内容：</td>
	<td><textarea id="g_reply" rows="8" style="width:200px;" value="" name="g_reply"></textarea>
	</td>
	</tr>
	<tr align="center">
      <td colspan="2"><input class="input" type="submit" value="保存" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel"> </td>
    </tr>
</table>
</form>
</div>
</body>
</html>
<%	
objdb.c(rs)
end sub
%>
