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

$table		="stock";

$kodegr	=$_POST[kodegr];
$kodest	=$_POST[kodest];
$namast	=$_POST[namast];
$tsatuan	=$_POST[tsatuan];
$hgbeli 	=$_POST[hgbeli];
$hgjual 	=$_POST[hgjual];

$sql = mysql_query("SELECT * FROM $table WHERE kode_st='$kodest'");
$row	= mysql_num_rows($sql);
if ($row>0){
	$input	= "UPDATE $table SET nama_st='$namast',satuan='$tsatuan',hg_beli='$hgbeli',hg_jual='$hgjual',lastupdate=now()
	WHERE kode_st= '$kodest'";
	mysql_query($input);
	echo "Data sukses diubah.";
}
else{
	$input = "INSERT INTO $table (kode_gr,kode_st,nama_st,satuan,hg_beli,hg_jual) VALUES('$kodegr','$kodest','$namast','$tsatuan','$hgbeli','$hgjual')";
	mysql_query($input);
	echo "Data sukses disimpan";
}
?>
