<?php
	include '../../inc/inc.koneksi.php';	
	
	$cari = $_GET[cari];
	$jml = 0;
	$tgllap =date('d-m-Y');
	if (!empty($cari)){
		$grup='KELOMPOK : '.$cari;
	}else{
		$grup='KESELURUHAN';
	}
		
	$content = "<b><li>DAFTAR NAMA PELANGGAN</li>	
		<li>$grup</li>
		<li>PER TANGGAL $tgllap</li></b>
		<br>
	
		<table width='390' border='1' style='border-collapse:collapse'>
		<tr>
			<th>No.</th>
			<th>Kode</th>
			<th>Nama Pelanggan</th>
			<th>Alamat</th>
			<th>Telepon</th>
			<th>Faxcimile</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";
		}
		else{
			$sql	= "SELECT * FROM customer ORDER BY kode_pl";
		}		
		$query = mysql_query($sql);
		
		$no=1;
		while($r_data=mysql_fetch_array($query)){
		
		$content .= "<tr>	
				<td>$no</td>
				<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>$r_data[bank]</td>
				<td>$r_data[nomor_ac]</td>
				<td>$r_data[nama_ac]</td>
				<td>$r_data[kontak]</td>				
			</tr>";
			$no++;
			$jml++;
		}
		$content .= "</table>";
		
		$content .= "<table>
			<tr>
				<td>Jumlah Data : $jml</td>
			</tr>
			</table>";
				
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=daftar_plg.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo $content;
?>
