<? 
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;
}
$crno=$_REQUEST['crno'];
$jvno=$_REQUEST['jvno'];
include("../opendb.php");
include("../test.php");
if(isset($_POST['del']))
{
    $pswd=$_REQUEST['pswd'];
    $crno=$_REQUEST['crno'];
$jvno=$_REQUEST['jvno'];
 if($pswd=='del')
 {
   $sql="delete from crnote_gst where ret_num='$crno' and jvno='$jvno' and brcode='$brcode'";
   mysqli_query($db,$sql)  or die(mysqli_error());
   $sql="delete from journal2 where jvno='$jvno' and brcode='$brcode'";
   mysqli_query($db,$sql) or die(mysqli_error());
   log_entry($brcode,$user,"$jvno|Credit Note|Del","Credit Note Delete JVNo: $jvno, Cr No: $crno",$db);
   print "<script> alert('Creditnote has been deleted'); document.location='crnote_gst.php'; </script>";
  }
  else
   print "<script> alert('Invalid Password');</script>";
}
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:c1d799}
</style>

<center>
<form action='<?print $PHP_SELF?>' method='POST'>
<input type=hidden name='crno' value='<?print $crno?>'>
<input type=hidden name='jvno' value='<?print $jvno?>'>

<table bgcolor=red>
<tr><td><B><font color=white><center>DELETE CREDIT NOTE</td></tr>
<tr><td bgcolor=white>
<table>
<tr><td>
Password</td><td><input type=password name='pswd'></td>
<td><input type=submit value='Delete' name='del'></td></tr>
</table>
</td></tr>
</table>
</form>
