<script type="text/javascript">	
$(document).ready(function() {
	$("#tabs").tabs({selected:0});
	$("#form").load('modul/akun_bp/form.php');
	$("#tampil_data_ak").load('modul/akun_bp/tampil_data_ak.php');	
	$("#tampil_data_sd").hide();
	$("#tampil_data_bp").hide();
	$("#info_bp").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);				
			}
		});
	}
	
	$("#txt_cari_ak").keyup(function() {
		var cari 	= $("#txt_cari_ak").val()
		
		$.ajax({
			type	: "GET",
			url		: "modul/akun_bp/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(){
		var cari 	= $("#txt_cari_ak").val()
		
		window.location.href='modul/laporan/daftar_akunbp.php?cari='+cari;
	});
	
	$("#tutup_ak").click(function(){
		document.location='?module=home';
	});
	
	$("#txt_cari_sd").keyup(function() {
		var tgl = $("#txt_tanggal").val();
		var cari= $("#txt_cari_sd").val();
		
		if(tgl.length==0){
			alert('Maaf, tanggal saldo masih kosong.')
			return (false);
		}
		
		$.ajax({
			type	: "GET",
			url		: "modul/akun_bp/tampil_data_sd.php",
			data	: "cari="+cari+
					"&tgl="+tgl,					
			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();		
		
		if(tgl.length==0){
			alert('Maaf, tanggal saldo masih kosong.')
			return (false);
		}
				
		$.ajax({
			type		: "GET",
			url		: "modul/akun_bp/tampil_data_sd.php",
			data	: "cari="+cari+
					"&tgl="+tgl,
			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();
		
		window.location.href='modul/laporan/daftar_saldo_bp.php?tgl='+tgl+'&cari='+cari;
	});
	
	$("#tutup_sd").click(function(){
		document.location='?module=home';
	});
	
	$("#txt_cari_bp").keyup(function() {
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir= $("#txt_tglakhir").val();
		var cari 	= $("#txt_cari_bp").val();		
		var akses	= 1;
		
		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_bp/tampil_data_bp.php",
			data	: "tgl_awal="+tgl_awal+
					"&tgl_akhir="+tgl_akhir+
					"&cari="+cari,			
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_bp").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_bp").show();
				$("#tampil_data_bp").html(data);				
			}
		});
	});
	
	$("#cari_tgl_bp").click(function() {
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir = $("#txt_tglakhir").val();
		var cari 	= $("#txt_cari_bp").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	: "POST",
			url		: "modul/akun_bp/ubah_tgl.php",
			data	: "tgl_awal="+tgl_awal+
					"&tgl_akhir="+tgl_akhir+
					"&cari="+cari,
			timeout	: 2000,
			beforeSend	: function(){		
				$("#tampil_data_bp").html("<img src='loading.gif' />");			
			},				  
			success	: function(data){
				$("#tampil_data_bp").show();
				$("#tampil_data_bp").html(data);
				$("#tampil_data_bp").load('modul/akun_bp/tampil_data_bp.php?tgl_awal='+tgl_awal+'&tgl_akhir='+tgl_akhir+'&cari='+cari);
			}
		});
	});
	
	$("#cetak_bp").click(function(){
		var noakun= $("#t_noakun").val();
		var tgaw = $("#t_tglawal").val();
		var tgak = $("#t_tglakhir").val();
			
		window.location.href='modul/laporan/laporan_bp.php?noakun='+noakun+'&tgaw='+tgaw+'&tgak='+tgak;		
	});
		
	$("#tutup_bp").click(function(){
		document.location='?module=home';
	});
	
	$("#refresh").click(function() {
		$("#tampil_data_bp").hide();
		$(".input_cari").val('');
	});
	
	$("#tutup_detail").click(function(){
		var tgl_awal = $("#txt_tglawal").val();
		var tgl_akhir = $("#txt_tglakhir").val();
		var cari 	= $("#txt_cari_bp").val();
		
		$("#info_bp").hide();
		$("#tampil_detail_bp").hide();
		$("#pencarian_bp").show();
		$("#tampil_data_bp").show();
		$("#tampil_data_bp").load('modul/akun_bp/tampil_data_bp.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'>Update Data Akun</a></li>
	       <li><a href='#data_ak'>Daftar Akun Buku Pembantu</a></li>
		   <li><a href='#data_sd'>Saldo Buku Pembantu</a></li>
		   <li><a href='#data_bp'>Laporan Buku Pembantu</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' name='txt_cari_ak' id='txt_cari_ak' size='50'></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 nama/kode akun : <input type='text' name='txt_cari_sd' id='txt_cari_sd' size='30'></td>					
					<td>Tanggal saldo : <input type='date' name='txt_tanggal' id='txt_tanggal' size='10'></td>
					<td 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_bp'>
			<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_bp'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Cari nama/kode akun : <input type='text' name='txt_cari_bp' id='txt_cari_bp' size='20' class='input_cari'></td>
					<td>Periode : <input type='date' name='txt_tglawal' id='txt_tglawal' size='10' class='input_cari'> sampai dengan <input type='date' name='txt_tglakhir' id='txt_tglakhir' size='10' class='input_cari'></td>
					<td colspan='12' align='center'>
						<button name='cari_tgl_bp' id='cari_tgl_bp'>Cari</button>
						<button name='refresh' id='refresh'>Refresh</button>						
						<button name='tutup_bp' id='tutup_bp'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
			</div><br>
			
			<div id='tampil_data_bp' align='center'></div>
			
			<div id='info_bp'>
				<table width='100%'>					
					<tr>
						<td align='right'>
							<button name='cetak_bp' id='cetak_bp'>Cetak</button>
							<button name='tutup_detail' id='tutup_detail'>Tutup Detail</button>
						</td>					
					</tr>
				</table>							
			</div>
			
			<div id='tampil_detail_bp' align='center'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>
