<?php 
include "koneksi.php";
if (!isset($_SESSION["UserID"]))
{
	header("location:login.php?p=3");
}

$id="";
if (isset($_GET["id"]))
{
	$id=mysqli_real_escape_string($conn,$_GET["id"]);
}

?>
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="style.css">
<html>
  <head>
	<title> Modifikasi Motor </title>
	<?php
				include "part/menu2.php";
				?>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php
		include "part/jss.php";
	?>
	
  </head>
  <body>
	
	<div class="container">
	
		<div class="span12">
			<div class="alert alert-info">
					<b><center><h1>MODIFIKASI MOTOR</h1></center></b>
			</div>
					
					<?php
	
						
						$q="SELECT * FROM histori WHERE id='$id'";
						
						$res=mysqli_query($conn,$q);
						$dataHistori=mysqli_fetch_assoc($res);
					?>
			
			
		<div class="alert alert-info" align='center'>
			 <h3>TANGGAL HISTORI <?php echo $dataHistori["tanggal"];?></h3>
			 <?php
				if (isset($_GET["p"]))
				{
					$p=mysqli_real_escape_string($conn,$_GET["p"]);
					if ($p=="3")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Nama motor berhasil dihapus
							</div>
						<?php
					}
					else if ($p=="1")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Nama motor berhasil ditambah
							</div>
						<?php
					}
				}
			 ?>
			 <table class="table table-bordered">
			    <thead>
				  <tr>
				    <th>
					   Rangking :
					</th>
					<th>
					  Sparepart :
					</th>
					<th>
					  Bobot :
					</th>
		         </tr>
				</thead>
				<tbody>
				    <?php
					 if (isset($_SESSION["UserID"]))
					 {
						$q="SELECT * FROM detail_histori WHERE id_kepala='". $_GET["id"] ."'";
						//echo $_GET["id"];
						$res=mysqli_query($conn,$q);
						$nilai = 0;
						while ($row=mysqli_fetch_assoc($res))
						{
							?>
							  <tr>
							    <td>
								  <?php
								  $nilai ++;
								  echo $nilai;
								  ?>
								</td>
								<td>
								  <?php
									//echo $row["id_sparepart"];
									$h="SELECT * FROM sparepart WHERE id='".$row["id_sparepart"]."'";
									$ress=mysqli_query($conn,$h);
									$zz=mysqli_fetch_assoc($ress);
									echo $zz["nama"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["bobot"];
								  ?>
								</td>
								
								<td>
								  
								  
								  
								  
								</td>
							  </tr>
							<?php
						}
					 }
					?>
				</tbody>
			 </table>
			 
			 <a href="history.php"><button type="button" class="btn btn-info">Kembali</button></a>
			 
		</div>		
	</div>
	
  
  </body>
</html>




