<?php $table='bill_material';
		$pcode= $rolepid;
		 function materialshow($PcateID, $dashVal)
		{
			global $db;
			$spacebar = $spacebar . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp;&nbsp;";
			    $s=new db_query();
   		 

		  	$sqlCate = "select * from bill_material  where  part_id  = '".$PcateID."'";
		 
			$rsCate  = DB_query($sqlCate,$db);	
 			if(DB_num_rows($rsCate)>0)
			{
				$rowCate = DB_fetch_array($rsCate);
				 $query_comprole=DB_query("select * from bill_raw_material where  bill_material_id='".$rowCate['id']."'",$db);
 			  while($row_comprole=DB_fetch_array($query_comprole))
			  {
				  			 echo '<tr><td><b>'.$spacebar.'<img src="css/professional/images/allocation.gif" border="0" align="absmiddle" style="cursor:pointer;">&nbsp;'.$s->getField('item_master','id',$row_comprole['mst_itemid'],'item_name').'   (rate='.$row_comprole['bom_costlanded_price'].'  <==>QTY='.$row_comprole['bom_qty'].'  <==>Total Amount='.$row_comprole['bom_amount'].')';
					  
					 echo  '</b>'.$spacebar.'
 				 					 
					 </td></tr>'; 
					 //materialshow($row_comprole['mst_itemid'], $spacebar);
				}
			}
		} 
		
	 
		
		$spacebar = "&nbsp;&nbsp;&nbsp;";	
		?>
 


<link href="Setup/css/pagnation.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
   <tr>
    <td><h2>BOM Tree <strong>Hierarchy&nbsp;</strong> </h2>
	  <div align="right"></div></td>
	</tr>
<tr><td >

		<table width="100%" border="0" cellspacing="0" cellpadding="0">
 		<tr>
		<td> 
		
 		<?php 
		  //echo "select * from bill_material where id='".$_REQUEST['bomid']."'";
		
		  $query=DB_query("select * from bill_material where id='".$_REQUEST['bomid']."'",$db);
		  while($row=DB_fetch_array($query))
		  {		    
 		    echo "<font face='Arial, Helvetica, sans-serif' size='+1'>".$s->getField('item_master','id',$row['part_id'],'item_name').'</font><br>' ;
			$spacebar = "&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;";
			?>
			<table width="100%" border="0" cellspacing="3" cellpadding="3">
			
 			<?php 			
		     $query_comprole=DB_query("select * from bill_raw_material where  bill_material_id='".$row['id']."'",$db);
 			  while($row_comprole=DB_fetch_array($query_comprole))
			  {
			  	 echo '<tr><td>&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;<img src="css/professional/images/menu_root.gif" border="0" align="absmiddle" style="cursor:pointer;"><b><font face="Arial, Helvetica, sans-serif">'.$s->getField('item_master','id',$row_comprole['mst_itemid'],'item_name').'   
				 (rate='.$row_comprole['bom_costlanded_price'].'  <==>QTY='.$row_comprole['bom_qty'].' <==>Total Amount='.$row_comprole['bom_amount'].')'.'</font> &nbsp;&nbsp;';
				
				 echo '</b></td></tr>';
  			  	 materialshow($row_comprole['mst_itemid'], $spacebar);
				  
 			  }	
 		 ?>
		 </table>
		<?php echo "<br>";} ?>		 	 </td>
		</tr>
		</table>

</td>
</tr>
</table>
 </td>
</table>
