<?php
	include 'koneksi.php';
	include 'common/header.php';
?>
<h2> <span class="glyphicon glyphicon-eye-open"></span> Order Detail</h2>

<hr> <br>

<a href="daftar_pesanan.php" class="btn btn-info"> <span class="glyphicon glyphicon-chevron-left"></span> Kembali </a>
<br> <br>

<table class="table table-condensed table-hover">
<tr>
	<th> NO </th>
	<th> Gambar </th>
	<th> Nama Menu </th>
	<th> Tanggal di pesan</th>
	<th> Harga Satuan </th>
	<th> Jumlah </th>
	<th> Subtotal </th>
</tr>
<?php
	global $total;
	$id_member = $_GET['id_member'];
	$query = mysqli_query($koneksi, "SELECT pemesanan.id_pemesanan, pemesanan.tanggal, pemesanan.jumlah, menu.nama AS nama_menu, menu.gambar,
	menu.kategori_id, menu.harga,kategori.nama_kategori FROM pemesanan INNER JOIN (menu INNER JOIN kategori ON kategori_id = id_kategori) ON menu_id = id_menu WHERE member_id = '$id_member'");	
	$no = 1; 
	while($row = mysqli_fetch_assoc($query)){
		$subtotal = $row['harga'] * $row['jumlah'];
?>
	<tr>
		<td> <?= $no;?> </td>
		<td> <img src="picture/<?= $row['gambar']?>" width="150" height="140"> </td>
		<td> <?= $row['nama_menu'] ?> </td>
		<td> <?= $row['tanggal']?> </td>
		<td> Rp. <?= number_format($row['harga'])?>,- </td>
		<td> <?= $row['jumlah']?> </td>
		<td> Rp. <?= number_format($subtotal) ?>,- </td>
	</tr>
	<?php  
		$no++;
		$total = $total += $subtotal;
		}
	?>
</table>

	<div align="right"> <font size="5" color="#321324"> Total : Rp. <?= number_format($total)?>,- </font> </div>
	<br>
<?php include 'common/footer.php'; ?>