<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>附件管理</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
	</head>
	<body>
		<div class="container-fluid">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
				<li class="breadcrumb-item active">附件管理</li>
			</ol>
			<div class="card shadow-sm mb-3">
				<div class="card-body">
					<form name="forms" action="media_main.php" method="post">
						<input type="text" name="keyword" id="keyword" placeholder="请输入关键词" value="<?php echo $keyword?>" class="admin-input-lg mr-2">
						<select name="mediatype" class="admin-input-sm mr-2">
							<option value="0">文件类型</option>
							<option value="1" <?php if ($mediatype==1) echo "selected"?>>图片</option>
							<option value="2" <?php if ($mediatype==2) echo "selected"?>>FLASH</option>
							<option value="3" <?php if ($mediatype==3) echo "selected"?>>视频音频</option>
							<option value="4" <?php if ($mediatype==4) echo "selected"?>>其它附件</option>
						</select>
						<select name="membertype" class="admin-input-sm">
							<option value="0">会员组</option>
							<option value="1" <?php if ($membertype==1) echo "selected"?>>管理员</option>
							<option value="2" <?php if ($membertype==2) echo "selected"?>>外部会员</option>
						</select>
						<button type="submit"class="btn btn-success btn-sm">搜索</button>
						<a href="media_add.php" class="btn btn-success btn-sm">添加附件</a>
					</form>
				</div>
			</div>
			<div class="card shadow-sm">
				<div class="card-header">附件管理</div>
				<div class="card-body">
					<form name="form1">
						<div class="table-responsive">
							<table class="table table-borderless table-hover">
								<thead>
									<tr>
										<td scope="col">选择</td>
										<td scope="col">文件标题</td>
										<td scope="col">文件大小</td>
										<td scope="col">上传会员</td>
										<td scope="col">上传时间</td>
										<td scope="col">文件类型</td>
										<td scope="col">操作</td>
									</tr>
								</thead>
								<tbody>
									{dede:datalist}
									<tr>
										<td><input type="checkbox" name="aids" id="aids{dede:field.aid/}" value="{dede:field.aid/}"></td>
										<td><a href="{dede:field.url/}" title="{dede:field.url/}" target="_blank">{dede:field.title/}</a></td>
										<td>{dede:field.filesize function='GetFileSize(@me)'/}</td>
										<td>{dede:field.adminname function="UploadAdmin(@me,$fields['membername'])"/}</td>
										<td>{dede:field.uptime function="MyDate('Y-m-d H:i:s',@me)"/}</td>
										<td>{dede:field.mediatype function="MediaType(@me,$fields['url'])"/}</td>
										<td>
											<a href="media_edit.php?aid={dede:field.aid/}&dopost=edit" class="btn btn-light btn-sm"><i class="fa fa-pencil-square" title="修改"></i></a>
											<a href="media_edit.php?aid={dede:field.aid/}&dopost=del" class="btn btn-danger btn-sm"><i class="fa fa-trash" title="删除"></i></a>
										</td>
									</tr>
									{/dede:datalist}
									<tr>
										<td colspan="7">
											<a href="javascript:AllSel();" class="btn btn-success btn-sm">全选</a>
											<a href="javascript:NoneSel();" class="btn btn-success btn-sm">取消</a>
											<a href="javascript:DelSel();" class="btn btn-danger btn-sm">删除</a>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
					{dede:pagelist listsize='6'/}
				</div>
			</div>
		</div>
		<script>
			function getCheckboxItem() {
				var allSel = '';
				if (document.form1.aids.value) return document.form1.aids.value;
				for (i = 0; i < document.form1.aids.length; i++) {
					if (document.form1.aids[i].checked) {
						if (allSel == "")
							allSel = document.form1.aids[i].value;
						else
							allSel = allSel + "," + document.form1.aids[i].value;
					}
				}
				return allSel;
			}
			function AllSel() {
				for (i = 0; i < document.form1.aids.length; i++) {
					document.form1.aids[i].checked = true;
				}
			}
			function NoneSel() {
				for (i = 0; i < document.form1.aids.length; i++) {
					document.form1.aids[i].checked = false;
				}
			}
			function DelSel() {
				var nid = getCheckboxItem();
				if (nid == "") {
					alert("请选择项目");
					return;
				}
				location.href = "media_edit.php?dopost=del&ids=" + nid;
			}
		</script>
	</body>
</html>