<?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">Kelola Data Buku</li>
				</ol>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- Page -->
		<?php 
			$per_hal		= 5;
			$jumlah_record	= mysqli_query($koneksi, "SELECT * FROM t_buku");
			$no 			= 1;
			$jum 			= mysqli_num_rows($jumlah_record);
			$halaman 		= ceil($jum / $per_hal);
			$page 			= (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
			$start 			= ($page - 1) * $per_hal;
		?>
	<!-- //Page -->
		<div class="col-md-12">
			<table class="col-md-3">
				<tr>
					<td>Jumlah Data Buku</td>		
					<td>:<b> <?php echo $jum; ?></b></td>
				</tr>
				<tr>
					<td>Total Dana</td>	
					<td>:<b>
					<?php 
						$modal = mysqli_query($koneksi, "SELECT SUM (harga) AS total FROM t_buku");	
						$data = ($modal);			
						echo " Rp.". number_format($data['total']).",-";		
					?>
					</b></td>
				</tr>
			</table>
		</div>
	<!-- checkout -->
			<div class="container"><br><br><br>
				<h2>Detail Buku : </h2><br>
				<div class="checkout-right">
					<table class="timetable_sub">
						<thead>
							<tr>	
								<th>ISBN</th>
								<th>Judul</th>
								<th>Pengarang</th>
								<th>Penerbit</th>
								<th>Kategori</th>
								<th>Tahun</th>		
								<th>Harga</th>
								<th>Jumlah</th>
								<th>Keterangan</th>
								<th>Pengelola</th>
								<th>Opsi</th>
							</tr>
						</thead>
						<?php
						 	$tampil = mysqli_query($koneksi, "SELECT * FROM t_buku LIMIT $start, $per_hal");	 
							while($data = mysqli_fetch_array($tampil)) {	
						?>
						<tr class="rem1">
							<td class="invert"><?php echo $data['isbn']; ?></td>
							<td class="invert"><?php echo $data['judul']; ?></td>
							<td class="invert"><?php echo $data['pengarang']; ?></td>
							<td class="invert"><?php echo $data['penerbit']; ?></td>
							<td class="invert"><?php echo $data['kategori']; ?></td>
							<td class="invert"><?php echo $data['tahun']; ?></td>
							<td class="invert">Rp.<?php echo number_format($data['harga'],2,",",".");?></td>
							<td class="invert"><?php echo $data['jumlah']; ?></td>
							<td class="invert"><?php echo $data['keterangan']; ?></td>
							<td class="invert"><?php echo $data['username']; ?></td>
							<td class="col-md-2">
								<div class="rem">
									<div>
										<a href="singlebook.php?kd=<?php echo $data['isbn'];?>">
											<img src="images/search.png" />
										</a>
						                <a href="editbook.php?id=<?php echo $data['isbn']; ?>">
						                	<img src="images/edit.png" />
						                </a>
						                <a href='deletebook_process.php?id=<?php echo $data['isbn']; ?>' }">
						                	<img src="images/close_1.png" />
						                </a>
									</div>
								</div>
							</td>
						</tr>
						<?php
							}
						?>
						<?php
							if(	isset($_SESSION['administrator'])){
								echo '
									<tr><td colspan="10" align="center" style="background-color:#ffffff"><b> Tambah Data Buku </b></td>
									<td><a href="addbook.php"><img src="images/tambah.png" /></td></tr></table>
								';
							}
							else {
								echo '
									<tr><td colspan="11" align="center" style="background-color:#ffffff"> Data buku kosong ! </td></tr></table>
								';
							}
						?>
					</table>
				</div>
			<nav class="numbering">
				<ul class="pagination paging">
					<li>
						<?php 
							for($page=1;$page<=$halaman;$page++){
								?>
								<li><a href="?page=<?php echo $page ?>"><?php echo $page ?></a></li>
								<?php
							}
						?>
					</li>
					<!--<li>
						<a href="?page=<?php echo $page++ ?>" aria-label="Next">
						<span aria-hidden="true">&raquo;</span>
						</a>
					</li>-->
					<br><br><br>
				</ul>
			</nav>		
		</div>
	<!-- //checkout -->

<?php
	include 'footer.php';
?>