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

include("../opendb.php");
include("../test.php");
//print $invno. $da;
$jvres=mysqli_query($db,"select jvno from veh_transout where invno='$invno' and da='$da' and brcode='$brcode'") or die(mysqli_error());
 $jvrow=mysqli_fetch_array($jvres);

mysqli_query($db,"update veh_transin set sale_invoice='-' where da='$da' and sale_invoice='$invno' and brcode='$brcode'") or die(mysqli_error());
mysqli_query($db,"delete from veh_invoice where invno='$invno' and da='$da' and invdate='$dt' and brcode='$brcode'") or die(mysqli_error());
mysqli_query($db,"delete from veh_movement where inv_no='$invno' and da='$da' and date='$dt' and brcode='$brcode'") or die(mysqli_error());
mysqli_query($db,"delete from veh_transout where invno='$invno' and da='$da' and invdate='$dt' and brcode='$brcode'") or die(mysqli_error());
mysqli_query($db,"update vehopstock set sold='-',transtype='' where dano='$da' and sold='$invno' and brcode='$brcode'") or die(mysqli_error());

$sql="update veh_purchase set sale_invoice='-',type='' ".
"where da='$da' and type='trans-out' and brcode='$brcode'";
mysqli_query($db,$sql) or die(mysqli_error());

mysqli_query($db,"delete from journal2 where jvno='$jvrow[0]' and brcode='$brcode'") or die(mysqli_error());
log_entry($brcode,$user,$REMOTE_ADDR,"Del transout da=$da invno=$invno jv=$jvrow[0]");

print "<script> alert('Transfer has been cancelled'); document.location='veh_transout.php' </script>";
?>
