<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
?>
<form action='<?print $PHP_SELF?>'>
<input type=hidden name=jvno value='<?print $jvno?>'>
<input type=hidden name=dt value='<?print $dt?>'>
<table>
<tr><td>Enter password </td><td><input type=password name='pswd'></td>
    <td><input type=submit value='Del' name='del'></td>
</tr>
</table>
</form>
<?
include("../opendb.php");
include("../test.php");
if($del && $pswd=='del')
{
$re=mysqli_query($db,"select j_type,no,tr_no from journal2 where jvno='$jvno' and brcode='$brcode'")or die(mysqli_error($db));
$j_row=mysqli_fetch_array($re);
$sq="delete from journal2 where jvno='$jvno' and brcode='$brcode'";
mysqli_query($db,$sq)or die(mysqli_error($db));

  if($j_row[j_type]=='CR Note')
  {
    mysqli_query($db,"delete from crnote where jvno='$jvno' and brcode='$brcode'")or die(mysqli_error($db));
  }
  if($j_row[j_type]=='CR')
  {
    mysqli_query($db,"delete from cshrec where j_type='$jvno' and brcode='$brcode'")or die(mysqli_error($db));
  }
  if($j_row[j_type]=='CP')
  {
    mysqli_query($db,"delete from cshpay where j_type='$jvno' and brcode='$brcode'")or die(mysqli_error($db));
  }
  if($j_row[j_type]=='BR')
  {
     $drr=mysqli_query($db,"select brec_date from bnkrec where j_type='$jvno' and brcode='$brcode'");
      $rec_row=mysqli_fetch_row($drr) or die(mysqli_error($db));
    $sql="delete from bnkrec where j_type='$jvno' and brcode='$brcode'"; 
    mysqli_query($db,$sql)or die(mysqli_error($db));
  }
  if($j_row[j_type]=='BP')
  {
     $drr=mysqli_query($db,"select brec_date from bnkpay where j_type='$jvno' and brcode='$brcode'");
      $rec_row=mysqli_fetch_row($drr) or die(mysqli_error($db));
    $sql="delete from bnkpay where j_type='$jvno' and brcode='$brcode'"; 
    mysqli_query($db,$sql)or die(mysqli_error($db));
  }
log_entry($brcode,$user,$REMOTE_ADDR,"Del $j_row[j_type] Journal - $jvno");
print "<font color=green>Data has been deleted</font><br>";
}// end if pswd
else
{
 print "Invalid Password";
}
?>


