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

$tglawal    =$_POST[tglawal];
$tglakhir   =$_POST[tglakhir];

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

$persed		= $r[persed];
$dobbm		= $r[do_bbm];
$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);
$nosubps	= substr($persed,0,3);

$sql=mysql_query("SELECT * FROM terima_bbm WHERE tanggal BETWEEN '$tglawal' AND '$tglakhir' AND batal='' ");
while($r=mysql_fetch_array($sql)){
    $kode	    =$r[kode_tb];
    $tanggal    =$r[tanggal];
    $kodedo     =$r[kode_do];
    $jenis		=$r[jenis];
    $jmlliter	=$r[jml_liter];
    $hgbeli 	=$r[hg_beli];
    $jumlah 	=$r[jumlah];
    $tanki 	    =$r[tanki];
    $user		=$r[user];

    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);

    mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,debet,keterangan,user) VALUES('$kode','PNB','$tanggal','$kode','$persed','$nosubps','$jumlah','Penerimaan $jenis $jmlliter liter','$user')");
    mysql_query("INSERT INTO rekapjur (kode_tr,jurnal,tanggal,no_bukti,noakun,nosub,nobp,kredit,keterangan,user) VALUES('$kode','PNB','$tanggal','$kode','$dobbm','$nosubdo','$bpdo','$jumlah','Penerimaan $jenis $jmlliter liter','$user')");
}
echo "Data penerimaan bbm tanggal $tglawal s/d $tglakhir telah diposting ulang.";
?>