<?php
// Manage Karyawan ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ($_GET[module]=='karyawan'){
	echo "<div class='post_title' style='margin-bottom:10px; position:relative;'><b>List atau Daftar Semua Karyawan Pada Optik<hr></b></div>";
    echo "<input class='linkkk' type=button value='Tambah Karyawan' onclick=\"window.location.href='tambah-karyawan.html';\">
          <hr>";

	echo " <div id='container'>
			<div id='demo'>
<table class='display' id='example'>
	<thead>
          <tr bgcolor='#2e2e2e'>
			<th>No</th>
			<th>Username</th>
			<th>Nama Karyawan</th>
			<th>Alamat Email</th>
			<th>No.Telepon/HP</th>
			<th>Alamat Lengkap</th>
			<th>Status</th>
			<th style='width:100px; text-align:center;'>Action</th>
		</tr>
	</thead>
	<tfoot>
		<tr style='border: 2px solid #e3e3e3;'>
			<th style='border: none;'>No</th>
			<th style='border: none;'>Username</th>
			<th style='border: none;'>Nama Karyawan</th>
			<th style='border: none;'>Alamat Email</th>
			<th style='border: none;'>No.Telepon/HP</th>
			<th style='border: none;'>Alamat Lengkap</th>
			<th style='border: none;'>Status</th>
			<th style='border: none;'></th>
		</tr>
	</tfoot>";
	echo "<tbody>";
	$no=1;
	$tampil = mysql_query("SELECT * FROM rb_users where level='karyawan' ORDER BY username");
    while($r=mysql_fetch_array($tampil)){
	  if(($no % 2)==0){ $warna="#ffffff"; }else{ $warna="#E1E1E1"; }
		
		if ($r[level]==admin){
			echo "<tr bgcolor=$warna><td style='background:red; color:#fff;' class='read_only'>$no</td>
			 <td style='background:red; color:#fff;'>$r[username]</td>
             <td style='background:red; color:#fff;'>$r[nama_lengkap]</td>
			 <td style='background:red; color:#fff;'>$r[email]</td>
		     <td style='background:red; color:#fff;'>$r[no_telp]</td>
		     <td style='background:red; color:#fff;'>$r[alamat_lengkap]</td>";
		}else{
		    echo "<tr bgcolor=$warna><td class='read_only'>$no</td>
			 <td>$r[username]</td>
             <td>$r[nama_lengkap]</td>
			 <td>$r[email]</td>
		     <td>$r[no_telp]</td>
		     <td>$r[alamat_lengkap]</td>
			 <td><span style='color:red;'>$r[status]</span></td>";
		}
            echo "<td><center><a class='linkkk' href=edit-karyawan-$r[username].html>Edit</a>
			 <a class='linkkk' style='color:red' href=aksi_karyawan.php?act=hapus&id=$r[username] onclick=\"return confirm('Anda yakin ingin hapus data ini?')\">X</a></center></td></tr>";
			 $no++;
		}
echo "	</tbody>
 </table>
</div></div>";
}

elseif ($_GET[module]=='tambahkaryawan'){
echo "<div class='post_title' style='margin-left:20%;'><b>Tambahkan Karyawan Baru.</b></div><hr><br/>
          <form method=POST action='aksi_karyawan.php?act=input'>
          <center><table width='60%'>
          <tr><td width='160px' class='td'><br>Username</td> <td class='td'><br/>:</td><td class='td'> <br><input type=text name='username' style='width:40%'></td></tr>  
          <tr><td class='td'>Password</td>   <td class='td'>:</td><td class='td'> <input type=password name='password' style='width:40%'></td></tr>
		  <tr><td class='td'>Nama Lengkap</td>   <td class='td'>:</td><td class='td'> <input type=text name='nama_lengkap' style='width:70%'></td></tr>
		  <tr><td class='td'>Alamat Email</td>   <td class='td'>:</td><td class='td'> <input type=text name='email' style='width:70%'></td></tr>
		  <tr><td class='td'>No Telp</td>   <td class='td'>:</td><td class='td'> <input type=text name='no_telp' style='width:40%'></td></tr>
		  <tr><td class='td'>Alamat Lengkap</td>   <td class='td'>:</td><td class='td'><textarea name='alamat_lengkap' style='width:100%; height:60px;'></textarea></td></tr>
		  <input type=hidden name='gaji' value='0' style='width:30%'>
		   <tr><td class='td'>Status</td>   <td class='td'>:</td><td class='td'> <select name='status'>
            <option value='-' selected>- Pilih Status -</option>
			<option value='biasa'> Karyawan Biasa </option>
			<option value='grosir'> Karyawan Grosir </option>
		   </select></td></tr>
          <tr><td class='td' colspan=3><br/><input class='button-reply' type=button value=Batal onclick=self.history.back()>
							<input class='button-reply' type=submit value=Simpan></td></tr>
          </table></center></form>";
}

elseif ($_GET[module]=='editkaryawan'){
$edit=mysql_query("SELECT * FROM rb_users WHERE username='$_GET[id]'");
    $r=mysql_fetch_array($edit);
echo "<div class='post_title' style='margin-left:20%;'><b>Edit Data $r[nama_lengkap] (Karyawan).</b></div><hr><br/>
          <form method=POST action='aksi_karyawan.php?act=update'>
		  
          <center><table width='60%'> 																	   <input type=hidden name='usernamee' value='$r[username]'>
          <tr><td width='160px' class='td'><br>Username</td> <td class='td'><br/>:</td><td class='td'> <br><input type=text name='username' value='$r[username]' style='width:40%' class='disabled'></td></tr>  
          <tr><td class='td'>Password</td>   <td class='td'>:</td><td class='td'> <input type=password name='password' style='width:40%' class='disabled'></td></tr>
		  <tr><td class='td'>Nama Lengkap</td>   <td class='td'>:</td><td class='td'> <input type=text name='nama_lengkap' value='$r[nama_lengkap]' style='width:70%'></td></tr>
		  <tr><td class='td'>Alamat Email</td>   <td class='td'>:</td><td class='td'> <input type=text name='email' value='$r[email]' style='width:70%'></td></tr>
		  <tr><td class='td'>No Telp</td>   <td class='td'>:</td><td class='td'> <input type=text name='no_telp' value='$r[no_telp]' style='width:40%'></td></tr>
		  <tr><td class='td'>Alamat Lengkap</td>   <td class='td'>:</td><td class='td'><textarea name='alamat_lengkap' style='width:100%; height:60px;'>$r[alamat_lengkap]</textarea></td></tr>
		  <input type=hidden name='gaji' value='$r[gaji]' style='width:30%'>
		  <tr><td class='td'>Status</td>   <td class='td'>:</td><td class='td'> <select name='status'>
            <option value='$r[status]' selected> Karyawan $r[status] </option>
			<option value='biasa'> Karyawan Biasa </option>
			<option value='grosir'> Karyawan Grosir </option>
		   </select></td></tr>
          <tr><td class='td' colspan=3><br/><input class='button-reply' type=button value=Batal onclick=self.history.back()>
							<input class='button-reply' type=submit value=Simpan></td></tr>
          </table></center></form>"; 
}

elseif ($_GET[module]=='editadmin'){
$edit=mysql_query("SELECT * FROM rb_users WHERE level='admin'");
    $r=mysql_fetch_array($edit);
echo "<div class='post_title' style='margin-left:20%;'><b>Manage Data $r[nama_lengkap] (Admin).</b></div><hr><br/>
          <form method=POST action='aksi_karyawan.php?act=updatee'>
		  
          <center><table width='60%'>
          <tr><td width='160px' class='td'><br>Username</td> <td class='td'><br/>:</td><td class='td'> <br><input type=text name='username' value='$r[username]' style='width:100%' class='disabled'></td></tr>  
          <tr><td class='td'>Password</td>   <td class='td'>:</td><td class='td'> <input type=password name='password' style='width:100%' class='disabled'></td></tr>
		  <tr><td class='td'>Nama Lengkap</td>   <td class='td'>:</td><td class='td'> <input type=text name='nama_lengkap' value='$r[nama_lengkap]' style='width:100%'></td></tr>
		  <tr><td class='td'>Alamat Email</td>   <td class='td'>:</td><td class='td'> <input type=text name='email' value='$r[email]' style='width:100%'></td></tr>
		  <tr><td class='td'>No Telp</td>   <td class='td'>:</td><td class='td'> <input type=text name='no_telp' value='$r[no_telp]' style='width:100%'></td></tr>
		  <tr><td class='td'>Alamat Lengkap</td>   <td class='td'>:</td><td class='td'><textarea name='alamat_lengkap' style='width:100%; height:60px;'>$r[alamat_lengkap]</textarea></td></tr>
		  
          <tr><td class='td' colspan=3><br/><input class='button-reply' type=button value=Batal onclick=self.history.back()>
							<input class='button-reply' type=submit value=Simpan></td></tr>
          </table></center></form>"; 
}

?>