<!DOCTYPE html>
<html lang="en">
  <?php include "head.php";
  
  include "dbconfig.php";
  ?>
  <?php

$booking_id=$_GET['booking_id'];
/*
$sql="SELECT bookings.days AS days,bookings.start_date AS start_date,bookings.end_date AS end_date,bookings.pickup_date,bookings.id AS booking_id,bookings.rate AS rate,bookings.supp_cost AS supp_cost,bookings.comments, bookings.parking,bookings.driver_id, bookings.drop_address,bookings.drop_post_code,bookings.pickup_address,bookings.pickup_post_code,bookings. bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,bookings.job_status,bookings.passengers, customers.id AS customer_id, customers.name AS customer_name,customers.address1,customers.post_code,customers.city, customers.phone as customer_phone, payment_type.name AS payment_type,  company_contact.name as company_contact,company_contact.email,company_contact.mobile as passenger_phone,company_contact.id as passenger_id, 
vehicle_make.make as make,vehicle_make.id as make_id
FROM bookings LEFT JOIN customers ON bookings.customer_id = customers.id 
LEFT JOIN vehicle_make on bookings.vehicle_id=vehicle_make.id
LEFT JOIN payment_type ON bookings.payment_type = payment_type.id  LEFT JOIN company_contact ON bookings.passenger_id = company_contact.id WHERE bookings.id=".$booking_id." ORDER BY bookings.id DESC";
*/
$sql="SELECT bookings.days AS days,bookings.start_date AS start_date,bookings.end_date AS end_date,bookings.flight_no,bookings.pickup_date,bookings.id AS booking_id,bookings.rate AS rate,bookings.supp_cost AS supp_cost,bookings.comments, bookings.parking,bookings.driver_id, bookings.drop_address,bookings.drop_post_code,bookings.pickup_address,bookings.pickup_post_code, bookings.passengers,bookings.bags,bookings.client_reference,bookings.job_type,bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,bookings.job_status,bookings.passengers, customers.id AS customer_id, customers.name AS customer_name,customers.address1,customers.post_code,customers.city, customers.phone as customer_phone, payment_type.name AS payment_type,  company_contact.name as company_contact,company_contact.email,company_contact.mobile as passenger_phone,company_contact.id as passenger_id, 
vehicle_make.make as make,vehicle_make.id as make_id
FROM bookings LEFT JOIN customers ON bookings.customer_id = customers.id 
LEFT JOIN vehicle_make on bookings.vehicle_id=vehicle_make.id
LEFT JOIN payment_type ON bookings.payment_type = payment_type.id  LEFT JOIN company_contact ON bookings.passenger_id = company_contact.id WHERE bookings.id=".$booking_id." ORDER BY bookings.id DESC";

//echo $sql;
$res=$con->query($sql);

$booking_data= mysqli_fetch_assoc($res);
  ?>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    

   <body>

  <div class="container-fluid">
  <div class="col-md-3"></div>
    <div class="panel col-md-6" style="background-color: #e9e9e9;box-shadow: 5px 5px 5px;">
                    
                     <div class="panel-body">
                    
                  
                     <form method="post" name="new_booking_form" id="new_booking_form">
                     
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        
                          <h2>Update Booking</h2>
                           <!--div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"-->
                            <input id="booking_id" name="booking_id" type="hidden" value="<?php echo $booking_data['booking_id'];?>">
							
							
                             <div class="form-group col-md-6">
							  <!--div class="form-group">
                                 <label for="ad">AD &nbsp; </label>
								 <input type="radio" name="ad_invoice" id="ad" value="0" <?php // if($booking_data['ad_invoice']=='0'){ echo 'checked="checked"'; } ?>  >
							 </div-->
                                 <label for="first_name">Company Name</label>
                                 <input type="text" id="company_name" name="company_name" value="<?php echo $booking_data['customer_name'];?>" placeholder="Enter Full Name" class="form-control"  tabindex="1" autocomplete="off">
                                   <input type="hidden" name="old_customer_id" id="old_customer_id" value="<?php echo $booking_data['customer_id'];?>"/>
									<div id="suggesstion-box"></div>
                              </div>
							  
                            <div class="form-group col-md-6">
							<!--div class="form-group">	 
								 <label for="non_ad">Non-AD &nbsp; </label>
								 <input type="radio" name="ad_invoice" id="non_ad" value="1" <?php // if($booking_data['ad_invoice']=='1'){ echo 'checked="checked"'; }?>>
							</div-->	
                                 <label for="client_reference">Client Reference</label>
                                 <input type="text" id="client_reference" name="client_reference" value="<?php echo $booking_data['client_reference'];?>" placeholder="Client Reference" class="form-control radius" tabindex="1" />
                              </div>
                             </legend>
                           <!--/div-->
                           
                        </div>
                        <div class="col-md-12">
                        
                           <h2>Passenger Details</h2>
                      
                              <div class="form-group col-md-4">
                                 <label for="pco_number">Passenger Name</label>
                                <input type="text" value="<?php echo $booking_data['company_contact'];?>" placeholder="Name" name="passenger_name" id="contact_name" class="form-control" autocomplete="off">
                                <input type="hidden" name="old_contact_id" id="contact_id" value="<?php echo $booking_data['passenger_id'];?>" />
								<input type="hidden" name="driver_id" id="driver_id" value="<?php echo $booking_data['driver_id'];?>" />
									<div id="passenger_suggesstion-box"></div>
                              </div>
                             
                              <div class="form-group col-md-4">
                                 <label for="d_l_number">Phone Number</label>
                                 <input type="text" value="<?php echo $booking_data['passenger_phone'];?>" placeholder="078-xxxx-xxxx" name="contact_mobile" id="contact_mobile" class="form-control">
                              </div>
                           
                          

                              <div class="form-group col-md-4">
                                 <label for="uplaod">Email</label>
                                 <input type="text" value="<?php echo $booking_data['email'];?>" placeholder="abc@outlook" name="contact_email" id="contact_email" class="form-control">
                              </div>    
        				 </div>
						 
						 <div class="col-md-12" >
             
							   <div class="form-group col-md-4">
                                 <label for="no_of_passengers">No. of Passengers</label>
                                 <input type="text" value="<?php echo $booking_data['passengers'];?>" placeholder="No. of Passengers" name="passengers" id="passengers" class="form-control" >
                              </div>  
							  
							  
							   <div class="form-group col-md-4">
                                 <label for="no_of_bags">No. of Bags</label>
                                 <input type="text" value="<?php echo $booking_data['bags'];?>" placeholder="No. of Bags" name="bags" id="bags" class="form-control" >
                              </div>  
							    
        				 </div>
						 
    				  <div class="col-md-12" >
             
             			<!-- show a loader when click on submit button -->
                        <div id="loader"><img src="images/image_loader.gif"></div>
                    
                        
                           <h2>Pickup Details</h2>
              <div class="col-md-4"> <label for="area">Pickup Date</label>
   <?php
					 $end_date = date('Y-m-d',(strtotime('21 day', time())));
					 $pickup_date = date("d/m/Y", strtotime('0 day', time()));
  					?>
                       
  <input type="text" style="width:100%;" name="pickup_date" class="form-control" value="<?php echo date("d/m/Y",strtotime($booking_data['pickup_date']));?>" placeholder="Select a Date" name="booking_date" id="pickup_date"  tabindex="7" >
                      </div>
                       <div class="col-md-2">
                          <label for="area">Hours</label>
                          <select style="width:100%;" id="hours" name="hours" class="form-control">
                            <option <?php if ($booking_data['hours'] =='01') { echo 'selected'; } ?> value="01">01</option>
                            <option <?php if ($booking_data['hours'] =='02') { echo 'selected'; } ?> value="02">02</option>
							 <option <?php if ($booking_data['hours'] =='03') { echo 'selected'; } ?> value="03">03</option>
                            <option <?php if ($booking_data['hours'] =='04') { echo 'selected'; } ?> value="04">04</option>
							 <option <?php if ($booking_data['hours'] =='05') { echo 'selected'; } ?> value="05">05</option>
                            <option <?php if ($booking_data['hours'] =='06') { echo 'selected'; } ?> value="06">06</option>
							 <option <?php if ($booking_data['hours'] =='07') { echo 'selected'; } ?> value="07">07</option>
                            <option <?php if ($booking_data['hours']=='08') { echo 'selected'; } ?> value="08">08</option>
							 <option <?php if ($booking_data['hours'] =='09') { echo 'selected'; } ?> value="09">09</option>
                            <option <?php if ($booking_data['hours'] =='10') { echo 'selected'; } ?> value="10">10</option>
							 <option <?php if ($booking_data['hours'] =='11') { echo 'selected'; } ?> value="11">11</option>
                            <option <?php if ($booking_data['hours'] =='12') { echo 'selected'; } ?> value="12">12</option>
							 <option <?php if ($booking_data['hours'] =='13') { echo 'selected'; } ?> value="13">13</option>
                            <option <?php if ($booking_data['hours'] =='14') { echo 'selected'; } ?> value="14">14</option>
							 <option <?php if ($booking_data['hours'] =='15') { echo 'selected'; } ?> value="15">15</option>
                            <option <?php if ($booking_data['hours'] =='16') { echo 'selected'; } ?> value="16">16</option>
							 <option <?php if ($booking_data['hours'] =='17') { echo 'selected'; } ?> value="17">17</option>
                            <option <?php if ($booking_data['hours'] =='18') { echo 'selected'; } ?> value="18">18</option>
							 <option <?php if ($booking_data['hours'] =='19') { echo 'selected'; } ?> value="19">19</option>
                            <option <?php if ($booking_data['hours'] =='20') { echo 'selected'; } ?> value="20">20</option>
							 <option <?php if ($booking_data['hours'] =='21') { echo 'selected'; } ?> value="21">21</option>
                            <option <?php if ($booking_data['hours'] =='22') { echo 'selected'; } ?> value="22">22</option>
							 <option <?php if ($booking_data['hours'] =='23') { echo 'selected'; } ?> value="23">23</option>
                            
                          </select>
                          
                          </div>
                          <div class="col-md-2">
                          <label for="area">Minutes</label>
                          <select style="width:100%;" id="mins" name="mins" class="form-control">
                            <option <?php if ($booking_data['mins'] =='00') { echo 'selected'; } ?> value="00">00</option>
                            <option <?php if ($booking_data['mins'] =='01') { echo 'selected'; } ?> value="01">01</option>
                            <option <?php if ($booking_data['mins'] =='02') { echo 'selected'; } ?> value="02">02</option>
							 <option <?php if ($booking_data['mins'] =='03') { echo 'selected'; } ?> value="03">03</option>
                            <option <?php if ($booking_data['mins'] =='04') { echo 'selected'; } ?> value="04">04</option>
							 <option <?php if ($booking_data['mins'] =='05') { echo 'selected'; } ?> value="05">05</option>
                            <option <?php if ($booking_data['mins'] =='06') { echo 'selected'; } ?> value="06">06</option>
							 <option <?php if ($booking_data['mins'] =='07') { echo 'selected'; } ?> value="07">07</option>
                            <option <?php if ($booking_data['mins'] =='08') { echo 'selected'; } ?> value="08">08</option>
							 <option <?php if ($booking_data['mins'] =='09') { echo 'selected'; } ?> value="09">09</option>
                            <option <?php if ($booking_data['mins'] =='10') { echo 'selected'; } ?> value="10">10</option>
							 <option <?php if ($booking_data['mins'] =='11') { echo 'selected'; } ?> value="11">11</option>
                            <option <?php if ($booking_data['mins'] =='12') { echo 'selected'; } ?> value="12">12</option>
							 <option <?php if ($booking_data['mins'] =='13') { echo 'selected'; } ?> value="13">13</option>
                            <option <?php if ($booking_data['mins'] =='14') { echo 'selected'; } ?> value="14">14</option>
							 <option <?php if ($booking_data['mins'] =='15') { echo 'selected'; } ?> value="15">15</option>
                            <option <?php if ($booking_data['mins'] =='16') { echo 'selected'; } ?> value="16">16</option>
							 <option <?php if ($booking_data['mins'] =='17') { echo 'selected'; } ?> value="17">17</option>
                            <option <?php if ($booking_data['mins'] =='18') { echo 'selected'; } ?> value="18">18</option>
							 <option <?php if ($booking_data['mins'] =='19') { echo 'selected'; } ?> value="19">19</option>
                            <option <?php if ($booking_data['mins'] =='20') { echo 'selected'; } ?> value="20">20</option>
							 <option <?php if ($booking_data['mins'] =='21') { echo 'selected'; } ?> value="21">21</option>
                            <option <?php if ($booking_data['mins'] =='22') { echo 'selected'; } ?> value="22">22</option>
							 <option <?php if ($booking_data['mins'] =='23') { echo 'selected'; } ?> value="23">23</option>
                            <option <?php if ($booking_data['mins'] =='24') { echo 'selected'; } ?> value="24">24</option>
							 <option <?php if ($booking_data['mins'] =='25') { echo 'selected'; } ?> value="25">25</option>
                            <option <?php if ($booking_data['mins'] =='26') { echo 'selected'; } ?> value="26">26</option>
							 <option <?php if ($booking_data['mins'] =='27') { echo 'selected'; } ?> value="27">27</option>
                            <option <?php if ($booking_data['mins'] =='28') { echo 'selected'; } ?> value="28">28</option>
							 <option <?php if ($booking_data['mins'] =='29') { echo 'selected'; } ?> value="29">29</option>
                            <option <?php if ($booking_data['mins'] =='30') { echo 'selected'; } ?> value="30">30</option>
							 <option <?php if ($booking_data['mins'] =='31') { echo 'selected'; } ?> value="31">31</option>
                            <option <?php if ($booking_data['mins'] =='32') { echo 'selected'; } ?> value="32">32</option>
							  <option <?php if ($booking_data['mins'] =='33') { echo 'selected'; } ?> value="33">33</option>
                            <option <?php if ($booking_data['mins'] =='34') { echo 'selected'; } ?> value="34">34</option>
							 <option <?php if ($booking_data['mins'] =='35') { echo 'selected'; } ?> value="35">35</option>

                            <option <?php if ($booking_data['mins'] =='36') { echo 'selected'; } ?> value="36">36</option>
							 <option <?php if ($booking_data['mins'] =='37') { echo 'selected'; } ?> value="37">37</option>
                            <option <?php if ($booking_data['mins'] =='38') { echo 'selected'; } ?> value="38">38</option>
							 <option <?php if ($booking_data['mins'] =='39') { echo 'selected'; } ?> value="39">39</option>
                            <option <?php if ($booking_data['mins'] =='40') { echo 'selected'; } ?> value="40">40</option>
							 <option <?php if ($booking_data['mins'] =='41') { echo 'selected'; } ?> value="41">41</option>
                            <option <?php if ($booking_data['mins'] =='42') { echo 'selected'; } ?> value="42">42</option>
							 <option <?php if ($booking_data['mins'] =='43') { echo 'selected'; } ?> value="43">43</option>
                            <option <?php if ($booking_data['mins'] =='44') { echo 'selected'; } ?> value="44">44</option>
							 <option <?php if ($booking_data['mins'] =='45') { echo 'selected'; } ?> value="45">45</option>
                            <option <?php if ($booking_data['mins'] =='46') { echo 'selected'; } ?> value="46">46</option>
							 <option <?php if ($booking_data['mins'] =='47') { echo 'selected'; } ?> value="47">47</option>
                            <option <?php if ($booking_data['mins'] =='48') { echo 'selected'; } ?> value="48">48</option>
							 <option <?php if ($booking_data['mins'] =='49') { echo 'selected'; } ?> value="49">49</option>
                            <option <?php if ($booking_data['mins'] =='50') { echo 'selected'; } ?> value="50">50</option>
							 <option <?php if ($booking_data['mins'] =='51') { echo 'selected'; } ?> value="51">51</option>
                            <option <?php if ($booking_data['mins'] =='52') { echo 'selected'; } ?> value="52">52</option>
							 <option <?php if ($booking_data['mins'] =='53') { echo 'selected'; } ?> value="53">53</option>
                            <option <?php if ($booking_data['mins'] =='54') { echo 'selected'; } ?> value="54">54</option>
							 <option <?php if ($booking_data['mins'] =='55') { echo 'selected'; } ?> value="55">55</option>
                            <option <?php if ($booking_data['mins'] =='56') { echo 'selected'; } ?> value="56">56</option>
							 <option <?php if ($booking_data['mins'] =='57') { echo 'selected'; } ?> value="57">57</option>
                            <option <?php if ($booking_data['mins'] =='58') { echo 'selected'; } ?> value="58">58</option>
							 <option <?php if ($booking_data['mins'] =='59') { echo 'selected'; } ?> value="59">59</option>
							
						   
                          </select>
                          
                          </div>
                          <div class="form-group col-md-4">
                                 <label for="uplaod">Flight No.</label>
                                 <input type="text" placeholder="Sg123" name="flight_no" id="flight_no"  value="<?php echo $booking_data['flight_no'];?>" class="form-control" tabindex="13" >
                              </div> 
                      <div class="clearfix"></div>
               <div class="col-md-6" style="margin-top:10px;"> <label for="area">Pickup Address</label>
                       
                         <input name="pickup_address" id="pickup_address" type="text" id="pickup_address" value="<?php echo $booking_data['pickup_address'];?>" placeholder="Enter Address" class="form-control"  tabindex="4" >
                         
                   </div>
                
        <div class="col-md-6" style="margin-top:10px;"> <label for="area">Pickup Postcode</label>
        <input name="pickup_post_code" id="pickup_post_code" type="text" id="pickup_post_code" value="<?php echo $booking_data['pickup_post_code'];?>" placeholder="12G 45D" class="form-control"  tabindex="4" >
        </div>
       	</div>

			<div class="col-md-12" >
             
             
                        
                           <h2>Drop off Details</h2>

									 <div class="col-md-6"> <label for="area">Address</label>
        <input name="drop_address" type="text" id="drop_address" value="<?php echo $booking_data['drop_address'];?>" placeholder="Enter Address" class="form-control"  tabindex="4" >
        </div>
 <div class="col-md-6"> <label for="area">Postcode</label>
        <input name="drop_post_code" type="text" id="drop_post_code" value="<?php echo $booking_data['drop_post_code'];?>" placeholder="12G 45D" class="form-control"  tabindex="4" >
        </div>
			
            <!--div class="col-md-2"> <label for="area">Passengers</label>
            <input name="passengers" type="number" id="passengers" value="<?php //echo $booking_data['passengers'];?>" class="form-control"  tabindex="4" >
            </div-->
            
            <!--div class="col-md-4"> <label for="area">Vehicle</label>
                     
            <select name="vehicle" style="width:100%;" id="vehicle" class="form-control">
                               <?php
                 /*
                  $skip_sql="SELECT * from vehicle_make order by make ASC";
				  
                  $t_result=mysqli_query($con,$skip_sql);
				  $i=0;
                  while($vehicle=mysqli_fetch_assoc($t_result))
                  {
					
                  ?>
  <option style="padding:10px; background-color:#2977C9; color:#F9F0F1; cursor:pointer;" value="<?php echo $vehicle['id'];?>" <?php if ($vehicle['id'] == $booking_data['make_id']) { echo 'selected'; } ?>>
     <?php echo $vehicle['make']; ?>
    </option>
            <?php
            $i++;
            }*/
            ?>
                                </select>
            </div-->
            
                       </div>
				
                  <div class="col-md-12" >
                    <h2>Booking Details</h2>
                    <div class="col-md-3"> <label for="area">Start Date</label>
   <?php
					 $start_date = date('Y-m-d',(strtotime('21 day', time())));
					 $start_date = date("d/m/Y", strtotime('0 day', time()));
					  $start_date=date("d/m/Y", strtotime($booking_data['start_date']));
  					?>
                       
  <input required type="text" style="width:100%;" value="<?php echo $start_date;?>" class="form-control" required placeholder="Select a Date" name="start_date" id="start_date" onchange="cal()"  tabindex="7" >
                      </div>
                      
                        <div class="col-md-3"> <label for="area">End Date</label>
   <?php
					 $end_date = date('Y-m-d',(strtotime('21 day', time())));
					 $end_date = date("d/m/Y", strtotime('0 day', time()));
					 $end_date=date("d/m/Y", strtotime($booking_data['end_date']));
  					?>
                       
  <input required type="text" style="width:100%;" value="<?php echo $end_date;?>" class="form-control" required placeholder="Select a Date" name="end_date" id="end_date" onchange="cal()"  tabindex="7" >
                      </div>
                      <div class="col-md-2"> <label for="area">Days</label>
            <input name="days" type="text" id="days" value="<?php echo $booking_data['days'];?>" class="form-control"  tabindex="4" >
            </div>
            <div class="col-md-4"> 
            Vehicle 
            <select name="vehicle" style="width:100%;background-color:#053DD4; color:#ffffff;" id="vehicle" class="form-control">
                               <?php
                 
                 $skip_sql="SELECT * from vehicle_make order by make ASC";
				  
                  $t_result=mysqli_query($con,$skip_sql);
				  $i=0;
                  while($vehicle=mysqli_fetch_assoc($t_result))
                  {
					
                  ?>
  <option style="padding:10px; background-color:#2977C9; color:#F9F0F1; cursor:pointer;" value="<?php echo $vehicle['id'];?>" <?php if ($vehicle['id'] == $booking_data['make_id']) { echo 'selected'; } ?>>
     <?php echo $vehicle['make']; ?>
    </option>
            <?php
            $i++;
            }
            ?>
                                </select>
            </div>
            		</div>	 
    
     <div class="col-md-12" >
            			 <h2>Additional Details</h2>
	<div class="form-group col-md-4">
						 <label for="area">Job Type</label>
						  <select class="form-control" name="job_type">
						   <option value="Account" <?php if ("Account" == $booking_data['job_type']) { echo 'selected'; } ?>>Account</option>
						  <option value="Cash" <?php if ("Cash" == $booking_data['job_type']) { echo 'selected'; } ?>>Cash</option>
						  <!--option  value="Paid" <?php //if ("Paid" == $booking_data['job_type']) { echo 'selected'; } ?>>Paid</option-->
						 
						  </select>
						</div>		
						
 
     <div class="form-group col-md-4">
  <label for="area">Rate</label>
  	<input type="text" class="form-control pull-right" placeholder="450.00" value="<?php echo $booking_data['rate'];?>" name="rate">
    
     </div>  
	 <div class="form-group col-md-4">
  <label for="area">Supplier Cost</label>
  	<input type="text" class="form-control pull-right" placeholder="300.00" value="<?php echo $booking_data['supp_cost'];?>" name="supp_cost">
    
     </div>  <div class="form-group col-md-12">
  <label for="area">Comments</label>
  	<textarea class="form-control pull-right" name="comments"><?php echo $booking_data['comments'];?></textarea>
    
     </div>  
     
              <div class="col-md-4"> 
   <input type="submit" class="btn btn-primary" value="Update Booking" onClick="addRecord();"></button>
   </div>	         
				  </div>
        
						 <input type="hidden" name="job_status" id="job_status" value="<?php echo $booking_data['job_status'];?>">
  <!--div class="col-md-12" ><h2>Comments</h2>
  	<div class="col-md-8"><textarea class="form-control pull-right" name="comments"><?php //echo $booking_data['comments'];?></textarea>
     </div>
     <input type="hidden" name="job_status" id="job_status" value="<?php //echo $booking_data['job_status'];?>"
   <div class="col-md-4"> 
   <input type="submit" class="btn btn-primary" value="Update Booking" onClick="addRecord();"></button>
   </div>					
   </div-->             
                     
						</form>
                       
				  </div>
                </div> 
              </div>
<script type="text/javascript">
 function GetDays(){
 var sdate = document.getElementById("start_date").value;
var sdatearray = sdate.split("/");

var snewdate = sdatearray[1] + '/' + sdatearray[0] + '/' + sdatearray[2];
//alert(snewdate);

var edate = document.getElementById("end_date").value;
var edatearray = edate.split("/");

var enewdate = edatearray[1] + '/' + edatearray[0] + '/' + edatearray[2];
 
 
               
				 var dropdt = new Date(enewdate);//document.getElementById("end_date").value);
                var pickdt = new Date(snewdate);//document.getElementById("start_date").value);
                return parseInt(((dropdt - pickdt) / (24 * 3600 * 1000))+1);
        }

        function cal(){
        if(document.getElementById("end_date")){
		if(GetDays()<1)
		{
		alert("Select proper date");
		}
		else
		{
            document.getElementById("days").value=GetDays();
		}
			
        }  
		}
 $(document).ready(
      function () {
      $('#pickup_date').datepicker({
        changeMonth: true,//this option for allowing user to select month
        changeYear: true, //this option for allowing user to select from year range
        dateFormat: 'dd/mm/yy'
      });
	  
	   $('#start_date').datepicker({
        changeMonth: true,//this option for allowing user to select month
        changeYear: true, //this option for allowing user to select from year range
        dateFormat: 'dd/mm/yy'
      });
	  
	  $('#end_date').datepicker({
        changeMonth: true,//this option for allowing user to select month
        changeYear: true, //this option for allowing user to select from year range
        dateFormat: 'dd/mm/yy'
      });
      }
    
    );
	
$(document).ready(function () {
	$('#loader').hide();
});
$(document).ready(function(){
	
	$("#company_name").keyup(function(){
		$('#old_customer_id').val('');
		
		//$("#delivery_address").hide();
		//if any other div are open close them or hide them
		var url11 = 'ajax/find_customer.php?'+new Date().getTime();
		$.ajax({
		type: "POST",
		url: url11,
		data:'keyword='+$(this).val(),
		beforeSend: function(){
			$("#company_name").css("background","#F5C211");
		},
		success: function(data){
			$("#suggesstion-box").show();
			$("#suggesstion-box").html(data);
			$("#company_name").css("background","#green");
		}
		});
	});
});
	
	function selectCustomer(val) {
	var data=val;
	 var data = data.split('-');
	var id=data[0];
	var name=data[1];
	var address=data[2];
	var post_code=data[3];
	var phone=data[4];
	//alert(id);
	$('#new_customer').hide();
	//now show the delivery div as well
	
	$("#company_name").val(name);
	$("#old_customer_id").text('');
	$("#old_customer_id").val(id);
    //$('#customer_address1').val(address);
	//$('#post_code').val(post_code);
	//$('#phone').val(phone);
	$("#suggesstion-box").hide();
	}
	// Now Select Passenger
	$(document).ready(function(){
	
	$("#contact_name").keyup(function(){
		$('#contact_id').val('');
		//$("#delivery_address").hide();
		//if any other div are open close them or hide them
		var url11 = 'ajax/find_passenger.php?'+new Date().getTime();
		$.ajax({
		type: "POST",
		url: url11,
		data:'keyword='+$(this).val(),
		beforeSend: function(){
			$("#contact_name").css("background","#F5C211");
		},
		success: function(data){
			$("#passenger_suggesstion-box").show();
			$("#passenger_suggesstion-box").html(data);
			$("#contact_name").css("background","#green");
		}
		});
	});
});
	
	function selectPassenger(val) {
	var data=val;
	 var data = data.split('-');
	var id=data[0];
	var name=data[1];
	var mobile=data[2];
	var email=data[3];
	
	//alert(data);
	//$('#new_customer').hide();
	//now show the delivery div as well
	
	
	$("#contact_id").val(id);
	$("#contact_name").val(name);
	$('#contact_mobile').val(mobile);
	$('#contact_email').val(email);
	$("#passenger_suggesstion-box").hide();
	}
	
	$("#new_booking_form").on('submit',(function(e) {
		//$('#driver_form').validate();
		e.preventDefault();
		$('#loader').show();
		var url11 = 'ajax/update_booking.php?'+new Date().getTime();
		$.ajax({
			
        	url: url11,
			type: "POST",
			data:  new FormData(this),
			contentType: false,
    	    cache: false,
			processData:false,
			success: function(data)
		    { 
			//alert(data);
			if(data=='success'){
		alert("Booking Updated");
		$('#loader').delay(500).fadeOut("slow");
		var url1 = 'list_bookings.php?'+new Date().getTime();
		window.location.replace(url1);
			}else{
				alert("Booking Was not Updated");
				$('#loader').delay(500).fadeOut("slow");
				}
					
				
			//$("#gallery").html(data);
			
				
				
		    },
		  	error: function() 
	    	{
	    	} 	        
	   });
	}));

	
</script>
   </body>
</html>
