<?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	= mysql_query("SELECT COUNT(*) FROM t_buku");
			$no 			= 1;
			$jum 			= mysql_result($jumlah_record, 0);
			$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 = mysql_query("SELECT SUM(harga) AS total FROM t_buku");	
						$data = mysql_fetch_array($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>No.</th>	
								<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 = mysql_query("SELECT * FROM t_buku LIMIT $start, $per_hal");	 
							while($data = mysql_fetch_array($tampil)) {	
						?>
						<tr class="rem1">
							<td class="invert"><?php echo $no++; ?></td>
							<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="11" 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="12" 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';
?>