<?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;
		 $t=time();
$username=$_SESSION["username"];
$userid=$_SESSION["userid"];
$bname=$_POST["bname"];


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

$i = 0;
while ($i < $size) {
	$sale_qty= $_POST['sale_qty'][$i];
	$item_name = $_POST['item_name'][$i];
	$id = $_POST['id'][$i];
	
	
	
	  $retail_price = $_POST['retail_price'][$i];
	  
 $sql5 = "SELECT * FROM rate_details where id = '$id' and  user_id='$userid'";
$result5=$conn->query($sql5);
$row5 = $result5->fetch_assoc();

   $prate=$row5['prate'] ;
	 $netamount=$sale_qty * $retail_price;
	 $totalpamount=$sale_qty * $prate;
$totaldiff=$netamount - $totalpamount;


	
	
 	
	$sql1 = "UPDATE rate_details SET srate='$sale_qty' WHERE id='$id'";
$conn->query($sql1);

$tnetamount = $tnetamount + $netamount;
	
	++$i;
// do the update and print out some info just to provide some visual feedback


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

?>
