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


$acpd=mysqli_query($db,"select * from acperiod") or die ('err'.mysqli_error($db));
$acrow=mysqli_fetch_row($acpd);
$acf= $acrow[0];
$act= $acrow[1];
      
if(isset($_POST['upd']))
{
    $grno = $_REQUEST['grno'];
    $acpd=mysqli_query($db,"select distinct jvno,entrydate,pbillno from sparepurchase where brcode = '$brcode' and grno = '$grno' ") or die ('err'.mysqli_error($db));
    $acrow=mysqli_fetch_row($acpd);
    print "<table><tr><td>";
    print "JV No.:".$acrow[0]." Dated : ".$acrow[1]." Invoice No.".$acrow[2]." will be deleled... ";
    //print "delete from journal2 where brcode = '$brcode' and jvno = '$acrow[0]' ";
    mysqli_query($db,"delete from journal2 where brcode = '$brcode' and jvno = '$acrow[0]' ") or die ('err'.mysqli_error($db));
    mysqli_query($db,"update sparepurchase set jvno = 0 where brcode ='$brcode' and jvno = '$acrow[0]' ") or die ('err'.mysqli_error($db));
    exit;
}
if(isset($_POST['del']))
{
    $grno = $_REQUEST['grno'];
    
    print "<table><tr><td>";
    print "JV No.:".$acrow[0]." Dated : ".$acrow[1]." Invoice No.".$acrow[2]." ";
    print "<input type=submit value='Delete' name='del'></td></tr>";
    exit;
}
?>
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body,td{font-family:'calibri';letter-spacing:1;}
tr{background-color:rgb(95, 197, 117);}
.mnu{margin-left:5}
</style>
<center>
<br><br><br><br><br><br>
<form action='' method='post' ENCTYPE="multipart/form-data">
<table border=1 width=60%>
<tr><td>
<table width=100%>
<th colspan=2><h1>Remove Account Posting</h1>
<tr><td>Enter GRNO <input type=text name='grno'><input type=submit value='Delete' name='upd'></td></tr>

</table>
</td></tr>
</table>
</form>