<?php 

require 'connection.php';

for($count = 0; $count<count($_POST['hidden_vno']); $count++)
{
 	$vno= $_POST['hidden_vno'][$count];
 	$description= $_POST['hidden_refno'][$count];
 	$dated= $_POST['hidden_dated'][$count];
 	$supid= $_POST['hidden_accid'][$count];
 	$custid= $_POST['hidden_custid'][$count];
 	$amount= $_POST['hidden_rate'][$count];
 
// *****************************

// Insert into Broiler Transfer table
 $query="INSERT INTO `jvvoucher`(`vno`, `dated`, `craccid`, `draccid`, `description`, `amount`) VALUES('$vno','$dated','$supid','$custid','$description','$amount')";
	$result=mysqli_query($connect,$query) or die(mysqli_error($connect));

	// Credit Side
 $ledgerqry="INSERT INTO `ledger`(`dated`, `accid`, `description`, `vno`, `refno`, `entrytype`, `credit`) VALUES('$dated','$supid','$description','$vno','$vno','JV','$amount')";
	$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','$custid','$description','$vno','$vno','JV','$amount')";
	$saleledgerrun=mysqli_query($connect,$saleledgerqry) or die(mysqli_error($connect));
	
	}
	if($result){
    echo "Voucher Created.....";
}