<script type="text/javascript">	
$(document).ready(function() {	
	$("#tabs").tabs({selected:0});
	
	var cari = $("#txt_cari").val()
	$("#tampil_data").load('spv/customer/tampil_data.php?cari='+cari);
	
	$("#txt_cari").keyup(function() {
		var cari 	= $("#txt_cari").val()
		
		$.ajax({
			type	: "GET",
			url	    : "spv/customer/tampil_data.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#tampil_data").html(data);
			}
		});
	});
	
	$("#cetak_cs").click(function(){
		var cari = $("#txt_cari").val();
		
		window.location.href='modul/laporan/daftar_pl.php?cari='+cari;
	});
	
	$("#tutup_cs").click(function(){
		document.location='?module=home';
	});
	
	$('#form_cari_plg').dialog({
		autoOpen: false,
		modal	: true,
		width: 700,
	});
		
	$('#x_namaplg').keyup(function(){
		$('#form_cari_plg').dialog('open');
		$("#info_pelanggan").load('modul/report/tampil_data_plg.php');
		$("#txt_cariplg").focus();
	});
	
	$("#txt_cariplg").keyup(function(){
		$("#info_pelanggan").show();
		var cari= $("#txt_cariplg").val();
		
		$.ajax({
			type	: "POST",
			url	    : "modul/report/tampil_data_plg.php",
			data	: "cari="+cari,
			success	: function(data){
				$("#info_pelanggan").html(data);
			}
		});
	});
	
	$("#cari_hp").click(function(){
		var kodepl= $("#x_kodeplg").val();
		var cari 	= $("#txt_caribrg").val();
		
		if(kodepl==''){
			alert('Maaf, kode pelanggan masih kosong.');
			$("#x_namaplg").val();
			return(false);
		}
		$("#tampil_data_hp").load('modul/customer/tampil_data_hp.php?kodepl='+kodepl+'&cari='+cari);
	});
	
	$("#txt_caribrg").keyup(function(){
		var kodepl= $("#x_kodeplg").val();
		var cari 	= $("#txt_caribrg").val();
		
		if(kodepl==''){
			alert('Maaf, kode pelanggan masih kosong.');
			$("#x_namaplg").val();
			return(false);
		}
		$.ajax({
			type	: "GET",
			url	    : "modul/customer/tampil_data_hp.php",
			data	: "cari="+cari+
					"&kodepl="+kodepl,
			success	: function(data){
				$("#tampil_data_hp").html(data);
			}
		});
	});
	
	$("#cetak_hp").click(function(){
		var kodepl	= $("#x_kodeplg").val();
		var namapl	= $("#x_namaplg").val();
		var cari 	= $("#txt_caribrg").val();
		
		if(kodepl==''){
			alert('Maaf, kode pelanggan masih kosong.');
			$("#x_namaplg").val();
			return(false);
		}
		window.location.href='modul/laporan/daftar_hp.php?cari='+cari+'&kodepl='+kodepl+'&namapl='+namapl;
	});
	
	$("#tutup_hp").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='#data'>DAFTAR PELANGGAN</a></li>
	   <li><a href='#data_hp'>HISTORY PELANGGAN</a></li>
    </ul>";

	echo "<div id='data'>
		<div id='pencarian'>
			<fieldset>
			<legend>Filter Data</legend>
			
			<input type='text' name='txt_saldo' id='txt_saldo' size='10' class='input' hidden />
			<table width='100%'>
				<tr>
					<td>Cari pelanggan : <input type='text' name='txt_cari' id='txt_cari' size='40'></td>
					<td>
						<button name='cetak_cs' id='cetak_cs'>Cetak</button>
						<button name='tutup_cs' id='tutup_cs'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div><br>
		<div id='tampil_data' align='center'></div>
	</div>";
	
	echo "<div id='data_hp'>
		<div id='pencarian_hp'>
			<fieldset>
			<legend>Filter Data</legend>
			<table width='100%'>
				<tr>
					<td>Pelanggan : <input type='text' id='x_namaplg' size='30'> <input type='text' id='x_kodeplg' size='3' readonly/></td>
					<td>Cari barang : <input type='text' id='txt_caribrg' size='40'></td>
					<td>
						<button id='cari_hp'>Cari</button>
						<button id='cetak_hp'>Cetak</button>
						<button id='tutup_hp'>Tutup</button>
					</td>
				</tr>
			</table>
			</fieldset>
		</div><br>
		<div id='tampil_data_hp' align='center'></div>
	</div>";
	
	echo "<div id='form_cari_plg' title='Pencarian Data Pelanggan'>
		<table width='100%'>
			<tr>
				<td>Cari Pelanggan : <input type='text' name='txt_cariplg' id='txt_cariplg' size='30'></td>
			</tr>
		</table>
		<div id='info_pelanggan' align='center'></div>
	</div>";
	
	echo "<div id='info' align='center'></div>";
echo "</div>";
?>
