<html>
<head>
<title>LIST KARYAWAN</title>
</head>
<body>
<h3><center> DAFTAR KARYAWAN </h3>
<p align="center"><font face="verdana" size="2">
<?php	
	include "connect.php"; //include file koneksi
	include"indo.php";
	session_start();



//cek level user
if($_SESSION['Level']=="hrd" || $_SESSION['Level']=="admin"){


	//$entries=2; //nilai awal==jumlah data yang ditampilkan setiap halaman
	
	//************awal paging************//
	$tampil="select * from staf"; //input
	$hasil=mysql_query($tampil);
	$total = mysql_num_rows($hasil);//dapatkan jumlah semua data
	
	if ($total>$entries)  //jika jumlah semua data lebih banyak dari nilai awal yang diberikan
	{
		echo "Halaman : ";
		$pages=1;
		while($pages<=ceil($total/$entries))
		{
			if ($pages!=1)
			{
				echo " | ";
			}
		?>
		<!--Membuat link sesuai nama halaman-->
		<a href="tampilstaf.php?id=<? echo ($pages-1); ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><? echo $pages; ?></font></a>
 
		 <?
				$pages++;
		}
	}else{
		$pages=0;
	}
	
	//**************akhir paging*****************//
	
	?>
	  </font>
	<?
	$page=(int)$_GET['id'];
	$offset=$page*$entries;
	
	//menampilkan data dengan menggunakan limit sesuai parameter paging yang diberikan
	$tampil2="select * from staf order by nama asc limit $offset,$entries";
	$hasil2=mysql_query($tampil2);
	$total2 = mysql_num_rows($hasil2);
?>
</p>
<table align="center" width="1197" border="0">
			<tr align="center" bgcolor='#6699FF'>
				<td width="87"><b><font face="verdana" size="1" color="#FFFFFF">NIK</font></b></td>
				<td width="134"><b><font face="verdana" size="1" color="#FFFFFF">Nama</font></b></td>
				<td width="97"><b><font face="verdana" size="1" color="#FFFFFF">Jabatan</font></b></td>
				<td width="106"><b><font face="verdana" size="1" color="#FFFFFF">No.HP</font></b></td>
				<td width="288"><b><font face="verdana" size="1" color="#FFFFFF">Alamat</font></b></td>
				<td width="155"><b><font face="verdana" size="1" color="#FFFFFF">TTL</font></b></td>
				<td width="102"><b><font face="verdana" size="1" color="#FFFFFF">Tgl Masuk</font></b></td>
				<td width="75"><b><font face="verdana" size="1" color="#FFFFFF">foto</font></b></td>
				<td width="115"><b><font face="verdana" size="1" color="#FFFFFF">Keterangan</font></b></td>
			</tr>
	<?
	if ($total2){
		while ($row=mysql_fetch_array($hasil2))
		{
		?>
			<tr bgcolor="#D5E9FF">
				<td valign="top"><font face="verdana" size="1"><? echo $row[0]; ?></font></td>
			    <td valign="top"><font face="verdana" size="1"><? echo $row[1]; ?></font></td>
			    <td valign="top"><font face="verdana" size="1"><? echo $row[2]; ?></font></td>
			    <td valign="top"><font face="verdana" size="1"><? echo $row[3]; ?></font></td>
			    <td valign="top"><font face="verdana" size="1"><? echo $row[4]; ?></font></td>
				<? $tgl_asli = $row[7];
				$ftgl=TanggalIndo($tgl_asli);
				$tgl_msk= $row[8];
				$ftgl_msk= TanggalIndo($tgl_msk);
				?>
				<td valign="top"><font face="verdana" size="1"><? echo $row[6]; ?>,<? echo " $ftgl"; ?></font></td>
				<td valign="top"><font face="verdana" size="1"><? echo " $ftgl_msk"; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><? echo "<img src=photo1.php?idf=$row[0] width=150 />"; ?></font></td>
				<td align="center" valign="top"><font face="verdana" size="2"><a href=formeditstaf.php?id=<? echo $row[0]; ?>>Edit</a> |
																<a href=hapusstaf.php?id=<? echo $row[0]; ?> onClick="return confirm('Yakin data ini akan dihapus...?')">Hapus</a></font></td>
	          <?	
		} 
	}else{
		?><p align="center"><font color="#FF0000" face="verdana" size="2"><b>Belum ada data!!</b></font></p><?
	}
	?>
		<tr bgcolor="#D5E9FF">
		<td colspan="7" align="center"><font face="verdana" size="1">JUMLAH: <? echo $total; ?></font></td>
		<td colspan="1" align="center"><a href="userhrd.php">Home</a>|<a href="fstaf.php">Input</a>		  </td>
		</tr>

</table> 
<?php
} else {
    die("Anda bukan admin");
}
?>
</body>
</html>
