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

$table	="tebus_do";

$kode	=$_POST[kode];

$sql = mysql_query("SELECT * FROM tebus_do WHERE kode_do='$kode'");
$r 	= mysql_fetch_assoc($sql);

$nobank	    =$r[nobank];
$jenis	 	=$r[jenis];
$jmlliter	=$r[jml_liter];
$jmlpph 	=$r[jml_pph];
$jumlah 	=$r[jml_harga];
$jmlsetor   =$r[jml_setor];
$hgbeli	    =$r[hg_beli];

$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];

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("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("UPDATE akun_bb SET mutasi_kd=mutasi_kd-$jmlsetor WHERE noakun='$nobank'");

//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("UPDATE akun_bb SET mutasi_db=mutasi_db-$jmlpph WHERE noakun='$labapb'");
//mysql_query("UPDATE akun_bb SET mutasi_kd=mutasi_kd-$jmlpph WHERE noakun='$labarugi'");

mysql_query("DELETE FROM stock_do WHERE kode_do='$kode'");
mysql_query("UPDATE tebus_do SET batal='BATAL' WHERE kode_do='$kode'");

mysql_query("DELETE FROM rekapjur WHERE kode_tr='$kode'");
?>