<?php
session_start();
include 'include/config.php';

if(!isset($_SESSION['id'])){
 echo "<script> window.location.href = 'index.php' </script>";
  }
?>

<?php
$select_spa = mysqli_query($conn,"select * from `vender`");
?>

<?php  include 'include/head.php'; ?>

<div class="container-fluid">
                        
                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box">
                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="">Home</a></li>
                                            <li class="breadcrumb-item active">Booking status</li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title">Booking Status</h4>
                                </div>
                            </div>
                        </div>
                        <!-- end page title --> 
                        
                        
                        <div class="row">
        <div class="card">
            <div class="card-body">
                <!-- Form start -->
                <form method="post" action="">
                    <!-- Dropdown and Input field -->
                    <div class="row">
                        <div class="col-lg-4">
                            <div class="form-group">
                                <label for="exampleFormControlSelect1">Select Spa</label>
                                <select name="spa" class="form-control" id="exampleFormControlSelect1">
                                    <option>Select..</option>
                                    <?php while($data = mysqli_fetch_assoc($select_spa)){?>
                                    <option value="<?php echo $data['unique_id'];?>"><?php echo $data['unique_id'] . ' = ' .$data['name'];?></option>
                                    <?php }?>
                                    
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-4">
                           <div class="form-group">
                               <label for="schedule">Boking ID</label>
                               <input type="text" name="booking_id" class="form-control" id="schedule">
                           </div>
                       </div>
                       
                       <!--<div class="col-lg-4">-->
                       <!--    <div class="form-group">-->
                       <!--        <label for="schedule">From Date</label>-->
                       <!--        <input type="date" name="from_date" class="form-control" id="schedule">-->
                       <!--    </div>-->
                       <!--</div>-->
                        <div class="col-lg-4" style="margin-top:20px;">
                         <button type="submit" name="submittt" class="btn btn-primary">Submit</button>
                         </div>
                    </div>
                    <!-- End of Dropdown and Input field -->
                    <!-- Submit button -->
                   
                </form>
                
                <?php 
                 if(isset($_POST['submittt'])){
                    $spa_id = $_POST['spa'];
                    $booking_id = $_POST['booking_id'];
                   
                   $selllll = mysqli_query($conn,"select * from `booking` where `vender_id`='$spa_id' AND `unique_id`='$booking_id'");
                 }
                ?>
                <!-- Form end -->
            </div>
        </div>
</div>

                          <!--<div>-->
                          <!--    <a href="service_cat.php"  class="btn btn-success"> Add Category</a>-->
                          <!--</div>-->

                        <div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
        <div class="table-responsive">
            <!-- Booking data table here -->
            <table id="datatable" class="table table-striped dt-responsive nowrap w-100">
                <!-- Table headings -->
                <thead>
                    <tr>
                        <th>Sr. No.</th>
                        <th>User Name</th>
                        <th>Phone No</th>
                        <th>Email</th>
                        <th>Booking Date</th>
                        <th>Booking Time</th>
                         <th>Booking Status</th>
                        <th>Spa Name</th>
                       
                        <th>Employee Name</th>
                        <th>Employee Charges</th>
                        
                        <th>Employee Profile</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
                    $i=1;
                   while($data = mysqli_fetch_assoc($selllll)){?>
                   
                    <!-- Row for each booking data -->
                    <tr>
                        <td><?= $i; ?></td>
                        <td><?= $data['user_name']; ?></td>
                        <td><?= $data['user_phone']; ?></td>
                        <td><?= $data['user_email']; ?></td>
                        <td><?= $data['booking_date']; ?></td>
                        <td><?= $data['booking_time']; ?></td>
                        <td><?= $data['booking_status']; ?></td>
                        <?php $select_spaaa = mysqli_fetch_assoc(mysqli_query($conn,"select * from `vender` where `unique_id`='{$data['vender_id']}'"));?>
                        <td><?= $select_spaaa['name']; ?></td>
                        
                        <td><?= $data['employee_name']; ?></td>
                        <td><?= $data['employee_chargs']; ?></td>
                        
                        <td>
                           
                            <?php  
                    $fullImagePath = $data['employee_profile'];

                    $prefixToRemove = 'upload/image/';

                    $imageFilename = str_replace($prefixToRemove, '', $fullImagePath);
                    ?>
                    <td><img src="<?= '../upload/image/' . $imageFilename; ?>" style="width:100px; height:60px;"></td>
                        </td>
                       
                    </tr>
                </tbody>
            </table>
        </div>
    
    <?php 
    $i++;
    }; ?>
</div>
        </div>
    </div>
</div>

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