<?php
$aksi = "modul/mod_pelanggan/aksi_pelanggan.php";

switch($_GET[act]){
	// Tampil Pelanggan
	default:
	echo "<h2>Data NRG</h2>
	<input type=button value='Tambah Data' onclick=\"window.location.href='?module=pelanggan&act=tambahpelanggan';\">
	<table class='list'>
	<thead>
	<tr>
		<td class='left'>No.</td>
		<td class='left'>NRG</td>
		<td class='left'>Nama PTK</td>
		<td class='left'>NUPTK</td>
		<td class='left'>Kelamin</td>
		<td class='left'>Bidang Studi</td>
		<td class='left'>Tahun Sertifikasi</td>
		<td class='left'>Ijazah Terakhir</td>
		<td class='left'>Sertifikat Pendidik</td>
		<td class='left'>Edit</td>
		
		
	</tr></thead><tbody>";
	$p      = new Paging;
    $batas  = 15;
    $posisi = $p->cariPosisi($batas);
	$tampil = mysql_query("select * from pelanggan order by no_polisi limit $posisi,$batas");
	$no=$posisi+1;
	while($data=mysql_fetch_array($tampil)){
		echo "<tr>
				<td class='left' width='25'>$no</td>
				<td class='left'>$data[no_polisi]</td>
				<td class='left'>$data[nm_pelanggan]</td>
				<td class='left'>$data[alamat]</td>
				<td class='left'>$data[kota]</td>
				<td class='left'>$data[telp]</td>
				<td class='left'>$data[tipe_kendaraan]</td>
				<td class='left'>$data[no_rangka]</td>
				<td class='left'>$data[no_mesin]</td>
				<td class='center'><a href='?module=pelanggan&act=editpelanggan&id=$data[no_polisi]'><img src='images/btn_edit.png' width='20' height='20' /></a></td>
				

			 </tr>";
		$no++;
	}
	echo "</tbody></table>";
	$jmldata = mysql_num_rows(mysql_query("SELECT * FROM pelanggan"));
	$jmlhalaman  = $p->jumlahHalaman($jmldata, $batas);
    $linkHalaman = $p->navHalaman($_GET[halaman], $jmlhalaman);

	echo "<div class=\"pagination\"> $linkHalaman</div>";
	break;
	
		case "tambahpelanggan":
	echo "<h2>Tambah Data NRG</h2>
	<form method='post' action='$aksi?module=pelanggan&act=input'>
	<table class='list'>
	<tr>
		<td>NRG</td>
		<td> : <input type='text' name='no_polisi' size='12' maxlength='12' /></td>
	</tr>
	<tr>
		<td>Nama PTK</td>
		<td> : <input type='text' name='nm_pelanggan' size='35' maxlength='100' /></td>
	</tr>
	<tr>
		<td>NUPTK</td>
		<td> : <input type='text' name='alamat' size='18' maxlength='18' /></td>
	</tr>

	
	<tr>
		<td>Kelamin</td>
		<td>
			: <select name='kota' >
				<option value='Laki-laki'>Laki-laki</option>
				<option value='Perempuan'>Perempuan</option>			
		</td>
	</tr>

	
	<tr>
		<td>Bidang Studi</td>
		<td> : <input type='text' name='telp' size='100' maxlength='100' /></td>
	</tr>


	
	<tr>
		<td>Tahun Sertifikasi</td>
		<td>
			: <select name='tipe_kendaraan' >
				<option value='2006'>2006</option>
				<option value='2007'>2007</option>
				<option value='2008'>2008</option>
				<option value='2009'>2009</option>
				<option value='2010'>2010</option>
				<option value='2011'>2011</option>
				<option value='2012'>2012</option>
				<option value='2013'>2013</option>
				<option value='2014'>2014</option>
		</td>
	</tr>

	<tr>
		<td>Ijazah terakhir</td>
		<td> : <input type='text' name='no_rangka' size='140' maxlength='240' /></td>
	</tr>
	<tr>
		<td>Sertifikat Pendidik</td>
		<td> : <input type='text' name='no_mesin' size='140' maxlength='240' /></td>
	</tr>
	
	<tr>
		<td colspan='2'><input type='submit' value='Simpan' />
		<input type='button' value='Batal' onclick=self.history.back()></td>
	</tr>
	</table>
	</form>";
	break;
	
	case "editpelanggan":
	$edit = mysql_query("select * from pelanggan where no_polisi='$_GET[id]'");
	$data = mysql_fetch_array($edit);
	echo "<h2>Edit NRG Guru</h2>
	<form method='post' action='$aksi?module=pelanggan&act=update'>
	<input type='hidden' name='id' value='$data[no_polisi]' />
	<table class='list'>
	<tr>
		<td>NRG</td>
		<td> : <input type='text' name='no_polisi' value='$data[no_polisi]' size='12' maxlength='12' /></td>
	</tr>
	<tr>
		<td>Nama PTK</td>
		<td> : <input type='text' name='nm_pelanggan' value='$data[nm_pelanggan]' size='35' maxlength='100' /></td>
	</tr>
	<tr>
		<td>NUPTK</td>
		<td> : <input type='text' name='alamat' value='$data[alamat]' size='18' maxlength='18' /></td>
	</tr>
	<tr>
		<td>Kelamin</td>
		<td> : <input type='text' name='kota' value='$data[kota]' size='10' maxlength='10' /></td>
	</tr>
	<tr>
		<td>Bidang Studi</td>
		<td> : <input type='text' name='telp' value='$data[telp]' size='100' maxlength='100' /></td>
	</tr>
	<tr>
		<td>Tahun Sertifikasi</td>
		<td> : <input type='text' name='tipe_kendaraan' value='$data[tipe_kendaraan]' size='4' maxlength='4' /></td>
	</tr>
	<tr>
		<td>Ijazah terakhir</td>
		<td> : <input type='text' name='no_rangka' value='$data[no_rangka]' size='140' maxlength='240' /></td>
	</tr>
	<tr>
		<td>Sertifikat Pendidik</td>
		<td> : <input type='text' name='no_mesin' value='$data[no_mesin]' size='140' maxlength='240' /></td>
	</tr>
	<tr>
		<td colspan='2'><input type='submit' value='Update' />
		<input type='button' value='Batal' onclick=self.history.back()></td>
	</tr>
	</table>
	</form>";
	break;
}
?>