<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});
</script>
<?php
include '../../inc/inc.koneksi.php';

$cari	= $_GET['cari'];
$hal	= $_GET['hal'] ? $_GET['hal'] : 0;
$lim	= 15;
	if (!empty($cari)){
		$query2	= "SELECT * FROM customer WHERE (nama LIKE '%$cari%' OR alamat LIKE '%$cari%' OR telepon LIKE '%$cari%')  ";
	}
	else{
		$query2	= "SELECT * FROM customer";
	}
	$data2	= mysql_query($query2);
	$jml	= mysql_num_rows($data2);
	
	$max	= ceil($jml/$lim);

echo "<table id='theList' width='100%'>
		<tr>
			<th width='2%'>No.</th>
			<th>Kode</th>
			<th>Nama Pelanggan</th>
			<th>Alamat</th>
			<th>Telepon</th>
			<th>Faxcimile</th>
			<th>Jaminan Rp</th>
			<th>Bank</th>
			<th>Nomor Rekening</th>
			<th>Atas Nama</th>
			<th>Contact Person</th>
		</tr>";
	if (!empty($cari)){
		$sql	= "SELECT * FROM customer WHERE (nama LIKE '%$cari%' OR alamat LIKE '%$cari%' OR telepon LIKE '%$cari%' ) 
				    ORDER BY kode_pl LIMIT $hal,$lim";		
	}

	else{
		$sql	= "SELECT * FROM customer ORDER BY kode_pl LIMIT $hal,$lim";
	}
						
		$query = mysql_query($sql);
		
		$no=1+$hal;
		while($r_data=mysql_fetch_array($query)){
			echo "<tr>
					<td align='center'>$no</td>
					<td>$r_data[kode_pl]</td>
					<td>$r_data[nama]</td>
					<td>$r_data[alamat]</td>
					<td>$r_data[telepon]</td>
					<td>$r_data[fax]</td>					
					<td align='right'>".number_format($r_data['jaminan'],0)."</td>
					<td>$r_data[bank]</td>
					<td>$r_data[nomor_ac]</td>
					<td>$r_data[nama_ac]</td>
					<td>$r_data[kontak]</td>					
					</tr>";
			$no++;
		}
		
	echo "</table>";
	
	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $jml</td>
			<td align='right'>Halaman :";
		if (!empty($cari)){
			for ($h = 1; $h <= $max; $h++) {
					$list[$h] = $lim * $h - $lim;
					echo " <a href='javascript:void(0)' ";?> 
                    onClick="$.get('spv/pelanggan/tampil_data.php?cari=<?php echo $_GET[cari];?>&hal=<?php echo $list[$h]; ?>', 
                    null, function(data) {$('#tampil_data').html(data);})" <?php echo">".$h."</a> ";
				}		
		}
		else{
			for ($h = 1; $h <= $max; $h++) {
					$list[$h] = $lim * $h - $lim;
					echo " <a href='javascript:void(0)' ";?> 
                    onClick="$.get('spv/pelanggan/tampil_data.php?hal=<?php echo $list[$h]; ?>', 
                    null, function(data) {$('#tampil_data').html(data);})" <?php echo">".$h."</a> ";
				}	
		}

	echo "</td>
		</tr>
		</table>";
?>