<?php 
include 'header.php';
$kode = $_GET['kode'];

$result = mysqli_query($conn, "SELECT * FROM inventory WHERE kode_bk = '$kode'");
$row= mysqli_fetch_assoc($result);
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Master Produk - UMKM Galeri 3D</title>
<style>
body {
    background: #f3f4f6;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}
.container {
  	max-width: 1200px;
    margin: 5px auto;
    padding: 0 30px;
}
/* Umum (untuk semua perangkat) */
.button-row .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
}

/* Untuk tampilan HP (maksimal 767px) */
@media (max-width: 767px) {
  .button-row {
    display: block;
    margin-top: 15px;
  }
  .button-row .col-md-6 {
    width: 100%;
    padding: 0 10px;
  }
  .button-row .btn {
    width: 100%;
    margin-bottom: 10px;
  }
}

/* Untuk tampilan Desktop (min 768px) */
@media (min-width: 768px) {
  .button-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    margin-bottom: 40px;
  }
  .button-row .col-md-6 {
    flex: 0 0 48%;
  }
}
</style>
</head>
<body>
<div class="container">
	<h2 style=" width: 100%; border-bottom: 4px solid gray"><b>Edit Inventory</b></h2>

	<form action="proses/edit_inv.php" method="POST">
		<div class="row">
			<div class="col-md-6">
				<div class="form-group">
					<label for="exampleInputEmail1">Kode Material</label>
					<input type="text" class="form-control" id="exampleInputEmail1" disabled value="<?= $row['kode_bk']; ?>">
					<input type="hidden" class="form-control" id="exampleInputEmail1" placeholder="Contoh : Kg atau gram" name="kd_material" value="<?= $row['kode_bk']; ?>">
				</div>
			</div>
			<div class="col-md-6">
				<div class="form-group">
					<label for="exampleInputEmail1">Nama Material</label>
					<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Masukkan Material" name="nama" value="<?= $row['nama']; ?>">
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-md-6">
				<div class="form-group">
					<label for="exampleInputEmail1">Stok</label>
					<input type="number" class="form-control" id="exampleInputEmail1"  name="stok" value="<?= $row['qty']; ?>">
				</div>
			</div>
			<div class="col-md-6">
				<div class="form-group">
					<label for="exampleInputEmail1">Satuan</label>
					<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Contoh : Kg" name="satuan" value="<?= $row['satuan']; ?>">
					<p class="help-block">Hanya Masukkan Satuan saja : Kg atau gram</p>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-md-6">
				<div class="form-group">
					<label for="exampleInputEmail1">Harga</label>
					<input type="number" class="form-control" id="exampleInputEmail1"  name="harga" placeholder="Contoh : 1000" value="<?= $row['harga']; ?>">
					<p class="help-block">Harga termasuk harga per kg atau per 	gram</p>
				</div>
			</div>
		</div>

		<div class="row button-row" style="margin-top: 20px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px;">
			<div class="col-md-6 mb-2">
				<button type="submit" class="btn btn-warning btn-block">
				<i class="glyphicon glyphicon-edit"></i> Edit
				</button>
			</div>
			<div class="col-md-6 mb-2">
				<a href="inventory.php" class="btn btn-danger btn-block">
				<i class="glyphicon glyphicon-remove"></i> Cancel
				</a>
			</div>
		</div>
	</form>
</div>

<br>

</div>
</form>

</div>

</body>
</html>