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

date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		 $my=$month_name . " " . $year;
$v_no=$_POST["v_no"];
$userid=$_SESSION["userid"];


$size = count($_POST['sale_qty']);
$i = 0;
while ($i < $size) {
$id= $_POST['id'][$i];
$sale_qty= $_POST['sale_qty'][$i];
	$item_name = $_POST['item_name'][$i];
	
	 
	  $srate = $_POST['srate'][$i];
 $tamount=$sale_qty * $srate;

	$sql = "update delivery_details set 
srate='$srate', qty='$sale_qty' , amount='$tamount' where id='$id'";
$conn->query($sql);

	++$i;

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


} 
 $sqlinactive = "SELECT * FROM delivery_details where  inv_no='$v_no'";
$resultinactive=$conn->query($sqlinactive);
while($rowinactive = $resultinactive->fetch_assoc())
 
  {
 $tmpurchase=$tmpurchase + $rowinactive['amount'];
 
  }
//$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());

$sql2 = "update delivery set 
 netamount='$tmpurchase' where inv_no='$v_no'";
$conn->query($sql2);

echo "Record Update";
//echo"<td> <a href ='open_customers.php?areaname=$party_area'>Click to Main Dashboard</a>";
echo"<td> <a href ='maindashboard.php'>Back</a>";
?>
