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

$kode	 	=$_POST[kode];
$tanggal 	=$_POST[tanggal];
$nomorsa 	=$_POST[nomorsa];
$nobank 	=$_POST[nobank];
$kodesp  	=$_POST[kodesp];
$namasp 	=$_POST[namasp];
$jmlunit	=$_POST[jmlunit];
$hgbeli		=$_POST[hgbeli];
$jumlah  	=$_POST[jumlah];
$setor		=$_POST[setor];
$bulat		=$_POST[bulat];
$user	 	=$_SESSION[namauser];
$nosubbk    =substr($nobank,0,3);

$sql1       = mysql_query("SELECT * FROM akun_bb WHERE noakun= '$nobank'");
$r1         = mysql_fetch_assoc($sql1);
$namabank   = $r1[naakun];

$sql 	= mysql_query("SELECT * FROM supplier WHERE kode_sp='$kodesp' ORDER BY kode_sp");
$r 	    = mysql_fetch_assoc($sql);
$namasp	= $r[nama];

$sql	= mysql_query("SELECT * FROM interface");
$r 	= mysql_fetch_assoc($sql);

$persed		= $r[persed]; 
$slsbulat		= $r[sls_bulat];
$labapb  		= $r[laba_pb];
$labarugi		= $r[laba_rugi];
$kodelpg		= $r[kode_lpg];
$nosubps		= substr($persed,0,3);
$nosubsls		= substr($slsbulat,0,3);
$nosublpb		= substr($labapb,0,3);
$nosublr 		= substr($labarugi,0,3);

mysql_query("INSERT INTO tebus_do (kode_tb,tanggal,nomor_sa,nobank,namabank,kode_sp,nama_sp,jml_unit,hg_beli,jumlah,setor,bulat,user) VALUES('$kode','$tanggal','$nomorsa','$nobank','$namabank','$kodesp','$namasp','$jmlunit','$hgbeli','$jumlah','$setor','$bulat','$user')");

mysql_query("UPDATE stock SET jml_stok=jml_stok+$jmlunit,hg_beli='$hgbeli',hb_akhir='$hgbeli' WHERE kode_st='$kodelpg'");
mysql_query("INSERT INTO rekap_mbr (kode_tr,jurnal,tanggal,no_bukti,no_urut,kode_st,keterangan,masuk,user) VALUES('$kode','TBD','$tanggal','$nomorsa','1','$kodelpg','Penebusanan DO LPG $namasp','$jmlunit','$user')");

mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$jumlah WHERE noakun='$persed'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,nobp,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nomorsa','$persed','$nosubps','$nobpump','$jumlah','Penebusan DO LPG $jmlunit tabung $namasp','$user')");

mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$bulat WHERE noakun='$slsbulat'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nomorsa','$slsbulat','$nosubsls','$bulat','Selisih pembulatan penebusan DO SA $nomorsa','$user')");

mysql_query("UPDATE akun_bb SET mutasi_kd=mutasi_kd+$setor WHERE noakun='$nobank'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,kredit,keterangan,user) VALUES('$kode','TBD','$tanggal','$nomorsa','$nobank','$nosubbk','$setor','Penebusan DO LPG $jmlunit tabung','$user')");

mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$bulat WHERE noakun='$labapb'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nomorsa','$labapb','$nosublp','$bulat','Penebusan DO LPG $jmlunit tabung','$user')");

mysql_query("UPDATE akun_bb SET mutasi_kd=mutasi_kd+$bulat WHERE noakun='$labarugi'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,kredit,keterangan,user) VALUES('$kode','TBD','$tanggal','$nomorsa','$labarugi','$nosublr','$bulat','Penebusan DO LPG $jmlunit tabung','$user')");
?>
