<?php 
include "koneksi.php";
if (!isset($_SESSION["UserID"]))
{
	header("location:login.php?p=3");
}
?>
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="style.css">
<html>
  <head>
	<title>PT. MULTI HIDRACHROME BALIKPAPAN</title>
	<link rel="icon" type="image/png" href="images/mhb.jpeg">
						<?php
						include "part/menu2.php";
					?>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php
		include "part/jss.php";
	?>
	
  </head>
  <body>
	
	<div style="width:1280px; height:220px" class="container" >

		
			<div class="alert alert-info" style='background-color:#F8F8FF' href="#">
            <div style="display: block; margin-left: auto; margin-right: auto; width: 1000px;  height:100px;"><img style="width: 1000px;  height:180px;" src="images/hd.jpg"></div>
                     <div>
                <center>
                    <h1>PT. MULTI HIDRACHROM BALIKPAPAN</h1>
                </center>
            </div>
            <div>
                <center>
                    <h4>PROFESIONAL INFORMATION SYSTEM</h4>
                </center>
            </div>
        </div>
					

			
			
		<div class="alert alert-info" align='center'>
		<h3>DATA KARYAWAN TETAP</h3>
		<?php
		if (isset($_GET["p"]))
				{
					$p=mysqli_real_escape_string($conn,$_GET["p"]);
					if ($p=="3")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Sparepart berhasil dihapus!
							</div>
						<?php
					}
					else if ($p=="1")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Spareaprt berhasil ditambah!
							</div>
						<?php
					}
					else if ($p=="2")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Nilai kriteria spareaprt berhasil ditambah!
							</div>
						<?php
					}
					else if ($p=="4")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Sparepart berhasil di update!
							</div>
						<?php
					}
				}
		?>
		
		<table class="table table-bordered">
			    <thead>
				  <tr>
				    <th>
					   Nik
					</th>
					<th>
					   Nama Karyawan
					</th>
					<th>
					   Tanggal Masuk
					</th>
					<th>
					   Lama Bekerja 
					</th>
					<th>
					   Durasi Kontrak()
					</th>
					<th>
					   Akhir Kontrak
					</th>
					<th>
					   Pilihan
					</th>
					
					<th>
						
					</th>
				  </tr>
				</thead>
				<tbody>
				    <?php
						$q="SELECT s.*,k.nama as ktg,j.nama as jns,m.nama as mrk,z.nama as mtr ".
						   "FROM sparepart s ".
						   "INNER JOIN kategori k ON (s.id_kategori=k.id) ".
						   "INNER JOIN jenis_motor j ON (j.id=s.id_jenisMotor) ".
						   "INNER JOIN merk_sparepart m ON (m.id=s.id_merkSparepart)".
						   "INNER JOIN kendaraan z ON (z.id=s.id_merkMotor)";
						$res=mysqli_query($conn,$q);
						while ($row=mysqli_fetch_assoc($res))
						{
							?>
							  <tr>
							    <td>
								  <?php
									echo $row["nama"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["ktg"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["jns"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["mtr"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["mrk"];
								  ?>
								</td>
								<td>
								  <a href="updatesparepart.php?id=<?php echo $row["id"];?>">Update</a>
								  |
								  <a href="deletesparepart.php?id=<?php echo $row["id"];?>">Hapus</a>
								  |
								  <a href="nilaisparepart.php?id=<?php echo $row["id"];?>">Nilai Kriteria</a>
								 
								</td>
							  </tr>
							<?php
						}
					?>
				</tbody>
			 </table>
			 <a href="tambahsparepart.php"><button type="button" class="btn btn-info">Tambah</button></a>
		</div>		
	</div>
	
  
  </body>
  
  <script>
    $(document).ready(function()
	{
		 $('.table-bordered').DataTable();
	});
  </script>
</html>




