<?php
session_start();
include "includes/database.php";

$username=$_SESSION["username"];
$dataPengguna=mysqli_query($con,"SELECT * from tbl_shop where shop_id='$username'");
$showDataPengguna=mysqli_fetch_array($dataPengguna);

$a=$_GET["id"];
$cari=mysqli_query($con, "select * from tbl_booking where booking_id='$a'");
$tunjuk=mysqli_fetch_array ($cari);

?>

<!DOCTYPE html>
<html lang="en">


  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>FIX-IT-ALL</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/heroic-features.css" rel="stylesheet">

  </head>

  <body>
<section class="content-header">

<div class="register-box-body">
                        <?php
            
            if (!(isset($_POST ["user_id"])))
            {
              ?>
                            
                        <form role="form" method="post" enctype="multipart/form-data">
                        
                            <fieldset>
                            
                            <div class="form-group">
                            <label>Name</label>
                                    <input class="form-control" name="user_id" type="text" value="<?php echo $tunjuk['user_id'];?>" required autocomplete"off"  readonly>
                                </div>

                            <div class="form-group">
                            <label>Booking Date</label>
                                    <input class="form-control" name="booking_date" type="text" value="<?php echo $tunjuk['booking_date'];?>" required autocomplete"off" readonly>
                                </div>
                                      

                            <div class="form-group">
                            <label>Booking Time</label>
                                    <input class="form-control" name="booking_time" type="text" value="<?php echo $tunjuk['booking_time'];?>" required autocomplete"off" readonly>
                                </div> 

                                <input type="hidden" name="booking_id" value="<?php echo $tunjuk['booking_id'];?>">

                                <label>Status</label>
                            <select class="form-control" name="booking_status" value="<?php echo $tunjuk['booking_status'];?>" >
                            <option value="APPROVED">APPROVED</option>
                            <option value="REJECT">REJECT</option>

                            </select>




                                <input type="submit" class="btn btn-lg btn-success btn-block" value="Update">
                                <a href="bookingstatus.php" class="btn btn-lg btn-danger btn-block">Cancel</a>
                                
                            </fieldset>
                        </form>
                        
                       <?php
            }
            else
            {
              
              //get data from input
              $user_id=$_POST["user_id"];
              $booking_date=$_POST["booking_date"];
              $booking_time=$_POST["booking_time"];
              $booking_status=$_POST["booking_status"];
              $booking_id=$_POST["booking_id"];


mysqli_query($con,"UPDATE tbl_booking set user_id='$user_id',booking_date='$booking_date',booking_time='$booking_time',booking_status='$booking_status' where booking_id='$booking_id'")or die (mysqli_error($con));               
                
                
                
                ?>
                
                <div class="alert alert-success">
                              Status Updated. <a href="bookingstatus.php" class="alert-link">Click here</a> to get back.
                            </div>
            <?php
              }
              ?>




</div></section>
   
    <br>
    <br>
    
    <!-- Footer -->
    <footer class="py-4 bg-dark">
      <div class="container">
        <p class="m-0 text-center text-white">Copyright &copy;Fix-It-All 2018</p>
      </div>
      <!-- /.container -->
    </footer>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  </body>

</html>

