<?php
session_start();
include_once 'functions/fungsi.php';
include_once 'connection/koneksi.php';

?> 
<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>Cafe Bunga Toba</title>
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css" media="screen" type="text/css">
        <link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Playball' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

        <link rel="stylesheet" href="css/style-portfolio.css">
        <link rel="stylesheet" href="css/picto-foundry-food.css" />
        <link rel="stylesheet" href="css/jquery-ui.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="css/font-awesome.min.css" rel="stylesheet">
        <link rel="icon" href="favicon-1.ico" type="image/x-icon">
    </head>

    <body>

        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="row">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="index.php">Cafe BUNGA TOBA</a>
                    </div>

                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav main-nav  clear navbar-right ">
                            <li><a class="navactive color_animation" href="index.php">WELCOME</a></li>
                            <?php
                            if (isset($_SESSION['isLogin']) && (get_session('role') == "member")) {
                                echo('<li><a class="color_animation" href="profil.php">PROFIL</a></li>');
                                echo('<li><a class="color_animation" href="index.php #menu">MENU</a></li>');
                                echo('<li><a class="color_animation" href="pesanan.php">PESANAN</a></li>');
                                echo('<li><a class="color_animation" href="upload_bukti.php">PEMBAYARAN</a></li>');
                                echo('<li><a class="color_animation" href="logout.php">LOGOUT (' . get_session('first_name') . ')</a></li>');
                            }
                            if (isset($_SESSION['isLogin']) && (get_session('role') == "karyawan" || get_session('role') == "admin")) {
                                echo('<li><a class="color_animation" href="tambah_menu.php">OLAH MENU</a></li>');
                                echo('<li><a class="color_animation" href="daftar_pesanan.php">DAFTAR PESANAN</a></li>');
                                echo('<li><a class="color_animation" href="list_komentar.php">DAFTAR KOMENTAR</a></li>');
                                echo('<li><a class="color_animation" href="logout.php">LOGOUT (' . get_session('first_name') . ')</a></li>');
                            }
                            if (!isset($_SESSION['isLogin'])) {
                                echo('<li><a class="color_animation" href="profil.php">PROFIL</a></li>');
                                echo('<li><a class="color_animation" href="#menu">MENU</a></li>');
                                echo('<li><a class="color_animation" href="login.php">LOGIN</a></li>');
                                echo('<li><a class="color_animation" href="signup.php">SIGN UP</a></li>');
                            }
                            ?> 



                        </ul>
                    </div><!-- /.navbar-collapse -->
                </div>
            </div><!-- /.container-fluid -->
        </nav>

       <!-- ============ Pesanan  ============= -->

        <section  id="pesanan"  class="description_content">

            <div class="text-content container"> 
                <div class="inner contact row">
                    <div class="contact-form">
                        <a href = "bayar.php?id='.$row['id'] . "><button class="btn btn-success">Bayar</button></a><br><br>

                        <!-- Form -->
                        <table class="table table-bordered"> 
                            <thead> 
                                <tr> 
                                    <th>Menu</th> 
                                    <th>Jumlah</th> 
                                </tr> 
                            </thead> 
                            <tbody> 

                                <?php
                                $id = get_session('id');
                                $query = "SELECT menu.nama as nama, pesanan.jumlah as jumlah FROM pesanan INNER JOIN menu ON pesanan.id_menu = menu.id ";
                                $result_set = $database->query($query);

                                if ($result_set != NULL) {
                                    while ($row = $result_set->fetch_array()) {
                                        ?>
                                        <tr>
                                            <td><?= $row['nama'] ?></td>
                                            <td><?= $row['jumlah'] ?></td>
                                        </tr>
                                        <?php
                                    }
                                } else {
                                    echo 'ada belum memesan pesan sekarang juga<br><a href="menu.php">Pesan</a>';
                                }
                                ?>


                            </tbody> 
                        </table>

                    </div><!-- End Contact Form Area -->
                </div><!-- End Inner -->
            </div>
        </section>
        <br><br><br><br><br><br><br><br><br><br><br><br>

                    <!-- ============ Pembayaran  ============= -->

            <section  id="pembayaran"  class="description_content">

                <div class="text-content container"> 
                    <div class="inner contact row">
                        <div class="contact-form">
                            <!-- Form -->
                            <table class="table table-bordered"> 
                                <thead> 
                                    <tr> 
                                        <th>Total Biaya Pembayaran</th>
                                        <th>Status Pembayaran</th>
                                    </tr> 
                                </thead> 
                                <tbody> 

                                    <?php
                                    $id = get_session('id');
                                    $query = "SELECT * FROM pembayaran where id_user = $id ";
                                    $result_set = $database->query($query);

                                    if ($result_set != NULL) {
                                        while ($row = $result_set->fetch_array()) {
                                            ?>
                                            <tr>
                                                <td><?= $row['total'] ?></td>
                                                <?php
                                                if ($row['status'] == NULL) {
                                                    echo '<td><a href="upload_bukti.php?id=' . $row['id'] . '"><button class="btn btn-success">Upload Bukti</button></td></a>';
                                                } else {
                                                    echo ' <td>' . $row['status'] . '</td> ';
                                                }
                                                ?>
                                            </tr>
                                            <?php
                                        }
                                    } else {
                                        echo 'ada belum memesan pesan sekarang juga<br><a href="menu.php">Pesan</a>';
                                    }
                                    ?>


                                </tbody> 
                            </table>
                        </div><!-- End Contact Form Area -->
                    </div><!-- End Inner -->
                </div>
            </section>
            <br><br><br><br><br><br><br><br><br><br><br><br>
