 <?php 
if(isset($_POST['vno'])){
extract($_POST);
require 'connection.php';

$qry="DELETE from ledger where vno='$vno' and entrytype='Med-SL'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));


$qry="DELETE from stockledger where vno='$vno' and invoiceno='Med-SL'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

  	  $qry="DELETE from sales where saleid='$vno'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

if($run){
	echo "Invoice Deleted !";
}
}
// PURCHASE DELETE

if(isset($_POST['vnoslr'])){
extract($_POST);
require 'connection.php';

$qry="DELETE from ledger where vno='$vnoslr' and entrytype='Med-SLR'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));


$qry="DELETE from stockledger where vno='$vnoslr' and invoiceno='Med-SLR'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

  	  $qry="DELETE from saleret where slrid='$vnoslr'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

if($run){
	echo "Invoice Deleted !";
}
}



// PURCHASE DELETE

if(isset($_POST['vnopr'])){
extract($_POST);
require 'connection.php';

$qry="DELETE from ledger where vno='$vnopr' and entrytype='Med-PR'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));


$qry="DELETE from stockledger where vno='$vnopr' and invoiceno='Med-PR'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

  	  $qry="DELETE from purchase where prid='$vnopr'";
  	  $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));

if($run){
	echo "Invoice Deleted !";
}
}
?>