<?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">
                   
                    <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="#">Cafe Bunga Toba</a>
                    </div>

                    <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="#top">WELCOME</a></li>
                            <?php
                            if (isset($_SESSION['isLogin']) && (get_session('role') == "member")) {
                                echo('<li><a class="color_animation" href="#pricing">MENU</a></li>');
                                echo('<li><a class="color_animation" href="#pesanan">PESANAN</a></li>');
                                echo('<li><a class="color_animation" href="#pembayaran">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="#olahmenu">OLAH MENU</a></li>');
                                echo('<li><a class="color_animation" href="#pricing">DAFTAR PESANAN</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="#pricing">MENU</a></li>');
                                echo('<li><a class="color_animation" href="#login">LOGIN</a></li>');
                                echo('<li><a class="color_animation" href="#signup">SIGN UP</a></li>');
                            }
                            ?> 



                        </ul>
                    </div>
                </div>
            </div>
        </nav>

        <div id="top" class="starter_container bg">
            <div class="follow_container">
                <div class="col-md-6 col-md-offset-3">
                    <h2 class="top-title"> Cafe Bunga Toba</h2>
                    <h2 class="white second-title">" Best in the Balige "</h2>
                    <hr>
                </div>
            </div>
        </div>
      

        <section id ="pricing" class="description_content">
            <div class="pricing background_content">
                <h1>Daftar Menu</h1>
            </div>
            <div class="text-content container"> 
                <div class="container">
                    <div class="row">
                        <div id="w">
                            <ul>

                                <div class="col-lg-12">
                                    <?php
                                    $query = "SELECT * FROM menu";
                                    $result_set = $database->query($query);

                                    while ($row = $result_set->fetch_assoc()) {
                                        ?>
                                        <div class="col-lg-3">

                                            <li class="item breakfast">
                                                <img src="foto/<?= $row['gambar'] ?>" class="img-responsive">
                                                <h2 class="white">Rp. <?php echo $row['harga']; ?></h2>
                                                <a href="pesan_barang.php?id=<?= $row['id'] ?>">
                                                    <button class="text-center btn-block form-btn">Pesan</button>
                                                </a>

                                            </li>
                                        </div>
                                    <?php }
                                    ?> 

                                </div>
                            </ul>






                        </div>
                    </div>
                </div>
            </div>  
        </section>
        <br><br><br><br><br><br><br><br><br><br><br><br>



        <?php if (!isset($_SESSION['isLogin'])) { ?>

            <!-- ============ Signup  ============= -->

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

                <div class="text-content container"> 
                    <div class="inner contact">
                        <!-- Form Area -->
                        <div class="contact-form">
                            <!-- Form -->
                            <form id="contact-us" method="post" action="register.php">
                                <!-- Left Inputs -->
                                <div class="container">
                                    <div class="row">
                                        <div class="col-lg-8 col-md-6 col-xs-12">
                                            <div class="row">
                                                <div class="col-lg-8 col-md-6 col-xs-6">
                                                    <!-- Name -->
                                                    <input type="text" name="first_name" id="first_name" required="required" class="form" placeholder="First Name" />
                                                    <input type="text" name="last_name" id="last_name" required="required" class="form" placeholder="Last Name" />
                                                    <input type="email" name="email" id="email" required="required" class="form" placeholder="Email" />
                                                    <input type="text" name="username" id="username" required="required" class="form" placeholder="Username" />
                                                    <input type="password" name="password" id="password" required="required" class="form" placeholder="Password" />
                                                </div>

                                                <div class="col-xs-6 ">
                                                    <!-- Send Button -->
                                                    <button type="submit" id="submit" name="submit" class="text-center form-btn form-btn">Register</button> 
                                                </div>

                                            </div>
                                        </div>

                                    </div>
                                </div>
                
                                <div class="clear"></div>
                            </form>
                        </div><!-- End Contact Form Area -->
                    </div>
                </div>
            </section>

            <!-- ============ Login  ============= -->

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

                <div class="text-content container"> 
                    <div class="inner contact">
                        <!-- Form Area -->
                        <div class="contact-form">
                            <!-- Form -->
                            <form id="contact-us" method="post" action="login_process.php">
                                <!-- Left Inputs -->
                                <div class="container">
                                    <div class="row">
                                        <div class="col-lg-8 col-md-6 col-xs-12">
                                            <div class="row">
                                                <div class="col-lg-8 col-md-6 col-xs-6">
                                                    <!-- Name -->
                                                    <input type="text" name="username" id="username" required="required" class="form" placeholder="Username" />
                                                    <input type="password" name="password" id="password" required="required" class="form" placeholder="Password" />
                                                </div>

                                                <div class="col-xs-6 ">
                                                    <!-- Send Button -->
                                                    <button type="submit" id="submit" name="submit" class="text-center form-btn form-btn">Login</button> 
                                                </div>

                                            </div>
                                        </div>

                                    </div>
                                </div>
                                
                                <div class="clear"></div>
                            </form>
                        </div><!-- End Contact Form Area -->
                    </div><!-- End Inner -->
                </div>
            </section>
            <br><br><br><br><br><br><br><br><br><br><br><br>


        <?php } else {
            ?>

            <?php if (get_session('role') == "karyawan") { ?>


                <!-- ============ Olah Menu  ============= -->

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

                    <div class="text-content container"> 
                        <div class="inner contact row">
                            <div class="contact-form">

                                <!-- Form -->
                                <table class="table table-bordered">
                                    <a class="color_animation" href="#tambahmenu"><button type="button" class="btn btn-success">Tambah Menu</button></a>


                                    <br>
                                    <br>
                                    <thead> 
                                        <tr> 
                                            <th>Nama Menu</th> 
                                            <th>Olah</th> 
                                        </tr> 
                                    </thead> 
                                    <tbody> 
                                        <?php
                                        $id = get_session('id');
                                        $query = "SELECT * FROM menu ";
                                        $result_set = $database->query($query);
                                        if ($result_set != NULL) {

                                            while ($row = $result_set->fetch_array()) {
                                                ?>
                                                <tr>
                                                    <td><?= $row['nama'] ?></td>
                                                    <td>

                                                        <a  href="update_menu.php?id=<?= $row['id'] ?>"><button type="button" class="btn btn-success">Update</button></a>
                                                        <a  href="delete_menu.php?id=<?= $row['id'] ?>"><button type="button" class="btn btn-danger">Delete</button></a>
                                                    </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>

                <!-- ============ Tambah Menu  ============= -->

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

                    <div class="text-content container"> 
                        <div class="inner contact">
                            <!-- Form Area -->
                            <div class="contact-form">
                                <form id="contact-us" method="post" action="tambah_menu.php" enctype="multipart/form-data">
                                    <!-- Left Inputs -->
                                    <div class="container">
                                        <div class="row">
                                            <div class="col-lg-8 col-md-6 col-xs-12">
                                                <div class="row">
                                                    <div class="col-lg-8 col-md-6 col-xs-6">
                                                        <!-- Name -->
                                                        <input type="text" name="nama" id="first_name" required="required" class="form" placeholder="Nama Menu" />
                                                        <input type="text" name="harga" id="last_name" required="required" class="form" placeholder="Harga" />
                                                        <textarea name="deskripsi" id="message" class="form textarea"  placeholder="Deskripsi"></textarea>
                                                        <input type="file" name="uploaded_file" id="username" required="required" class="form" placeholder="Username" />


                                                    </div>

                                                    <div class="col-xs-6 ">
                                                        <!-- Send Button -->
                                                        <button type="submit" id="submit" name="submit" class="text-center form-btn form-btn">Tambah</button> 
                                                    </div>

                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                    <!-- Clear -->
                                    <div class="clear"></div>
                                </form>
                            </div><!-- End Contact Form Area -->
                        </div><!-- End Inner -->
                    </div>
                </section>

            <?php } ?>          

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

            <section  id="pesanan"  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>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>
                            <a href = "bayar.php"><button class="btn btn-success">Bayar</button></a>

                        </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><button class="btn btn-success">Upload Bukti</button></td>';
                                                } 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>



        <?php }
        ?>


        <!-- ============ Footer Section  ============= -->
        <br>
        <footer class="sub_footer">
            <div class="container">
                <div class="col-md-4"><p class="sub-footer-text text-center">&copy; Cafe Bunga Toba, Design by <a href="#">PA1-1617-D3TI05</a></p></div>
                <div class="col-md-4"><p class="sub-footer-text text-center">Back to <a href="#top">TOP</a></p></div>
            </div>
        </footer>


        <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="js/bootstrap.min.js" ></script>
        <script type="text/javascript" src="js/jquery-1.10.2.js"></script>     
        <script type="text/javascript" src="js/jquery.mixitup.min.js" ></script>
        <script type="text/javascript" src="js/main.js" ></script>

    </body>
</html>