<?php
include("CheckSession.php");
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="馬戲團" />
<title>馬戲團</title>
<Script Language="javascript" src="control/calendar.js"></Script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css"/>
<style type="text/css">
body {
	font: 13px Arial, Helvetica, Sans-serif;
}
</style>
</head>

<?php

require_once("class/DBConfig.php");
require_once("class/DBOperation.php");

$CUser = "";
if($_POST["AId"] == null || $_POST["AId"] == "")
{
	$CUser = $_SESSION['userId'];
}
else
{
	$CUser = $_POST["AId"];
}

$CMemo = $_POST["CMemo"];

$db = new DBOperation();

$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);

$querySql = "select * from AdminUser where AId = ".$CUser." and AFlag = '1'";

if($querySql != "")
{
	$db->query($querySql);
	$myrow = $db->fetch_array();
	$AName = $myrow['AName'];
}

?>
<SCRIPT language="JavaScript">
function validateForm(objThisUi) 
{
	return true;  
}
</SCRIPT>
<script type="text/javascript">
		<?php $timestamp = time();?>
		var img_id_upload=new Array();
		var i=0;
		$(function() {
			$('#file_upload').uploadify({
			  'auto'     : false,//关闭自动上传
			  'removeTimeout' : 1,//文件队列上传完成1秒后删除
			  'cancelImg': 'uploadify-cancel.png',//单个取消上传的图片
				'swf'      : 'uploadify.swf',
				'uploader' : 'uploadify.php',
				'buttonText' : '選擇檔案',//设置按钮文本
				'method'   : 'post',
				'formData' : {
    		'CMemo' :'<?php echo $CMemo; ?>',
    		'AId' :'<?php echo $CUser; ?>'},
    		'onUploadComplete' : function(event,data) {
    			//getResult(response);//获得上传的文件路径
    			$.post("uploader/insert.php");
    		},
				'onUploadSuccess' : function(file, data, response) {
				       img_id_upload[i]=data;
               i++;               
               //alert(data);
        },
        'onQueueComplete' : function(queueData) {//上传队列全部完成后执行的回调函数
           if(img_id_upload.length>0)
           {
              alert('新增成功');
              window.opener.location.href = 'FileDataIndex.php?page=1';
              window.close();
           }
        } 

			});
		});
	</script>
<body>
<input type="hidden" value="<?php echo $CUser; ?>" name="AId" id="AId" />
<table border="0" cellspacing="0" cellspadding="0" width="100%">
<tr>
<td align="left" colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td align="left" colspan="2">
<span class="t14b"><b>選擇上傳多個檔案資料</b></span>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<table border="3" cellspacing="2" cellspadding="2" width="100%">
<tr>
<td align="left" width="20%">
<span class="t12">誰的檔案資料</span>
</td>
<td align="left" width="80%">
<input type="text" value="<?php echo $AName; ?>" name="AName" id="AName" size="70" maxlength="70" style="font-size: 12.0pt;font-family: 微軟正黑體;" readonly/>
</td>
</tr>
<tr>
<td align="left" width="30%">
<span class="t12">備註</span>
</td>
<td align="left" width="70%">
<input type="text" value="<?php echo $CMemo; ?>" name="CMemo" id="CMemo" size="70" maxlength="70" style="font-size: 12.0pt;font-family: 微軟正黑體;" readonly/>
</td>
</tr>
<tr>
<td align="left" width="30%">
<span class="t12">選擇上傳檔案</span>
</td>
<td align="left" width="70%">
<input id="file_upload" name="file_upload" type="file" multiple="true">
<p>
<a href="javascript:$('#file_upload').uploadify('cancel','*')">
<span class="t12r">清除上傳檔案列表</span>
</a>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="button" name="btnSub" id="btnSub" value="確定新增" class="t12" 
 onclick="javascript:$('#file_upload').uploadify('upload','*');" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
