<!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>
<title>刀客建站系统   管理中心  - 留言列表</title>
<%{include file="header.html"}%>
</head>
<body>
<style type="text/css">
#page-link {
	margin-right:10px;
}
#page-link a{
	background-color:#FFFFFF;
	border:1px solid #DDEEF2;
	margin:0 2px;
	padding:0 5px;
	text-decoration:none;
}
#page-link b{
	background-color:#999999;
	border			:1px solid #999999;
	color				:	#FFFFFF;
	margin:0 2px;
	padding	:0 5px;
}
#page-link a:hover  {
		background-color:#0075c2;
		color:#ffffff
}


</style>
<h1>
<span class="action-span1"><a href="index.php?act=index.default_page">刀客建站系统   管理中心 </a>  -  留言列表</span>
<span style='float:right;margin-right:10px;'><img src='images/top_help.gif'><a href="http://sitepub.cn/help"> 帮助 </a></span>
<span style='float:right;margin-right:10px;'><img src='images/top_forum.gif'><a href="http://bbs.sitepub.cn"> 论坛 </a></span>
<div style="clear:both"></div>
</h1>

<div class="form-div">
  <form action="" method='GET' name="searchForm">
		<input type='hidden' name='act' value='<%{$smarty.get.act}%>'>
	 	<img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />

    留言类型<select name="type" >
	 	<option value="0">所有留言类型</option>
		<%{foreach from=$out.leave_word_type item=v key=k}%>
			<option value="<%{$k}%>" <%{if $smarty.get.type==$k}%>selected=true<%{/if}%> ><%{$v|escape:html}%></option>
		<%{/foreach}%>
		</select>
	&nbsp;&nbsp;状态
	<select name='state' >
		<option <%{if $smarty.get.state==0}%> selected=true<%{/if}%> value=0>未读</option>
		<option <%{if $smarty.get.state==1}%> selected=true<%{/if}%> value=1>已读</option>
		<option <%{if $smarty.get.state==-1}%> selected=true<%{/if}%> value='-1'>全部</option>
	</select>

		&nbsp;&nbsp;
    留言人姓名<input name="name" size="15"  value='<%{$smarty.get.name|escape:html}%>' /> &nbsp;&nbsp;
    留言email<input name="email" size="15"  value='<%{$smarty.get.email|escape:html}%>' /> &nbsp;&nbsp;
    <input type="submit" value=" 搜索 " class="button" />
  </form>
</div>
<div class="leave_word_content_background" id='leave_word_content_background'></div>
<div class="list-div" id="listDiv">
	<%{if $out.leave_word_res}%>
		<table >
			<tr>
				<th>留言人姓名</th>		
				<th>留言人Email</th>		
				<th>留言内容</th>		
				<th>附件</th>		
				<th>时间</th>	
				<th>操作</th>	
			</tr>
			<%{foreach from=$out.leave_word_res item=v key=k}%>
		 		<tr style='background-color:#FFF;' onmouseover='this.style.backgroundColor="";' onmouseout='this.style.backgroundColor="#FFF";'>
					<td><%{$v.name}%></td>	
					<td><%{$v.email}%></td>	
					<td><a href="javascript:void(0);" style='float:right;' onclick='display_content(<%{$v.leave_word_id}%>,this)'>查看全部</a><%{$v.content|sub_str:40}%></td>	
					<td><%{if $v.attachment}%><a href="<%{$v.attachment_link}%>"><%{$v.attachment_name}%></a><%{else}%>无<%{/if}%></td>	
					<td><%{$v.time|date_format:"%Y-%m-%d %H:%I:%S"}%></td>	
					<td><%{if $v.state==1}%><a href="javascript:void(0);" style='color:blue' onclick='change_state(<%{$v.leave_word_id}%>,0,this)'>已读</a><%{else}%><a href="javascript:void(0);" style='color:red' onclick='change_state(<%{$v.leave_word_id}%>,1,this)'>未读</a><%{/if}%> &nbsp;&nbsp;<a href="mailto:<%{$v.email}%>">回复</a>
					&nbsp;&nbsp;<a href="javascript:void();" onclick='del_leave_word(<%{$v.leave_word_id}%>,this)'>删除</a>
					</td>	
				</tr>
				<div id='leave_word_content_id_<%{$v.leave_word_id}%>' class="leave_word_content">
					<div class="l_title">
						<span class="close" onclick='close_content(<%{$v.leave_word_id}%>)' >X</a></span>
						<p><span class="n">名称</span><span class="v"><%{$v.name|escape:html}%></span></p>
						<p><span class="n">Email</span><span class="v"><%{$v.email}%></span></p>
						<p><span class="n">附件</span><span class="v"><%{if $v.attachment}%><a href="<%{$v.attachment_link}%>"><%{$v.attachment_name}%></a><%{else}%>无<%{/if}%></span></p>
						<p><span class="n">留言时间</span><span class="v"><%{$v.time|date_format:"%Y-%m-%d %H:%I:%S"}%></span></p>
						<p><span class="n">留言内容</span><span class="v"><div class="content"><%{$v.content|escape:html|nl2br}%></div></p>
						
					</div>	
				</div>
			<%{/foreach}%>
		</table>
<table id="page-table" >
  <tr style='background-color:#FFF;' >
    <td align="right" nowrap="true">
            <div id="turn-page">
        共 <span id="totalRecords"><%{$out.page_arr.total}%></span>条留言 
        <span id="page-link">
		  <%{foreach from=$out.page_arr.thepage item=v key=k}%>	
				<%{if $k==$out.page_arr.page}%>	
					<b><%{$k}%></b>			
				<%{else}%>
				<a href="<%{$v}%>"><%{$k}%></a>			
				<%{/if}%>
			<%{/foreach}%>	
		  </span>
      </div>

    </td>
  </tr>
</table>
	<%{else}%>
	<div align='center'> 暂无留言</div>
	<%{/if}%>
</div>
<script>
function display_content(id,obj)
{
	var offset		=		$(obj).offset();
	var top			=		offset.top;
	var left			=		$(document).width()/2-($("#leave_word_content_id_"+id).width())/2;
	$("#leave_word_content_id_"+id).css({top:top+"px",left:left+"px"});
	$("#leave_word_content_id_"+id).show();
	$("#leave_word_content_background").css({height:$(document).height()});
	$("#leave_word_content_background").show();

}

function close_content(id)
{
	$("#leave_word_content_id_"+id).hide();
	$("#leave_word_content_background").hide();
}
var D=document;
	function F(n){
		var u,r,c,x;
		if(n.nodeType==3){
			u=n.data.search(/\S{10}/);
			if(u>=0) {
				r=n.splitText(u+10);
				n.parentNode.insertBefore(D.createElement("WBR"),r);
			}
		}
		else if(n.tagName != "STYLE" && n.tagName != "SCRIPT"){
			for (c=0;x=n.childNodes[c];++c){
				F(x);
			}
		}
	}
	F(D.body);


function change_state(id,state,obj)
{
	$.ajax({
	url			:	"index.php?act=leave_word.change_state&leave_word_id="+id+"&state="+state+"&is_ajax=1",
	dataType		:	"json",
	type			:	"GET",
	success		:	function(json){
				if(json=='ok'){
					if(state==1){
						$(obj).text('已读');
						obj.onclick			=		function(){change_state(id,0,obj);}
						obj.style.color	=		'blue';	
					}else if(state==0){
						$(obj).text('未读');
						obj.onclick		=		function(){change_state(id,1,obj);}
						obj.style.color	=		'red';	
					}	
				}else{
					alert('标记留言状态失败');
				}	
	}
	});	
}
function del_leave_word(id,obj)
{
	if(!window.confirm('确定删除该留言?')){
		return ;
	}		
	$.ajax({
		url			:	"index.php?act=leave_word.del_leave_word&leave_word_id="+id+"&is_ajax=1",
		dataType		:	"json",
		type			:	"GET",
		success		:	function(json){
			if(json=='ok'){
				alert('删除成功');
				$(obj).parent().parent().remove();
			}else{
				alert('删除失败');
			}
		}
	});

}


</script>

</body>
</html>


