<?php
class ProductType{

    var $clsTree;
	var $proTree;

	function ProductType(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,pic,lang from products";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from products where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}









	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName'];
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

	function ShowProTypeTree_pro($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "";
				else if($i==(count($rows)-1))$sp = " ";
				else $sp = " ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName'];
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree_pro($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

function ShowProTypeTree1($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName'];
				$tmpary['pic']  = $dr['pic'];
				$tmpary['show']  = $dr['show'];
				$tmpary['lang']  = $dr['lang'];
				$tmpary['Price']  = $dr['Price'];
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree1($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

	function ShowProClassTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				if($rows[$i]['Type']=='class'){
					$repeator = "";
					$sp = "";
					if($deep==0) $sp = "";
					else if($i==(count($rows)-1))$sp = "©» ";
					else $sp = "©Ç ";
					$repeator = str_repeat("¡¡",$deep);
					$tmpary = $rows[$i];
					$tmpary['Level'] = $deep;
					$tmpary['Disp']  = $repeator . $sp . $rows[$i]['ProductName'];
					array_push($outarray,$tmpary);
					$this->ShowProClassTree($rows[$i]['IDProduct'],$deep+1,$outarray);
				}
			}
		}
		return $outarray;
	}
    
	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from products where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}


}





class ProductType1{

    var $clsTree;
	var $proTree;

	function ProductType(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from products";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from products where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}




function ProductType1(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from types";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct1($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from types where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}




function ProductType2(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from types ";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct2($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from menu where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}



	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;
$tmpary['productid']  = $dr['productid'];
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}







	function ShowProTypeTree_news($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "";
				else if($i==(count($rows)-1))$sp = " ";
				else $sp = " ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;
$tmpary['productid']  = $dr['productid'];
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}


	function ShowProClassTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				if($rows[$i]['Type']=='class'){
					$repeator = "";
					$sp = "";
					if($deep==0) $sp = "";
					else if($i==(count($rows)-1))$sp = "©» ";
					else $sp = "©Ç ";
					$repeator = str_repeat("¡¡",$deep);
					$tmpary = $rows[$i];
					$tmpary['Level'] = $deep;

					$tmpary['Disp']  = $repeator . $sp . $rows[$i]['ProductName'];
					array_push($outarray,$tmpary);
					$this->ShowProClassTree($rows[$i]['IDProduct'],$deep+1,$outarray);
				}
			}
		}
		return $outarray;
	}
    
	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from products where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}

function DeleteTree1($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from types where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}


function DeleteTree2($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from menu where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}
}















































class ProductType2{

    var $clsTree;
	var $proTree;

	function ProductType(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from products";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from products where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}




function ProductType1(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from types";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct1($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from types where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}





function ProductType2(){
		global $DB;
		$this->clsTree = array();
		$sql = "select isindex,IDProduct,ParentID,Type,ProductName,productid,lang from menu  ORDER BY  productid , productid ";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}



	function GetProduct2($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from menu where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}

function GetProduct3($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from notes where ID='$IDProduct'";
		return $DB->getdata($sql);
	}

	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;

				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}



function ShowmenuTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";

				if($deep==0) $sp = "<li>";

else if($i==0)$sp = "<ul><li>";
				else if($i==(count($rows)-1))$sp = "<li>";


		
		else $sp = "<li>";
				$dr = $rows[$i];
					$repeator = str_repeat("¡¡",$deep);
	
			$tmpary = $dr;

if($deep==0) $spa = "";
else if($i==(count($rows)-1))$spa = "</li></ul></li>";
else $spa = "</li>";
if($dr['isindex']==1 )
$spb="<a href='/admin/edittpl/index.php'>";
else
$spb="<a href='/admin/edittpl/index.php?page_id=".$dr['IDProduct']."'>";
if($edit==0 and $dr['isindex']==1)

$spb="<a href='/index.php'>";
else if($edit==0 and $dr['isindex']!=1)
$spb="<a href='/index.php?page_id=".$dr['IDProduct']."'>";
$spc="</a>";
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $sp.$spb.$dr['ProductName'].$spc.$spa ;
				array_push($outarray,$tmpary);
				$this->ShowmenuTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

	function ShowProClassTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				if($rows[$i]['Type']=='class'){
					$repeator = "";
					$sp = "";
					if($deep==0) $sp = "";
					else if($i==(count($rows)-1))$sp = "©» ";
					else $sp = "©Ç ";
					$repeator = str_repeat("¡¡",$deep);
					$tmpary = $rows[$i];
					$tmpary['Level'] = $deep;
					$tmpary['Disp']  = $repeator . $sp . $rows[$i]['ProductName'];
					array_push($outarray,$tmpary);
					$this->ShowProClassTree($rows[$i]['IDProduct'],$deep+1,$outarray);
				}
			}
		}
		return $outarray;
	}
    
	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from products where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}

function DeleteTree1($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from types where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}


function DeleteTree2($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from menu where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}
}






class ProductType3{

    var $clsTree;
	var $proTree;

	function ProductType(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from products";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from products where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}




function ProductType1(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from types";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct1($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from types where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}





function ProductType3(){
		global $DB;
		$this->clsTree = array();
		$sql = "select isindex,IDProduct,ParentID,Type,ProductName,productid,lang from menu  ORDER BY  productid , productid ";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}



	function GetProduct2($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from menu where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}

function GetProduct3($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from notes where ID='$IDProduct'";
		return $DB->getdata($sql);
	}

	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;

				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}



function ShowmenuTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";

				if($deep==0) $sp = "<li>";

else if($i==0)$sp = "<ul><li>";
				else if($i==(count($rows)-1))$sp = "<li>";


		
		else $sp = "<li>";
				$dr = $rows[$i];
					$repeator = str_repeat("¡¡",$deep);
	
			$tmpary = $dr;

if($deep==0) $spa = "";
else if($i==(count($rows)-1))$spa = "</li></ul></li>";
else $spa = "</li>";
if($dr['isindex']==1)
$spb="<a href='/admin/edittpl/index.php'>";
else
$spb="<a href='/admin/edittpl/index.php?page_id=".$dr['IDProduct']."'>";
if($edit==0 and $dr['isindex']==1)

$spb="<a href='/index.php'>";
else if($edit==0 and $dr['isindex']!=1)
$spb="<a href='/index.php?page_id=".$dr['IDProduct']."'>";
$spc="</a>";
				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $sp.$spb.$dr['ProductName'].$spc.$spa ;
				array_push($outarray,$tmpary);
				$this->ShowmenuTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

	function ShowProClassTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				if($rows[$i]['Type']=='class'){
					$repeator = "";
					$sp = "";
					if($deep==0) $sp = "";
					else if($i==(count($rows)-1))$sp = "©» ";
					else $sp = "©Ç ";
					$repeator = str_repeat("¡¡",$deep);
					$tmpary = $rows[$i];
					$tmpary['Level'] = $deep;
					$tmpary['Disp']  = $repeator . $sp . $rows[$i]['ProductName'];
					array_push($outarray,$tmpary);
					$this->ShowProClassTree($rows[$i]['IDProduct'],$deep+1,$outarray);
				}
			}
		}
		return $outarray;
	}
    
	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from products where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}

function DeleteTree1($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from types where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}


function DeleteTree2($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from menu where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}
}








class ProductType4{

    var $clsTree;
	var $proTree;

	function ProductType(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from products";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from products where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}




function ProductType1(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,Type,ProductName,lang from types";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct1($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from types where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}





function ProductType4(){
		global $DB;
		$this->clsTree = array();
		$sql = "select showindex,menu_link,isindex,IDProduct,ParentID,Type,ProductName,pic,productid,lang from menu   ORDER BY  productid , productid ";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}



	function GetProduct2($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from menu where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}

function GetProduct3($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from notes where ID='$IDProduct'";
		return $DB->getdata($sql);
	}

	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;

				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}



function ShowmenuTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				

$repeator = "";
				$sp = "";

				if($deep==0) $sp = "<li";

else if($i==0)$sp = "<ul><li";

				else if($i==(count($rows)-1))$sp = "<li";


		
		else $sp = "<li";
				$dr = $rows[$i];
					$repeator = str_repeat("¡¡",$deep);
	
			$tmpary = $dr;

			

$sql1 = mysql_query("select * from menu where ParentID =$dr[IDProduct]") or die(mysql_error());
$row11 =  mysql_fetch_array($sql1);


if( $row11[0]) $spa = "";

else if( $i==(count($rows)-1))$spa = "</li></ul><span class='sp'></span></li>";






else $spa = "</li>";
$sqllanginfo =  mysql_query("select * from ch_lang  where ProductName='".$dr[lang]."' ");

	
		$langinfo=mysql_fetch_array($sqllanginfo);
$AutoDo=$langinfo['AutoDo'];

	
	if($AutoDo!="1"){
$splang='?lang='.$dr[lang];
$splang1='';
}
else{
$splang='';
$splang1='';
}

if($dr['isindex']==1 )
if($dr['menu_link'])
if($dr['pic'])

$spb="<a href='$dr[menu_link]$splang' target=_blank><img src='$dr[pic]' alt='$dr[ProductName]' align='absmiddle'  />";
else
$spb="<a href='$dr[menu_link]$splang' target=_blank>";
else
if($dr['pic'])
$spb="<a href='index.html$splang'><img src='$dr[pic]' alt='$dr[ProductName]' align='absmiddle'  />";
else
$spb="<a href='index.html$splang'>";
else
if($dr['menu_link'])
	if($dr['pic'])
$spb="<a href=$dr[menu_link]$splang target=_blank><img src='$dr[pic]' alt='$dr[ProductName]' align='absmiddle'  />";
else
$spb="<a href=$dr[menu_link]$splang target=_blank>";
else
	if($dr['pic'])
$spb="<a href='p".$dr['IDProduct'].".html".$splang1."'><img src='$dr[pic]'  alt='$dr[ProductName]' align='absmiddle' />";
else
$spb="<a href='p".$dr['IDProduct'].".html".$splang1."'>";
$spc="</a>";
				$tmpary['Level'] = $deep;
	

$tmpary['showindex'] = $dr['showindex'];
if($dr['isindex']==1)
	$sps=" id='M'>";
else if($i==count($rows)-1)
$sps=" class='bg_end' id='M".$dr['IDProduct']."'>";
else
$sps=" id='M".$dr['IDProduct']."'>";
$tmpary['Disp']  = $sp.$sps.$spb.$dr['ProductName'].$spc.$spa ;

				array_push($outarray,$tmpary);
				$this->ShowmenuTree($dr['IDProduct'],$deep+1,$outarray);

			}
		}
		return $outarray;
	}

	function ShowProClassTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				if($rows[$i]['Type']=='class'){
					$repeator = "";
					$sp = "";
					if($deep==0) $sp = "";
					else if($i==(count($rows)-1))$sp = "©» ";
					else $sp = "©Ç ";
					$repeator = str_repeat("¡¡",$deep);
					$tmpary = $rows[$i];
					$tmpary['Level'] = $deep;

					$tmpary['Disp']  = $repeator . $sp . $rows[$i]['ProductName'];
					array_push($outarray,$tmpary);
					$this->ShowProClassTree($rows[$i]['IDProduct'],$deep+1,$outarray);
				}
			}
		}
		return $outarray;
	}
    
	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from products where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}

function DeleteTree1($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from types where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}


function DeleteTree2($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from menu where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}
}










class ProductType5{

    var $clsTree;
	var $proTree;


function ProductType5(){
		global $DB;
		$this->clsTree = array();
		$sql = "select IDProduct,ParentID,productid,ProductName,zc,wjmm,sjb,dl,jrsc,jg,ckxq,ProductIntro,rmb,yuan,AutoDo,sjtime,zz,sl,cpjs,cply,dqwz,syindex,soshuo,cpsoshuo,wzsoshuo,tjwt,wtlx,lxr,dzyj,lybt,lylr,yzm,wtlb,gong,gong1,gong2,gong3,oprice,nprice,lb,ljgm,cz,more,fh,wdl,ydl,yhm,mm,sj,qrmm,lxrz,lxry,gsmz,gsmy,gj,sf,cs,txdzz,txdzy,yb,czh,email from ch_lang";
		$rs = $DB->query($sql);
		while($proInfo = $DB->fetch_array($rs)){
			$this->proTree[$proInfo['ParentID']][] = $proInfo;
			if($proInfo['Type']=='class'){
				$this->clsTree[$proInfo['ParentID']][] = $proInfo;
			}
		}
		//print_r($this->clsTree);
	}

	function GetProduct($IDProduct)
	{
		global $DB;
		$this->clsTree = array();
		$sql = "select * from ch_lang where IDProduct='$IDProduct'";
		return $DB->getdata($sql);
	}






	function ShowProTypeTree($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "<b>";
				else if($i==(count($rows)-1))$sp = "©¸ ";
				else $sp = "©À ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;

				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}
function ShowProTypeTree1($pid="0",$deep=0,&$outarray)
	{
		$rows = $this->proTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$repeator = "";
				$sp = "";
				if($deep==0) $sp = "";
				else if($i==(count($rows)-1))$sp = " ";
				else $sp = " ";
				$dr = $rows[$i];
				$repeator = str_repeat("¡¡",$deep);
				$tmpary = $dr;

				$tmpary['Level'] = $deep;
				$tmpary['Disp']  = $repeator . $sp . $dr['ProductName']  ;
				array_push($outarray,$tmpary);
				$this->ShowProTypeTree($dr['IDProduct'],$deep+1,$outarray);
			}
		}
		return $outarray;
	}

	function GetSubProTypeIDs($pid)
	{
		$subclassid = "";
		$rows = $this->clsTree[$pid];
		if(count($rows)>0)
		{
			for($i=0;$i<count($rows);$i++)
			{
				$subclassid .= $rows[$i]["IDProduct"].",";
				$subclassid .= $this->GetSubProTypeIDs($rows[$i]["IDProduct"]);
			}
		}
		if($subclassid) $subclassid = substr($subclassid,0,strlen($subclassid)-1);
		return $subclassid;
	}

	function DeleteTree($ProductID)
	{
		global $DB;
		$ProductIDs = $ProductID;
		$SubIDs = $this->GetSubProTypeIDs($ProductID);
		if($SubIDs) $ProductIDs .= ",".$SubIDs;
		$sql = "delete from ch_lang where IDProduct IN($ProductIDs)";
		$DB->query($sql);
	}



}


?>