<?php
	session_start();
	require_once("../Wx.Config.php");	//只加载一次
	//执行上传文件的
	$stritemno = trim($_REQUEST['itmno']);
	$strRetVal = trim($_REQUEST['retv']);
	$intImgID = trim($_REQUEST['imgid']);
	$stritemname="";
?>

<html>
<head>
	<meta http-quive="content-type" content="text/html;charset=gb2312" ></meta>
	<link rel="stylesheet" href="css/mycss.css"> 
	<script src="jsp4/jquery.js"></script>
</head>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
	<?php
			//加载系统参数信息
			require_once("db/db.php");	
			require_once("common/common.php");
			
			$sql = sprintf("SELECT ItemNo,ItemName FROM CGS_Item_List Where ItemNo='%s'",$stritemno);
			$result = querySql($sql);
	
			if($row = fetch_array($result))
			{
				$stritemno = $row['ItemNo'];
				$stritemname = $row['ItemName'];
			}
			freeResult($result);	//释放数据库
			closeDb();				//关闭数据库

	?>
<!--第一个页面的内容实现---------------------------->
<section data-role="page" id="page1">
	<header data-role="header" data-position="fixed" data-tap-toggle="false" style="border-top-width:0px;border-bottom-width:0px;">
        <table width="100%" height="20" border="0" cellpadding="0" cellspacing="0" bgcolor="<?php echo WxMainConfig::colHeadBkColor;?>">
		   	<tr>
				<td height="52" width="40"></td>
				<td height="52" align="center" valign="middle">
	                <span style="color:<?php echo WxMainConfig::colHeadTextColor;?>;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:19px;text-shadow:none;"><?php echo $stritemname; ?>图片设置</span>
               	</td>
				<td height="52" width="20" valign="middle"></td>
		  	</tr>
		</table>
	</header>
	
	<article data-role="none">
		
		<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
			<tr>
				<td width="100%" align="center" valign="top">
					<table width="480" height="400" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
						<?php if(strlen($strRetVal)>0) { ?>
							<tr><td height ="20" colspan="3" align="center"></td></tr>
							
							<tr>
								<td width="10"></td>
								<td align="center" valign="middle">
									<span style="color: #000;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:16px;text-shadow:none;" ><?php echo $strRetVal;?>，保存图片失败！</span> 
								<td>
								<td width="10"></td>
							</tr>
						<?php } else {?>
							<tr><td height ="10" colspan="3" align="center"></td></tr>
						<?php } ?>
											
						<tr><td height ="20" colspan="3" align="center"></td></tr>
						 <tr>
							<td width="10"></td>
							<td valign="top">
								
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td height="20" width="15"></td>
										<td height="20" align="left"></td>
										<td height="20" width="15"></td>
									</tr>

									<tr>
										<td height="15" width="15"></td>
										<td height="15" align="center">
											<?php if(strlen($stritemno)>0) { ?>
												<div  align="center"  style="width:180px;height:36px;border-radius:4px; background-color:#D7AA28;">	
													<label class="ui_button ui_button_primary" for="xFile">
														<div align="center"  style="width:180px;height:32px; padding-top:4px; border-radius:4px;">		
														<span style="color: #fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">选择图片</span> 
														</div>
													</label>
												</div>
											<?php } ?>
										</td>
										<td height="15" width="15"></td>
									</tr>
									
									<tr>
										<td height="30" width="15"></td>
										<td height="30" align="left"></td>
										<td height="30" width="15"></td>
									</tr>
									
									<tr>
										<td height="20" width="15"></td>
										<td height="20" align="center">
											<div id="bmpUpImg" align="center" style="width:180px;height:36px;border-radius:4px; background-color:#D7AA28;" hidden >	
												<label class="ui_button ui_button_primary" for="xSub">
													<div  align="center"  style="width:180px;height:32px; padding-top:4px; border-radius:4px;">		
													<span style="color: #fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;" >上传图片</span> 
													</div>
												</label>
											</div>
										</td>
										<td height="20" width="15"></td>
									</tr>

									<tr>
										<td height="15" width="15"></td>
										<td height="15" align="center">
											<form action="Fileupload.php?itmno=<?php echo $stritemno;?>&imgid=<?php echo $intImgID;?>" method="post" enctype="multipart/form-data" style="position:absolute;clip:rect(0 0 0 0);">
												<input type="file" name="pic[]" id="xFile<?php echo $intRowIndex;?>" accept="image/jpg,image/jpeg,image/png,image/gif" style="position:absolute;clip:rect(0 0 0 0);" onchange="myView()">
												<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
												<input type="submit" name="xSub" id="xSub" value="上传图片" style="position:absolute;clip:rect(0 0 0 0);" hidden >
											</form>		
										</td>
										<td height="15" width="15"></td>
									</tr>

									<tr>
										<td height="20" width="15"></td>
										<td height="20" align="left"></td>
										<td height="20" width="15"></td>
									</tr>
									
									<tr>
										<td height="15" width="15"></td>
										<td height="15" align="center">
											<img src="" id='show' width="260" height="260">
										</td>
										<td height="15" width="15"></td>
									</tr>
									
									<tr>
										<td height="30" width="15"></td>
										<td height="30" align="left"></td>
										<td height="30" width="15"></td>
									</tr>

									<tr>
										<td height="15" width="15"></td>
										<td height="15" align="center">
												<div  onClick="bmtReturnBK()" align="center"  style="width:180px;height:36px;border-radius:4px; background-color:#F7060A;">	
													<div align="center" style="width:180px;height:32px; padding-top:4px; border-radius:4px;">		
														<span style="color: #fff;font: 12px/1.5 '微软雅黑',tahoma, Srial, helvetica, sans-serif; font-size:14px;text-shadow:none;">返 回</span> 
													</div>
												</div>
											
										</td>
										<td height="15" width="15"></td>
									</tr>
									
									
									<tr>
										<td height="20" width="15"></td>
										<td height="20" align="left"></td>
										<td height="20" width="15"></td>
									</tr>
								</table>
								
							</td>
							<td width="10"></td>
						</tr>
											 

						
						<tr><td height ="15" colspan="3" align="center"></td></tr>
					
					</table>
				</td>
			</tr>
		</table>
		
		
		 
		  <script type="text/javascript">
			
			function myView() 
			{
				var r= new FileReader();
				var strFileName = 'xFile';
				
				f=document.getElementById(strFileName).files[0];
				r.readAsDataURL(f);
				r.onload=function  (e) 
				{
					var imgSize = f.size;
					
					//alert(imgSize);
					//在此处我们限制图片大小为100KB
					if(imgSize>100*1024)
					{
						alert('上传的图片的大于100KB,请重新选择');
						return false;
					}
					var imgName = 'show';
					document.getElementById(imgName).src=this.result;
					
					//显示上传按钮
					var DivButID = '#bmpUpImg';
					$(DivButID).show();
					
				};
				
			}
			
			function bmtReturnBK()
			{
				window.location="itemimg.php";	
			};
					
		</script>
	
	</article>
	
	
 </body>
 
</html>