<?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_list');?>" 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_list" name="a">
		 原名称：<input type="text" name="originname" placeholder="附件原名" style="width:135px" class="input-text" value="<?php if(isset($_GET['originname'])) echo $_GET['originname'];?>">
		 上传者：<input type="text" name="username" placeholder="上传者" style="width:135px" class="input-text" value="<?php if(isset($_GET['username'])) echo $_GET['username'];?>">
		 上传时间：<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'); ?>">
		 附件类型：<input type="text" name="fileext" placeholder="如：jpg" style="width:135px" class="input-text" value="<?php if(isset($_GET['fileext'])) echo $_GET['fileext'];?>"><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="yzm_dels('id', 1)" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>
	  <a href="javascript:;" onclick="yzm_count()" class="btn btn-success radius"><i class="yzm-iconfont yzm-iconchart-line"></i> 附件统计</a>
	  </span> 
	  <span class="r">共有数据：<strong><?php echo $total?></strong> 条</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>ID<?php echo field_order('id');?></th>
		<th>模块名称<?php echo field_order('module');?></th>
		<th>附件预览</th>
		<th>附件原名</th>
		<th>附件大小<?php echo field_order('filesize');?></th>
		<th>上传时间<?php echo field_order('uploadtime');?></th>
		<th>上传者<?php echo field_order('username');?></th>
		<th>上传者IP<?php echo field_order('uploadip');?></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><?php echo $val['id']?></td>
			<td><?php echo $val['module'] ? $val['module'] : '/' ?></td>
			<td>
				<?php 
				$src = $val['isimage'] ? $val['filepath'].$val['filename'] : file_icon($val['filename']); 
				$click = $val['isimage'] ? 'onclick="yzm_show_img(\''.$src.'\',800,500)"' : 'onclick="yzm_open(\'附件预览\',\''.U('public_att_view',array('id'=>$val['id'])).'\',800,500)"';
				?>
				 <a title="点击预览" href="javascript:;" <?php echo $click;?> style="text-decoration:none"><img src="<?php echo $src;?>" height="30" style="max-width:100px" onmouseover="yzm_img_browse(this, '<?php echo $src;?>')" onmouseout="layer.closeAll('tips')"></a>
			</td>
			<td>
				<?php if($val['contentid']){ ?>
				<i class="yzm-iconfont yzm-iconlianjie" title="关联内容<?php echo $val['contentid']?>"></i> 
				<?php } ?>
				<?php echo !empty($val['originname']) ? $val['originname'] : $val['filename']?>
			</td>
			<td><?php echo sizecount($val['filesize'])?></td>
			<td><?php echo date('Y-m-d H:i:s', $val['uploadtime'])?></td>
			<td><?php echo $val['username']?></td>
			<td><?php echo $val['uploadip']?></td>
			<td>
				<a title="点击预览" href="javascript:;" <?php echo $click;?> class="yzm-box-img btn-primary"><i class="yzm-iconfont yzm-iconyulan"></i> 预览</a> 
				<a title="删除" href="javascript:;" onclick="yzm_del('<?php echo U('del_one',array('id'=>$val['id']));?>', 1)" class="yzm-box-img btn-danger ml-5"><i class="yzm-iconfont yzm-iconshanchu2"></i> 删除</a>
			</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 yzm_count(){
			layer.msg('正在统计中……', {icon:16, time:0, shade:0.3});
			$.ajax({
	        type: "GET",
	        url: "<?php echo U('public_count');?>", 
		    	dataType: "json", 
	        success: function (msg) {
	        	if(msg.status == 1){
	        		var message = '文件总计：'+msg.data.total+'个（'+msg.data.total_size+'）<br>图像文件：'+msg.data.img_total+'个（'+msg.data.img_size+'，空间占比：'+msg.data.img_proportion+'%）<br>其他文件：'+msg.data.att_total+'个（'+msg.data.att_size+'，空间占比：'+msg.data.att_proportion+'%）';
	        		layer.alert(message, {title:"附件统计"});
	        	}else{
	        		layer.msg(msg.message, {icon:2,time:2500});
	        	}
	        }
	    })
	}
</script>
</body>
</html>