<?php 
$this->display(tpl('head',true)); 
?>
<style>
	.layui-table td, .layui-table th {
	    position: relative;
	    padding: 9px 5px;
	    min-height: 20px;
	    line-height: 20px;
	    font-size: 14px;
	    text-align: center;
	}
	.layui-table td:nth-child(2), .layui-table th:nth-child(2){
	    text-align:left;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  	<legend>广告管理</legend>
</fieldset>
<table class="layui-table" cellspacing="0" cellpadding="0" border="0"  lay-filter="demoEvent">
	<thead>
		<tr>
			<th>ID</th>
			<th>广告名称</th>
			<th>广告类型</th>
			<th>是否出售</th>
			<th>已失效</th>
			<th>有效的</th>
			<th>创建时间</th>
			<th>广告代码</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
<?php 
foreach($data AS $row){
	$row['posttime']=date('Y-m-d H:i:s',$row['posttime']);
	if($row['ad_type']=="images"){
		$row['ad_type']="图片类型";
	}elseif($row['ad_type']=="text"){
		$row['ad_type']="文字类型";
	}else{
		$row['ad_type']="代码类型";
	}
	$adurl=WEBURL.'/'.P_MODULE.'/index/index/tag/'.$row['tag'].C('html');
	$ad=htmlentities("<script src='$adurl'></script>");
?>
		<tr>
			<td><?php echo $row['id'] ?></td>
			<td><?php echo $row['name'] ?></td>
			<td><?php echo $row['ad_type'] ?></td>
			<td><?php echo $row['is_sell'] ? '<span class="green">是</span>' : '<span class="red">否</span>' ?></td>
			<td><?php echo $row['invalid'] ?></td>
			<td><?php echo $row['effective'] ?></td>
			<td><?php echo $row['posttime'] ?></td>
			<td><input type="text" class="layui-input" value="<?php echo $ad ?>" /></td>
			<td>
				<a class="layui-btn layui-btn-sm layui-btn-warm" href="<?php echo admin_plugin_url ?>/index/edit/id_<?php echo $row['id'] ?>">编辑</a>
				<a class="layui-btn layui-btn-sm layui-btn-danger" href="<?php echo admin_plugin_url ?>/index/del/id_<?php echo $row['id'] ?>">删除</a>
			</td>
		</tr>
<?php } ?>
	</tbody>
</table>
<div class="page">
	<?php echo $Get_Page ?>
</div>
<script>
	layui.use('table', function() {
	});
</script>
<?php 
$this->display(tpl('foot',true)); 
?>

