<?php
include "koneksi.php";
if (!isset($_SESSION["UserID"])) {
	header("location:login.php?p=3");
}
$q="SELECT * FROM user WHERE id='". $_SESSION["UserID"] ."'";
						$res=mysqli_query($conn,$q);
						$dataUser=mysqli_fetch_assoc($res);
					
						$nik = $dataUser["nik_data_karyawan"];
						
$id = $_GET['id'];
?>
<!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>DAFTAR PO DIPROSES GABUNGAN</h3>
					<h5>menampilkan seluruh list pr yang telah diproses dan mendapatkan suplier / harga</h5>
					<h5>tekan SELESAI jika hanya barang sudah sampai ke user</h5>
					<?php
					if (isset($_GET["p"])) 
					{
						$p = $_GET["p"];
						if ($p == "1") 
						{
						?>
						<div class="alert alert-success">
							PR CLOSE
						</div>
						<?php
						} 
						else if ($p == "3") 
						{
						?>
							<div class="alert alert-danger">
								PR GAGAL!
							</div>
						<?php
						}
						else if ($p == "4") 
						{
						?>
							<div class="alert alert-danger">
								PR GAGAL CETAK!
							</div>
						<?php
						}
					}
					?>
					<?php
					$z = 1;
					?>
					<table class="table table-bordered">
						<thead>
							<tr>
							    <th>
									NO 
								</th>
								<th>
									KODE GABUNGAN
								</th>
								<th>
									SUPLIER
								</th>
								<th>
									ALAMAT
								</th>
								<th>
									KODE SUPLIER
								</th>
								<th>
					
								</th>
								
							</tr>
						</thead>
						<tbody>
							<?php
							$status = '1';
							$o = "SELECT DISTINCT gabung FROM data_purchasing_requisition WHERE id_suplier = '$id'";
							
							
							
							$reso = mysqli_query($conn, $o);
							$rowo = mysqli_fetch_assoc($reso);
							
							$gabungkan = $rowo["gabung"];	
							//echo "ini id = ".$id;
							//echo "ini gabung = ".$gabungkan;
							
							$q = "SELECT DISTINCT gabung,id_suplier FROM data_purchasing_requisition WHERE id_suplier = '$id' AND jadikan_satu = '3'";
							$res = mysqli_query($conn, $q);
							
							//echo "q = ".$q;
							
							
							
							while ($row = mysqli_fetch_assoc($res)) 
							{
							?>
								<tr>
									<td>
									     <?php
									         echo $z;
									         $z = $z + 1;
											 //echo $row["id"];
									     ?>
								    </td>
									<td>
										<?php
										echo $row["gabung"];
										?>
									</td>
									<td>
										<?php
										
										$suplier = $row["id_suplier"];
										$d = "SELECT * FROM data_suplier WHERE id ='$suplier'";
										$resd = mysqli_query($conn, $d);
										$rowd = mysqli_fetch_assoc($resd);
										echo $rowd["nama_suplier"];
										?>
									</td>
									<td>
										<?php
										$suplier = $row["id_suplier"];
										$d = "SELECT * FROM data_suplier WHERE id ='$suplier'";
										$resd = mysqli_query($conn, $d);
										$rowd = mysqli_fetch_assoc($resd);
										echo $rowd["alamat"];
										
										?>
									</td>
									<td>
										<?php
										$suplier = $row["id_suplier"];
										$d = "SELECT * FROM data_suplier WHERE id ='$suplier'";
										$resd = mysqli_query($conn, $d);
										$rowd = mysqli_fetch_assoc($resd);
										echo $rowd["kode_suplier"];
									
										?>
									</td>
									<td>
										
										<a href="simpanPrSelesaiGabungan.php?id=<?php echo $row["gabung"]; ?>"    type="button" class="btn btn-danger"   >selesai</a>
										<a href="detailHistoryPoGabung2.php?id=<?php echo $row["gabung"]; ?>"    type="button" class="btn btn-info"   >detail/ubah</a>
									     <a href="cetakPrPDFGabung.php?id=<?php echo $row["gabung"]; ?>"    type="button" class="fa fa-file-pdf-o btn btn-warning"   > po</a>
									    <a href="printHistoryPr2.php?id=<?php echo $row["gabung"]; ?>"    type="button" class="fa fa-file-pdf-o btn btn-warning"   >pr</a>
									</td>
								
									</td>
								</tr>
								
							<?php
							}
							
							?>
						</tbody>
						
					</table>
					<td>
					
				</div>

		<center><h5 class="form-signin">Copyright &copy; <a href="#" data-toggle="modal" data-target="#contact">SatrioPringgondani</a></h5></center>  
	</body>
</html>

<script>
$(document).ready(function()
{
	 $('.table-bordered').DataTable();
});
</script>