<?php 

// **************************************EDIT ACCOUNT********************************
if(isset($_POST['amtbox'])){
extract($_POST);

	$descbox=strtoupper($descbox);
 require 'connection.php'; 
  //  
    $purqry = "UPDATE `jvvoucher` SET dated='$dated',craccid='$craccid',draccid='$draccid',description='$descbox', amount='$amtbox' where vno=$jvno";
		$purrun = mysqli_query($connect, $purqry) or die(mysqli_error($connect));

		   $purqry = "DELETE FROM ledger where vno='$jvno' and entrytype='JV'";
		$purrun = mysqli_query($connect, $purqry) or die(mysqli_error($connect));

	// Credit Side
 $ledgerqry="INSERT INTO `ledger`(`dated`, `accid`, `description`, `vno`, `refno`, `entrytype`, `credit`) VALUES('$dated','$craccid','$descbox','$jvno','$jvno','JV','$amtbox')";
	$ledgerrun=mysqli_query($connect,$ledgerqry) or die(mysqli_error($connect));

// Debit Sides
	$saleledgerqry="INSERT INTO `ledger`(`dated`, `accid`, `description`, `vno`, `refno`, `entrytype`, `debit`) VALUES('$dated','$draccid','$descbox','$jvno','$jvno','JV','$amtbox')";
	$saleledgerrun=mysqli_query($connect,$saleledgerqry) or die(mysqli_error($connect));
	

echo "Voucher Updated....";

}


// **************************************DELETE********************************
if(isset($_POST['jvnodlt'])){
extract($_POST);

 require 'connection.php'; 
  //  
	   $purqry = "DELETE FROM jvvoucher where vno='$jvnodlt'";
		$purrun = mysqli_query($connect, $purqry) or die(mysqli_error($connect));


		   $purqry = "DELETE FROM ledger where vno='$jvnodlt' and entrytype='JV'";
		$purrun = mysqli_query($connect, $purqry) or die(mysqli_error($connect));

echo "Voucher Deleted....";

}