<!--#include file="function.asp"-->
<%
checkLogin()

header("基本信息 &gt; 在线留言管理")
select case Request.QueryString("action")
case "new"
	call new_()
case "submit"

	f_id=request.Form("f_id")
	f_reply=request.Form("f_reply")
	
	if f_reply="" then
	p3t ErrMsg("请输入回复内容")
	end if
	
	
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from p3t_feedback where f_id="&f_id,conn,1,3
	rs("f_reply")=f_reply
	rs.update
	rs.close
	set rs=nothing
	
	p3t "<script>alert('操作成功');parent.location.href='?';</script>"
	p3t_end
	
case "del"
	
	f_id=request.QueryString("f_id")
	if f_id="" then f_id=request.QueryString("val")
	conn.execute("delete from p3t_feedback where f_id in ("&f_id&")")	
	p3t "<script>parent.location.reload();</script>"
	p3t_end
	
case else
	call main_()
end select
footer()

sub main_()
%>
<script type="text/javascript" src="images/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$("table tr").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
});
function checkAll(){
	$("table input:checkbox").each(function(){
		this.checked = !this.checked; 
	});
}
function edit(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else if (val.split(",").length > 1)
		alert("请选择一条信息");
	else
		location.href = "?action=new&val=" + val;
}
function del(){
	var val = $("table input:checkbox:checked").map(function(data){return this.value}).get().join(",");
	if (val == "")
		alert("请至少选择一条信息");
	else
		if(confirm("您确定要删除这 " + val.split(",").length + " 条信息吗？"))yukiiak.location.href = "?action=del&val=" + val;
}
</script>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:del()"><img src="images/btn_del.gif" />删除</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
      <tr>
        <th width="20"><input type="checkbox" onclick="checkAll()" title="全选/反选" /></th>
        <th width="80">客户姓名</th>
        <th width="100">联系方式</th>
        <th>留言标题</th>
        <th width="100">留言时间</th>
        <th width="50">状态</th>
        <th width="80">基本操作</th>
      </tr>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from p3t_feedback order by f_id desc"
rs.open sql,conn,1,1
if rs.eof then 
p3t "<tr><td class=""center"" colspan=""10"">暂无信息</td></tr>"
else
PageSize=10
NowPage=Request.QueryString("Page")
If NowPage="" Then:NowPage=1:Else:NowPage=Int(NowPage):End If
rs.PageSize=PageSize
rs.AbsolutePage=NowPage
i=0:PageList=0
'分页
pages=getPages(rs,NowPage,PageSize,PageList,"?")
do while not rs.eof
%>
      <tr>
        <td class="center"><input name="f_id" type="checkbox" value="<%=rs("f_id")%>" /></td>
        <td><%=rs("f_name")%></td>
        <td><%=rs("f_contact")%></td>
        <td><%=rs("f_title")%></td>
        <td class="center"><%=formatDate(rs("f_date"),3)%></td>
        <td class="center"><%if rs("f_reply")<>"" then p3t "已回复" else p3t "未回复"%></td>
        <td class="center">
        	<a href="?action=new&f_id=<%=rs("f_id")%>">回复</a> |
            <a href="javascript:;" onclick="if(confirm('您确定要删除这条信息吗？'))yukiiak.location.href = '?action=del&f_id=<%=rs("f_id")%>';">删除</a>
        </td>
      </tr>
<%
i=i+1
if i=PageSize Then Exit Do  
rs.movenext
LOOP
end if
rs.close
set rs=nothing
%>
    </table>
    <div class="pager"><%=pages%></div>
</div>
<%
end sub
sub new_()
f_id=request.QueryString("f_id")
if f_id="" then f_id=request.QueryString("val")
if f_id="" or isnumeric(f_id)=false then f_id=0
if f_id<>0 then
set rs=conn.execute("select * from p3t_feedback where f_id="&f_id)
if not rs.eof then
f_name=rs("f_name")
f_contact=rs("f_contact")
f_title=rs("f_title")
f_content=rs("f_content")
f_reply=rs("f_reply")
end if
set rs=nothing
end if
%>
<div class="main_ctrl">
	<p><a>操作选项：</a>
    <a href="javascript:history.back()"><img src="images/btn_list.gif" />返回列表</a>
    </p>
</div>
<div class="main_body">
	<table cellspacing="1">
    <form name="form1" action="?action=submit" method="post" target="yukiiak">
      <tr>
        <th colspan="2" class="left"><%="回复留言："&f_id%></th>
      </tr>
      <tr>
        <td width="100" class="right">客户姓名</td>
        <td><%=f_name%></td>
      </tr>
      <tr>
        <td class="right">联系方式</td>
        <td><%=f_contact%></td>
      </tr>
      <tr>
        <td class="right">留言内容</td>
        <td><%=f_content%></td>
      </tr>
      <tr>
        <td class="right">回复内容</td>
        <td><textarea name="f_reply" cols="60" rows="6"><%=f_reply%></textarea></td>
      </tr>
      <tr>
        <td></td>
        <td>
			<input name="f_id" type="hidden" value="<%=f_id%>">
        	<input type="submit" name="submit" class="button" value=" 提 交 " />
        </td>
      </tr>
    </form>
    </table>
</div>
<%
end sub
%>