<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");
            }
        );
    });	
});

	function edit_data(ID){	
		var kode = ID;
		$.ajax({
			type	: "POST",
			url		: "modul/supplier/cari.php",
			data	: "kode="+kode,
			dataType: "json",
			success	: function(data){
				$("#txt_kode").val(kode);
				$("#txt_nama").val(data.tnama);
				$("#txt_alamat").val(data.talamat);
				$("#txt_telepon").val(data.ttelepon);
				$("#txt_fax").val(data.tfax);
				$("#txt_jaminan").val(data.tjaminan);
				$("#txt_bank").val(data.tbank);
				$("#txt_nomorac").val(data.nomorac);
				$("#txt_namaac").val(data.namaac);
				$("#txt_kontak").val(data.tkontak);
				$("#akses").val(data.akses);
				$("#info").html("Data sudah di tampung pada tab inputan, silahkan klik");
			}
		});
	}
		
	function hapus_data(ID){
		var pilih = confirm('Data yang akan dihapus kode = '+ID+ '?');
		
		if (pilih==true) {
		var kode = ID;
		$.ajax({
			type	: "POST",
			url		: "modul/supplier/hapus.php",
			data	: "kode="+kode,
			success	: function(data){
				$("#info").html(data);
				$("#tampil_data").load('modul/supplier/tampil_data.php');
				$("#akses").val('');
			}
		});
		}
	}

</script>
<?php
include '../../inc/inc.koneksi.php';

$cari	= $_GET['cari'];
echo "<table id='theList' width='100%'>
	<tr>
		<th width='2%'>No.</th>
		<th>Kode</th>
		<th>Nama Supplier</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>
		<th>Aksi</th>
	</tr>";
	if (!empty($cari))
		$sql= "SELECT * FROM supplier WHERE (nama LIKE '%$cari%' OR alamat LIKE '%$cari%' OR telepon LIKE '%$cari%' ) 
			    ORDER BY kode_sp";		
	else
		$sql= "SELECT * FROM supplier ORDER BY kode_sp";
						
	$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_sp]</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>
			<td align='center'>
				<a href='javascript:void(0)' onClick=\"edit_data('$r_data[kode_sp]')\">
				<img src='icon/thumb_up.png' border='0' id='edit' title='Edit' width='12' height='12' >
				</a>
				<a href='javascript:void(0)' onClick=\"hapus_data('$r_data[kode_sp]')\">
				<img src='icon/thumb_down.png' border='0' id='hapus' title='Hapus' width='12' height='12' >
				</a>					
			</td>
		</tr>";
		$no++;
	}
	echo "</table>";
?>