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



$userid=$_SESSION["userid"];

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

$i = 0;
while ($i < $size) {
	$saleqty= $_POST['saleqty'][$i];
	
	$id = $_POST['id'][$i];
	$inv_no= $_POST['inv_no'][$i];
	
	$item_name= $_POST['item_name'][$i];
	$srate= $_POST['srate'][$i];
	$inv_no= $_POST['inv_no'][$i];
	$st= $_POST['st'][$i];
	


	$netamount=$saleqty * $srate;
	$stamount=$netamount * $st / 100;
$sttotalamount=$netamount + $stamount;
 	
	$sql1 = "UPDATE invoice_details_st SET srate='$srate',qty='$saleqty',amount='$netamount',st='$st',stamount='$stamount',netamount='$sttotalamount' WHERE id='$id'";
$conn->query($sql1);

$tnetamount = $tnetamount + $netamount;
$tstamount = $tstamount + $stamount;
$totalamount = $totalamount + $sttotalamount;
	
	++$i;
$sql2 = "UPDATE invoice_st SET netamount='$tnetamount',st='$st',stamount='$tstamount',tnetamount='$totalamount' WHERE id='$inv_no'";
$conn->query($sql2);
// do the update and print out some info just to provide some visual feedback



} 
header("location:Open_Invoice_st.php");

?>
