<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});
	var cari = $("#txt_cari_ak").val()
	$("#form").load('modul/akun_bb/form.php');
	$("#tampil_data_ak").load('modul/akun_bb/tampil_data_ak.php?cari='+cari);
	$("#info_bb").hide();
	
	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_tglawal").val(data.tanggal);
				$("#txt_tglakhir").val(data.tanggal);
				$("#mbb_tglawal").val(data.tanggal);
				$("#mbb_tglakhir").val(data.tanggal);
			}
		});
	}
	
	$("#txt_cari_ak").keyup(function() {
		var cari 	= $("#txt_cari_ak").val()
		
		$.ajax({
			type	: "GET",
			url		: "modul/akun_bb/tampil_data_ak.php",
			data	: "cari="+cari,
			timeout	: 3000,
			beforeSend	: function(){		
				$("#tampil_data_ak").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_ak").html(data);
			}
		});
	});
	
	$("#cetak_ak").click(function(){
		window.location.href='modul/laporan/daftar_akunbb.php?';
	});
	
	$("#tutup_ak").click(function(){
		document.location='?module=home';
	});

	$("#cari_tgl").click(function(){
		var tanggal	= $("#txt_tanggal").val();
			
		if(tanggal.length==0){
			alert('Maaf, tanggal saldo masih kosong.');
			$("#txt_tanggal").focus();
			return (false);
		}
		$("#tampil_data_sd").load('modul/akun_bb/tampil_data_sd.php?tanggal='+tanggal);
	});
	
	$("#cetak_sd").click(function(){
		var tanggal	= $("#txt_tanggal").val();
			
		if(tanggal.length==0){
			alert('Maaf, tanggal saldo masih kosong.');
			$("#txt_tanggal").focus();
			return (false);
		}
		window.location.href='modul/laporan/neraca_saldo.php?tanggal='+tanggal;
	});
		
	$("#tutup_sd").click(function(){
		document.location='?module=home';
	});
	
	$("#cari_tgl_bb").click(function() {
		var tgl_awal 	= $("#txt_tglawal").val();
		var tgl_akhir	= $("#txt_tglakhir").val();
		var cari 		= $("#txt_cari_bb").val();		
		
		$("#tampil_data_bb").load('modul/akun_bb/tampil_data_bb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
	});
	
	$("#cetak_bb").click(function(){
		var noakun	= $("#t_noakun").val();
		var tglawal	= $("#txt_tglawal").val();
		var tglakhir= $("#txt_tglakhir").val();
		window.location.href='modul/laporan/laporan_bb.php?noakun='+noakun+'&tglawal='+tglawal+'&tglakhir='+tglakhir;
	});
	
	$("#tutup_bb").click(function(){
		document.location='?module=home';
	});
	
	$("#refresh").click(function() {
		$("#tampil_data_bb").hide();
		$(".input_cari").val('');
	});
	
	$("#tutup_detail").click(function(){
		var tgl 	= $("#txt_tanggal").val();
		var cari 	= $("#txt_cari_bb").val();
		var level	= $(".radio_level:checked").val();
		var cek_level= $(".radio_level:checked");
		
		$("#info_bb").hide();
		$("#tampil_detail_bb").hide();
		$("#pencarian_bb").show();
		$("#tampil_data_bb").show();
		$("#tampil_data_bb").load('modul/akun_bb/tampil_data_bb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
	});
	
	$("#cari_mbb").click(function() {
		var tgl_awal 	= $("#mbb_tglawal").val();
		var tgl_akhir	= $("#mbb_tglakhir").val();
		var cari 		= $("#mbb_cari_bb").val();		
		
		$("#tampil_data_mbb").load('modul/akun_bb/tampil_data_mbb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
	});
	
	$("#cetak_mbb").click(function(){
		var noakun	= $("#mbb_noakun").val();
		var tglawal	= $("#mbb_tglawal").val();
		var tglakhir= $("#mbb_tglakhir").val();
		window.location.href='modul/laporan/rekap_mbb.php?noakun='+noakun+'&tglawal='+tglawal+'&tglakhir='+tglakhir;
	});
	
	$("#tutup_mbb").click(function(){
		document.location='?module=home';
	});
	
	$("#refresh_mbb").click(function(){
		$("#tampil_data_mbb").hide();
		$(".input_cari_mbb").val('');
	});
	
	$("#tutup_detail_mbb").click(function(){
		var tgl_awal = $("#mbb_tglawal").val();
		var tgl_akhir= $("#mbb_tglakhir").val();
		var cari 	 = $("#mbb_carimbb").val();
		
		$("#info_mbb").hide();
		$("#tampil_detail_mbb").hide();
		$("#pencarian_mbb").show();
		$("#tampil_data_mbb").show();
		$("#tampil_data_mbb").load('modul/akun_bb/tampil_data_mbb.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
	});
});
</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'>Buat/Ubah Akun Buku Besar</a></li>
	       <li><a href='#data_ak'>Daftar Akun Buku Besar</a></li>
		   <li><a href='#data_sd'>Neraca Saldo</a></li>
		   <li><a href='#data_bb'>Laporan Buku Besar</a></li>
		   <li><a href='#rekap_mbb'>Rekap Mutasi Buku Besar</a></li>
      </ul>";
	echo "<div id='form'></div>";
	
	echo "<div id='data_ak'>
		<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari Nama/Kode Akun : <input type='text' id='txt_cari_ak' size='40'></td>
					<td>
						<button name='cetak_ak' id='cetak_ak'>Cetak</button>
						<button name='tutup_ak' id='tutup_ak'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div><br>
		<div id='tampil_data_ak' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='data_sd'>
		<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Tanggal Saldo : <input type='date' id='txt_tanggal' size='10'></td>
					<td>
						<button name='cari_tgl' id='cari_tgl'>Cari</button>
						<button name='cetak_sd' id='cetak_sd'>Cetak</button>
						<button name='tutup_sd' id='tutup_sd'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div><br>
		<div id='tampil_data_sd' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='data_bb'>
		<input type='text' id='t_noakun' hidden />
		<input type='text' id='t_naakun' hidden />
		<input type='text' id='t_kode' hidden />
		<input type='date' id='t_tglawal' hidden />
		<input type='date' id='t_tglakhir' hidden />
			
		<div id='pencarian_bb'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari Nama/Kode Akun : <input type='text' id='txt_cari_bb' size='30' class='input_cari'></td>
					<td>Periode : <input type='date' id='txt_tglawal' size='10' class='input_cari'> sampai dengan <input type='date' id='txt_tglakhir' size='10' class='input_cari'></td>				
					<td>
						<button id='cari_tgl_bb'>Cari</button>
						<button id='refresh'>Refresh</button>						
						<button id='tutup_bb'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div><br>
	
		<div id='tampil_data_bb' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
			
		<div id='info_bb'>
			<table width='100%'>					
				<tr>
					<td align='right'>
						<button name='cetak_bb' id='cetak_bb'>Cetak</button>
						<button name='tutup_detail' id='tutup_detail'>Tutup Detail</button>
					</td>					
				</tr>
			</table>							
		</div>
			
		<div id='tampil_detail_bb' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='rekap_mbb'>
		<input type='text' id='mbb_noakun' hidden/>
		<input type='text' id='mbb_naakun' hidden/>
		<input type='text' id='mbb_kode' hidden/>
			
		<div id='pencarian_mbb'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari Nama/Kode Akun : <input type='text' id='mbb_cari_bb' size='30' class='input_cari_mbb'></td>
					<td>Periode : <input type='date' id='mbb_tglawal' size='10' class='input_cari_mbb'> sampai dengan <input type='date' id='mbb_tglakhir' size='10' class='input_cari_mbb'></td>
					<td>
						<button id='cari_mbb'>Cari</button>
						<button id='refresh_mbb'>Refresh</button>
						<button id='tutup_mbb'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div>
		<br>

		<div id='tampil_data_mbb' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
	
		<div id='info_mbb'>
			<table width='100%'>
				<tr>
					<td align='right'>
						<button id='cetak_mbb'>Cetak</button>
						<button id='tutup_detail_mbb'>Tutup Detail</button>
					</td>					
				</tr>
			</table>							
		</div>
			
		<div id='tampil_detail_mbb' align='center' style='overflow-x: auto;height: 500px;scroll-behavior: smooth'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>