<?php
ob_start();
$PageSecurity = 11;
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/SQL_CommonFunctions.inc');
 

	$sql_search="SELECT * FROM item_master WHERE CategoryID='".$_REQUEST['q']."' ";
	$search_result = DB_query($sql_search, $db);
	//echo $sql_search;
    $i=0;
  	if($i%2==0)
	{$bg="#CCCCCC";}
	else
	$bg="#C8BECB";
	?>

	<table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
	<?php 
	if(DB_num_rows($search_result)>0)
	{
		while($myrow=DB_fetch_array($search_result))
	  	{ 	
	  		$parameter=$myrow['id'];
	  			$unit=$s->getField('unitsofmeasure','unitid',$myrow['mst_unitid'],'unitname'); 
				
				
				
				
				 $data1='';
		 
		 $unit=DB_query("select * from  unitsofmeasure 
		where unitid ='".$myrow['mst_unitid']."'   ",$db);
		$numrow=DB_num_rows($unit);
		if($numrow>0)
		{
						   while($unit_row=DB_fetch_array($unit))
						   {
						   $data1.="<option value=".$unit_row['unitid'].">".$unit_row['unitname']."</option>";
						   }
		 
		 }
		
		 
		   $data2='';
		 $secondaryunit=DB_query("select * from  unitsofmeasure 
		where  unitid='".$myrow['conv_unit']."'  ",$db);
		$numrow1=DB_num_rows($secondaryunit);
		if($numrow1>0)
		{
						   while($unit_row1=DB_fetch_array($secondaryunit))
						   {
						   $data2.="<option value=".$unit_row1['unitid'].">".$unit_row1['unitname']."</option>";
						   }
		 
		 }
         
		 if($myrow['conv_factor']!='')
		 $convac=$myrow['conv_factor'];
		 else
		 $convac=0;	
				
				
				
				
				
  ?>
 <tr bgcolor="<?php echo $bg;?>">
    <td width="9%">
	<input type="checkbox" name="row_id[<?php echo $i;?>]" id="row_id_<?php echo $i;?>" value="<?php echo $parameter;?>"<?php echo $c;?> onclick="getItemsList('<?php echo $parameter;?>','<?php echo $myrow['StockID'];?>','<?php echo  $myrow['item_name'];?>','<?php echo $myrow['item_desc'];?>','<?php echo $myrow['net_rate'];?>','<?php echo $myrow['mrp_rate'];?>','<?php echo $data1; ?>','<?php echo $data2; ?>',<?php echo $total_current; ?>,<?php echo $convac; ?>,'<?php echo $i;?>')"/></td>
      <td width="20%"><strong><?php echo $myrow['StockID'];?></strong></td>
      <td width="20%"><?php echo $myrow['item_name'];?></td>
       <td width="35%"><?php echo $myrow['item_desc'];?></td>
       <td width="20%"><?php //$unit=$s->getField('unitsofmeasure','unitid',$myrow['unit'],'unitname'); echo $unit;
	   						echo $unit?></td>
     
    </tr>
<?php $i++;
		} 
}?>
<input type="hidden" name="datalist[]" id="datalist" value="<?php print_r($x);?>">
<input type="hidden" name="row_sount" id="row_count" value="<?php echo $i;?>">
</table>

