<script type="text/javascript">
	$(document).ready(function(){
	$("#data_detail").hide();
	
	$("#mulai").focus();
	
	$("#mulai").click(function(){
		$(".input_detail").val('');
		$(".input_header").val('');
		cari_tgl();
	});
	
	function cari_tgl(){
		var no = 1;
		$.ajax({
			type	: "POST",
			url		: "modul/report/cari_tanggal.php",
			data	: "no="+no,
			dataType: "json",
			success	: function(data){
				$("#txt_tanggal").val(data.tanggal);
				$("#txt_tanggaljt").val(data.tanggal);
				var tanggal=$("#txt_tanggal").val();
				var tahun  =tanggal.substr(0,4);
				$("#t_tahun").val(tahun);
				$("#txt_tanggal").focus();
				cari_nomor();
			}
		});
	}
	
	function cari_nomor(){
		var tanggal = $("#txt_tanggal").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/cari_nomor.php",
			data	: "tanggal="+tanggal,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(data.nomor);
				$('#input_pb').show();
				cari_nourut();
				tampil_data_detail();
			}
		});
	}
	
	function cari_nourut(){
		var kode = $("#txt_kode").val();
				
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/cari_nourut.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){				
				$("#txt_nourut").val(data.nourut);		
			}
		});
	}
	
	function tampil_data_detail(){
		var kode = $("#txt_kode").val();
		$("#data_detail").show();
		$("#data_detail").load("modul/pembelian/tampil_data_detail.php?kode="+kode);
		hitung_total();
	}
	
	function hitung_total(){
		var kode= $("#txt_kode").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/cari_total.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_total").val(data.total);				
			}
		});
	}
	
	$("#txt_tanggal").keyup(function(){
		cari_nomor();
	});
	
	$("#txt_nomorfk").keyup(function(){
		var nomorfk = $("#txt_nomorfk").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/cari_nofk.php",
			data	: "nomorfk="+nomorfk,
			dataType: "json",
			success	: function(data){
				$("#t_nomorfk").val(data.nofkt);
				var nofk = $("#t_nomorfk").val();
				
				if(!(nofk.length==0)){
					alert('Nomor faktur '+nomorfk+' sudah ada.')
					return (false);
				}	
			}
		});
	});
	
	$('#form_cari_kodepb').dialog({
		autoOpen: false,
		modal	: true,
		width: 800,
	});
		
	$('#cari_kodepb').click(function(){
		$('#form_cari_kodepb').dialog('open');
		$("#info_pbl").show();	
		$("#txt_carikode").focus();		
	});
		
	$("#txt_carikode").keyup(function(){
		var cari = $("#txt_carikode").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/tampil_kodepb.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#info_pbl").html(data);				
			}
		});
	});
	
	$('#form_cari_sup').dialog({
		autoOpen: false,
		modal	: true,
		width: 700,
	});
		
	$('#txt_namasup').keyup(function(){		
		$('#form_cari_sup').dialog('open');
		$("#info_supplier").load('modul/pembelian/tampil_data_sup.php');
		$("#txt_carisup").focus();
	});
	
	$('#txt_namasup').click(function(){		
		$('#form_cari_sup').dialog('open');
		$("#info_supplier").load('modul/pembelian/tampil_data_sup.php');
		$("#txt_carisup").focus();
	});
	
	$("#txt_carisup").keyup(function(){
		var cari = $("#txt_carisup").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/tampil_data_sup.php",
			data	: "cari="+cari,			
			success	: function(data){
				$("#info_supplier").html(data);
			}
		});
	});
	
	$('#form_cari_kodeopb').dialog({
		autoOpen: false,
		modal	: true,
		width: 800,
	});
		
	$('#txt_kodeopb').keyup(function(){
		$('#form_cari_kodeopb').dialog('open');
		$("#info_opb").show();	
		$("#txt_cariopb").focus();		
	});
		
	$("#txt_cariopb").keyup(function(){
		var cari    = $("#txt_cariopb").val();
		var kodesup = $("#txt_kodesup").val();
		
		$.ajax({
			type	: "GET",
			url		: "modul/pembelian/tampil_data_opb.php",
			data	: "cari="+cari+
			    "&kodesup="+kodesup,
			success	: function(data){
				$("#info_opb").html(data);
			}
		});
	});
	
	$('#txt_barcode').keyup(function(){
		var barc = $('#txt_barcode').val();
		
		if(barc=='Q') $("#txt_bayar").focus();
		else if(barc=='q') $("#txt_bayar").focus();
		else{
			if(barc.length>5){
			$.ajax({
				type	: "POST",
				url		: "modul/pembelian/cari_barcode.php",
				data	: "barc="+barc,
				dataType: "json",
				success	: function(data){				
					$("#txt_kodest").val(data.kodest);
					$("#txt_namast").val(data.namast);
					$("#txt_satuan").val(data.satuan);
					$("#txt_expired").val(data.expired);
					$("#txt_hgbeli").val(data.hgbeli);
					$("#txt_hbakhir").val(data.hgbeli);
					$("#txt_hgjual").val(data.hgjual);
					$("#txt_jmlunit").focus();
				}			
			});
			}
		}
	});
	
	$('#form_cari_barang').dialog({
		autoOpen: false,
		modal	: true,
		width: 700,
	});
	
	$('#txt_namast').click(function(){
		$('#form_cari_barang').dialog('open');
		$("#txt_caribr").focus();
	});
	
	$('#txt_namast').keyup(function(){
		$('#form_cari_barang').dialog('open');
		$("#txt_caribr").focus();
	});
	
	$("#txt_caribr").keyup(function(){
		var cari	= $("#txt_caribr").val();
		if(cari.length>3){
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/tampil_data_barang.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#info_barang").html(data);				
			}
		});
		}
	});
	
	$('#form_buat_kodebr').dialog({
		autoOpen: false,
		modal	: true,
		width: 800,
	});
		
	$('#buat_databr').click(function(){
		var kode = $("#i_kodegr").val();
		$('#form_buat_kodebr').dialog('open');
		if(!kode=='') cari_kodest();
		$("#i_kodegr").focus();
	});
	
	$('#form_cari_gr').dialog({
		autoOpen: false,
		modal	: true,
		width: 600,
	});
	
	$('#cari_gr').click(function(){
		$('#form_cari_gr').dialog('open');
		$("#txt_carigr").focus();
	});
	
	$("#txt_carigr").keyup(function(){
		var cari	= $("#txt_carigr").val();
		$.ajax({
			type	: "GET",
			url		: "modul/pembelian/tampil_data_gr.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#info_gr").html(data);
			}
		});
	});
	
	$("#i_kodegr").keyup(function() {
		var kode 	= $("#i_kodegr").val()
		
		if(kode.length==2){
		$.ajax({
			type	: "POST",
			url		: "modul/inventory/cari_grup.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#i_kodegr").val(kode);				
				$("#i_namagr").val(data.namagr);
				cari_kodest();
			}
		});
		}
	});
	
	function cari_kodest(){
		var kode = $("#i_kodegr").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/inventory/cari_nomor.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#i_kodest").val(data.nomor);
				$("#i_namast").focus();
			}
		});
	}
	
	$('#form_i_cari_barang').dialog({
		autoOpen: false,
		modal	: true,
		width: 800,
	});
	
	$('#cari_brg').click(function(){
		$('#form_i_cari_barang').dialog('open');
		$("#i_caribr").focus();
	});
	
	$("#i_caribr").keyup(function(){
		var kodegr	= $("#i_kodegr").val();
		var cari	= $("#i_caribr").val();
		if(cari.length>3){
		$.ajax({
			type	: "GET",
			url		: "modul/pembelian/tampil_data_ibrg.php",
			data	: "cari="+cari+
					"&kodegr="+kodegr,
			success	: function(data){
				$("#info_i_barang").html(data);				
			}
		});
		}
	});
	
	$("#i_barcode").keyup(function(){
		var kode 	= $("#i_barcode").val();
		
		if(kode.length>4){
		$.ajax({
			type	: "POST",
			url		: "modul/inventory/cari_barcode.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){				
				$("#t_barcode").val(data.barcode);
				$("#t_kodest").val(data.kodest);
				var barc   = $("#t_barcode").val();
				var kodest = $("#t_kodest").val();
				var kodesta= $("#i_kodest").val();
				
				if(!(barc.length==0)){
					if(kodest==kodesta){
						alert('Maaf, Barcode '+kode+' sudah ada.');
						$("#i_barcode").val('');
						$("#i_barcode").focus();
						return (false);
					}
				}				
			}
		});
		}
	});
	
	$("#simpan_br").click(function(){
		var kodegr	= $("#i_kodegr").val();
		var namagr	= $("#i_namagr").val();
		var kodest	= $("#i_kodest").val();
		var namast	= $("#i_namast").val();
		var barcode = $("#i_barcode").val();
		var satuan	= $("#i_satuan").val();
		var hgbeli	= $("#i_hgbeli").val();
		var ungros	= $("#i_ungros").val();
		var expired	= $("#i_expired").val();
		var hgresep	= $("#i_hgresep").val();
		var hgparam	= $("#i_hgparam").val();
		var minstok = $("#i_minstok").val();
	
		if(kodegr.length == 0){
           alert("Maaf, Kode grup tidak boleh kosong");
		   $("#txt_kodegr").focus();
		   return (false);
        }
		if(kodest.length == 0){
           alert("Maaf, Kode persediaan tidak boleh kosong");
		   $("#txt_kodest").focus();
		   return (false);
        }
		if(namast.length == 0){
           alert("Maaf, Nama barang tidak boleh kosong");
		   $("#txt_namast").focus();
		   return (false);
        }
		if(satuan.length == 0){
			alert("Maaf, Satuan tidak boleh kosong");
			$("#txt_expired").focus();
			return (false);
        }
		if(expired.length == 0){
			alert("Maaf, Harga jual umum harus diisi.");
			$("#txt_expired").focus();
			return (false);
        }
        if(hgresep.length == 0){
			alert("Maaf, Harga jual resep harus diisi.");
			$("#txt_hgresep").focus();
			return (false);
        }
        if(hgparam.length == 0){
			alert("Maaf, Harga jual paramedis harus diisi.");
			$("#txt_hgparam").focus();
			return (false);
        }
		
		$.ajax({
			type	: "POST",
			url		: "modul/inventory/simpan.php",
			data	: "kodegr="+kodegr+
					"&namagr="+namagr+
					"&kodest="+kodest+
					"&namast="+namast+
					"&barcode="+barcode+
					"&satuan="+satuan+
					"&minstok="+minstok+
					"&hgbeli="+hgbeli+
					"&expired="+expired+
					"&hgresep="+hgresep+
					"&hgparam="+hgparam,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#info").html("<img src='loading.gif' />");
			},				  
			success	: function(data){
				$("#info").html(data);				
				$("#txt_kodest").val(kodest);
				$("#txt_namast").val(namast);
				$("#txt_satuan").val(satuan);
				$("#txt_barcode").val(barcode);
				$("#txt_hgbeli").val(hgbeli);
				$(".input_st").val('');
				cari_kodest();
			}
		});
	});
	
	$("#txt_jmlunit").keyup(function(){
		hitung_hbeli();
	});
	
	$("#txt_jmlbruto").keyup(function(){		
		hitung_hbeli();
	});
	
	$("#txt_diskon").keyup(function(){
		hitung_hbeli();
	});
	
	$("#txt_ppn").keyup(function(){
		hitung_hbeli();
	});
		
	function hitung_hbeli(){
		var unit	=$("#txt_jmlunit").val();
		var jmlbruto=$("#txt_jmlbruto").val();
		var diskon	=$("#txt_diskon").val();
		var ppn  	=$("#txt_ppn").val();
		var hgjual	=$("#txt_hgjual").val();
		
		if(!(unit.length==0))
			var junit=parseFloat(unit);
		else
			var junit=0;
		
		if(!(jmlbruto.length==0))
			var jbruto=parseFloat(jmlbruto);
		else
			var jbruto=0;
		
		if(!(diskon.length==0))
			var jdiskon=parseFloat(diskon);
		else
			var jdiskon=0;
		
		if(!(ppn.length==0))
			var jppn=parseInt(ppn);
		else
			var jppn=0;
		
		var hgbruto = jbruto/junit;
		var ndiskon = hgbruto*(jdiskon/100);
		var hgnetto	= hgbruto-ndiskon;
		var hgppn   = hgnetto*(jppn/100);
		var hgbeli	= hgnetto+hgppn;
		var jumlah	= hgbeli*junit;
		var margin  = ((parseInt(hgjual)-hgbeli)/hgbeli)*100;
		var margin  = margin.toFixed(2);
		
		$("#txt_jumlah").val(jumlah);
		$("#txt_hgbruto").val(hgbruto);
		$("#txt_hgbeli").val(hgbeli);
		$("#txt_margin").val(margin);
	}
	
	$("#simpan").click(function(){
		var kode	= $("#txt_kode").val();
		var tanggal	= $("#txt_tanggal").val();
		var nomorfk	= $("#txt_nomorfk").val();
		var kodesup	= $("#txt_kodesup").val();
		var namasup	= $("#txt_namasup").val();
		var kodeopb = $("#txt_kodeopb").val();
		var kodecab = $("#txt_kodecab").val();
		var tanggaljt= $("#txt_tanggaljt").val();
		var nourut	= $("#txt_nourut").val();
		var kodest	= $("#txt_kodest").val();
		var namast	= $("#txt_namast").val();
		var barcode	= $("#txt_barcode").val();
		var satuan	= $("#txt_satuan").val();
		var jmlunit	= $("#txt_jmlunit").val();
		var jmlbruto= $("#txt_jmlbruto").val();
		var hgbruto = $("#txt_hgbruto").val();
		var diskon 	= $("#txt_diskon").val();
		var ppn   	= $("#txt_ppn").val();
		var hgbeli	= $("#txt_hgbeli").val();
		var expired	= $("#txt_expired").val();
		var jumlah	= $("#txt_jumlah").val();
		var hgjual	= $("#txt_hgjual").val();
		var margin	= $("#txt_margin").val();
		var kodetgl = kode.substring(3,9);
		var thn		= tanggal.substring(2,4);
		var bln     = tanggal.substring(5,7)
		var tgl     = tanggal.substring(8,10);
		var tglfak  = thn+bln+tgl;

        if(!(tglfak==kodetgl)){
			alert('Maaf, penulisan tanggal tidak benar. Isi kolom tanggal dengan diketik.');
			$("#txt_tanggal").focus();
			return(false);
		}
		if(nomorfk.length == 0){
           alert("Maaf, Nomor faktur tidak boleh kosong");
		   $("#txt_nomorfk").focus();
		   return (false);
        }
        if(kodeopb.length == 0){
           alert("Maaf, Nomor pesanan tidak boleh kosong.");
		   $("#txt_kodeopb").focus();
		   return (false);
        }
		if(kodest.length == 0){
           alert("Maaf, Kode Barang tidak boleh kosong");
		   $("#txt_kodest").focus();
		   return (false);
        }
		if(jmlunit.length == 0){
           alert("Maaf, Jumlah barang tidak boleh kosong");
		   $("#txt_jmlunit").focus();
		   return (false);
        }
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/simpan.php",
			data	: "kode="+kode+
					"&tanggal="+tanggal+
					"&nomorfk="+nomorfk+
					"&kodesup="+kodesup+
					"&namasup="+namasup+
					"&kodeopb="+kodeopb+
					"&kodecab="+kodecab+
					"&tanggaljt="+tanggaljt+
					"&nourut="+nourut+
					"&kodest="+kodest+
					"&namast="+namast+
					"&barcode="+barcode+
					"&jmlunit="+jmlunit+
					"&satuan="+satuan+
					"&jmlbruto="+jmlbruto+
					"&hgbruto="+hgbruto+
					"&diskon="+diskon+
					"&ppn="+ppn+
					"&hgbeli="+hgbeli+
					"&hgjual="+hgjual+
					"&margin="+margin+
					"&expired="+expired+		
					"&jumlah="+jumlah,
			timeout	: 2000,
			beforeSend	: function(){
				$("#info").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#info").html(data);
				$(".input_detail").val('');
				$("#txt_barcode").focus();
				cari_nourut();
				tampil_data_detail();
			}
		});
	});
	
	$('#form_lihat_detail').dialog({
		autoOpen: false,
		modal	: true,
		width: 700,
	});
	
	$("#detail").click(function(){
		var kodepb = $("#txt_kode").val();
		$('#form_lihat_detail').dialog('open');
		$("#lihat_detail").load('modul/pembelian/detail_nota.php?kodepb='+kodepb);
	});
	
	$("#txt_pot").keyup(function(){
		var total= $("#txt_total").val();
	
		if(total.length==0){
			alert('Maaf, total pembelian masih kosong.');
			return(false);
		}
		var pot  	= $("#txt_pot").val();
		var bayar	= parseInt(total)-parseInt(pot);
		$("#txt_bayar").val(bayar);
	});

	$("#txt_bayar").keyup(function(){
		hitung_bayar();
	});
	
	function hitung_bayar(){
		var total 	= $("#txt_total").val();
		var bayar 	= $("#txt_bayar").val();
		var pot   	= $("#txt_pot").val();
		
		if(!(pot.length==0))			
			var netto = parseFloat(total)-parseFloat(pot);
		else
			var netto = parseFloat(total);
		
		var jbayar = parseFloat(bayar);
		
		if(jbayar>netto){
			alert('Maaf, jumlah bayar tidak boleh melebihi netto.');
			return(false);
		}
		var kurang	= netto - jbayar;
		
		$("#txt_netto").val(netto);
		$("#txt_kurang").val(kurang);
	}
	
	$("#rekam_pb").click(function(){	
		var kode		= $("#txt_kode").val();
		var tanggal 	= $("#txt_tanggal").val();
		var kodesup 	= $("#txt_kodesup").val();
		var namasup		= $("#txt_namasup").val();
		var kodecab		= $("#txt_kodecab").val();
		var nomorfk		= $("#txt_nomorfk").val();
		var tanggaljt	= $("#txt_tanggaljt").val();
		var total	 	= $("#txt_total").val();
		var potong		= $("#txt_pot").val();
		var bayar	 	= $("#txt_bayar").val();		
		var kurang	 	= $("#txt_kurang").val();

		if(kode.length == 0){
           alert("Maaf, Kode pembelian  masih kosong.");
		   return (false);
        }		
		if(total.length == 0){
			alert("Maaf, Total pembelian masih kosong.");
			$("#txt_namast").focus();
			return (false);
        }
		if(bayar.length == 0){
			alert("Maaf, Jumlah dibayar tidak boleh kosong.");
			$("#txt_bayar").focus();
			return (false);
        }
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/simpan_pb.php",
			data	: "kode="+kode+
				"&tanggal="+tanggal+
				"&kodesup="+kodesup+
				"&namasup="+namasup+
				"&kodecab="+kodecab+
				"&nomorfk="+nomorfk+
				"&tanggaljt="+tanggaljt+
				"&total="+total+					
				"&potong="+potong+
				"&bayar="+bayar+
				"&kurang="+kurang,
			success	: function(data){
				$("#info").html(data);
				$("#data_detail").hide();
				$(".input_header").val('');
			}
		});
	});
	
	$("#cetak_fkt").click(function(){
		var	kode	= $("#txt_kode").val();
		
		$.ajax({
			type	: "POST",
			url		: "modul/pembelian/cek_posting.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_posting").val(data.posting);
				var posting=$("#txt_posting").val();
				
				if(posting==''){
					alert("Maaf, Data pembelian belum direkam.");
					$("#rekam_pj").focus();
					return (false);
				}else print_faktur();
			}
		});
	});
	
	function print_faktur(){
		var	kode	= $("#txt_kode").val();		
		var	total	= $("#txt_total").val();
		var	tbayar	= $("#txt_bayar").val();
		var	tgl		= $("#txt_tanggal").val();
		
		if(total.length == 0){
			alert("Maaf, Data input faktur belum ada. Klik tombol Input Faktur untuk mulai.");
			$("#mulai").focus();
			return (false);
        }
		
		if(tbayar.length == 0){
			alert("Maaf, Total dibayar masih kosong");
			$("#txt_bayar").focus();
			return (false);
        }
		window.location.href='modul/laporan/faktur_pb.php?kode='+kode+'&tgl='+tgl;
		$("#mulai").focus();
	}
	
	$("#tutup").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#txt_kode {
	background:#CCC;
}
</style>

<?php
echo "<table width='100%'>	
	<tr>
		<input type='text' id='t_nomorfk' class='input_header' hidden/>
		<input type='text' id='t_tahun' class='input_header' hidden/>
		<td width='9%'>Kode Transaksi</td>
		<td>: <input type='text' id='txt_kode' size='13' class='input_header' readonly/>
			<img src='images/view.png' width='18' height='18' title='Cari kode transaksi' id='cari_kodepb'>
		</td>
		<td width='5%'>Tanggal</td>
		<td>: <input type='date' id='txt_tanggal' size='10' class='input_header'></td>
		<td width='8%'>No. Faktur</td>
		<td>: <input type='text' id='txt_nomorfk'  size='15' class='input_header'></td>
		<td>Supplier : <input type='text' id='txt_namasup' size='25' class='input_header'> <input type='text' id='txt_kodesup' size='3' class='input_header' readonly /></td>
	</tr>
    <tr>
        <td>No. Pesanan</td>
        <td>: <input type='text' id='txt_kodeopb' size='15' class='input_header'></td>
		<td>Cabang</td>
		<td>: <input type='text' id='txt_kodecab' size='2' class='input_header'></td>
		<td>Jatuh Tempo</td>
		<td>: <input type='date' id='txt_tanggaljt' size='10' class='input_header'></td>
	</tr>
</table>
<hr>";

echo "<div id='form_input'>
	<table>
		<tr>
			<th>Barcode</th>
			<th>Nama Barang</th>
			<th>Satuan</th>			
			<th>Jml.Unit</th>
			<th>Jml. Bruto</th>
			<th>HB. Bruto</th>
			<th>Diskon</th>
			<th>PPN</th>
			<th>Jml.Harga</th>
			<th>Expired</th>
			<th></th>
		</tr>
		<tr>
			<input type='text' id='txt_nourut' class='input_detail' size='4' hidden/>
			<input type='text' id='txt_kodest' class='input_detail' size='6' hidden/>
			<td align='center'><input type='text' id='txt_barcode' class='input_detail' size='13'>
			<td align='center'><input type='text' id='txt_namast' class='input_detail' size='30'></td>
			<td align='center'><input type='text' id='txt_satuan' class='input_detail' size='7' readonly/></td>
			<td align='center'><input type='text' id='txt_jmlunit' class='input_detail' size='8'></td>
			<td align='center'><input type='text' id='txt_jmlbruto' class='input_detail' size='9'></td>
			<td align='center'><input type='text' id='txt_hgbruto' class='input_detail' size='9' readonly/></td>
			<td align='center'><input type='text' id='txt_diskon' class='input_detail' size='6' maxlength='6'>%</td>
			<td align='center'><input type='text' id='txt_ppn' class='input_detail' size='2' maxlength='3'>%</td>
			<td align='center'><input type='text' id='txt_jumlah' class='input_detail' size='9' readonly/>
			<td align='center'><input type='date' id='txt_expired' class='input_detail'></td>
			<td><button id='simpan'>Rekam</button></td>
		</tr>
		<tr>
		    <th>HB. Rata2</th>
			<th>HB. Akhir</th>
			<th>HJ. Umum</th>
			<th>Margin</th>
			<th>Stok Gdg</th>
		</tr>
		<tr>
		    <td align='center'><input type='text' id='txt_hgbeli' class='input_detail' size='8' readonly/></td>
			<td align='center'><input type='text' id='txt_hbakhir' class='input_detail' size='8' readonly/></td>
			<td align='center'><input type='text' id='txt_hgjual' class='input_detail' size='8'></td>
			<td align='center'><input type='text' id='txt_margin' class='input_detail' size='4' readonly/> %</td>
			<td align='center'><input type='text' id='txt_jmlstok' class='input_detail' size='8' readonly/></td>
		</tr>
	</table>
	<hr>
	</div>";

echo "<div id='input_pb'>
	<table>
		<tr>		
			<input type='text' id='txt_posting' class='input_header' hidden/>
			<input type='text' id='txt_netto' class='input_header' hidden/>
			<td>Total : <input type='text' id='txt_total' class='input_header' size='12' readonly/></td>
			<td>Potongan : <input type='text' id='txt_pot' class='input_header' size='9'></td>
			<td>Dibayar : <input type='text' id='txt_bayar' class='input_header' size='12'></td>
			<td>Kurang : <input type='text' id='txt_kurang' class='input_header' size='12' readonly/></td>
			<td>
				<button id='rekam_pb'>Rekam Faktur</button>
				<button id='cetak_fkt'>Cetak Faktur</button>
				<button id='buat_databr'>Buat Data Br</button>
				<button id='detail'>Lihat Detail</button>
			</td>
		</tr>
	</table>
	</div>";

echo "<div id='data_detail' style='overflow-x: auto;height: 300px;scroll-behavior: smooth'></div>";

echo "<table width='100%'>
		<tr>
			<td align='center'>
				<button id='mulai'>Input Faktur</button>		
				<button id='tutup'>Tutup</button>
			</td>
		</tr>
	</table>";
	
echo "<div id='form_cari_kodepb' title='Pencarian Kode Transaksi'>
		<table width='100%'>
			<tr>
				<td>Cari kode transaksi : <input type='text' id='txt_carikode' size='20'></td>
			</tr>
		</table>

		<div id='info_pbl' align='center'></div>
	</div>";
	
echo "<div id='form_cari_kodeopb' title='Pencarian Data Pesanan Pembelian'>
		<table width='100%'>
			<tr>
				<td>Cari Nomor Pesanan : <input type='text' id='txt_cariopb' size='20'></td>
			</tr>
		</table>

		<div id='info_opb' align='center'></div>
	</div>";

echo "<div id='form_cari_sup' title='Pencarian Data Supplier'>
		<table>
			<tr>
				<td>Cari Supplier : <input type='text' name='txt_carisup' id='txt_carisup' size='40'></td>
			</tr>
		</table>
		<div id='info_supplier' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";

echo "<div id='form_cari_barang' title='Pencarian Barang'>
		<table width='100%'>
			<tr>
				<td>Cari Barang : <input type='text' name='txt_caribr' id='txt_caribr' size='40'></td>
			</tr>
		</table>
		<div id='info_barang' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
	
echo "<div id='form_i_cari_barang' title='Pencarian Barang'>
		<table width='100%'>
			<tr>
				<td>Cari Barang : <input type='text' id='i_caribr' size='40'></td>
			</tr>
		</table>
		<div id='info_i_barang' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";

echo "<div id='form_buat_kodebr' title='Pembuatan Data Barang Dagangan'>
		<table width='100%'>
			<tr>
				<td width='18%'>Kode Kelompok</td>
				<td width='15%'>: <input name='i_kodegr' id='i_kodegr' size='2' maxlength='2'>
					<img src='images/view.png' width='18' height='18' title='Cari kelompok barang' id='cari_gr'>
				</td>
				<td width='2%'></td>
				<td>Nama Kelompok</td>
				<td>:</td>
				<td><input name='i_namagr' id='i_namagr' size='25' readonly />
			</tr>
		</table>
		<hr>
		
		<table width='100%'>
			<input type='text' id='t_kodest' class='input_detail' hidden/>
			<input type='text' id='t_barcode' class='input_detail' hidden/>
			<input type='text' id='t_namast' class='input_detail' hidden/>
			<input type='text' id='t_expired' class='input_detail' hidden/>
			<tr>
				<td width='18%'>Kode Persediaan</td>
				<td>: <input type='text' name='i_kodest' id='i_kodest' class='input_st' size='6' readonly />
					<img src='images/view.png' width='18' height='18' title='Cari data barang' id='cari_brg'>
				</td>
			</tr>
			<tr>
				<td>Nama Barang</td>
				<td>: <input type='text' name='i_namast' id='i_namast' class='input_st' size='40'></td>
			</tr>
			<tr>
				<td>Barcode</td>
				<td>: <input type='text' name='i_barcode' id='i_barcode' class='input_st' size='40'></td>
			</tr>
			<tr>
				<td>Satuan</td>
				<td>: <input type='text' name='i_satuan' id='i_satuan' class='input_st' size='10'></td>
			</tr>
			<tr>
				<td>Harga Beli</td>
				<td>: <input type='text' name='i_hgbeli' id='i_hgbeli' class='input_st' size='10' readonly/></td>	
			</tr>
			<tr>				
				<td>Harga Jual Umum</td>
				<td>: <input type='text' id='i_expired' class='input_st' size='10' ></td>
			</tr>
			<tr>				
				<td>Harga Jual Resep</td>
				<td>: <input type='text' id='i_hgresep' class='input_st' size='10'></td>
			</tr>
			<tr>				
				<td>Harga Jual Paramedis</td>
				<td>: <input type='text' id='i_hgparam' class='input_st' size='10'></td>
			</tr>
			<tr>
				<td>Minimal Stok</td>
				<td>: <input type='text' id='i_minstok' class='input_st' size='5'></td>
			</tr>
		</table>
	
		<table width='100%'
			<tr>
				<td colspan='3' align='center'><button name='simpan_br' id='simpan_br'>Simpan</button></td>
			</tr>
		</table>
	</div>";
	
echo "<div id='form_cari_gr' title='Pencarian grup'>
		<table width='100%'>
			<td>
				<td>Cari Kelompok : <input type='text' id='txt_carigr' size='30'></td>
			</td>
		</table>
		<div id='info_gr' align='center' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";

echo "<div id='form_lihat_detail' title='Detail nota'>
		<div id='lihat_nota' style='overflow-x: auto;height: 400px;scroll-behavior: smooth'></div>
	</div>";
?>