<?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 Artikel</li>
				</ol>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- Page -->
		<?php 
			$per_hal		= 5;
			$jumlah_record	= mysql_query("SELECT COUNT(*) FROM t_artikel");
			$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-2">
				<tr>
					<br>
					<td>Jumlah Data Artikel</td>		
					<td>: <b><?php echo $jum; ?></b></td>
				</tr>
			</table>
		</div>
	<!-- checkout -->
			<div class="container"><br><br><br>
				<h2>Daftar Artikel : </h2><br>
				<div class="checkout-right">
					<table class="timetable_sub">
						<thead>
							<tr>
								<th>No.</th>	
								<th>ID</th>
								<th>Judul</th>
								<th>Tanngal Dibuat</th>
								<th>Tanngal Diubah</th>
								<th>Pengelola</th>
								<th>Opsi</th>
							</tr>
						</thead>
						<?php
						 	$tampil = mysql_query("SELECT * FROM t_artikel 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['id_artikel']; ?></td>
							<td class="invert"><?php echo $data['judul_artikel']; ?></td>
							<td class="invert"><?php echo $data['tanggal_dibuat']; ?></td>
							<td class="invert"><?php echo $data['tanggal_diedit']; ?></td>
							<td class="invert"><?php echo $data['username']; ?></td>
							<td class="invert">
								<div class="rem">
									<div>
										<a href="singlearticle.php?kd=<?php echo $data['id_artikel'];?>">
											<img src="images/search.png" />
										</a>
						                <a href="editarticle.php?id=<?php echo $data['id_artikel']; ?>">
						                	<img src="images/edit.png" />
						                </a>
						                <a href='deletearticle_process.php?id=<?php echo $data['id_artikel']; ?>' }">
						                	<img src="images/close_1.png" />
						                </a>
									</div>
								</div>
							</td>
						</tr>
						<?php
							}
						?>
						<?php
							if(	isset($_SESSION['administrator'])){
								echo '
									<tr><td colspan="6" align="center" style="background-color:#ffffff"><b> Tambah Artikel </b></td>
									<td><a href="addarticle.php"><img src="images/tambah.png" /></td></tr></table>
								';
							}
							else {
								echo '
									<tr><td colspan="7" 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 $x++ ?>" aria-label="Next">
						<span aria-hidden="true">&raquo;</span>
						</a>
					</li>-->
					<br><br><br>
				</ul>
			</nav>		
		</div>
	<!-- //checkout -->

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