<?php 
	require_once('_approot.php');

	$ls_msg="修改产品大类";
	$id=$_GET['id'];
	$ls=$_GET['ls'];
	
	$cate_sql="select * from ls_products where ID=".$id." ";
	$cate_query=$opendb->query($cate_sql);
	$cate_rows=mysqli_fetch_assoc($cate_query);
	if($cate_rows['catePagePic']==""){
		$classPath="images/picture.gif";
	}else{
		$classPath="../".$cate_rows['cateFolders']."/".$cate_rows['catePagePic'];
	}
	$select_sql2="select * from ls_products  where ID=".$id."";
	$select_query2=$opendb->query($select_sql2);
	$rows2=mysqli_fetch_assoc($select_query2);
			 
			
	switch ($ls)
	{
		case "delattachedfile":
		$attachedfile="../".$cate_rows['cateFolders']."/".$rows2['attachedfile'];
		//echo $attachedfile."--";exit;
		if(file_exists($attachedfile)) 
			if(!unlink($attachedfile)) $ls_msg.=$tpl."删除 $attachedfile 错误! "; else $ls_msg.="删除 $attachedfile 操作成功！";
		$cate_sql="update ls_products set attachedfile='' , attachedfilesize='' where ID=".$id." ";
		$cate_query=$opendb->query($cate_sql);
		
		writelog($_SERVER['PHP_SELF'],"delete attachedfile $attachedfile ","ID: ".$id);
		break;  
		
		case "delcateIconPic":
		$cateIconPic1="../".$cate_rows['cateFolders']."/".$rows2['cateIconPic'];
		//echo $cateIconPic1."--";exit;
		if(file_exists($cateIconPic1)) 
			if(!unlink($cateIconPic1)) $ls_msg.=$tpl."删除 $cateIconPic1 错误! "; else $ls_msg.="删除 $cateIconPic1 操作成功！";
		$cate_sql="update ls_products set cateIconPic=''  where ID=".$id." ";
		$cate_query=$opendb->query($cate_sql);
		
		writelog($_SERVER['PHP_SELF'],"delete cateIconPic $cateIconPic1 ","ID: ".$id);
		break;
		
		case "delcatePagePic":
		$catePagePic1="../".$cate_rows['cateFolders']."/".$rows2['catePagePic'];
		//echo $catePagePic."--";exit;
		if(file_exists($catePagePic1)) 
			if(!unlink($catePagePic1)) $ls_msg.=$tpl."删除 $catePagePic1 错误! "; else $ls_msg.="删除 $catePagePic1 操作成功！";
		$cate_sql="update ls_products set catePagePic=''  where ID=".$id." ";
		$cate_query=$opendb->query($cate_sql);
		
		writelog($_SERVER['PHP_SELF'],"delete catePagePic $catePagePic1 ","ID: ".$id);
		break;
	}

?>
<!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 href="css/style2.css" rel="stylesheet"  type="text/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="cateBrief"]', {
				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="cateDetail"]', {
				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="characteristics"]', {
            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="advantages"]', {
            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="parameters"]', {
            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="addcate" enctype="multipart/form-data" method="post" action="savecate.php" onSubmit="return Checkaddcate()">
	  <input type="hidden" value="modi" name="ls">
	  <input type="hidden" value="<?php echo $cate_rows['ID'];?>" name="id">
	<div class="editableoverall">
	  <table width="98%" border="0" cellpadding="" cellspacing="0" style="background-color: #f0f0ee;">
	    <tr>
	      <td width="4%" height="34" valign="top">&nbsp;</td>
	      <td width="44%" valign="middle">提示：<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="324" colspan="2" valign="top"><fieldset class="infofield" >
	        <table width="104%" border="0" cellspacing="8" cellpadding="">
	          <tr>
	            <td width="17%" height="112" align="right"><span class="gcatelabelnormal">大类名称 *</span></td>
	            <td width="83%"><span class="">
	             <textarea name="cateName" class="gcateinputboxnoblank" onMouseOver="ibov(this);" onMouseOut="ibou(this);"  onKeyUp="this.value=this.value.replace(/&/g, '');" ><?php echo $cate_rows['cateName'];?></textarea>
	              </span><br /></td>
	            </tr>
	          <tr>
	            <td height="69" align="right"><span class="gcatelabelnormal">目录名</span><br /></td>
	            <td align="left"><span class="">
	              <textarea name="cateFolders" class="gcateinputboxnoblank" <?=($folderchange==1||$_SESSION['adlans']=="adlans"?"":"readonly") ?> ><?php echo $cate_rows['cateFolders'];?></textarea>
	              </span></td>
	            </tr>
	          <tr>
	            <td align="right" style="padding-right:18px;">&nbsp;</td>
	            <td align="left" style="padding-right:;"><?=$cate_tips?></td>
	            </tr>
	          </table>
	        </fieldset></td>
	      <td width="52%" 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 $cate_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 $cate_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 $cate_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="7%" align="right"> 简介 </td>
	          <td colspan="3"><textarea name="cateBrief" rows="6" class="inputareabigbrief" onmouseover="ibov(this);" onmouseout="ibou(this);"  style="width:98%;"><?php echo str_replace("<br />","\n",htmlspecialchars_decode($cate_rows['cateBrief'],ENT_QUOTES));?></textarea>
	            <?=$promlv>1?$brief_tips:""?></td>
	          </tr>
	        <tr>
	          <td height="436" align="right"> 详细 </td>
	          <td colspan="3"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;"><span class="lsgcateeditorarea" style="margin-top:10px; clear:both;">
<textarea name="cateDetail" style="width:98%;height:400px;visibility:hidden;"><?php echo htmlspecialchars_decode($cate_rows['cateDetail'],ENT_QUOTES); ?></textarea>	            </span><span class="gcateprompt2">
<?=$catedetails_tips?>
</span></span></td>
	          </tr>
	        <tr>
            <?php file_exists("widget/ls_products_addandmodi_moreinfo.php")?include "widget/ls_products_addandmodi_moreinfo.php":"" ?>
	          <td colspan="4" align="right"><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
	          </tr>
	        <tr>
	          <td height="38%" align="right">附加文件</span></td>
	          <td width="61%"><input type="file" name="attachedfile" onchange="addcate.Changeattachedfile.value='yes';"   onmouseover="ibov(this);" onmouseout="ibou(this);" value="<?=$cate_rows['attachedfile']?>"/><input type="hidden" name="Changeattachedfile" value="no"> <strong>
	            <label>
	              <?php if($cate_rows['attachedfile']!=""){?>
	              &nbsp;</label>
	            </strong></td>
	          <td>
	            <label>
	              <?=$cate_rows['attachedfile'];?>
	              <?=$cate_rows['attachedfilesize']==0?"":" &nbsp; 大小". round($cate_rows['attachedfilesize']/1000,0) ."K";?>
	              <input type="submit" name="delattachedfile" id="delattachedfile" value="删除"    onclick= "document.addcate.action='?ls=delattachedfile&id=<?=$id?>'"/>
	              <?php }?>
	              </label>
	           </td>
	          <td width="6%" align="right"><a href="cate.php">返回</a></td>
	          </tr>
	        <tr>
	          <td height="38%" align="right"> 代表图 Icon </td>
	          <td><p> <img src='<?=$cate_rows['cateIconPic']!=""?"../".$cate_rows['cateFolders']."/".$cate_rows['cateIconPic']:"images/picture.gif"?>' alt="" name="Iconpic"   width="50%" border="1" id="Iconpic" />
	            </p>
	            <p>
	              <input type="file" name="cateIconPic" onchange="addcate.ChangecateIconPic.value='yes';pictype(this);picsize(this);preview(this);"   onblur="document.Iconpic.src=addcate.cateIconPic.value;"  onmouseover="ibov(this);" onmouseout="ibou(this);" value="<?=$cate_rows['cateIconPic']?>"/>
	              <input type="hidden" name="ChangecateIconPic" value="no">
	              <input type="hidden" value="<?php echo $cate_rows['cateIconPic'];?>" name="cateIconPicOld" />
                </p></td>
	          <td width="26%" valign="middle">
	            <?php if($cate_rows['cateIconPic']!=""){?>
	            <?=$cate_rows['cateIconPic']?>  
	            <input type="submit" name="delcateIconPic" id="delcateIconPic" value="删除"    onclick= "document.addcate.action='?ls=delcateIconPic&amp;id=<?=$id?>'"/><?php }?>
	            </td>
	          <td valign="bottom">&nbsp;</td>
	          </tr>
	        <tr>
	          <td height="70" align="right">主题图 Banner</td>
	          <td><p><img src="<?php echo $classPath==""?"images/picture.gif":$classPath  ?>" alt="" name="pic" width="92%" height="106" border="1" id="pic" /></p>
	              <input type="file" name="catePagePic" onchange="addcate.ChangecatePagePic.value='yes';pictype(this);picsize(this);preview(this);" onblur="document.pic.src=addcate.catePagePic.value;"   onmouseover="ibov(this);" onmouseout="ibou(this);" value="<?=$cate_rows['catePagePic']?>"/>
	              </strong><br/><?=$nmpic_tips?>
	            <input type="hidden" name="ChangecatePagePic" value="no" /></td>
	          <td><?php if($cate_rows['catePagePic']!=""){?> <?=$cate_rows['catePagePic']?>
	            <input type="submit" name="delcatePagePic" id="delcatePagePic" value="删除"    onclick= "document.addcate.action='?ls=delcatePagePic&amp;id=<?=$id?>'"/>
	            <?php }?>
	            <input type="hidden" value="<?php echo $cate_rows['catePagePic'];?>" name="catePagePicOld" /></td>
	          <td>&nbsp;</td>
	          </tr>
	        <tr>
	          <td height="24">&nbsp;</td>
	          <td colspan="3">宽度
	            <input type="text" class="ifinfoinputvshort"   name="width" onBlur="document.pic.width=document.addcate.width.value;" onMouseOver="ibov(this);" onMouseOut="ibou(this);" value="<?php echo $cate_rows['catePagePicWidth']; ?>">
	            px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 高度
	            <span class="gcatePagePicsetxy">
	              <input type="text" class="ifinfoinputvshort"   name="height" onblur="document.pic.height=document.addcate.height.value;" onmouseover="ibov(this);" onmouseout="ibou(this);" value="<?php echo $cate_rows['catePagePicHeight'];?>" />
                </span> 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>
	   
	  </fieldset>
	  <table width="100%" border="0" cellspacing="8">
	    <tr>
	      <td colspan="3" align="center"><button name="submit2" type="submit" value="确定" class="ifsinglebutton">确定</button></td>
        </tr>
      </table>
	  </div>
 
	</form>
</div>


</body>
</html>

