<?
session_start();
include_once('../opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$code=$_REQUEST['code'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='index.php'; </script>";
 return;
}
if($user=='antony'||$user=='thomas')
{
$find_jv=mysqli_query($db,"select * from sparepurchase where purno='$code' and brcode='$brcode'");
$f_j=mysqli_fetch_row($find_jv);
$j_no=$f_j[jvno];

mysqli_query($db,"delete from sparepurchase where purno='$code' and brcode='$brcode'");
if($j_no >0)
	{
		mysqli_query($db,"delete from journal2 where jvno='$j_no' and brcode='$brcode'");
  	}
print "<script> alert('Data Has been Deleted');document.location='item_purchase.php'; </script>";
}
else
{
    print "<script>alert('You Don't Have Permision...!!!');document.location='item_purchase.php';</script>";
}
}
?>
