<?
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'];
//echo "select a.custname,a.code,b.invno,b.da,b.model_code,b.config,b.netamt,b.unit,b.disc, b.taxp, b.tax, b.amt2,b.chasis from cust_master a,veh_invoice b where chasis like '%$inno%' and b.brcode='$brcode' and b.type='-' and a.code=b.cust order by b.da limit 10";
$re=mysqli_query($db,"select a.custname,a.code,b.invno,b.da,b.model_code,b.config,b.netamt,b.unit,b.disc, b.taxp, b.tax, b.amt2,b.chasis from cust_master a,veh_invoice b where chasis like '%$inno%' and b.brcode='$brcode' and b.type='-' and a.code=b.cust order by b.da limit 10") or die("ERR6:".mysqli_error());
//echo "select a.custname,a.code,b.invno,b.da,b.model_code,b.config,b.netamt,b.unit,b.disc, b.taxp, b.tax, b.amt2 from cust_master a,veh_invoice b where da like '%$inno%' and b.brcode='$brcode' and b.type='-' and a.code=b.cust order by b.da limit 10";
$json="";
while($row=mysqli_fetch_array($re))
{
  
$json.= '{"cr":"'.$row[12].'","stock":"'.$row[0].'","crcbal":"'.$row[5].'","rate":"'.addslashes($row[2]).'","reduct":"'.addslashes($row[1]).'","tax":"'.addslashes($row[8]).'"},';

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