<?php include "cn.php"; ?>
<?php $title = "New Booking"; ?>
<!DOCTYPE html>
<html lang="en">
<?php include "head-tag.php"; ?>

<body>
<div class="inner-wrapper">
<?php include "pre-loader.php"; ?>

<?php include "header.php"; ?>
<div class="page-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xl-3 col-lg-4 col-md-12 theiaStickySidebar">
                <aside class="sidebar sidebar-user">
                    <div class="card ctm-border-radius shadow-sm">
                        <div class="card-body py-4">
                            <div class="row">
                                <div class="col-md-12 mr-auto text-left">
                                        <div class="custom-search input-group">
                                            <div class="custom-breadcrumb">
                                                <ol class="breadcrumb no-bg-color d-inline-block p-0 m-0 mb-2">
                                                    <li class="breadcrumb-item d-inline-block"><a href="index.php" class="text-dark">Home</a></li>
                                                    <li class="breadcrumb-item d-inline-block active">Bookings</li>
                                                </ol>
                                                <h4 class="text-dark">New Booking</h4>
                                            </div>
                                        </div>
                                    </div>
                            </div>
                        </div>
                    </div>
                </aside>
            </div>
            <div class="col-xl-9 col-lg-8 col-md-12">
                <div class="card shadow-sm ctm-border-radius">
                    <div class="card-body">
                        <h4 class="card-title mb-0 mt-2">New Booking</h4>
                    </div>
                </div>
                
                <div class="ctm-border-radius shadow-sm card">
                    <div class="card-body">
                        <form method = "post" action="ajax/save-booking.php" class="form-group" enctype='multipart/form-data'>
                            <input type="hidden" name="user" value="<?php echo $_SESSION["userid"]; ?>"> 
                            <div class="row">
                                
                                <div class="col-md-6 col-sm-12 col-xs-12 form-group cardiv">
                                    <label><h5>Select Car<span style="color:red;">*</span>:</h5></label>
                                        <select class="form-control select" name="car" id="car" required>

                                            <option value="">-- Select car --</option>
                                            <?php
                                            $sql = mysqli_query(
                                                $connect,
                                                "select cars.* 
            								from cars"
                                            );
                                            while (
                                                $data_m = mysqli_fetch_assoc(
                                                    $sql
                                                )
                                            ) { ?>
            								
                    <option value="<?php echo $data_m['car_id']; ?>" <?php //echo $data_m['car_id'] == $where ? "selected" : ""; ?>>
                        <?php
                        echo $data_m["car_name"].' ('.$data_m["car_nameplate"].')'
                        // ." @ " .$data_m["ac_price"] ."/m ... " ." @ " .$data_m["ac_price_per_day"] ."/day"
                        ; ?>
                        </option>							
            								<?php }
                                            ?>
            	                    </select>
                                    </div>

             <!--                   <div class="col-md-6 col-sm-12 col-xs-12 form-group driverdiv">-->
             <!--                        <select class="form-control select" name="driver" id="driver">-->
             <!--                               <option value="">-- Select Driver --</option>-->
                                            
                                            <?php
//  $sql = mysqli_query($connect, "select driver.* from driver");
// while($data_m = mysqli_fetch_assoc($sql)){
?>
            	<!--<option value="<?php /*echo $data_m[
                 "driver_id"
             ]; ?>" <?php echo $data_m["driver_id"] == $where
    ? "selected"
    : ""; ?>><?php echo $data_m["driver_name"]; ?></option>							-->
            								<?php
// 	}*/
?>
             <!--                           </select>-->
             <!--                       </div>-->
		 <div class="col-md-6 col-sm-12 col-xs-12 form-group">	
		<h5> Voucher No.  &nbsp;
        <br>
            <input type="Text" class="form-control" name="VoucherNumber" id="VoucherNumber" value="" style="width:100%">
			</h5>
        </div>
            <!-- <div class="col-md-6 col-sm-12 col-xs-12 form-group"> -->
            <!-- <h5> Charge type:  &nbsp;</h5>-->
            <!--<input onclick="reveal()" type="radio" name="radio1" value="min" ng-model="myVar"><b> per Min</b> &nbsp;-->
            <!--<input onclick="reveal()" type="radio" name="radio1" value="days" ng-model="myVar"><b> per day</b>-->
            <!-- </div> -->
            
            
            <?php
            date_default_timezone_set("Asia/Dubai"); //  $today = date("Y-m-d H:i:s", strtotime('+5 hours')); //  $pick = date("Y-m-d H:i:s", strtotime('+4 hours')); //  $pick = date("Y-m-d H:i:s", strtotime('+4 hours 30 minutes'));
            //  $today = date("Y-m-d")
            $pick = date("Y-m-d H:i:s", strtotime("+30 minutes"));
            $pick = date("Y-m-d\TH:i", strtotime($pick)); //  $drop = date("Y-m-d H:i:s", strtotime('+5 hours'));
            $drop = date("Y-m-d H:i:s", strtotime("+1 hours 30 minutes"));
            $drop = date("Y-m-d\TH:i", strtotime($drop));

//  $today = now();
?>


         <div class="col-md-6 col-sm-12 col-xs-12 form-group">
          <label><h5>Start Date*:</h5></label>
            <input type="datetime-local" class="form-control" name="rent_start_date" min="<?php echo $pick; ?>" value="<?php echo $pick; ?>" required>
            
          </div>
         <!-- <div class="col-md-6 col-sm-12 col-xs-12 form-group">-->
         <!-- <label><h5>End Date*:</h5></label> &nbsp;-->
         <!-- <input type="datetime-local" class="form-control" name="rent_end_date" min="<?php echo $pick; ?>" value="<?php echo $drop; ?>" required>-->
         <!--</div>      -->
         <div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <h5> Pickup From<span style="color:red;">*</span>:  &nbsp;
        <br>
            <input type="Text" class="form-control" name="Pickup"  value="" style="width:100%" required>
			</h5>
		</div>
		 <div class="col-md-6 col-sm-12 col-xs-12 form-group">	
		<h5> Dropoff At:  &nbsp;
        <br>
            <input type="Text" class="form-control" name="Dropoff"  value="" style="width:100%">
			</h5>
        </div>
        
        
        
        <div class="col-md-6 col-sm-12 col-xs-12 form-group">
         <label><h5>Customer Email</label>
          <input type="email" name="email" id="customer_email" value="" placeholder="Customer Email" />
          <span id="message1"></span>
         <br>
        </div>
        <div class="col-md-6 col-sm-12 col-xs-12 form-group">
          <label><h5>Name of Customer<span style="color:red;">*</span>:</h5></label>
            <input type="text" name="name" id="name" value="" placeholder="Customer Name" required/>
        <br>
        </div>
       <div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <label><h5>Customer Phone:</h5></label>
          <input type="text"  name="phone" id="phone" value="" placeholder="Customer Phone"   />
          <br>
          </div>
        <div class="col-md-6 col-sm-12 col-xs-12 form-group" hidden="yes">  
        <label><h5>Customer Address:</h5></label>
          <input type="text" name="address" id="address" value="Not Available" placeholder="Customer Address"   />
        <br>
        </div>
       
        <div class="col-md-6 col-sm-12 col-xs-12 form-group">
         <label><h5>Company/Hotel:</h5></label>
            <input type="text" name="Hotel" value="" placeholder="Company/Hotel" />
        <br>
        </div>
        <div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <label><h5>Room no.:</h5></label>
            <input type="text" name="Room" value="" placeholder="Room no." />
        <br>
        </div>
        <div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <label><h5>Flight Detail:</h5></label>
            <input type="text" name="Flight" value="" placeholder="Flight Detail" />
        <br>
        </div>
         <div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <label><h5>Amount:</h5></label>
          <input type="text" name="Amount" value="0" placeholder="Charges per trip"  />
                  </div>
        <br>

        <br>
        
        <div class="col-12 form-row" >
            <div class="col-6 form-group">
        <select class="form-control custom-select" name="select_hotel"id="select_hotel" required>
        <option value="" disabled selected >-- Select Hotel --</option>
        <?php 
            $sql_hotels =  "SELECT * FROM users WHERE role = 'hotel' ";
            $query_hotels = mysqli_query($connect, $sql_hotels);
            while($row_hotel = mysqli_fetch_assoc($query_hotels)){?>
                <option value="<?php echo $row_hotel['FullName'] ?>" ><?php echo $row_hotel['FullName'] ?></option>
            <?php } ?>

        </select>
        </div>
        <div class="col-6 form-group">
        <select class="form-control custom-select" name="pay_option" id="pay_option" required>
        <option value="" disabled selected >-- Select Pay Option --</option>
        <option value="By Room">By Room</option>
        <option value="By Cash">By Cash</option>
        <option value="By Credit Card">By Credit Card</option>
        </select>
        </div>
        
         
        </div>
        <br><br>
                <div class="col-md-12 col-sm-12 col-xs-12 form-group">
        <label><h5>Comments.:</h5></label>
        <textarea input type="text" name="Comments" value="" placeholder="Comments">
        </textarea>
        <br><br>

        
        <br>
        </div>
        
        
        
        
        <div class="col-md-12 col-sm-12 col-xs-12 form-group">
                <button type="submit"  class="float-right dt-button ">Save Booking</button>
        </div>
<!--    <div class="col-md-6 col-sm-12 col-xs-12 form-group">-->
<!--   <div class="cal-icon">-->
<!--    <input class="form-control datetimepicker cal-icon-input"  name="reservation_date" type="text" -->
<!--    value="" placeholder="Booking Date"/>-->
<!--</div>-->
<!--</div>-->

<!--<div class="col-md-6 col-sm-12 col-xs-12 form-group">-->
<!--    <input type="number" class="form-control" placeholder="Booking Days" min='1' name="days" id="days" required/>-->
<!--</div>-->

<!-- <div class="col-md-6 col-sm-12 col-xs-12 form-group apply1">-->
<!--    <button type="button" class="btn btn-theme button-1 text-white ctm-border-radius btn-block apply">Apply Rates</button>-->
<!--</div>-->

<!--<div class="col-md-12 col-sm-12 col-xs-12 form-group" >-->
<!--    <input type="text" class="form-control" placeholder="Booking Charges" name="amount" id="amount" readonly />-->
<!--</div>-->

<!--<div class="col-md-12 col-sm-12 col-xs-12 form-group">-->
<!--    <textarea  class="form-control" placeholder="Write any note here..." name="notes"></textarea>-->
<!--</div>-->
                                
                                
                                
                            </div>
                            
                            </form>
                    </div>
                </div>
            </div>
            
        </div>
    </div>
</div>


</div>
<div class="sidebar-overlay" id="sidebar_overlay"></div>

<?php include "scripts.php"; ?>
</body>
<script>
//     $(document).ready(function() {
//         $(".apply1").hide();
//         $(".proceed").hide();
//         $("#car").on("change",function(){
//             var car = $("#car").val();
//             getRoutes(car);
//         });
//         $("body").on("change","#source,#destination,#days", function(){
//             var source = parseFloat($("#source").val());
//             var destination = parseFloat($("#destination").val());
//             var days = parseFloat($("#days").val());
//             if(!Number.isNaN(source) && !Number.isNaN(destination) && !Number.isNaN(days)){
//                  $(".apply1").show();
//             }else{
//                 $(".apply1").hide();
//             }
//         });
//         function getRoutes(id){
                  
//                   $.ajax({
//         			url: 'ajax/get-route.php',
//         			type: 'POST',
//         			beforeSend: function() {
//         			    $("body").find("#pickup").remove();
//         			    $("body").find("#dropoff").remove();
//         				swal.fire({
//         					title: 'Please Wait...',
//         					allowOutsideClick: false
//         				});
//         				swal.showLoading();
//         			},
//         			data: {
//         				car: id
//         			},
//         			success: function(data) {
//         			    $(".cardiv").after(data);
//         			    swal.close();
        								
//         			}
// 		        });
//               }
//           $(".apply1").on("click",function(){
             
//               getRate();
//           });
          
//         function getRate(){
//              var car = $("#car").val();  
//              var  days = parseInt($("#days").val());
//           $.ajax({
// 			url: 'ajax/get-rate.php',
// 			type: 'POST',
// 			beforeSend: function() {
// 				swal.fire({
//         					title: 'Please Wait...',
//         					allowOutsideClick: false
//         				});
//         				swal.showLoading();
// 			},
// 			data: {
// 				car: car,
// 				pickup: $("#source").val(),
// 				destination: $("#destination").val()
// 			},
// 			success: function(data) {
// 			    var total = days * data;
// 				$("#amount").val(total);
// 				swal.close();
// 				if(total==0){
//         				    $(".proceed").hide();
//         				}else{
//         				    $(".proceed").show();
//         				}
// 			}
//         });
//       }
//     });
</script>
</html>