<?php include $this->admin_tpl('meta','admin');?>
<title>评论管理 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 评论管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
  <div> 
		<form action="<?php echo U('search');?>" method="get">
		 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
		 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
		 <input type="hidden" value="search" name="a">
		 <span class="select-box inline">
			<select name="modelid" class="select">
			<option value="0">所有模型</option>
			<?php 
				foreach($modelinfo as $val){
					$str = $val['modelid']==$modelid ? 'selected' : '';
					echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
			</select>
		</span>	
		发布时间：<input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
    	 至 <input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d H:i:s'); ?>">			 
		 <span class="select-box inline">
			<select name="status" class="select">
				<option value="99">状态</option>
				<option <?php if(isset($_GET["status"]) && $_GET["status"]=='0'){echo "selected";} ?> value="0">未审核</option>
				<option <?php if(isset($_GET["status"]) && $_GET["status"]=='1'){echo "selected";} ?> value="1">通过审核</option>
			</select>
		</span>
		 <span class="select-box inline">
			<select name="type" class="select">
				<option <?php if(isset($_GET["type"]) && $_GET["type"]=='1'){echo "selected";} ?> value="1">原文标题</option>
				<option <?php if(isset($_GET["type"]) && $_GET["type"]=='2'){echo "selected";} ?> value="2">评论内容</option>		
				<option <?php if(isset($_GET["type"]) && $_GET["type"]=='3'){echo "selected";} ?> value="3">发布人</option>		
			</select>
		</span>
		 <input type="text" name="searinfo"  class="input-text" style="width:170px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
		 <a href="<?php echo U('init');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
		 </form>	
  </div>
	<div class="cl mt-15 tb-top"> <span class="l">
		<a href="javascript:;" onclick="adopt()" class="btn btn-primary radius"><i class="yzm-iconfont yzm-icontongguo"></i> 通过审核</a> 
		<a href="javascript:;" onclick="yzm_dels('id', 1)" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>
		<a href="javascript:;" onclick="yzm_confirm('<?php echo U('del_all');?>', '确定要删除所有未审核的评论吗？', 1)" class="btn btn-warning radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 删除所有未审核</a>
	</span>
	</div>
	<form method="post" action="<?php echo U('del');?>" id="myform">
	<table class="table table-border table-bg table-hover yzm-table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox"></th>
				<th width="120">发布人<?php echo field_order('username');?></th>
				<th>评论内容</th>
				<th width="260">原文标题<?php echo field_order('title');?></th>	
				<th width="135">发布时间<?php echo field_order('inputtime');?></th>	
				<th width="100">发布IP<?php echo field_order('ip');?></th>	
				<th width="70">审核<?php echo field_order('status');?></th>	
			</tr>
		</thead>
		<tbody>
			<?php 
			   foreach($data as $val){
				if(strpos($val['content'], 'original_comment') !==false){
					$pos = strrpos($val['content'], '</a>');
					$val['content'] = substr($val['content'], $pos+7);
				}			   
			 ?>
			<tr class="text-c">
				<td><input type="checkbox" value="<?php echo $val['id']?>" name="id[]"></td>
				<td><?php echo $val['username']?></td>
				<td><?php echo $val['content']?></td>
				<td><?php echo '<a href="'.$site_url.$val['url'].'" title="'.$val['title'].'" target="_blank">'.str_cut($val['title'],66).'</a>'; ?></td>				
				<td><?php echo date("Y-m-d H:i:s",$val['inputtime'])?></td>				
				<td><?php echo $val['ip']?></td>				
				<td>
					<?php if($val['status']){ ?>
					<span class="yzm-status-enable" data-field="status" data-id="<?php echo $val['id']?>" onclick="yzm_change_status(this,'<?php echo U('adopt');?>')"><i class="yzm-iconfont">&#xe81f;</i>是</span>
					<?php }else{ ?>
					<span class="yzm-status-disable" data-field="status" data-id="<?php echo $val['id']?>" onclick="yzm_change_status(this,'<?php echo U('adopt');?>')"><i class="yzm-iconfont">&#xe601;</i>否</span>
					<?php } ?>
				</td>				
			</tr>
			<?php 
			   }		 
			?>	
		</tbody>
	</table>
	<?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
	</form>
	<div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer','admin');?> 
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">
	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);

	//通过审核
	function adopt(){
		if ($("input[name='id[]']:checked").length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}
		layer.msg('正在操作中...', { icon: 16, shade: 0.21, time:false });
	    $.ajax({
			type: 'POST',
			url: '<?php echo U('adopt');?>', 
			data: $("#myform").serialize(),
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:1000}, function(){
						location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
			}
	    })
	}
</script>	
</body>
</html>