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

$table		="tebus_do";

$kode	 	=$_POST[kode];
$tanggal 	=$_POST[tanggal];
$nobukti 	=$_POST[nobukti];
$nobank 	=$_POST[nobank];
$namabank   =$_POST[namabank];
$jenis	 	=$_POST[jenis];
$jmlliter	=$_POST[jmlliter];
$jmlpph  	=$_POST[jmlpph];
$jumlah  	=$_POST[jumlah];
$jmlsetor	=$_POST[jmlsetor];
$hgbeli		=$_POST[hgbeli];
$user	 	=$_SESSION[namauser];

$sql	= mysql_query("SELECT * FROM interface");
$r 	    = mysql_fetch_assoc($sql);
$dobbm		= $r[do_bbm];
//$labapb		= $r[laba_pb];
//$bipajak 	= $r[bi_pajak];
//$labarugi	= $r[laba_rugi];
$prem   	= $r[premium];
$solar  	= $r[solar];
$ptmx   	= $r[pertamax];
$ptmp   	= $r[ptm_plus];
$ptlt   	= $r[pertalite];
$dex        = $r[ptmn_dex];
$dexlite 	= $r[dexlite];
$solek   	= $r[solar_eko];
$nosubdo	= substr($dobbm,0,3);
$nosubbk	= substr($nobank,0,3);
//$nosublp 	= substr($labapb,0,3);
//$nosubpj 	= substr($bipajak,0,3);
//$nosublr 	= substr($labarugi,0,3);

if($jenis=='Premium')
	$kodest=$prem;
else if($jenis=='Bio Solar')
	$kodest=$solar;
else if($jenis=='Pertamax')
	$kodest=$ptmx;
else if($jenis=='Pertamax Turbo')
	$kodest=$ptmp;
else if($jenis=='Pertalite')
	$kodest=$ptlt;
else if($jenis=='Pertamina Dex')
	$kodest=$dex;
else if($jenis=='Dexlite')
	$kodest=$dexlite;
else
	$kodest=$solek;

$bpdo = $dobbm.substr($kodest,2,4);
$bppj = $bipajak.substr($kodest,2,4);

mysql_query("INSERT INTO $table (kode_do,tanggal,nobukti,nobank,namabank,jenis,jml_liter,hg_beli,jml_harga,jml_pph,jml_setor,user) VALUES('$kode','$tanggal','$nobukti','$nobank','$namabank','$jenis','$jmlliter','$hgbeli','$jumlah','$jmlpph','$jmlsetor','$user')");
mysql_query("INSERT INTO stock_do (kode_do,tanggal,nobukti,jenis,jml_liter,hg_beli,jumlah) VALUES('$kode','$tanggal','$nobukti','$jenis','$jmlliter','$hgbeli','$jumlah')");

mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$jumlah WHERE noakun='$dobbm'");
mysql_query("UPDATE akun_bp SET mutasi_db=mutasi_db+$jumlah WHERE noakun='$bpdo'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,nobp,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nobukti','$dobbm','$nosubdo','$bpdo','$jumlah','Penebusan DO $jenis $jmlliter liter','$user')");

mysql_query("UPDATE akun_bb SET mutasi_kd=mutasi_kd+$jmlsetor WHERE noakun='$nobank'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,kredit,keterangan,user) VALUES('$kode','TBD','$tanggal','$nobukti','$nobank','$nosubbk','$jmlsetor','Penebusan DO $jenis $jmlliter liter','$user')");

/*
mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$jmlpph WHERE noakun='$bipajak'");
mysql_query("UPDATE akun_bp SET mutasi_db=mutasi_db+$jmlpph WHERE noakun='$bppj'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,nobp,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nobukti','$bipajak','$nosubpj','$bppj','$jmlpph','Penebusan DO $jenis $jmlliter liter','$user')");


mysql_query("UPDATE akun_bb SET mutasi_db=mutasi_db+$jmlpph WHERE noakun='$labapb'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,debet,keterangan,user) VALUES('$kode','TBD','$tanggal','$nobukti','$labapb','$nosublp','$jmlpph','Penebusan DO $jenis $jmlliter liter','$user')");

mysql_query("UPDATE akun_bb SET mutasi_kd=mutasi_kd+$jmlpph WHERE noakun='$labarugi'");
mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,kredit,keterangan,user) VALUES('$kode','TBD','$tanggal','$nobukti','$labarugi','$nosublr','$jmlpph','Penebusan DO $jenis $jmlliter liter','$user')");
*/
?>
