<?php 
 // echo @$_GET['msg'];
 //  session_start();
 //  if(isset($_SESSION['userId'])){ 

require 'connection.php';

for($count = 0; $count<count($_POST['hidden_accid']); $count++)
{
	
 	$accid= $_POST['hidden_accid'][$count];
 	$dated= $_POST['hidden_dated'][$count];
 	$vno= $_POST['hidden_vno'][$count];
 	$description= $_POST['hidden_desc'][$count];
 	$refno= $_POST['hidden_refno'][$count];
 	$debit= $_POST['hidden_amtdr'][$count];

 	if($debit>0){
 		// Insert Into Cash Book For Cash Book Account
 $query="INSERT INTO `voucher`(`dated`, `vno`, `accid`, `description`, `refno`, `credit`) VALUES('$dated','$vno','3','$description','$refno','$debit')";
	$result=mysqli_query($connect,$query) or die(mysqli_error($connect));

// Insert Into Voucher For Party Account
 $partyqry="INSERT INTO `voucher`(`dated`, `vno`, `accid`, `description`, `refno`, `debit`) VALUES('$dated','$vno','$accid','$description','$refno','$debit')";
	$partyresult=mysqli_query($connect,$partyqry) or die(mysqli_error($connect));
// Insert Into Ledger For CashBook Account
 $ledgercashbook="INSERT INTO `ledger`(`comid`,`dated`, `vno`, `accid`, `description`, `entrytype`, `credit`) VALUES('1','$dated','$vno','3','$description','$refno','$credit')";
	$cashbokresult=mysqli_query($connect,$ledgercashbook) or die(mysqli_error($connect));

// Insert Into Ledger For Party Account
 $ledgerparty="INSERT INTO `ledger`(`comid`,`dated`, `vno`, `accid`, `description`, `entrytype`, `debit`) VALUES('1','$dated','$vno','$accid','$description','$refno','$debit')";
	$ledgerresult=mysqli_query($connect,$ledgerparty) or die(mysqli_error($connect));

 	}
}

echo "Data added !";


// }
// else
// {
// header('location: index.php');
// }
 ?>
