<?php $this->display(tpl('head',true)); ?>
<style>
.order .layui-input {
    padding-left: 0;
}
.layui-form-checkbox {
    height: 20px;
    line-height: 20px;
    padding-right: 20px;
}
.layui-form-checkbox i {
    width: 25px;
    font-size: 18px;
}
.layui-form{
	
}
#add_category{
	margin-left: 30px;
}
#add_category span{
	float: left;
	line-height: 40px;
	color: #666;
}
.add_category{
	width: 160px;
	float: left;
	margin-right: 10px;
}
.add_category_button{
	float: left;
	height: 35px;
	margin-left: 10px;
}
#add_category .layui-form-select{
	width: 20%;
	float: left;
}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>专题分类管理</legend>
</fieldset>
<div class="layui-row">
	<form class="layui-form" id="add_category" method="post">
		<span>分类名称：</span>
		<input type="text" class="layui-input add_category" placeholder="请输入需要创建的分类名称" name="name" />
		<span>所属分类：</span>
		<select name="sid">
			<option>不选择将成为一级分类</option>
			<?php echo $special_list ?>
		</select>
		<input type='hidden' name="step" value="post" />
		<button  class="layui-btn layui-btn-sm layui-btn-warm add_category_button">添加分类</button>
	</form>
</div>

<form class="layui-form" id="from" method="post" action="/admin/special/batch_category_action">
	<table class="layui-table">
		<thead>
			<tr>
				<th width="20"></th>
				<th width="50">排序</th>
				<th width="50">Id</th>
				<th>名称</th>
				<th>目录</th>
				<th style="text-align: center" width="70">记录集</th>
				<th width="260" style="text-align: center">操作</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ($data AS $row){ 
				$curl=U(['special'=>'category','sid'=>$row[sid]]);
			?>
			<tr>
				<td>
					<input name="iddb[]" value="<?php echo $row[sid] ?>" type="checkbox">
				</td>
				<td class="order">
					<input class="layui-input center" name="reorder[<?php echo $row[sid] ?>]" value="<?php echo $row[reorder] ?>" type="text">
				</td>
				<td><?php echo $row[sid] ?></td>
				<td>
					<?php echo $row[levels] ?><a class="onloading" target="_blank" href=" <?php echo  $curl  ?>"><?php echo $row[name] ?></a>
				</td>
				<td><?php echo $row[dir_name] ?></td>

				<td style="text-align: center"><a class="onloading" href="/admin/special/alllist/sid_<?php echo $row[sid] ?>"><?php echo $row[num] ?></a></td>
				<td class="center">
					<a class="layui-btn layui-btn-sm " href="<?php echo $curl ?>" target="_blank"> <i class="fa fa-send"></i> 访问</a>					
					<a class="layui-btn layui-btn-sm layui-btn-warm" href="/admin/special/category_edit/sid_<?php echo $row[sid] ?>"> <i class="fa fa-edit"></i> 修改</a>
					<a class="layui-btn layui-btn-sm layui-btn-danger" href="/admin/special/category_del/sid_<?php echo $row[sid] ?>"> <i class="fa fa-edit"></i> 删除</a>
				</td>
			</tr>
			<?php } ?>			
		</tbody>
	</table>
	<div class="button">
		<button class="layui-btn layui-btn-sm layui-btn-warm" onclick="return all_checkbox_check('1')">全选</button>
		<button class="layui-btn layui-btn-sm layui-btn-warm" onclick="return all_checkbox_check('-1')">反选</button>
		<button class="layui-btn layui-btn-sm layui-btn-warm" onclick="return all_checkbox_check('0')">取消选择</button>
		<button class="layui-btn layui-btn-sm layui-btn-danger" name="step" value="reorder" >批量排序</button>
		<button class="layui-btn layui-btn-sm layui-btn-danger" name="step" value="pinyin" >批量伪静态目录</button>
	</div>
</form>
<script>
	function all_checkbox_check(type) {
		if(document.getElementsByClassName('layui-form-checkbox') != undefined && document.getElementsByClassName('layui-form-checkbox').length > 0) {
			var class_box = document.getElementsByClassName('layui-form-checkbox');
			var ids = document.getElementsByName('iddb[]');
			if(type == "1") { //全选
				for(var i = 0; i < class_box.length; i++) {
					$(ids[i]).prop("checked", true);
					$(class_box[i]).addClass("layui-form-checked");
				}
			} else if(type == "0") { //全不选
				for(var i = 0; i < class_box.length; i++) {
					$(ids[i]).prop("checked", false);
					$(class_box[i]).removeClass("layui-form-checked");
				}
			} else if(type == "-1") { //反选
				for(var i = 0; i < class_box.length; i++) {
					if(ids[i].checked == true) {
						$(ids[i]).prop("checked", false);
					} else {
						$(ids[i]).prop("checked", true);
					}
					$(class_box[i]).toggleClass("layui-form-checked");
				}
			}
		}
		return false;
	}
	layui.config({
		version: 'NOWTIME' //为了更新 js 缓存，可忽略
	});
	layui.use(['form','layer'], function(){
	  	var $ = layui.jquery
	  	,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
	
	   	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
		var form = layui.form;
		
	});
</script>
<?php $this->display(tpl('foot',true)); ?>   
