<?php
include "../../inc/inc.koneksi.php";
session_start();

$table	="st_opname";

$kode	=$_POST['kode'];
$tanggal=$_POST['tanggal'];
$kodest =$_POST['kodest'];
$namast =$_POST['namast'];
$satuan =$_POST['satuan'];
$hgbeli	=$_POST['hgbeli'];
$jmlstok=$_POST['jmlstok'];
$jmlopn =$_POST['jmlopn'];
$jmlsls =$_POST['jmlsls'];
$nilsls =$_POST['nilsls'];
$gudang =$_POST['gudang'];
$user	=$_SESSION['namauser'];

$sql = mysql_query("SELECT * FROM $table WHERE kode_op='$kode' AND kode_st='$kodest' ORDER BY kode_op");
$row= mysql_num_rows($sql);

if($row>0)
	mysql_query("UPDATE $table SET tanggal='$tanggal',gudang='$gudang',satuan='$satuan',hg_beli='$hgbeli',jml_stok='$jmlstok',jml_opn='$jmlopn',jml_sls='$jmlsls',nilai_sls='$nilsls',user='$user' WHERE kode_op='$kode' AND kode_st='$kodest'");
else
	mysql_query("INSERT INTO $table (kode_op,tanggal,gudang,kode_st,nama_st,satuan,hg_beli,jml_stok,jml_opn,jml_sls,nilai_sls,user) VALUES('$kode','$tanggal','$gudang','$kodest','$namast','$satuan','$hgbeli','$jmlstok','$jmlopn','$jmlsls','$nilsls','$user')");
?>