cart.php 2.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
	include 'koneksi.php';
	include 'common/header.php';
?>

<h2> <span class="glyphicon glyphicon-shopping-cart"></span>Cart </h2>
<br/> <hr/>

<div class="col-md-12" align="center">
<table class="table table-hover table-condensed">
<tr>
	<th> No </th>
	<th> Nama </th>
14
	<th> Harga Satuan </th>
15 16 17 18 19 20
	<th> Jumlah </th>
	<th> Subtotal </th>
	<th> Opsi</th>
</tr>

<?php
Mei Romauli Sagala committed
21
	$id_member = $_GET['id_member'];
Roy Junedi Simamora committed
22
	$query = mysqli_query($koneksi, "SELECT menu.nama AS nama_menu, menu.harga, pemesanan.id_pemesanan ,pemesanan.jumlah FROM menu 
23 24 25 26 27 28 29 30 31
	INNER JOIN (pemesanan INNER JOIN member ON member_id = id_member) ON menu_id= id_menu WHERE member_id= '$id_member'");
	$no = 1;
	
	while($row = mysqli_fetch_assoc($query)){
		$subtotal = $row['jumlah'] * $row['harga'];
?>
	<tr>
		<td> <?= $no?> </td>
		<td> <?php echo $row['nama_menu'] ?> </td>
32
		<td> Rp. <?= number_format($row['harga'])?>,- </td>
33
		<td> <?= $row['jumlah']?> </td>
Roy Junedi Simamora committed
34
		<td> Rp. <?= number_format($subtotal)?>,- </td>
Roy Junedi Simamora committed
35
		<td> <a onclick="if(confirm('Apakah anda yakin ingin membatalkan pesanan ini?')){
Roy Junedi Simamora committed
36
			location.href='batal.php?id=<?= $row['id_pemesanan'] ?>&id_member=<?= $id_member?>';
Roy Junedi Simamora committed
37
		}" class="btn btn-danger"> <span class="glyphicon glyphicon-remove"></span> Batalkan </a> </td>
38 39 40
	</tr>
	
	<?php
41 42 43
		global $total;
		$total = $total += $subtotal;	
		$no++;
44 45 46 47
	}
	?>
</table>
	<div align="right">
48 49 50 51 52 53
		<font face="arial" size="5"> Total : Rp. <?php  if(mysqli_num_rows($query)){
			echo number_format($total);
			}else{
				echo '0';
			}
			?>,- </font>
54 55 56
	</div>
	
	<div align="center">
Roy Junedi Simamora committed
57 58 59 60 61 62 63 64 65 66
		<?php
		if(!mysqli_num_rows($query)){
			echo '<br><br> <h2> Cart anda masih kosong! </h2><h3> Silahkan pesan terlebih dahulu. </h3>';
			echo '<a href="member_menu.php" class="btn btn-info"><span class="glyphicon glyphicon-chevron-left"></span> Pesan</a> ';
		}
		else{
			echo '<a href="member_menu.php" class="btn btn-info"><span class="glyphicon glyphicon-chevron-left"></span> Pesan Lagi</a> ';
			echo '<a href="bayar.php?id_member=<?= $id_member ?>" class="btn btn-success"> Checkout<span class="glyphicon glyphicon-chevron-right"></span> </a>';
		}
		?>
67 68 69 70 71 72 73
	</div>
<br>
</div>

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