<?php
session_start();
include 'dbc.php';


$username=$_SESSION["username"];
$userid=$_SESSION["userid"];
$today=$_POST["vdate"];
$v_no=$_POST["v_no"];
$v_type=$_POST["v_type"];
$acc_name_cr=$_POST["acc_name_cr"];
$disc=$_POST["disc"];


$size = count($_POST['sale_qty']);

$i = 0;
while ($i < $size) {
	$sale_qty= $_POST['sale_qty'][$i];
	$acc_name = $_POST['acc_name'][$i];
	
	 $acc_type = $_POST['acc_type'][$i];
	  
   
	// $tamount=$sale_qty * $product_sale;
	 
							
							
							
							
							
	$ledger_amount=$ledger_amount + $sale_qty;

if($sale_qty > 0)
{
	$sql = "Insert into expense_voucher (id,date,month_name,tr_no,acc_name_dr,acc_name_cr,discription,amount,user_id,v_type) values (null,'$today','$acc_type','$v_no','$acc_name','$acc_name_cr','$disc','$sale_qty','$userid','$v_type')";
mysql_query($sql) or die("Error : " . mysql_error());

$sql1 = "Insert into acc_ledger (id,date,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$today','$v_no','$acc_name','$disc','$acc_type','$sale_qty','0','0','$userid')";
mysql_query($sql1) or die("Error : " . mysql_error());

 
		}					


	++$i;

// do the update and print out some info just to provide some visual feedback


} 
//$sql11 = "Insert into expense_voucher (id,date,tr_no,acc_name_dr,discription,amount,user_id,v_type) values (null,'$today','$v_no','$acc_name_dr','$disc','$ledger_amount','$userid','$v_type')";
//mysql_query($sql11) or die("Error : " . mysql_error());

$sql122 = "Insert into acc_ledger (id,date,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$today','$v_no','$acc_name_cr','$disc','$v_type','0','$ledger_amount','0','$userid')";
mysql_query($sql122) or die("Error : " . mysql_error());echo "Record Update";
//echo"<td> <a href ='open_customers.php?areaname=$party_area'>Click to Main Dashboard</a>";
echo"<td> <a href ='expense_vocher_entry2.php'>Click to Main Dashboard</a>";
?>
