<?php include("cn.php");?>
<?php $title = "Book Now";?>
<!DOCTYPE html>
<html lang="en">

<?php include("head-tag.php");?>
<?php 
       $sql_1 = mysqli_query($connect,"select * from app_users where
        Id = '".$_SESSION["userid"]."' ");
        $data_1 = mysqli_fetch_assoc($sql_1);
?>
 <?php if(isset($data_1["GuestId"])){
    // header("Location:index.php");
} ?>


<body>
    
<?php include("header.php");?>

<div class="inner-wrapper">

<?php //include("pre-loader.php");?>

<?php 

if (isset($_POST['id']))
{
    $_SESSION['carid']=$_POST['id'];
}
?>
 <div class="page-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xl-3 col-lg-3 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">Booking </li>
                                            </ol>
                                            <h4 class="text-dark">Booking</h4>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                   
                </aside>
            </div>
     <div class="col-xl-9 col-lg-9 col-md-9 ctm-border-radius shadow-sm card"style="float: none; margin: 2 auto; padding: 10;">
<div style="float: none; margin: 2 auto; padding: 10;">

<?php 

if($_SESSION['guestid']>0)
    $sql = 'SELECT * FROM rentedcars WHERE guest_id='.$data_1['GuestId'].' AND PaymentStatus=\'Un-paid\' ORDER BY rentedcars.id DESC';
else

    $sql = 'SELECT * FROM rentedcars WHERE AppUser='.$data_1['Id'].' AND PaymentStatus=\'Un-paid\' ORDER BY rentedcars.id DESC';

    $sql = mysqli_query($connect,$sql);
    $row = mysqli_num_rows($sql);
    if($row>0)
    {
        $sql = mysqli_fetch_assoc($sql);
        include("pre-loader.php");
        include("scripts.php");
        die ('
        <div class="card-body">
        <center>
            You have already <br/>an <h1>Un-Paid</h1> <br/>Booking Number: <h1>'.$sql['BookingNumber'].' <br/>In-Progress.</h1>
            <br/><h2>You can make a new booking only after it\'s Completion</h2>
            <br/><a href="bookingdetail.php?id='.$sql['BookingNumber'].'">Click Here to View Details</a>
        </center>
        </div>
        ');
    }
    else
    {
        include("pre-loader.php");
    }


?>    
   <!--<form id="booking" role="form" action="bookingconfirm.php" method="POST">-->
   <form id="booking" role="form" action="<?php if($_SESSION['guestid']>0) echo 'bookingconfirmdriver.php'; else echo 'bookingconfirm.php';?>" method="POST">
        <br style="clear: both">
          <br/>

<?php

// echo $verify;
$car_id = $_GET["id"];
$sql1 = "SELECT * FROM cars WHERE car_id = '$car_id'";
$result1 = mysqli_query($connect, $sql1);
$url="../admin/";

if(mysqli_num_rows($result1)){
    while($row1 = mysqli_fetch_assoc($result1)){
        $car_name = $row1["car_name"];
        $car_nameplate = $row1["car_nameplate"];
        $car_model = $row1["model"];
        $ac_price = $row1["ac_price"];
        $non_ac_price = $row1["non_ac_price"];
        $ac_price_per_day = $row1["ac_price_per_day"];
        $non_ac_price_per_day = $row1["non_ac_price_per_day"];
		$carimg= $url.$row1["car_img"];
    }
}

?>

<table>
<tr>
<td>
<img src="<?php echo($carimg);?>" widht="100" height="100">
</td>

<td>
          <!-- <div class="form-group"> -->
              <h5> Car:&nbsp;  <b><?php echo($car_name);?></b></h5>
         <!-- </div> -->
         
          <!-- <div class="form-group"> -->
            <h5> Number Plate:&nbsp;<b> <?php echo($car_nameplate);?></b></h5>
          <!-- </div>      -->
          <!-- <div class="form-group"> -->
            <h5> Model:&nbsp;<b> <?php echo($car_model);?></b></h5>
          <!-- </div>      -->
	</td>

</tr>
</table>	

<!-- Face Starts-->
		  
<!--<div ng-switch="myVar"> 
        <div ng-switch-default>
                    <div class="form-group">
                    <h5>Fare: </h5> 
                        </div>
                     </div>
        <div ng-switch-when="ac">
                <div class="form-group">
                 <h5>Fare: <b><?php echo("AED. " . $ac_price . "/Min and AED. " . $ac_price_per_day . "/day");?></b></h5> 
                <input type="hidden" name="permin" id="permin" value="<?php echo $ac_price; ?>">
                <input type="hidden" name="permin" id="perday" value="<?php echo $ac_price_per_day; ?>">
                <h5><STRONG><?php 
                // $minutes = round(abs($pick - $drop) / 60,2);
                // echo("AED. " . $minutes*$ac_price);
                ?></STRONG></h5>    
                 </div>  
        </div>
        <div ng-switch-when="non_ac">
                      <div class="form-group">
                        <h5>Fare: <b><?php echo("AED. " . $non_ac_price . "/Min and AED. " . $non_ac_price_per_day . "/day");?></b></h5>  
                      </div> 
        </div>
        <h5>Fare: <b><?php echo("AED. " . $ac_price . "/Min and AED. " . $ac_price_per_day . "/day");?></b></h5>    

</div>  
-->        

</div>
<br>	  
<!-- Face Ends-->
		  
<!-- <div class="form-group"> -->
<div class="row">
    <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" name="Pickup"  value="" required="yes" 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" name="Dropoff"  value="" style="width:100%">
		</h5>
	</div>

       <?php
        
        date_default_timezone_set('Asia/Dubai');
        //  $today = date("Y-m-d")
        //  $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'));
            // $pick = date("Y-m-d H:i:s", strtotime('+30 minutes'));
        $pick=  date("Y-m-d\TH:i");

        //  $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 H:i:s", strtotime('+1 hours'));
        
         $drop=  date("Y-m-d\TH:i", strtotime($drop));
        //  $today = now();
        if($_SESSION['guestid']>0)
        {
         echo '
         <div class="col-md-6 col-sm-12 col-xs-12 form-group">
         <label><h5>Customer Email:</h5></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"  />
        <br>
        </div>
        <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>
        </div>
        
        
        ';
        }
          ?>
          <br>
          
        <!-- </div>      -->
        
		<?php if(!$_SESSION['guestid']>0)
		{ ?>
		<div class="col-md-6 col-sm-12 col-xs-12 form-group">
		<label><h5>Start Date*:</h5></label>
            <input type="datetime-local" name="rent_start_date" min="<?php echo($pick);?>" value="<?php echo ($pick);?>" required/>
          <br/>
          </div>
          <div class="col-md-6 col-sm-12 col-xs-12 form-group">
		<label><h5>End Date*:</h5></label>
          <input type="datetime-local" name="rent_end_date" min="<?php echo($pick);?>" value="<?php echo($drop);?>" required/>
          </div>
		<?php
		echo '
		<div class="col-md-6 col-sm-12 col-xs-12 form-group">
        <h5> Charge type*:
            <input onclick="reveal()" type="radio" name="radio1" value="min" ng-model="myVar" selected required><b> per Min</b> &nbsp;
            <input onclick="reveal()" type="radio" name="radio1" value="days" ng-model="myVar"><b> per day</b>
        </h5>
        </div>';
        
		}
        ?>
        </div>
                   
        <div ng-switch="myVar1">
                <input type="hidden" name="hidden_carid" value="<?php echo $car_id; ?>">
                <div class="col-md-12" style="float: none; margin: 0 auto; text-align: center;">
                </div>
        </div>
		

		<!--<h6><strong>Note:</strong> You will be charged with extra <span class="text-danger">AED. 500</span> for each day after the due date ends.</h6>-->
		<br>
           <input type="submit" name="submit" value="Book Now" style="float: right;" class="btn btn-theme text-white ctm-border-radius btn-block"/>
         <br><br><br>  
        </form>
        
      
</div>
</div>
        </div>
    </div>
</div>


<?php include("scripts.php");?>
    
<div class="sidebar-overlay" id="sidebar_overlay"></div>
</div>
</body>
</html>