<? 
session_start();
$brcode = $_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
$chasisno = $_REQUEST['chasisno'];
$engineno = $_REQUEST['engineno'];
$statusflg = $_REQUEST['statusflg'];
$rsqry=mysqli_query($db,"select chasis from vehstatus where chasis='$chasisno' and brcode='$brcode'");
    $rwnum=mysqli_num_rows($rsqry);
    if($rwnum>0)
    {
        $sql10="update vehstatus set stsflg='$statusflg' where brcode='$brcode' and chasis='$chasisno'";
    }
    else
    {
        $sql10="insert into vehstatus (chasis,engno,brcode,stsflg) values('$chasisno','$engineno','$brcode','$statusflg')";  
    }
    mysqli_query($db,$sql10) or die("J V Write error dif:".mysqli_error());

 print "<font color='Green'> Data has been saved</font>";
print "<script>document.location='dwstockrepo.php'</script>";
?>