<?php
// 产品侧边栏菜单 536 public {ls_p_cate} ， 支持产品在菜单类别下列出，如存在文件 _menu_product_side_pro.php。

	$s_pro_cate="";
	$pro_cate_sql="select * from ls_products where midcateName 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 asc";
	$pro_cate_query=$opendb->query($pro_cate_sql);
	$pro_cate_num=mysqli_num_rows($pro_cate_query);
	$j=1;
	//$s_pro_cate="\n <div class=\"cate_list\">\n";
	$s_pro_cate.="\n";
	while($pro_cate_rows=mysqli_fetch_assoc($pro_cate_query))
	{
	  $pro_midcate_sql="select * from ls_products where cateName 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 and midcateID=".$pro_cate_rows['ID']." order by Num asc";
	  $pro_midcate_query=$opendb->query($pro_midcate_sql);
	  $pro_midcate_num=mysqli_num_rows($pro_midcate_query);
	  
	  if($pro_midcate_num==0)//大类
	  {
		//$s_pro_cate.="&nbsp;<img src='../Templates/images/cate.gif' border='0'> \n";	//大类前导图

		$s_pro_cate.="    		   <a href='../".rawurlencode($pro_cate_rows['cateFolders'])."/index.html' >  \n".$pro_cate_rows['cateName']."</div></a><br> ";	//大类菜单链接
		//$s_pro_cate.="\n <div class=\"cate_list\">\n";
	  }
	  else//大类中类
	  {
		$onmouseoverscript="";
		$onmouseoverscript2="";
		$menuListscate_sql="select distinct midcateID from ls_products where enable=1";		//  get the number of cate that has midecate
		$menuListscate_query=$opendb->query($menuListscate_sql);
		$menuListscate_num=mysqli_num_rows($menuListscate_query);

		for($i=1;$i<$menuListscate_num;$i++)		// total $menuListscate_num .=-1	//鼠标经过脚本生成，勿动
		{
			if($i==$j)
			{
				$onmouseoverscript.="menuLists".$i.".style.display = 'block';jia".$i.".style.display = 'none';jian".$i.".style.display = 'block';";
			}else{
				$onmouseoverscript.="menuLists".$i.".style.display = 'none';jia".$i.".style.display = 'block';jian".$i.".style.display = 'none';";
			}
		}
		for($i=1;$i<$menuListscate_num;$i++)		// total $menuListscate_num .=-1	//鼠标经过脚本生成，勿动
		{
			if($i==$j)
			{
				$onmouseoverscript2.="menuLists".$i.".style.display = 'none';jia".$i.".style.display = 'block';jian".$i.".style.display = 'none';";
			}else{
				$onmouseoverscript2.="menuLists".$i.".style.display = 'none';jia".$i.".style.display = 'block';jian".$i.".style.display = 'none';";
			}
		}
		//$s_pro_cate.="&nbsp;<img src='../Templates/images/cate.gif' border='0'> \n";		//大类前导图
		$s_pro_cate.="\n<a href=\"javascript:void(0);\"><div class=\"dtClass\" id='".$j."'  onclick='menuopenclose(this.id);'><div id=\"jia".$j."\" class=\"jia\"></div><div id=\"jian".$j."\" class=\"jian\" style=\"display:none;\"></div>".$pro_cate_rows['cateName']."&nbsp;&nbsp;&gt;&gt;\n</div></a>";	//大类菜单链接
		//$s_pro_cate.="\n <div class=\"cate_list\">\n";
		
		if($j == 1){
		$s_pro_cate.="<div  id=\"menuLists".$j."\" style=\"display:block;\">\n";	// don't change it will be changed by ls_syscode
		}else{
			$s_pro_cate.="<div  id=\"menuLists".$j."\" style=\"display:none;\">\n";	// don't change it will be changed by ls_syscode
		}

		while($pro_midcate_rows=mysqli_fetch_assoc($pro_midcate_query))	//中类获取
		{
			$pro_subcate_sql="select * from ls_products where midcateName is null and cateName is null and cateFolders is null and catePagePic is null and catePagePicWidth is null and catePagePicHeight 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 and subcateID=".$pro_midcate_rows['ID']." order by Num asc";
			$pro_subcate_query=$opendb->query($pro_subcate_sql);
			$pro_subcate_num=mysqli_num_rows($pro_subcate_query); 

			//$s_pro_cate.="<div class=\"catelist\">";
	
			if($pro_subcate_num==0)//没小类
			{
			//$s_pro_cate.="    		    <img src='../Templates/images/midcate.gif' border='0'> \n";	//无小类的中类前导图
			$s_pro_cate.="\n<a class=\"smidcatemenu\" href='../".rawurlencode($pro_cate_rows['cateFolders'])."/".rawurlencode($pro_midcate_rows['midcateFolders'])."/index.html?menuId=".$j."' ><div class=\"ddClass\"><div class=\"jian1\"></div>\n".$pro_midcate_rows['midcateName']."\n</div></a>\n";	//中类菜单链接
			}
			else//有小类
			{
			//$s_pro_cate.="    		    <img src='../Templates/images/midcate.gif' border='0'> \n";	//有小类的中类前导图
			$s_pro_cate.="\n<a href=\"javascript:void(0);\"><div class=\"ddClass\"><div class=\"jian1\"></div>".$pro_midcate_rows['midcateName']."&nbsp;&nbsp;&gt;&gt;\n</div></a>\n";
			}
		
			while($pro_subcate_rows=mysqli_fetch_assoc($pro_subcate_query))
			 {
				if(strlen($pro_subcate_rows['subcateName'])>32){
					$subName = substr($pro_subcate_rows['subcateName'],0,32)."..";
				}else{
					$subName = $pro_subcate_rows['subcateName'];
				}
				//$s_pro_cate.="    		    <img src='../Templates/images/subcate.gif' border='0' >&nbsp; \n";	//小类前导图
				$s_pro_cate.="<a class=\"ssubcatemenu\" href=\"../".rawurlencode($pro_cate_rows['cateFolders'])."/".rawurlencode($pro_midcate_rows['midcateFolders'])."/".rawurlencode($pro_subcate_rows['subcateFolders'])."/index.html?menuId=".$j."\" ><div class=\"liClass\"><div class=\"jian\"></div>\n".$subName."<br></div></a>\n";	//小类菜单链接
			 }
		}
		$j++;
		$s_pro_cate.="	</div>\n";
	  }//if($pro_midcate_num==0)//dalei
	//$s_pro_cate.="</div>\n ";
	}

	$s_cate=str_replace("../","",$s_pro_cate);//cate
	$s_pro2_cate=str_replace("../","../../",$s_pro_cate);//pro2_cate
	$s_pro3_cate=str_replace("../","../../../",$s_pro_cate);//pro3_cate
	$s_pro4_cate=str_replace("../","../../../../",$s_pro_cate);//pro4_cate

	$s_p_cate=$s_pro_cate;

/*	$s_p_cate="<ul id=\"pro-menu\" class=\"no-responsive list-group\">";
	$x = $p_num;
	$y = 0;
	$oldcatename= $oldpropath? "index.html" :"";
	while($p_cate_rows=mysqli_fetch_assoc($p_cate_query))
	{
	  $detailsfile = "";
	  $y++;
	  $p_midcate_sql="select * from ls_products where cateName 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 and midcateID=".$p_cate_rows['ID']." order by Num asc";
	  $p_midcate_query=$opendb->query($p_midcate_sql);
	  $p_midcate_num=mysqli_num_rows($p_midcate_query);
	  
	  $detailsfile=$ifcatelink?"../".$p_cate_rows['cateFolders']."/".($oldcatepath?$p_cate_rows['cateFolders'].".html":$menucatename):"javascript:void(01)"; //22-4-19 ".$p_cate_rows['cateFolders'].".html
	  $detailsfile2="../".$templates_var."/catedetail.html";	  
	  
	  if($p_midcate_num==0)//大类
	  {
		//$s_p_cate.="&nbsp;<img src='../Templates/images/cate.gif' border='0'> \n";
		//$s_p_cate.="\n<dt>".$p_cate_rows['cateName']."</dt>";
		 // $s_p_cate.="<li class=\"list-group-item side-pro-list-item\"><a href='../".$p_cate_rows['cateFolders']."/".$p_cate_rows['cateFolders'].".html'> <translate>".$p_cate_rows['cateName']."</translate></a></li>";
		$myproid=$p_cate_rows['ID'];
		$cateurl1= catepro1($myproid);//大类下1个产品
		$detailsfile=$cateurl1!=">1"?$cateurl1:$detailsfile; //1个产品跳过列表页
		 
		$s_p_cate.="<li class=\"list-group-item1 side-pro-list-item\"><a class=\"dalei_said\" href='".$detailsfile."'> <translate>".$p_cate_rows['cateName']."</translate></a>";
		// $s_p_cate.="\n <div class=\"cate_list\">\n"; //大类菜单样式，div css:cate_list
		  $mycatefolder="../".$p_cate_rows['cateFolders']."/"; //2021-4-15
		  //产品列表			
		  //echo  "bott大类无中类-".$mycatefolder;
		   if($ifmenupro)file_exists("_menu_product_side_pro.php")?include "_menu_product_side_pro.php":""; 
		  $s_p_cate.="</li>";
	  } 
	  else//大类中类
	  {
		//$s_p_cate.="&nbsp;<img src='../Templates/".$templates_var."/images/cate.gif' border='0'> \n";  //大类引导图
		if(file_exists($detailsfile2)){
			//".$detailsfile."
			$s_p_cate.="\n<li class=\"list-group-item1 side-pro-list-item\"><a class=\"dalei_said\" href='".$detailsfile."' > <translate>".$p_cate_rows['cateName']."</translate></a><ul class=\"list-unstyled\" id=\"content".$p_cate_rows['ID']."\" >";
		}else{
			$s_p_cate.="\n<li class=\"list-group-item side-pro-list-item\"><a href='javascript:void(0)' onclick=\"turnit(".$p_cate_rows['ID'].",".$p_cate_rows['ID'].");this.href=this.href+'?menuId='+".$p_cate_rows['ID']."+'&cate='+".$p_cate_rows['ID'].";\" > <translate>".$p_cate_rows['cateName']."</translate></a><ul class=\"list-unstyled\" id=\"content".$p_cate_rows['ID']."\" >";
		}
		//？ 不应该有$s_p_cate.="\n <div class=\"cate_list\">\n";
		while($p_midcate_rows=mysqli_fetch_assoc($p_midcate_query))
		{
			$p_subcate_sql="select * from ls_products where midcateName is null and cateName is null and cateFolders is null and catePagePic is null and catePagePicWidth is null and catePagePicHeight 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 and subcateID=".$p_midcate_rows['ID']." order by Num asc";
			$p_subcate_query=$opendb->query($p_subcate_sql);
			$p_subcate_num=mysqli_num_rows($p_subcate_query);
			$mdetailsfile="../".$p_cate_rows['cateFolders']."/".$p_midcate_rows['midcateFolders']."/".($oldcatepath?$p_midcate_rows['midcateFolders'].".html":$menucatename); //22-4-19	".$p_midcate_rows['midcateName'].".html
			//$s_p_cate.="<div class=\"midcate_list\">"; //中类菜单样式
			$myproid=$p_midcate_rows['ID'];
		    $cateurl1= catepro1($myproid);//中类下1个产品
		    $mdetailsfile=$cateurl1!=">1"?$cateurl1:$mdetailsfile; //1个产品跳过列表页
			if($p_subcate_num==0)//没小类
			{
				$s_p_cate.="\n<li  class=\"list-group-item side-pro-list-item\"><a href='".$mdetailsfile."' onclick=\"turnit(".$p_cate_rows['ID'].",".$p_cate_rows['ID'].");this.href=this.href+'?menuId='+".$p_cate_rows['ID']."+'&cate='+".$p_cate_rows['ID'].";\"> <translate>".$p_midcate_rows['midcateName']."</translate></a>"; //".$p_midcate_rows['midcateFolders'].".html
				$mycatefolder=$mdetailsfile;	
				//产品列表		
		 		 if($ifmenupro)file_exists("_menu_product_side_pro.php")?include "_menu_product_side_pro.php":""; 
		  		$s_p_cate.="</li>";
			}
			else//有小类
			{
			//$s_p_cate.="&nbsp;<img src='../Templates/".$templates_var."/images/midcate.gif' border='0'> \n"; //中类引导图
			if(file_exists($detailsfile))
			{$s_p_cate.="<a href='".$mdetailsfile."'><translate>".$p_midcate_rows['midcateName']."</translate></a>";}
			else
			{$s_p_cate.="\n<li  class=\"list-group-item side-pro-list-item\"> <a href='javascript:void(0)' > <translate>".$p_midcate_rows['midcateName']."</translate></a>\n<ul class=\"sub-menu\">\n";}
			//$s_p_cate.="<div class=\"subcate_list\">";//小类菜单样式
			while($p_subcate_rows=mysqli_fetch_assoc($p_subcate_query))		//小类生成
			 {
 				$sdetailsfile="../".$p_cate_rows['cateFolders']."/".$p_midcate_rows['midcateFolders']."/".$p_subcate_rows['subcateFolders']."/".($oldcatepath?$p_subcate_rows['subcateFolders'].".html":$menucatename)	; //22-4-19
				$myproid=$p_subcate_rows['ID'];
		    	$cateurl1= catepro1($myproid);//小类下1个产品
		   	 	$sdetailsfile=$cateurl1!=">1"?$cateurl1:$sdetailsfile; //1个产品跳过列表页
				$s_p_cate.="<li> <a href=\"".$sdetailsfile." ><translate>".$p_subcate_rows['subcateName']."</translate></a></li>\n"; 			 }
				$s_p_cate.="</ul>\n\n"; 
				$mycatefolder=$sdetailsfile;	
		  		 if($ifmenupro)file_exists("_menu_product_side_pro.php")?include "_menu_product_side_pro.php":""; 
				$s_p_cate.="</li>";
			} 
		}
		$s_p_cate.="</ul>";
	  }//if($p_midcate_num==0)//dalei
	}
	$s_p_cate.="\n </ul>";
*/			
?>
