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

include("../opendb.php");
include("../test.php");
if($del && $pswd=='del')
{
 $sql="select jvno,saleordno from spareinvoice where invno='$invno' and brcode='$brcode'";
  $jvres=mysqli_query($db,$sql) or die(mysqli_error($db));
  $jvrow=mysqli_fetch_row($jvres);
  
$sql="delete from spareinvoice where invno='$invno' and brcode='$brcode'";
mysqli_query($db,$sql) or die(mysqli_error($db));
$sq="delete from journal2 where jvno='$jvrow[0]' and narr like'%$invno%' and brcode='$brcode'";
mysqli_query($db,$sq) or die('jv err'.mysqli_error($db));


log_entry($brcode,$user,$REMOTE_ADDR,"Del spareinvoice:$invno,invtype:$invtype,vatorcst:$vatorcst , Journal: $jvrow[0]");
print "<script> alert('Record has been deleted'); document.location='invrepo.php';</script>";
}
else 
 print "<font color=red>Invalid Password</font>";

?>
<form action='<?print $PHP_SELF?>'>
<input type=hidden name='invno' value='<?print $invno?>'>

Enter Password <input type=password name='pswd'>
<input type=submit value='Del' name='del'>
</form>
 
