<?
session_start();
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='index.php'; </script>";
 return;
}
$inno=$_GET['key'];
if(isset($_GET['type'])=='name')
{
$re=mysqli_query($db,"select * from sales_details where (customer_name like '%$inno%' or address like '%$inno%')  and brcode='$brcode' order by customer_name asc limit 10") or die("ERR6:".mysqli_error());
}
else
{
$re=mysqli_query($db,"select * from sales_details where pan_no like '%$inno%' and brcode='$brcode' order by customer_name asc limit 10") or die("ERR6:".mysqli_error());
}
//$re=mysqli_query($db,"select * from cust_master where acname like '%$inno%' and branch='$brcode' and tin!='' order by acname asc limit 10") or die("ERR6:".mysqli_error());
$json="";
while($row=mysqli_fetch_array($re))
{
    $json.= '{"supnm":"'.$row['pan_no'].'","partcode":"'.addslashes($row['customer_name']).'","partname":"'.addslashes($row['address']).'","stock":"'.addslashes($row['phone']).'","rate":"'.addslashes($row['email']).'","gstno":"'.addslashes($row['gst_no']).'"},';
}
echo '['.trim($json,',').']';
?>