<!DOCTYPE html>
<html>
	<head>
		<meta charset="<?php echo $cfg_soft_lang; ?>">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>数据还原</title>
		<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/web/css/admin.css">
		<script>
			//获得选中文件的数据表
			function getCheckboxItem() {
				var myform = document.form1;
				var allSel = "";
				if (myform.bakfile.value) return myform.bakfile.value;
				for (i = 0; i < myform.bakfile.length; i++) {
					if (myform.bakfile[i].checked) {
						if (allSel == "")
							allSel = myform.bakfile[i].value;
						else
							allSel = allSel + "," + myform.bakfile[i].value;
					}
				}
				return allSel;
			}
			//反选
			function ReSel() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					if (myform.bakfile[i].checked) myform.bakfile[i].checked = false;
					else myform.bakfile[i].checked = true;
				}
			}
			//全选
			function SelAll() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					myform.bakfile[i].checked = true;
				}
			}
			//取消
			function NoneSel() {
				var myform = document.form1;
				for (i = 0; i < myform.bakfile.length; i++) {
					myform.bakfile[i].checked = false;
				}
			}
			function checkSubmit() {
				var myform = document.form1;
				myform.bakfiles.value = getCheckboxItem();
				return true;
			}
		</script>
	</head>
	<body>
		<table width="99%" cellpadding="3" cellspacing="1" align="center" class="table maintable mt-3 mb-3">
			<tr>
				<td height="26" colspan="4" background="../static/web/img/tbg.gif">
					<table width="96%" cellspacing="1" cellpadding="1" class="table table-borderless">
						<tr>
							<td width="30%" style="padding-left:10px">数据还原</td>
							<td width="70%" align="right">
								<a href="sys_data.php" class="btn btn-success btn-sm">数据备份</a>
								<a href="sys_sql_query.php" class="btn btn-success btn-sm">SQL命令行工具</a>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<form name="form1" onSubmit="checkSubmit()" action="sys_data_done.php" method="post" target="stafrm">
				<input type="hidden" name="dopost" value="redat">
				<input type="hidden" name="bakfiles" value="">
				<tr>
					<td height="26" colspan="4">发现的备份文件：<?php if(count($filelists)==0) echo " 没找到任何备份文件 "; ?></td>
				</tr>
				<?php
				for($i=0;$i<count($filelists);$i++)
				{
					echo "<tr  align='center' height='26'>";
				$mtd = "<td width='10%'><input name='bakfile' id='bakfile' type='checkbox' class='np' value='".$filelists[$i]."' checked='1'></td><td width='40%'>{$filelists[$i]}</td>";
				echo $mtd;
				if(isset($filelists[$i+1]))
				{
					$i++;
					$mtd = "<td width='10%'><input name='bakfile' id='bakfile' type='checkbox' class='np' value='".$filelists[$i]."' checked='1'></td><td width='40%'>{$filelists[$i]}</td>";
					echo $mtd;
				} else {
					echo "<td></td><td></td>";
				}
					echo "</tr>";
				}
				?>
				<tr>
					<td height="26" bgcolor="#F8FCF1" colspan="4">
						<input name="structfile" type="checkbox" class="np" id="structfile" value="<?php echo $structfile?>" checked="1">&nbsp;还原表结构信息（<?php echo $structfile?>）
						<input name="delfile" type="checkbox" class="np" id="delfile" value="1">&nbsp;还原后删除备份文件&nbsp;
						<button name="b1" type="button" id="b1" onClick="SelAll()" class="btn btn-success btn-sm">全选</button>
						<button name="b2" type="button" id="b2" onClick="ReSel()" class="btn btn-success btn-sm">反选</button>
						<button name="b3" type="button" id="b3" onClick="NoneSel()" class="btn btn-success btn-sm">取消</button>
						<button type="submit" name="Submit" class="btn btn-success btn-sm">还原</button>
					</td>
				</tr>
			</form>
			<tr>
				<td height="26" colspan="4">结果：</td>
			</tr>
			<tr>
				<td height="360" colspan="4">
					<iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe>
				</td>
			</tr>
		</table>
	</body>
</html>