<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Invalid Login') </script>";
 return;
}

include("opendb.php");

if(@$_GET['type']=='name')
{
$partname=$_GET['key'];
$re=mysqli_query($db,"select web,branch,code,addr1,cst from sup_master where supname like '%$partname%'  order by web asc limit 20");
 
}
else
{
$partcode=$_GET['key'];

$sql="select acname,brcode,code,addr1,cst,cramt,state1 from customer where   acname like '$partcode%' and brcode='$brcode' order by acname asc limit 50";
//echo $sql;
$re=mysqli_query($db,"select acname,brcode,code,addr1,cst,state1 from customer where acname like '%$partcode%'  order by acname asc limit 50");

//$re=mysqli_query($db,"select  web,branch,code,addr1,cst from sup_master where supname like '%$partcode%'  order by web asc limit 20");


}
$json="";
while($row=mysqli_fetch_array($re))
{
//    $sql="select msno from minput where cust='$row[code]' and brcode='$brcode'";
    //$result = mysqli_query($db,$sql);
    //$rowdt=mysqli_fetch_array($result);
	 //echo $row[0];
	 
	 $json.= '{"orderto":"'.$row[0].'","partname":"'.addslashes($rowdt[0]).'","price":"'.addslashes($row[addr1]).'","supqty":"'.addslashes($row[cst]).'","mrgnprc":"'.addslashes($row[code]).'"},';
	 
}
echo '['.trim($json,',').']';
?>