<?php include $this->admin_tpl('meta', 'admin');?>
<title>选择素材 - YzmCMS内容管理系统</title>
</head>
<body>
<div class="page-container">
	<div> 
    <form action="<?php echo U(ROUTE_A);?>" method="get" id="search">
	 素材类型：
     <span class="select-box inline">
		<select name="media_type" class="select">
			<option value="99">全部素材</option>
			<option value="1" <?php if(isset($_GET['media_type']) && $_GET['media_type']=='1'){?> selected <?php }?>>永久素材</option>
			<option value="0" <?php if(isset($_GET['media_type']) && $_GET['media_type']=='0'){?> selected <?php }?>>临时素材</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="type" class="select">
			<option value="">所有类型</option>
			<option <?php if(isset($_GET['type']) && $_GET['type']=='news'){?> selected <?php }?> value="news">图文</option>	
			<option <?php if(isset($_GET['type']) && $_GET['type']=='image'){?> selected <?php }?> value="image">图片</option>
			<option <?php if(isset($_GET['type']) && $_GET['type']=='voice'){?> selected <?php }?> value="voice">语音</option>	
			<option <?php if(isset($_GET['type']) && $_GET['type']=='video'){?> selected <?php }?> value="video">视频</option>	
			<option <?php if(isset($_GET['type']) && $_GET['type']=='thumb'){?> selected <?php }?> value="thumb">缩略图</option>	
		</select>
	</span>
    <button name="dosubmit" class="btn btn-success radius" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
    <a href="<?php echo U(ROUTE_A);?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
	 </form>
	</div>
  <form method="post" action="" id="myform" class="mt-10">
  <table class="table table-border table-bg table-hover">
    <thead>
      <tr class="text-c">
        <th width="25">选择</th>
		<th>素材</th>
		<th>素材类型</th>
		<th>类型</th>
		<th>上传时间</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="radio" name="media_id" value="<?php echo $val['media_id']?>"></td>
			<td><?php if($val['type']=='image' || $val['type']=='thumb'){echo '<img src="'.$val['filepath'].$val['filename'].'" title="'.$val['originname'].'" height="20">';}elseif($val['type']=='news'){echo $val['url'];}else{echo '<span title="'.$val['originname'].'">'.$val['filename'].'</span>';}?></td>
			<td><?php echo $val['media_type'] ? '永久素材' : '临时素材';?></td>
			<td><?php echo $types[$val['type']];?></td>
			<td><?php echo date('Y-m-d H:i:s', $val['created_at'])?></td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
  <input class="dosubmit w_100 btn-primary radius mt-10" name="dosubmit" type="button" onclick="dosub()" value="确定">
  </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">

	function dosub(){
		var media_id = $("input[type='radio']:checked").val();
		if(media_id == undefined){
			layer.alert('请选择素材！');		
			return false;
		}
		
		var index = parent.layer.getFrameIndex(window.name);
		parent.$("#media_id").val(media_id);
		parent.layer.close(index);
	}
</script> 

</body>
</html>