<?php
	require_once("koneksi.php");
    include 'header.php';
?>

	<!-- breadcrumbs -->
		<div class="breadcrumbs">
			<div class="container">
				<ol class="breadcrumb breadcrumb1">
					<li><span><i class="fa fa-sign-in" aria-hidden="true"></i><a href="login.php"> Masuk</a></span></li>
					<li class="active">Form Kelola Buku</li>
				</ol>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- register -->
		<div class="register">
			<div class="container">
				<h2>Edit Data Buku</h2>
				<div class="login-form-grids">
					<h5>Data Buku</h5>
					<?php
					$id_buku 	= mysqli_real_escape_string($koneksi, $_GET['id']);
					$cari 		= mysqli_query($koneksi, "SELECT * FROM t_buku WHERE isbn='$id_buku'")or die(mysql_error());
					while($data = mysqli_fetch_array($cari)) {
					?>		
					<form  action="editbook_process.php" method="POST" enctype="multipart/form-data">
						<input type="hidden" name="id" placeholder="ISBN" value="<?php echo $data['isbn'] ?>" >
						<b>Judul Buku 			: </b>
						<input type="text" name="judul" placeholder="Judul Buku" value="<?php echo $data['judul'] ?>" >
						<b><br>Nama Pengarang 		:</b>
						<input type="text" name="pengarang" placeholder="Nama Pengarang" value="<?php echo $data['pengarang'] ?>" >
						<b><br>Nama Penerbit 		:</b>
						<select class="form-control" name="penerbit" required="Pilih Penerbit" value="<?php echo $data['penerbit'] ?>">
								<?php
									$penerbit   = mysqli_query($koneksi, "SELECT * FROM t_penerbit ORDER BY id_penerbit");
									while($pilih = mysqli_fetch_array($penerbit)) {
								?>
									<option value="<?= $pilih['id_penerbit'];?>"><i class="fa fa-arrow-right" aria-hidden="true"></i><?php echo $pilih['nama_penerbit']; ?></option>
								<?php   
									}
							 	?>
						</select>
						<b><br>Kategori Buku :</b>
						<select class="form-control" name="kategori" required="Pilih Kategori" value="<?php echo $data['kategori'] ?>">
								<?php
									$kategori   = mysqli_query($koneksi, "SELECT * FROM t_kategori ORDER BY id_kategori");
									while($pilih = mysqli_fetch_array($kategori)) {
								?>
									<option value="<?= $pilih['id_kategori'];?>"><i class="fa fa-arrow-right" aria-hidden="true"></i><?php echo $pilih['nama_kategori']; ?></option>
								<?php   
									}
							 	?>
						</select>
						<b><br>Tahun Terbit	:</b>
						<input type="text" name="tahun" placeholder="Tahun Terbit" value="<?php echo $data['tahun'] ?>" >
						<b><br>Harga per Eksemplar	:</b>
						<input type="text" name="harga" placeholder="Harga per Eksemplar" value="<?php echo $data['harga'] ?>" >
						<b><br>Jumlah Tersedia		:</b>
						<input type="text" name="jumlah" placeholder="Jumlah Tersedia" value="<?php echo $data['jumlah'] ?>" >
						<b><br>Keterangan Buku 	:</b>
						<select class="form-control" name="keterangan" value="<?php echo $data['keterangan'] ?>" required>
									<option value="1"><i class="fa fa-arrow-right" aria-hidden="true"></i>Tidak ada penawaran khusus</option>
									<option value="2"><i class="fa fa-arrow-right" aria-hidden="true"></i>Penjualan Terbaik</option>
									<option value="3"><i class="fa fa-arrow-right" aria-hidden="true"></i>Potongan Harga</option>
									<option value="4"><i class="fa fa-arrow-right" aria-hidden="true"></i>Rilis Terbaru</option>
						</select>
						<b><br>File Gambar : <br></b>
						<div class="col-md-5 agileinfo_single">
							<img src="<?php echo $data['gambar']; ?>" class="img-responsive"/>
						</div><br>
						<input type="file" name="gambar" accept="img/*" required>
						<input type="submit" name="edit" value="edit">
					</form>
					<?php 
						}
					?>
				</div>
				<div class="register-home">
					<a href="processbook.php">BATAL</a>
				</div>
			</div>
		</div>
	<!-- //register -->
	
<?php
	include 'footer.php';
?>