<?php include $this->admin_tpl('meta', 'admin');?>
<title><?php echo L('link');?> - 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> <?php echo L('link');?> <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(ROUTE_A);?>" method="get" id="search">
	<input type="hidden" name="m" value="<?php echo ROUTE_M;?>" >
	<input type="hidden" name="c" value="<?php echo ROUTE_C;?>" >
	<input type="hidden" name="a" value="<?php echo ROUTE_A;?>" >
     添加时间：<input type="text" class="input-text laydate-icon" style="width:175px;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:175px;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 value="1" <?php if(isset($_GET['status']) && $_GET['status']=='1'){?> selected <?php }?>>已审核</option>
			<option value="0" <?php if(isset($_GET['status']) && $_GET['status']=='0'){?> selected <?php }?>>未审核</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="linktype" class="select">
			<option value="99">链接类型</option>
			<option value="1" <?php if(isset($_GET['linktype']) && $_GET['linktype']=='1'){?> selected <?php }?>>图片链接</option>
			<option value="0" <?php if(isset($_GET['linktype']) && $_GET['linktype']=='0'){?> selected <?php }?>>文字链接</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="type" class="select">
		<option <?php if(isset($_GET['type']) && $_GET['type']=='1'){?> selected <?php }?> value="1">网站名称</option>
		<option <?php if(isset($_GET['type']) && $_GET['type']=='2'){?> selected <?php }?> value="2">网站地址</option>
		<option <?php if(isset($_GET['type']) && $_GET['type']=='3'){?> selected <?php }?> value="3">站长姓名</option>	
		<option <?php if(isset($_GET['type']) && $_GET['type']=='3'){?> selected <?php }?> value="4">站长邮箱</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 class="btn btn-primary radius" onclick="yzm_open('<?php echo L('add_link');?>','<?php echo U('add');?>','750','520')"  href="javascript:;"><i class="yzm-iconfont yzm-icontianjia"></i> <?php echo L('add_link');?></a>
	  <a href="javascript:;" onclick="mydel()" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>  
	  </span> 
	  <span class="r">共有数据：<strong><?php echo $total?></strong> 条</span> 
  </div>
  <form method="post" action="<?php echo U('order');?>" 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>排序<?php echo field_order('listorder');?></th>
		<th>网站名称</th>
		<th>网站地址</th>
		<th>网站logo</th>
		<th>站长姓名</th>
		<th>链接分类<?php echo field_order('typeid');?></th>
		<th>链接类型<?php echo field_order('linktype');?></th>
		<th>添加时间<?php echo field_order('addtime');?></th>
		<th>审核<?php echo field_order('status');?></th>
		<th>管理操作</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" value="<?php echo $val['id']?>" name="id[]"></td>
			<td><input type="text" class="input-text listorder" name="listorder[]" value="<?php echo $val['listorder']?>"><input type="hidden" name="order_id[]" value="<?php echo $val['id']?>"></td>
			<td><a href="<?php echo $val['url']?>" target="_blank"><?php echo $val['name']?></a></td>
			<td><a href="<?php echo $val['url']?>" target="_blank"><?php echo $val['url']?></a></td>
			<td>
				<?php if(!$val['logo']){ 
					echo '无图片'; 
				} else {
					echo '<img src="'.$val['logo'].'" title="点击查看大图" onclick="yzm_show_img(\''.$val['logo'].'\',800,500)" style="height:35px;cursor:pointer;">';
				}
				?>
			</td>
			<td>
				<?php echo $val['username'] ? $val['username'] : '无';?>
				<?php 
					if($val['email']) { echo '<br>( '.$val['email'].' )';}
				?>
			</td>
			<td><?php if($val['typeid'] ==0 ) echo '默认'; else if($val['typeid'] ==1 ) echo '首页'; else if($val['typeid'] ==2 ) echo '列表页'; else if($val['typeid'] ==3 ) echo '内容页';?></td>
			<td><?php echo $val['linktype'] ? '图片链接' : '文字链接';?></td>
			<td><?php echo date('Y-m-d H:i:s', $val['addtime'])?></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>
			<td><a title="编辑" href="javascript:;" onclick="yzm_open('<?php echo L('edit_link');?>','<?php echo U('edit',array('id'=>$val['id']));?>','750','520')" style="text-decoration:none"><i class="yzm-iconfont yzm-iconbianji2"></i></a> <a title="删除" href="javascript:;" onclick="yzm_confirm('<?php echo U('del_one',array('id'=>$val['id']));?>', '确定要删除【<?php echo $val['name'];?>】吗？')" class="ml-5" style="text-decoration:none"><i class="yzm-iconfont yzm-iconshanchu2 f14"></i></a></td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
  <div class="cl mt-5"> <span class="l"><input class="orderbutton btn-primary radius" name="dosubmit" value="排序" type="submit"></span></div>
  </form>
  <div id="page" style="margin-top:5px;"><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>
<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 mydel(){
		if ($("input[name='id[]']:checked").length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}	
		
		layer.confirm('确认要删除吗？', {title:"操作提示"}, function(index){
			document.getElementById('myform').action='<?php echo U('del');?>';
			document.getElementById('myform').submit();
		});	
		
	}

	//排序
	function mylistorder(){	
		document.getElementById('myform').action='<?php echo U('order');?>';
		document.getElementById('myform').submit();
	}
</script>
<?php include $this->admin_tpl('footer', 'admin');?>
</body>
</html>