<?php 
	session_start(); 

	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/admin.class.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$ls_msg="修改产品信息操作";
	$id=$_GET['id'];
	$cateid=$_GET['cateid'];
	$midcateid=$_GET['midcateid'];
	$subcateid=$_GET['subcateid'];
	$page=$_GET['page'];
	
	$lan = array();
	if($lang != "en"){
		$lan = $lang_cn;
	}else{
		$lan = $lang_en;
	}
	$admininfo = $admin->getInfo();
	//评论
	$comment_id=$_GET['comment_id'];
	$ls=$_GET['ls'];
	
	switch ($ls){
	 	case "unenable":
			$unenable_sql="update ls_comments set enable=0 where id=".$comment_id." ";
			//echo $unenable_sql;
			$unenable_query=$opendb->query($unenable_sql);
			$ls_msg="不显示操作成功！";
			break;
		case "enable":
			$enable_sql="update ls_comments set enable=1 where id=".$comment_id." ";
			//echo $enable_sql;
			$enable_query=$opendb->query($enable_sql);
			$ls_msg="显示操作成功！";
			break;
		case "del":
			$del_sql="delete from ls_comments where ID=".$comment_id."";
	   		//echo $del_sql;
	   		$del_query=$opendb->query($del_sql);
			break;
	}
	//评论结束
	
	$products_sql="select * from ls_products where ID=".$id." ";
	$products_query=$opendb->query($products_sql);
	$products_rows=mysql_fetch_assoc($products_query);
	
	//获取文件目录
	$subcate_sql="select productID from ls_products where ID=".$id." "; 
	$subcate_sql="select * from ls_products where ID=(".$subcate_sql.")";
	$subcate_query=$opendb->query($subcate_sql);
	$subcate_myrows=mysql_fetch_assoc($subcate_query);
	if($subcate_myrows['subcateFolders']!="")
	{
		$pathFoldersProducts=$subcate_myrows['subcateFolders'];

		$midcate_sql="select productID from ls_products where ID=".$id." "; 
		$midcate_sql="select subcateID from ls_products where ID=(".$midcate_sql.") "; 
		$midcate_sql="select * from ls_products where ID=(".$midcate_sql.")";
		$midcate_query=$opendb->query($midcate_sql);
		$midcate_myrows=mysql_fetch_assoc($midcate_query);
		
		if($midcate_myrows['midcateFolders']!="")
		{
			$pathFoldersProducts=$midcate_myrows['midcateFolders']."/".$pathFoldersProducts;
			
			$cate_sql="select productID from ls_products where ID=".$id." "; 
			$cate_sql="select subcateID from ls_products where ID=(".$cate_sql.")";
			$cate_sql="select midcateID from ls_products where ID=(".$cate_sql.") "; 
			$cate_sql="select * from ls_products where ID=(".$cate_sql.")";
			$cate_query=$opendb->query($cate_sql);
			$cate_myrows=mysql_fetch_assoc($cate_query);
			
			$pathFoldersProducts="../".$cate_myrows['cateFolders']."/".$pathFoldersProducts;
		}			
	}
	else //又大类和中类，没有小类
	{
		$midcate_sql="select productID from ls_products where ID=".$id." "; 
		$midcate_sql="select * from ls_products where ID=(".$midcate_sql.")";
		$midcate_query=$opendb->query($midcate_sql);
		$midcate_myrows=mysql_fetch_assoc($midcate_query);
		
		if($midcate_myrows['midcateFolders']!="")
		{
			$pathFoldersProducts=$midcate_myrows['midcateFolders'];
		
			$cate_sql="select * from ls_products where ID=".$midcate_myrows['midcateID']." "; 
			$cate_query=$opendb->query($cate_sql);
			$cate_myrows=mysql_fetch_assoc($cate_query);
		
			$pathFoldersProducts="../".$cate_myrows['cateFolders']."/".$pathFoldersProducts;
		}
		else //只有大类
		{
			$cate_sql="select productID from ls_products where ID=".$id." "; 
			$cate_sql="select * from ls_products where ID=(".$cate_sql.")";
			$cate_query=$opendb->query($cate_sql);
			$cate_myrows=mysql_fetch_assoc($cate_query);
			
			$pathFoldersProducts="../".$cate_myrows['cateFolders'];
			
		}
	
	}
	
	//获取文件目录
	$picsrc=$pathFoldersProducts."/".$SmallFoldersProducts."/".$products_rows['productPic']; 
	//echo $picsrc."<br>";
	$picsrcnopath=$products_rows['productPic'];
	
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysql_fetch_assoc($title_query);
?>
<!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">
<script language="JavaScript" src="js/jquery.js"></script>
<script language="JavaScript" src="js/ls.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="productSpecification"]', {
            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>
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
	<tr>
		<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>修改产品信息</strong></font></div></td>
	</tr>
	<tr>
		<td height="213" valign="top" bgcolor="#dee7ff"><br>
			<form name="myform" enctype="multipart/form-data" method="post" action="saveproducts.php?cateid=<? echo $cateid?>&midcateid=<? echo $midcateid?>&subcateid=<? echo $subcateid?>&page=<? echo $page ?>" onSubmit="return Checkaddproducts()">
				<input type="hidden" value="update" name="ls">
				<input type="hidden" value="<?php echo $id;?>" name="id">
				<input type="hidden" value="<?php echo $products_rows['productPic'];?>" name="Pic">
				<input type="hidden" name="ChangecatePagePic" value="no">
			  <table border="0" width="94%" align="center">
					<tr>
						<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
						<td align="right"><img src="images/shao.gif">&nbsp;<a href="products.php?cateid=<? echo $cateid?>&midcateid=<? echo $midcateid?>&subcateid=<? echo $subcateid?>&page=<? echo $page ?>"><u>返回</u></a></td>
					</tr>
				</table>
				<table width="94%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
				  <tr bgcolor="#B9DAFF">
						<td height="28" colspan="3"></td>
					</tr>
					<tr bgcolor="#f4f4f4">
						<td style="padding-left:15px;" width="8%">产品类别：</td>
						<td colspan="2"  style="padding-left:3em;" ><?php
									//cate change
									$midcate_sql="select * from ls_products where subcateName is null and cateName is null and cateFolders is null and cateBrief is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 order by Num desc";
									$midcate_query=$opendb->query($midcate_sql);
									echo "<script language = 'JavaScript'>" ;
									echo " var onecount; " ;
									echo " midcat = new Array(); " ;
									$count=0;
									while($midcate_rows=mysql_fetch_assoc($midcate_query))
									{
										echo " midcat[".$count."] = new Array(\"" ;
										echo 			trim($midcate_rows['midcateName'])."\",\"" ;
										echo 			trim($midcate_rows['midcateID'])."\",\"" ;
										echo 			trim($midcate_rows['ID'])."\"); " ;
										$count++	;
									}
									echo "onecount=".$count.";"	;

									
									
									$subcate_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and midcateName is null and midcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 order by Num desc";
									$subcate_query=$opendb->query($subcate_sql);
									
									echo " var onecount2; " ;
									echo " subcat = new Array(); " ;
									$count2=0;
									while($subcate_rows=mysql_fetch_assoc($subcate_query))
									{
										echo " subcat[".$count2."] = new Array(\"" ;
										echo 			trim($subcate_rows['subcateName'])."\",\"" ;
										echo 			trim($subcate_rows['subcateID'])."\",\"" ;
										echo 			trim($subcate_rows['ID'])."\"); " ;
											
										$count2++	;
									}
									echo "onecount2=".$count2.";"	;
								 	
									
									echo "function changelocation_big(locationid) "	;
								  echo "  {"	;
								  echo "  document.myform.MiddleClassName.length = 0; ";
								  echo "  var locationid=locationid;";
								  echo "  var i;";
								  echo "  var j=1;";
								  echo "  for (i=0;i < onecount; i++)";
								  echo "	  {";
								  echo "		  if (midcat[i][1] == locationid)";
								  echo "		  { ";
								  echo "			  document.myform.MiddleClassName.options[document.myform.MiddleClassName.length] = new Option(midcat[i][0], midcat[i][2]);";
								  echo "		  	  if (j == 1)";
								  echo "		  	  	{";
								  echo "		  	  	changelocation_middle(midcat[i][2]);";
								  echo "		  	  	j++;";
								  echo "		  	  	}";
								  echo "		  } ";	   
								  echo "	   	  if (j == 1)";
								  echo "	   	  {";
								  echo " 	 	  	changelocation_middle(-1);";//clear smallclass select
								  echo "	   	  }";
								  echo "	  }";
								  echo "  }"; 
								   
								   //midcate change
									echo "function changelocation_middle(locationid) "	;
								  echo "  {"	;
								  echo "  document.myform.SmallClassName.length = 0; ";
								  echo "  var locationid=locationid;";
								  echo "  var i;";
								  echo "  for (i=0;i < onecount2; i++)";
								  echo "	  {";
								  echo "		  if (subcat[i][1] == locationid)";
								  echo "		  { ";
								  echo "			  document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);";
								  echo "		  } ";	   
								  echo "	  }";
								  echo "  }"; 
								  echo "</script>";   
								  								   
								  $cate_bigclass_sql="select * from ls_products where midcateName is null and midcateID is null and subcateName is null and subcateFolders is null and subcateBrief is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null and enable=1 order by Num ";
									$cate_bigclass_query=$opendb->query($cate_bigclass_sql);
									$cate_bigclass_num=mysql_num_rows($cate_bigclass_query); 
									if($cate_bigclass_num==0)
									{
										echo "请先添加大类!";
									}
									else
									{
									echo "大类: <select name='BigClassName' onChange='changelocation_big(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)' size='1'>" ;
									$i=1;
									while($cate_bigclass_rows=mysql_fetch_assoc($cate_bigclass_query))
									 {
									 	 if($i==1)
									 	 {
									 	 	
									 	 	echo " <option ";
									 	 	if($cate_myrows['ID']==$cate_bigclass_rows['ID'] || $_POST['BigClassName']==$cate_bigclass_rows['ID'])
									 	 	{
									 	 		echo "selected";
									 	 	}
									 	 	echo " value=".trim($cate_bigclass_rows['ID']).">".trim($cate_bigclass_rows['cateName'])."</option>";
									 	 }
									 	 else
									 	 {
									 	  echo "	<option ";
									 	  if($cate_myrows['ID']==$cate_bigclass_rows['ID'] || $_POST['BigClassName']==$cate_bigclass_rows['ID'])
									 	 	{
									 	 		echo "selected";
									 	 	}
									 	  echo " value=".trim($cate_bigclass_rows['ID']).">".trim($cate_bigclass_rows['cateName'])."</option>";
									 	 }
									 	  $i++;
									 }
									echo "</select>";


									

								  
								 	if($midcate_myrows['ID']==""&&$_POST['MiddleClassName']==""||$midcate_myrows['midcateName']==""&&$_POST['MiddleClassName']=="")
								  	{
								  		$midcate_middleclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and subcateName is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and midcateID=''";
									}
									else
									{
										if($midcate_myrows['ID']!="")
										{
											$midcate_middleclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and subcateName is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and midcateID=".$cate_myrows['ID']."";
										}
										else
										{
											$midcate_middleclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and subcateName is null and subcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and midcateID=".$_POST['bigClassName']."";
										}
									}
									$midcate_middleclass_query=$opendb->query($midcate_middleclass_sql);
									$midcate_middleclass_num=mysql_num_rows($midcate_middleclass_query);
									
									
									echo " 中类: <select name='MiddleClassName'onChange='changelocation_middle(document.myform.MiddleClassName.options[document.myform.MiddleClassName.selectedIndex].value)' size='1'>" ;
									
								  	while($midcate_middleclass_rows=mysql_fetch_assoc($midcate_middleclass_query))
								  	{
								  		echo "<option ";
								  		if($midcate_myrows['ID']==$midcate_middleclass_rows['ID']||$_POST['MiddleClassName']==$midcate_middleclass_rows['ID'])
								  		{
												echo "selected";
										}
								  		echo " value=".$midcate_middleclass_rows['ID'].">".$midcate_middleclass_rows['midcateName']."</option>";
									}
									echo "</select>";
									
									

									echo " 小类: <select name='SmallClassName'>";
										if($_POST['SmallClassName']==""&&$subcate_myrows['ID']==""||$_POST['SmallClassName']==""&&$subcate_myrows['subcateName']=="")
										{
									  		$subcate_smallclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and midcateName is null and midcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and subcateID=''";
										}
										else
										{
											if($subcate_myrows['ID']!="")
											{
												echo $subcate_myrows['ID'];
												$subcate_smallclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and midcateName is null and midcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and subcateID=".$midcate_myrows['ID']."";
											}
											else
											{
												$subcate_smallclass_sql="select * from ls_products where cateName is null and cateFolders is null and cateBrief is null and midcateName is null and midcateID is null and productPic is null and productItemNo is null and productName is null and productSpecification is null and productID is null  and enable=1 and subcateID=".$_POST['MiddleClassName']."";
											}
										}
										$subcate_smallclass_query=$opendb->query($subcate_smallclass_sql);
										$subcate_smallclass_num=mysql_num_rows($subcate_smallclass_query);

									  	while($subcate_smallclass_rows=mysql_fetch_assoc($subcate_smallclass_query))
									  	{
									  		echo "<option ";
									  		if($_POST['SmallClassName']==$subcate_smallclass_rows['ID']||$subcate_myrows['ID']==$subcate_smallclass_rows['ID'])
									  		{
												echo "selected";
											}
									  		echo " value=".$subcate_smallclass_rows['ID'].">".$subcate_smallclass_rows['subcateName']."</option>";
										}
									
								echo "</select>";
							}//if($cate_bigclass_num==0)
							
								?></td>
					</tr>
					<tr bgcolor="#f4f4f4">
						<td style="padding-left:15px;" width="8%">产品货号：</td>
						<td colspan="2" style="padding-left:3em;" ><input name="productItemNo" type="text" value="<?php echo htmlspecialchars_decode($products_rows['productItemNo'],ENT_QUOTES);?>" size="36"></td>
					</tr>
					<tr bgcolor="#f4f4f4">
						<td style="padding-left:15px;" width="8%">产品名称：</td>
						<td width="31%" style="padding-left:3em;" ><input name="productName" type="text" value="<?php  echo htmlspecialchars_decode($products_rows['productName'],ENT_QUOTES);?>" size="36">
					    <label  style="padding-left:1em;">
					      <input type="button" name="button" id="button" value="SEO"  onclick="
                          if(confirm('您确定要修改SEO设置吗？')){
document.myform.productTitle.value=this.form.productName.value+'<?php if(strpos($title_value['companyName'],"-")){echo ", ".$title_value['companyName'];}else{echo " - ".$title_value['companyName'];}?>';document.myform.productKeywords.value=this.form.productName.value+', <?=$lan['seoFrefix1']?> '+this.form.productName.value+'<?=$lan['seoSufix1']?>, <?=$lan['seoFrefix2']?>'+this.form.productName.value+' <?=$lan['seoSufix2']?>'+', '+document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].text;
if($('#productSpecification').val().length <= 0){
	document.myform.productDescription.value=document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].text+'<?=$lan['seoFrefix1']?> Suppliers'+', '+document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].text+'<?=$lan['seoFrefix2']?><?=$lan['seoSufix2']?>';
}else{
	$('#productDescription').val($('#productSpecification').val().substr(0, 200).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
}

}else{
		return false;
	}"  />
					    </label></td>
						<td width="61%" style="padding-left:3em;"><? 
						if(intval($products_rows['AdditionalAttributes'])&1){ ?>
						  <input id="showonhome" name="showonhome" type="checkbox" value="0" checked />
							 <label for="showonhome" style="margin-right:10px;">首页热点，位置
						       <input type="text" size="3" name="No" value="<?=$products_rows[No]?>" /></label>
						<? }else{ ?>
						  <input id="showonhome" name="showonhome" type="checkbox" value="0" />
						  <label for="showonhome" style="margin-right:10px;">首页热点，显示位置
						    <input type="text" size="3" name="No" value="<?=$products_rows[No]?>" /></label>
						<? }
						if($ls_classproType == "selectPic"){
							if(intval($products_rows['AdditionalAttributesClassPro'])&1){ ?>
							  <input id="classproduct" name="classproduct" type="checkbox" value="0" checked />
								 <label for="classproduct" style="margin-right:10px;">产品类，位置
								   <input type="text" size="3" name="NoClassPro" value="<?=$products_rows[NoClassPro]?>" /></label>
							<? }else{ ?>
							  <input id="classproduct" name="classproduct" type="checkbox" value="0" />
							  <label for="classproduct" style="margin-right:10px;">产品类，位置
								<input type="text" size="3" name="NoClassPro" value="<?=$products_rows[NoClassPro]?>" /></label>
							<? }
						}
						if(intval($products_rows['AdditionalAttributes'])&2)
						{ ?>
						  <input id="hotproduct" name="hotproduct" type="checkbox" value="1" checked />
						  <label for="hotproduct" style="margin-right:10px;">促销产品</label>
						<? }
						else
						{ ?>
						  <input id="hotproduct" name="hotproduct" type="checkbox" value="1" />
						  <label for="hotproduct" style="margin-right:10px;">促销产品</label>
					 	<? 	}
						if(intval($products_rows['AdditionalAttributes'])&4)
						{ ?>
						  <input id="newproduct" name="newproduct" type="checkbox" value="2" checked /><label for="newproduct" style="margin-right:10px;">新产品</label>
						<? }
						else
						{ ?>
						  <input id="newproduct" name="newproduct" type="checkbox" value="2" /><label for="newproduct" style="margin-right:10px;">新产品</label>
					  <? 	}
						?></td>
					</tr>
                    <tr bgcolor="#f4f4f4">
                    	<td style="padding-left:15px;">添加到：</td>
                    	<td colspan="2" style="padding-left:3em;" >
                        	
								<select style="color:#F09;FONT-SIZE:14px;" name='isbranch'>
                            	<option value="0" <?php if($products_rows['isbranch']==0){echo "selected='selected'";} ?>>
                                	普通产品
                                </option>
                                <option value="1" <?php if($products_rows['isbranch']!=0){echo "selected='selected'";} ?>>
                                	只有本部门会员可见
                                </option>
                            </select>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;产品所属部门：&nbsp;&nbsp;
                   <?  
				   $admininfo = $admin->getInfo();
				   if($admininfo['branchID']==0){
				   
				   			echo "
						<select name='branchID'>
							<option value='0'>无</option>
						";
							
							$list = $admin->getAllBranch("ls_branch");
							foreach($list as $v){
								if($v['ID']==$products_rows['branchID']){
								echo "<option value='".$v['ID']."' selected='selected' >".$v['branchName']."</option>";
								}else{
									echo "<option value='".$v['ID']."'  >".$v['branchName']."</option>";
									}
							}
						echo "</select>";  
				   }?>
                        </td>
                    </tr>
                    <?
					$select_sql2="select * from ls_prospec where productID = ".$id;
					$select_query2=$opendb->query($select_sql2);
					$select_rows2=mysql_num_rows($select_query2); //总产品数
					$i=0;
					$gotSpecNames=array();
					$specificationName=explode(',',$specNames);
               	    $specificationValue=explode(',',$specValue);

					while($prospec_row=mysql_fetch_assoc($select_query2))  //循环处理变量处理 变量名
					{	
						if($specificationName[0]!="")
						{
							if(in_array($prospec_row['specName'],$specificationName))  //原有的参数代码则修改
							{
								$gotSpecNames[]=$prospec_row['specName'];

					?>
					<tr bgcolor="#f4f4f4">
					  <td style="padding-left:12px;" >代码参数：</td>
					  <td colspan="2" style="padding-left:3em;" ><input name="specificationName[<?=$i?>]" type="text" value="<?php echo $prospec_row['specName'];?>:" size="13"  id="specificationName<?=$i?>"     readonly="readonly" style="border:none"/>					    
                      <input name="specificationValue[<?=$i?>]" type="text" value="<?php echo $prospec_row['specValue'];?>" size="16" id="specificationValue<?=$i?>"   /></td>
				  </tr>
                  <?
						}
				
					}
				  $i++;
                  }
				
				 
					for($j=$i;$j<(count($specificationName));$j++)  //在原来基础上 增加的 代码参数 进行增加操作
					{	
						if(!in_array($specificationName[$j],$gotSpecNames))
						{
					?>
					<tr bgcolor="#f4f4f4">
					  <td style="padding-left:12px;" >代码参数：</td>
					  <td colspan="2" style="padding-left:3em;" ><input name="specificationName[<?=$j?>]" type="text" value="<?php echo $specificationName[$j];?>:" size="13"  id="specificationName<?=$j?>"     readonly="readonly" style="border:none"/>					    
                      <input name="specificationValue[<?=$j?>]" type="text" value="<?php echo $specificationValue[$j];?>" size="16" id="specificationValue<?=$j?>" onfocus="this.value=((this.value=='<?php echo $specificationValue[$j];?>')?'':(this.value));"  onblur="this.value=((this.value=='')?('<?php echo $specificationValue[$j];?>'):this.value); "  style="color:#999" onchange="document.getElementById('specificationValue<?=$j?>').style.color ='black';"/></td>
				  </tr>
                  <?
                 		 }
                 	 }
				  ?>
					<tr bgcolor="#f4f4f4">
						<td rowspan="2" style="padding-left:12px;" >产品图片：</td>
						<td style="padding-left:3em;" >
						<div id="preview">
						<? if($picsrcnopath=="")
						{?>
							<img src="<?php echo $picsrc."?i=".rand();?>" width="<?php echo $SmallPicW ?>" height="<?php echo $SmallPicH?>" border="1" name="pic" style="float:left;">
							<? }else{  // 动画 gif
							if($products_rows['automationGif']==1){
							?>
							<img src="<?php echo $picsrc."?i=".rand();?>"  width="<?php echo $SmallPicW ?>" height="<?php echo $SmallPicH?>" border="1" name="pic" id="showproductpic" style="float:left;">
							<? }
							else  //不是 动画 gif
							{?>
							<img src="<?php echo $picsrc."?i=".rand();?>"   name="pic" id="showproductpic" width="<?php echo $SmallPicW ?>" height="<?php echo $SmallPicH?>" border="1" style="float:left;">
							<? } }?>
							<br>
							<br>
							<br>
							<br></div>
<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 ?>" height="<?php echo $SmallPicH?>" 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>';
}
}
</script>
                            </td>
						<td style="padding-left:1em;" >
						<fieldset class="infofield" onMouseOver="ibov(this);" onMouseOut="ibou(this);" style="padding-left:1em; width:550px;">
						<legend>SEO参数</legend>
						<table width="531" border="0">
						  <tr>
						    <td width="131" bgcolor="#f4f4f4" >本页标题 Title</td>
						    <td width="383"><input name="productTitle" id="productTitle" type="text" value="<?php echo $products_rows['productTitle'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" >本页关键字 Keywords</td>
						    <td><input name="productKeywords" id="productKeywords" type="text" value="<?php echo $products_rows['productKeywords'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4"  >本页描述 Description</td>
						    <td><textarea name="productDescription" cols="72" rows="3" id="productDescription"><?php echo $products_rows['productDescription'];?></textarea></td>
					      </tr>
					    </table>
						</fieldset>
						</td>
					</tr>
					<tr bgcolor="#f4f4f4">
					  <td colspan="2" style="padding-left:3em;" >
			            <input type="file" name="productPic" style="width:300px;"  onchange="myform.ChangecatePagePic.value='yes';document.pic.src=myform.productPic.value;preview(this);" />
				        
					    <input id="automationGif" name="automationGif" type="checkbox" value="1"  <?=($products_rows['automationGif']==1)?'checked':''?>/>
					    动画透明
						  GIF PNG<br />
				        图片宽度应在200-600点、高度在200-600点，格式为jpg、gif、png，大小不要超过<?php echo $PicSize/1000; ?>KB</td>
				  </tr>
                  <tr bgcolor="#f4f4f4">
					  <td style="padding-left:12px;" >图片名称：</td>
				    <td colspan="2" style="padding-left:3em;" ><input name="productPicName" type="text" value="<?php echo $products_rows['productPic'];?>" size="80" /><input name="productPicName_old" type="hidden" value="<?php echo $products_rows['productPic'];?>"  /></td>
				  </tr>
					<tr bgcolor="#f4f4f4">
					  <td colspan="3" style="padding-left:12px;"><div align="right">
					    <input name="submit2" type="submit" value="保存" />
					    </div></td>
				  </tr>
					<tr bgcolor="#f4f4f4">
					  <td style="padding-left:15px;">产品属性：</td>
						<td colspan="2" align="left" valign="top" style="padding-left:3em;">
							
								<? $encode_canshu=htmlspecialchars_decode($products_rows['canshu'],ENT_QUOTES); ?>
                          <textarea name="canshu" id="canshu" style="width:500px;height:150px;font-size:12px;line-height:20px;"><?=$encode_canshu?>
						    </textarea>
						  <div style="width:360px; float:right">
                          <p style="color:red;"><span style="padding-left:2px;"> 属性名与属性</span>值用 空格 分割 ，每个属性对占一行，如下图:</p>
                          <span style="padding-left:12px;">
						    <textarea name="textarea" disabled="disabled" style="vertical-align:middle;width:210px;height:45px;line-height:20px;color:#BBB;">额定电压 220VAC/380VAC
频率 50HZ&plusmn;10%</textarea>
						  </span>
						    
						  </div></td>
					</tr>
					<tr bgcolor="#f4f4f4">
						<td colspan="3" style="padding-left:12px;">&nbsp;</td>
					</tr>
					<tr bgcolor="#f4f4f4">
						<td style="padding-left:15px;" width="8%">产品说明</span>：</td>
						<td colspan="2" style="padding-left:3em;">
                        <textarea name="productSpecification" id="productSpecification" style="width:100%;height:400px;visibility:hidden;"><?php echo htmlspecialchars($products_rows['productSpecification']); ?></textarea>
						</td>
					</tr>
					<!--<?php file_exists("widget/ls_products_addandmodi_moreinfo.php")?include "widget/ls_products_addandmodi_moreinfo.php":"" ?>
					<?php file_exists("widget/ls_comment.php")?include "widget/ls_comment.php":"" ?>-->
					<tr bgcolor="#f4f4f4">
					  <td style="padding-left:15px;">&nbsp;</td>
					  <td colspan="2" align="center" ><div align="middle">
					    <input name="submit" type="submit" value="保存" />
				        <label>
				          <input type="reset" name="button2" id="button2" value="重置" />
			            </label>
					  </div></td>
				  </tr>
					<tr bgcolor="#B9DAFF">
						<td height="25" colspan="3" align="center">&nbsp;</td>
					</tr>
				</table>
			</form></td>
	</tr>
</table>
<?  if($_SESSION["refreshModi"]){?>
<script> document.execCommand('Refresh') ;</script>
<? 
$_SESSION["refreshModi"]=false;
}?>
</body>
</html>