<?
session_start();
include_once('../opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$tbl2="partmaster";
$partcode=$_GET['key'];
if(isset($_GET['type'])=='name')
{
	$re=mysqli_query($db,"select * from $tbl2 where partname like '%$partcode%' limit 10 ") or die("ERR6:".mysqli_error($db));
}
else
{
	$re=mysqli_query($db,"select * from $tbl2 where partcode  like '$partcode%' order by partcode asc limit 10 ") or die("ERR6:".mysqli_error($db));
}

$json="";
while($row=mysqli_fetch_array($re))
{

$query1="select ndpcost from spareprmast where partcode='$row[0]'";
$rs1=mysqli_query($db,$query1);
$rw1=mysqli_fetch_array($rs1);
$query2="select curstk from spareopstock where itemcode='$row[0]'";
$rs2=mysqli_query($db,$query2);
$rw2=mysqli_fetch_array($rs2);

$json.= '{"partcode":"'.$row[0].'","partname":"'.addslashes($row[1]).'","stock":"'.addslashes($rw2[0]).'","rate":"'.addslashes($rw1[0]).'","reduct":"'.addslashes($row[10]).'","tax":"'.addslashes($rw[0]).'"},';

}


echo '['.trim($json,',').']';
?>