<?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 Pesanan</li>
				</ol>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- Page -->
		<?php 
			$per_hal		= 10;
			$jumlah_record	= mysqli_query($koneksi, "SELECT * FROM t_pemesanan");
			$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 Pemesanan</td>		
					<td>:<b> <?php echo $jum; ?></b></td>
				</tr>
				<tr>
					<td>Total Harga</td>	
					<td>:<b>
					<?php 
						$modal = mysqli_query($koneksi, "SELECT SUM (total_harga) AS total FROM t_pemesanan");	
						$data  = ($modal);			
							echo " Rp.". number_format($data['total']).",-";		
					?>
					</b></td>
				</tr>
			</table>
		</div>
	<!-- checkout -->
			<div class="container"><br><br><br>
				<h2>Daftar Pesanan : </h2><br>
				<div class="checkout-right">
					<table class="timetable_sub table table-bordered table-hover">
						<thead>
							<tr>
								<th>No.</th>	
								<th>Judul Buku</th>
								<th>Akun</th>
								<th>Total Harga</th>
								<th>Status</th>
								<th>Tanggal Dipesan</th>
								<th>Tanggal Dibayar</th>
								<th>Opsi</th>
							</tr>
						</thead>
						<?php
						 	$tampil = mysqli_query($koneksi, "SELECT * FROM t_pemesanan LIMIT $start, $per_hal");	 
							while($data = mysqli_fetch_array($tampil)) {	
						?>
						<tr class="rem1">
							<td class="invert"><?php echo $no++; ?></td>
							<td class="invert"><?php echo $data['buku']; ?></td>
							<td class="invert"><?php echo $data['username']; ?></td>
							<td class="invert"><?php echo $data['total_harga']; ?></td>
							<td class="invert"><?php echo $data['status']; ?></td>
							<td class="invert"><?php echo $data['tanggal_dipesan']; ?></td>
							<td class="invert"><?php echo $data['tanggal_dibayar']; ?></td>
							<td class="col-md-2">
								<div class="rem">
									<div>
						                <a href="editorder.php?id=<?php echo $data['isbn']; ?>">
						                	<img src="images/edit.png" />
						                </a>
						                <a onclick="if(confirm('Apakah Anda yakin ingin menghapus data ini ?')){ location.href='deleteorder_process.php?id=<?php echo $data['isbn']; ?>' }">
						                	<img src="images/close_1.png" />
						                </a>
									</div>
								</div>
							</td>
						</tr>
						<?php
							}
						?>
						<?php
							if(	isset($_SESSION['administrator']) && $no>=1){
								echo '	';
							}
							else {
								echo '
									<tr><td colspan="12" align="center" style="background-color:#ffffff"> Data pesanan 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';
?>