<?php
include "../../inc/inc.koneksi.php";

mysql_query("UPDATE stock SET jml_stok=stok_tl WHERE 1");

$sql = mysql_query("SELECT kode_st,sum(masuk) as jmasuk,sum(keluar) as jkeluar FROM rekap_mbr GROUP BY kode_st");

while($r=mysql_fetch_array($sql)){
    $kodest = $r[kode_st];
	$jmasuk = $r[jmasuk];
	$jkeluar= $r[jkeluar];
	$mutasi = $jmasuk-$jkeluar;

    mysql_query("UPDATE stock SET jml_stok=jml_stok+$mutasi WHERE kode_st='$kodest'");
} 

echo "Kartu persediaan selesai diposting ulang.";
?>
