<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});	
	$("#tampil_data").hide();
	$("#info_beli").hide();
	
	$("#form").load('modul/pembelian/form.php');

	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){								
				$("#t_tgl_awal").val(data.tanggal);
				$("#t_tgl_akhir").val(data.tanggal);
			}
		});
	}
	
	$("#data").load('modul/report/daftar_pb.php');
	
	$("#cari_pb").click(function(){				
		var tgl_awal	= $("#t_tgl_awal").val();
		var tgl_akhir	= $("#t_tgl_akhir").val();

		$("#tampil_data").show();
		$("#tampil_data").load('modul/pembelian/tampil_data_cf.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir);
	});
	
	$("#cetak_ft").click(function(){				
		var	kode	 = $("#t_kodepb").val();
		var	tgl		 = $("#t_tanggal").val();
		window.location.href='modul/laporan/faktur_pb.php?kode='+kode+'&tgl='+tgl;
	});

	$("#tutup_detail").click(function(){
		$("#pencarian_ft").show();
		$("#info_beli").hide();
		$("#tampil_detail").hide();
		$("#tampil_data").show();		
	});
	
	$("#tutup_pb").click(function(){
		document.location='?module=home';
	});
});
</script>

<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>

<?php
echo "<div id='tabs'>";
echo "<ul >
	       <li><a href='#form'>INPUT PEMBELIAN BARANG</a></li>
		   <li><a href='#form_cetakft'>CETAK FAKTUR</a></li>
		   <li><a href='#data'>DAFTAR PEMBELIAN BARANG</a></li>
      </ul>";
	  
echo "<div id='form'></div>";

echo "<div id='form_cetakft'>
		<div id='pencarian_ft'>
			<table>
				<tr>
					<td>Penjualan tanggal : <input type='date' id='t_tgl_awal' size='10'> sampai dengan <input type='date' id='t_tgl_akhir' size='10'></td>
					<td>
						<button id='cari_pb'>Cari</button>
						<button id='tutup_pb'>Tutup</button>
					</td>
				</tr>
			</table>
		</div>
			
		<div id='tampil_data' align='center' style='overflow-x: auto;height: 450px;scroll-behavior: smooth'></div>
			
		<div id='info_beli'>
			<table width='100%'>
				<tr>
					<input type='text' name='t_total' id='t_total' size='10' hidden/>
					<td>Kode Transaksi : <input type='text' id='t_kodepb' size='12' class='input_header' readonly/></td>
					<td>Tanggal : <input type='date' id='t_tanggal' size='10' class='input_header'></td>
					<td>No.Faktur : <input type='text' id='t_nomorfk'  size='10' class='input_header'></td>
					<td>Supplier : <input type='text' id='t_namasup' size='20' class='input_header'>
						<input type='text' id='t_kodesup' size='3' class='input_header' readonly /></td>		
					<td>Jatuh Tempo : <input type='date' id='t_tanggaljt' size='10' class='input_header'></td>
				</tr>
			</table>
			<table width='100%'>
				<tr>
					<td align='center'>
						<button id='cetak_ft'>Cetak Faktur</button>
						<button id='tutup_detail'>Tutup Detail</button>
					</td>					
				</tr>
			</table>						
		</div>
			
		<div id='tampil_detail' align='center' style='overflow-x: auto;height: 450px;scroll-behavior: smooth'></div>
	</div>";

echo "<div id='data'></div>";
		
echo "<div id='info' align='center'></div>";

echo "</div>";
?>
