<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});	
	$("#tampil_data_ak").load('spv/akun_bb/tampil_data_ak.php');
	$("#tampil_data_sd").load('modul/akun_bb/tampil_data_sd.php');	
	$("#tampil_data_sd").hide();
	$("#tampil_data_bb").hide();
	$("#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_tglawal").val(data.tanggal);
				$("#txt_tglakhir").val(data.tanggal);
				$("#txt_tanggal").val(data.tanggal);
			}
		});
	}
	
	$("#txt_cari_ak").keyup(function() {
		var cari 	= $("#txt_cari_ak").val()
		var akses	= 1; 
		$.ajax({
			type	: "GET",
			url	: "spv/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';
	});
	
	$("#txt_cari_sd").keyup(function() {
		var tgl 	= $("#txt_tanggal").val();
		var cari 	= $("#txt_cari_sd").val();
		var	level	= $(".radio_level:checked").val();
		var cek_level= $(".radio_level:checked");
		var akses	= 1;
		
		if(tgl.length==0){
			alert('Maaf, tanggal saldo masih kosong.')
			return (false);
		}
		
		if(cek_level.length==0){
			alert('Maaf, Level akun belum dipilih.')
			return (false);
		}
		
		$.ajax({
			type	: "GET",
			url		: "modul/akun_bb/tampil_data_sd.php",
			data	: "cari="+cari+
					"&tgl="+tgl+
					"&level="+level,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_sd").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){			
				$("#tampil_data_sd").html(data);
				$("#tampil_data_sd").show();
			}
		});
	});
	
	$("#cari_tgl").click(function() {
		var tgl 	= $("#txt_tanggal").val();
		var cari 	= $("#txt_cari_sd").val();
		var	level	= $(".radio_level:checked").val();
		var cek_level= $(".radio_level:checked");
		
		if(tgl.length==0){
			alert('Maaf, tanggal saldo masih kosong.')
			return (false);
		}
		
		if(cek_level.length==0){
			alert('Maaf, Level akun belum dipilih.')
			return (false);
		}
		
		$.ajax({
			type	: "GET",
			url	: "modul/akun_bb/tampil_data_sd.php",
			data	: "cari="+cari+
					"&tgl="+tgl+
					"&level="+level,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_sd").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_sd").html(data);
				$("#tampil_data_sd").show();				
			}
		});
	});
	
	$(".radio_level").click(function() {
		var tgl 	= $("#txt_tanggal").val();
		var cari 	= $("#txt_cari_sd").val();
		var level = $(".radio_level:checked").val();
		var cek_level= $(".radio_level:checked");
		
		$.ajax({
			type	: "GET",
			url	: "modul/akun_bb/tampil_data_sd.php",
			data	: "cari="+cari+
					"&tgl="+tgl+
					"&level="+level,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_sd").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_sd").html(data);
				$("#tampil_data_sd").show();				
			}
		});
	});
	
	$("#cetak_sd").click(function(){
		var tgl = $("#txt_tanggal").val();
		var cari= $("#txt_cari_sd").val();
		var level = $(".radio_level:checked").val();
		
		window.location.href='modul/laporan/neraca_saldo.php?tgl='+tgl+'&cari='+cari+'&level='+level;
	});
	
	$("#tutup_sd").click(function(){
		document.location='?module=home';
	});
	
	$("#txt_cari_bb").keyup(function(){
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir= $("#txt_tglakhir").val();
		var cari 	 = $("#txt_cari_bb").val();				
		
		if(tgl_awal.length==0){
			alert('Maaf, tanggal awal buku besar masih kosong.')
			return (false);
		}
		
		if(tgl_akhir.length==0){
			alert('Maaf, tanggal akhir buku besar masih kosong.')
			return (false);
		}
		
		$.ajax({
			type	: "GET",
			url		: "modul/akun_bb/tampil_data_bb.php",
			data	: "tgl_awal="+tgl_awal+
					"&tgl_akhir="+tgl_akhir+
					"&cari="+cari,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_bb").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_bb").show();
				$("#tampil_data_bb").html(data);				
			}
		});
	});
	
	$("#cari_tgl_bb").click(function(){
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir = $("#txt_tglakhir").val();
		var cari 	= $("#txt_cari_bb").val();
		
		if(tgl_awal.length==0){
			alert('Maaf, tanggal awal buku besar harus diisi.')
			return (false);
		}
		
		if(tgl_akhir.length==0){
			alert('Maaf, tanggal akhir buku besar masih kosong.')
			return (false);
		}
				
		$.ajax({
			type	: "POST",
			url		: "modul/akun_bb/ubah_tgl.php",
			data	: "tgl_awal="+tgl_awal+
					"&tgl_akhir="+tgl_akhir+
					"&cari="+cari,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_bb").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_bb").show();
				$("#tampil_data_bb").html(data);				
				$("#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 tgaw 	= $("#t_tglawal").val();
		var tgak	= $("#t_tglakhir").val();
			
		window.location.href='modul/laporan/laporan_bb.php?noakun='+noakun+'&tgaw='+tgaw+'&tgak='+tgak;		
	});
	
	$("#tutup_bb").click(function(){
		document.location='?module=home';
	});
	
	$("#refresh").click(function() {
		$("#tampil_data_bb").hide();
		$(".input_cari").val('');
	});
	
	$("#tutup_detail").click(function(){
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir = $("#txt_tglakhir").val();
		var cari 	= $("#txt_cari_bb").val();
		
		$("#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);
	});
});
</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='#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>
      </ul>";
	
	echo "<div id='data_ak'>
			<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td width='14%'>Cari Kelompok</td>
					<td width='2%'>:</td>
					<td><input type='text' name='txt_cari_ak' id='txt_cari_ak' size='40'></td>
					<td colspan='6' align='right'>
						<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'></div>
		</div>";
	
	echo "<div id='data_sd'>
			<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari Kelompok</td>
					<td>:</td>
					<td><input type='text' name='txt_cari_sd' id='txt_cari_sd' size='25'></td>
					<td>Level</td>
					<td>:</td>
					<td><input type='radio' name='txt_level' id='txt_level' value='1' class='radio_level'>1</td>
					<td><input type='radio' name='txt_level' id='txt_level' value='2' class='radio_level'>2</td>
					<td>Tanggal Saldo</td>
					<td>:</td>
					<td><input type='date' name='txt_tanggal' id='txt_tanggal' size='10'></td>
				</tr>
				<tr>
					<td colspan='12' align='center'>
						<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'></div>
	</div>";
	
	echo "<div id='data_bb'>
			<input type='text' name='t_noakun' id='t_noakun' hidden />
			<input type='text' name='t_naakun' id='t_naakun' hidden />
			<input type='text' name='t_kode' id='t_kode' hidden />
			<input type='date' name='t_tglawal' id='t_tglawal' hidden />
			<input type='date' name='t_tglakhir' id='t_tglakhir' hidden />
			
			<div id='pencarian_bb'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari Kelompok</td>
					<td>:</td>
					<td><input type='text' name='txt_cari_bb' id='txt_cari_bb' size='22' class='input_cari'></td>
					<td>Periode</td>
					<td>:</td>
					<td><input type='date' name='txt_tglawal' id='txt_tglawal' size='10' class='input_cari'></td>
					<td>s.d</td>
					<td><input type='date' name='txt_tglakhir' id='txt_tglakhir' size='10' class='input_cari'></td>
				</tr>
				<tr>
					<td colspan='12' align='center'>
						<button name='cari_tgl_bb' id='cari_tgl_bb'>Cari</button>
						<button name='refresh' id='refresh'>Refresh</button>						
						<button name='tutup_bb' id='tutup_bb'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			
			<div id='tampil_data_bb' align='center'></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'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>
