
<?php
include('config.php');


$pos_autoid = $_POST['pos_autoid'];
$posd_autoid = $_POST['posd_autoid'];
$qty = $_POST['qty'];


	$sql_in = "UPDATE posdetail set posd_qty = $qty WHERE pos_autoid = '$pos_autoid' AND posd_autoid = '$posd_autoid'";
	$conn->query($sql_in) or die($sql_in);		

if($qty<=0){
	$conn->query("delete from posdetail where posd_autoid = '$posd_autoid' AND pos_autoid = '$pos_autoid'");
	}

$sql = "select (posd_qty * posd_price) as subtotal from posdetail where pos_autoid = '$pos_autoid' AND posd_autoid = '$posd_autoid'";
$dcon 	= $conn->query($sql) or die($sql);	
$rs = $dcon->fetch_assoc();
$subtotal = $rs['subtotal'];

$sql = "select SUM(posd_qty * posd_price) as gtotal from posdetail where pos_autoid = '$pos_autoid'";
$dcon 	= $conn->query($sql) or die($sql);	
$rs = $dcon->fetch_assoc();
$total = $rs['gtotal'];
?>
<input type="hidden" name="adj_subtotal" id="adj_subtotal" value="<?php echo number_format($subtotal)?>">
<input type="hidden" name="adj_gtotal" id="adj_gtotal" value="<?php echo $total?>">


