<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="${ctx}/resources/css/main.css" type="text/css" />
<link rel='stylesheet' href='${ctx}/resources/css/easyui.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/easyui/icon.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/user-center-style.css' type='text/css' media='screen' />
<%@ include file="../common/top.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/swfupload/DBFhandlers.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/papers/batchPaper.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/jquery.mask.js"></script>
<title>系统备份还原</title>
<script type="text/javascript">
	$(function(){
		swfuFormal=new SWFUpload({
		    upload_url :"${ctx}/examSetting/restoreSys",
		    use_query_string : false,
		    
		   // File Upload Settings
		   file_size_limit : "1000 MB",  // 1000MB
		   file_types : "*.zip",
		   file_types_description : "所有文件",
		   file_upload_limit : "0",
		                   
		   file_queue_error_handler : fileQueueError,
		   file_dialog_complete_handler : restoreFileDialogComplete,//选择好文件后提交
		   upload_progress_handler : uploadProgress,
		   upload_error_handler : uploadError,
		   upload_success_handler : restoreUploadSuccess,
		   upload_complete_handler : restoreUploadComplete,
		
		   // Button Settings
		   button_image_url : '${ctx}/resources/images/SmallSpyGlassWithTransperancy_17x18.png',
		   button_placeholder_id : "formalPaperReturnBtn",
		   button_width: 370,
		   button_height: 18,
		   button_text : '<span class="button">上传还原文件</span><span style="color: red;">(提示:上传zip压缩包)</span>',
		   button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12px; } .buttonSmall { font-size: 10px; color: #ff0000;}',
		   button_text_top_padding: 0,
		   button_text_left_padding: 18,
		   button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
		   button_cursor: SWFUpload.CURSOR.HAND,
		   
		   // Flash Settings
		   flash_url : '${ctx}/resources/js/swfupload/swfupload.swf',
		
		   custom_settings : {
		       upload_target : "divFileProgressContainer"
		   },
		   // Debug Settings
		   debug: false  //是否显示调试窗口
		});
		
		
		
		
		$("#backupsBtn").on('click',function(){
			$.messager.confirm("操作提示", "因为系统还原需要输入相应的密码,所以建议系统备份之前下载好密码本!是否现在进行系统备份?", function (data) {
				if (data) {
					$(document).mask('正在备份，请稍等...');
					$.ajax({
						type : "POST",
						url : "${ctx}/examSetting/validateCodeBook",
						data : "",
						contentType : "application/json; charset=utf-8",
						dataType : "json",
						success : function(callback) {
							$(document).unmask();
							callback=eval(callback);
							if(callback.result=="success"){
								location.href="${ctx}/examSetting/backupSys";
							}else{
								$.messager.alert("操作提示", "备份失败,密码本密码已用完,请重新生成可用的密码本","error");
							}
			    		}
					}); 
				}
			});
		});
	});
</script>
</head>
<body>
<div class="container-fluid">
	<%@ include file="../common/header.jsp"%>
	
	<div class="row-fluid">
		<%@ include file="../common/sub_menu.jsp"%>
		
		<div class="span10">
			<ul class="breadcrumb">
	            <li class="active">备份还原</li>
            </ul>
			<div style="margin-top:10px;">
				<input type="button" style="width: 300px;height: 204px;" id="backupsBtn" value="系统备份"/>
				<input type="button" style="width: 300px;height: 204px;" id="restoreBtn" value="系统还原" onclick="$('#w5').window('open')"/>
			</div>
		</div>
	</div>
</div>
<%@ include file="../common/footer.jsp"%>

	<div id="w5" class="easyui-window" title="系统还原" data-options="modal:true,closed:true,iconCls:'icon-import'" style="width:480px;height:200px;padding:10px;">
		<div id="passwordDiv" style="display: none; padding-top: 20px;" align="center">
			<table style="font-size: 16px;">
				<tr>
					<td>随&nbsp;机 &nbsp;码:</td>
					<td><span id="randomCode" style="color: red"></span></td>
				</tr>
				<tr>
					<td>解压密码:</td>
					<td><input id="password" type="text" style="width: 191px;"/></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="button" value="还原" style="width: 72px;height: 30px;" id="continueRestoreSysBtn" onclick="restoreSys('${ctx}')"/></td>
				</tr>
			</table>
		</div>
	    <div  id="uploadDiv">
		    <div id="do_import_paper_button">
		        <div id="rukuPaperUploadMsg" ></div>
		        <span id="formalPaperReturnBtn"></span>
		    </div>
		    <div style="font-size: 14px;color: red; padding-top: 15px;">提示:上传的文件结构为:<br />zip包里包含一个随机码文本文件和一个加密的zip包,加密的zip包包含一个数据库脚本文件后缀为sql和加密的试卷包</div>
	    </div>
	</div>
</body>
</html>