<?php include "configuration.inc.php";?>
<?php

if ( !isset($_REQUEST['term']) )
    exit;
$rs = mysql_query('select * from  view_stock where item_name like "%'. $_REQUEST['term'] .'%" and tot_qty>0 order by id asc');

$data = array();

if ( $rs && mysql_num_rows($rs) )
{

$data[] = array(
            'label' =>'<table border="0" cellpadding="2" cellspacing="1" style="width:100%">
			<tr style="color:#fff;"><td style="background:#336666" nowrap>Item Name</td><td style="background:#336666">Unit</td><td style="background:#336666">Price</td><td style="background:#336666" nowrap>Avail Qty</td></tr></table> ' ,'value' => ''
           
        ); 
			
    while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
    {
	$index=$row['item_id'];
    $data[] = array(
            'label' =>'<table border="0" cellpadding="2" cellspacing="1"  style="width:100%"><tr><td>'. $row['item_name'] .'</td><td>'. $row['unit_name'] .'</td><td>'. $row['sell_price'] .'</td><td>'. $row['tot_qty'] .'</td></tr></table> ' ,
            'id' => $index,
			'value' => $row['item_name'],
			'unit_id' => $row['unit_id'],
			'unit_name'=>$row['unit_name'],
			'sell_price'=>$row['sell_price'],	
			'tot_qty'=>$row['tot_qty'],
			'unit_price'=>$row['unit_price'],
			'hsn_code'=>$row['hsn_code'],			
        );
    }
	
}

echo json_encode($data);
flush();

?>