<?php
	include 'koneksi.php';
	include 'common/header.php';
?>
	<h3> <span class="glyphicon glyphicon-credit-card"></span> Menu Pembayaran </h3>
	<br/> <hr/>
	
	<?php
		global $total;
		$member_id = $_GET['id_member'];
		$query = mysqli_query($koneksi, "SELECT menu.nama AS nama_menu, menu.harga, pemesanan.jumlah FROM menu 
		INNER JOIN (pemesanan INNER JOIN member ON member_id = id_member) ON menu_id= id_menu WHERE member_id= '$id_member'");
		while($row = mysqli_fetch_assoc($query)){
			$jumlah = $row['jumlah'] * $row['harga'];
			$total = $total += $jumlah;
		}
	?>
	
	<div class="col-md-12" align="center">
			<?php
				$kueri = mysqli_query($koneksi, "SELECT * FROM pembayaran WHERE member_id = '$member_id'");
				$row = mysqli_fetch_array($kueri);
				if($row['bukti'] == NULL){
			?>
		<h3> Terimakasih Telah Memesan. </h3>
		<div> Pesanan anda sebesar Rp. <?= $total?>,- <br> 
			Silahkan Kirim uang dengan nominal tertera ke No. Rekening 0413- XXX. <br>
		</div>
		<br> <br>
		<div>
			Setelah mengirim uang upload bukti pengiriman :<br>
			<form action="checkout.php?id_member=<?= $member_id?>" method="post" enctype="multipart/form-data">
				<input type="file" name="bukti">
				<input type="submit" class="btn btn-info" value="Upload">
			</form>
			<br> </div>
				<?php 
				}else{
					if($row['status'] == NULL){
						echo '<h3 style="color: #b30000"> Terimakasih telah membayar. </h3>';
						echo 'Silahkan tunggu konfirmasi pembayaran dari admin. <br>';
					}else{
						echo 'Pesanan anda telah dikonfirmasi. Terimakasih telah memesan. <br> <br>';
						echo "<a href='selesai.php?id=". $member_id ."' class='btn btn-success'> Selesai </a> <br>";
					}
				}
				?>
		<br>
	</div>

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