<?php
	require_once('_approot.php');
	$id=$_GET['id'];
	
	$subcate_sql="select * from ls_products where ID=".$id." ";
	$subcate_query=$opendb->query($subcate_sql);
	$subcate_rows=mysqli_fetch_assoc($subcate_query);
	
	$midcate_sql="select * from ls_products where ID=".$subcate_rows['subcateID']." ";
	$midcate_query=$opendb->query($midcate_sql);
	$midcate_rows=mysqli_fetch_assoc($midcate_query);
	
	$cate_sql="select * from ls_products where ID=".$midcate_rows['midcateID']." ";
	$cate_query=$opendb->query($cate_sql);
	$cate_rows=mysqli_fetch_assoc($cate_query);
	
	if($subcate_rows['catePic']==null){
		$classPath="images/picture.gif";
	}else{
		$classPath="../".$cate_rows['cateFolders']."/".$midcate_rows['midcateFolders']."/".$subcate_rows['subcateFolders']."/".$subcate_rows['catePic'];
	}
	
	$ls_msg="修改产品小类";
?>
<!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">
<link href="css/admin.css" rel="stylesheet" type="text/css">
<link href="css/newui.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/style2.css" />
<script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
<script language="JavaScript" src="js/ls.js"></script>
<script type="text/javascript" src="js/newui.js"></script>
<title>修改产品小类</title>
    <link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
	<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
	<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
    <script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="subcateBrief"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});

		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="subcateDetail"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
    <script type="text/javascript">  
function preview(file)
{
var prevDiv = document.getElementById('preview');
if (file.files && file.files[0])
{
var reader = new FileReader();
reader.onload = function(evt){
prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="<?php echo $SmallPicW ?>"  border="1" name="pic" style="float:left;" />';
}  
reader.readAsDataURL(file.files[0]);
}
else  
{
prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
}
}


//图片类型验证 ".jpg", 
function pictype(file)
{
   var fileTypes = [<?=$imagetypes2?>];
    var filePath = file.value;
    //当括号里面的值为0、空字符、false 、null 、undefined的时候就至关于false
    if(filePath){
        var isNext = false;
        var fileEnd = filePath.substring(filePath.indexOf("."));
        for (var i = 0; i < fileTypes.length; i++) {
            if (fileTypes[i] == fileEnd) {
                isNext = true;
                break;
            }
        }
        if (!isNext){
            alert('<?=$imagealert?>');
            file.value = "";
            return false;
        }
    }else {
        return false;
    }
}

//图片大小验证
function picsize(file) {
    var fileSize = 0;
    var fileMaxSize =<?=$PicSize/1000?>;// 1M
    var filePath = file.value;
    if(filePath){
        fileSize =file.files[0].size;
        var size = fileSize / 1024;
        if (size > fileMaxSize) {
            alert("<?=$imagealertsize?>");
            file.value = "";
            return false;
        }else if (size <= 0) {
            alert("图片大小不能为0！");
            file.value = "";
            return false;
        }
    }else{
        return false;
    }
}

</script>
</head><body>
<div class="maintitle"> <strong>添加产品小类</strong> </div>
<div class="mainfield">
	<form name="addsubcate" enctype="multipart/form-data"  method="post" action="savesubcate.php" onSubmit="return Checksubaddcate()"  >
		  <input type="hidden" value="update" name="ls">
		  <input type="hidden" value="<?php echo $midcate_rows['ID'];?>" name="midcate_id">
		  <input type="hidden" value="<?php echo $id ;?>" name="subcateID">
		  <input type="hidden" value="<?php echo $subcate_rows['catePic'];?>" name="PicOld">
		  <input type="hidden" name="ChangecatePagePic" value="no">
		<table width="98%" border="0" cellpadding="" cellspacing="0" style="background-color: #f0f0ee;">
		  <tr>
		    <td width="3%" height="34" valign="top">&nbsp;</td>
		    <td width="47%"  >提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
		    <td align="right" style="padding-right:40px;"><img src="images/shao.gif" alt="" />&nbsp;<a href="cate.php">返回</a></td>
	      </tr>
		  <tr>
		    <td height="315" colspan="2" valign="top"><fieldset class="infofield" >
		      <table width="100%" border="0" cellspacing="8" cellpadding="">
		        <tr>
		          <td width="17%" height="73" align="right"><span class="gcatelabelnormal">中类名 *</span></td>
		          <td width="83%" valign="top"> 
		            <input type="text" name="midcateName" value="<?php echo $midcate_rows['midcateName']?>" readonly="readonly" class="midcateinputboxnoblank" /></td>
	            </tr>
		        <tr>
		          <td height="68" align="right"><span class="gcatelabelnormal">小类名 *</span></td>
		          <td align="left" valign="top">
	              <input type="text" name="subcateName" class="midcateinputboxnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);" onKeyUp="this.value=this.value.replace(/&/g, '');" value="<?php echo $subcate_rows['subcateName'];?>" /></td>
	            </tr>
		        <tr>
		          <td height="71" align="right"><span class="gcatelabelnormal">目录名</span><br /></td>
		          <td align="left" valign="top"> 
	              <input name="subcateFolders" type="text" class="midcateinputboxnoblank" value="<?php echo $subcate_rows['subcateFolders'];?>" <?=($folderchange==1?"":"readonly") ?> /></td>
	            </tr>
		        <tr>
		          <td align="right" style="padding-right:18px;">&nbsp;</td>
		          <td align="left" style="padding-right:;"><?=$cate_tips?>		            <input type="hidden" name="midcate_id2" value="<?php echo $cate_rows['ID']?>" /></td>
	            </tr>
	          </table>
		      </fieldset></td>
		    <td width="50%" valign="top"><fieldset class="infofield"  >
		      <table width="94%" border="0" cellspacing="8" cellpadding="0">
		        <tr>
		          <td align="right" ><br />
		            标题<br />
		            Keywords</td>
		          <td> 
	              <textarea name="cateTitle" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);"><?php echo trim($subcate_rows['cateTitle']);?></textarea></td>
	            </tr>
		        <tr>
		          <td width="21%" align="right" ><br />
		            关键字<br />
		            Keywords</td>
		          <td width="79%"><textarea name="cateKeywords" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);"><?php echo trim($subcate_rows['cateKeywords']);?></textarea></td>
	            </tr>
		        <tr>
		          <td align="right">描述<br />
		            Description *</td>
		          <td><textarea name="cateDescription" class="inputareashortnoblank" onmouseover="ibov(this);" onmouseout="ibou(this);"><?php echo trim($subcate_rows['cateDescription']);?></textarea></td>
	            </tr>
		        <tr>
		          <td height="37" colspan="2" align="right" style="padding-top:10px;"><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
	            </tr>
	          </table>
		      </fieldset></td>
	      </tr>
		  <tr>
		    <td height="325" colspan="4"><table width="100%" border="0" cellspacing="8">
		      <tr>
		        <td width="9%" align="right"> 简介 </td>
		        <td colspan="2">
	            <textarea name="subcateBrief" rows="6" class="inputareabigbrief" onmouseover="ibov(this);" onmouseout="ibou(this);" style="width:98%;"><?php echo str_replace("<br />","\n",htmlspecialchars_decode($subcate_rows['subcateBrief'],ENT_QUOTES));?></textarea>
	            <?=$promlv>1?$brief_tips:""?></td>
	          </tr>
		      <tr>
		        <td height="436" align="right"> 详细 </td>
		        <td colspan="2"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;">
	            <textarea name="subcateDetail" style="width:98%;height:400px;visibility:hidden;"><?php echo htmlspecialchars_decode($subcate_rows['subcateDetail'],ENT_QUOTES); ?></textarea>
		        </span><span class="gcateprompt2">
		        <?=$catedetails_tips?>
		        </span></span></td>
	          </tr>
		      <tr>
		        <td colspan="3" align="right"><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
	          </tr>
		      <tr>
		        <td height="38%" align="right"> 代表图 Icon</span></td>
		        <td width="22%"><input type="file" name="subcateIconPic" onblur="document.Iconpic.src=addcate.cateIconPic.value;pictype(this);picsize(this);preview(this);"  onmouseover="ibov(this);" onmouseout="ibou(this);" />
		          </span></td>
		        <td width="69%"><span class="gcatepicleft"><img src="images/picture.gif" alt="" name="Iconpic"   width="100%" border="1" id="Iconpic" /></span></td>
	          </tr>
		      <tr>
		        <td height="70" align="right">主题图 Banner</td>
		        <td><span  >
		          <input type="file" name="productPic2" onchange="addsubcate.ChangecatePagePic.value='yes';pictype(this);picsize(this);preview(this);"   onmouseover="ibov(this);" onmouseout="ibou(this);" />
		          </span></td>
		        <td><img src="<?php echo $classPath==""?"images/picture.gif":$classPath  ?>" alt="" name="pic" width="97%" height="106" border="1" id="pic" /><br/><?=$nmpic_tips?></td>
	          </tr>
		      <tr>
		        <td height="24">&nbsp;</td>
		        <td>&nbsp;</td>
		        <td>宽度
                  <input type="text" class="ifinfoinputvshort"   name="width" onblur="document.pic.width=document.addcate.width.value;" onmouseover="ibov(this);" onmouseout="ibou(this);" value="<?php echo $subcate_rows['catePagePicWidth']; ?>" />
px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 高度
<input type="text" class="ifinfoinputvshort" value="<?php echo $subcate_rows['catePagePicHeight'];?>"  name="height" onblur="document.pic.height=document.addcate.height.value;" onmouseover="ibov(this);" onmouseout="ibou(this);" />
px </td>
	          </tr>
		      </table></td>
	      </tr>
		  <script> keypress2();</script>
		  <?php file_exists("widget/ls_language.php")?include '<tr><td colspan="4">'."widget/ls_language.php".'</td></tr>':"" ?>
	  </table>

	</form>
</div>
 
</body>
</html>