<style>
#pd {
width:70%;
height:auto;
margin-left:15%;
float:left;

margin-top:4%;
/*border:solid #990033;*/
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
#half {
width:45%;
height:auto;

}
#halfh {
width:30%;
height:auto;
margin-left:1%;
}
#full {
width:100%;
height:auto;
padding:2%;

}
#fullh {
width:100%;
height:auto;

}
@media screen and (max-width:768px) {

#pd {
width:100%;
height:auto;
margin-left:0;



}
#half {
width:100%;
height:auto;

}
#halfh {
width:100%;
height:auto;
margin-left:0;
}
}
</style>

                          
	<style>
		/* these are just styles added for this demo page */
		#canvas{
	
			width:100%;
			height:100%;
			background:#FFFFFF;
			/*background-image: url(bg_img/bg.jpg);*/
			/*margin: 0 auto;*/
		}
		#invoice_div{
	
			/*width:100%;
			height:100%;*/
			background:#FFFFFF;
			
			width:100%;
			left:10%;
			text-align:justify;
			padding-left:10%;
			
			/*padding:5%;*/
			/*background-image: url(bg_img/bg.jpg);*/
			/*margin: 0 auto;*/
		}
		.movable_div{
		margin-top:10px;
		width:80px;
		height:80px;
		padding:10px;
		
			color: white;
			font-family: Verdana;
			cursor: move;
			position: absolute;
		}
		#design{
		
			width: 510px;
			margin: 0 auto;
			background: purple;
			border: 1px solid black;
			color : white;
			padding: 30px;
			
		}
		
	</style>		
<form action="" method="post">

           
           
 <!--div class="form-group col-sm-3 pull-right"  style="margin-top:-30;" >
  <div class="col-md-6">
			       	   <select name="invoice_id" id="invoice_id" class="form-control">
			       	   	 <option style="padding:10px; background-color:#E7D91E; color:#F9F0F1; cursor:pointer;" value="">Select Invoice </option>
                               <?php  /*
							   
							        $customers_sqli="SELECT invoices.invoice_no,invoices.date, invoices.customer_id, invoices.vat,invoices.gross, invoices.pay_date
FROM invoices";
									$t_resulti=mysqli_query($con,$customers_sqli);
									while($inv=mysqli_fetch_assoc($t_resulti))
									{
									
									?>
	<option style="padding:20px; background-color:#2977C9; color:#F9F0F1; cursor:pointer;" value="<?php echo $inv['invoice_no']; ?>">
	   <?php echo $inv['invoice_no']; ?>
    </option>
						<?php
						
						}
			*/
						?>
			       	   </select>
					   </div>
					    <input  type="submit" name="allocate_invoice" class="btn btn-sm btn-success" value="Allocate Invoice"/>
   
			       	   </div-->
		    
<div class="continer-fluid col-md-12 well">
        <div class="col-md-2 pull-left">
			<?php
			date_default_timezone_set ("Europe/London");
            $rowcount=mysqli_num_rows($res);

if($rowcount==0)
{
	echo '<tr style="cursor:pointer; background-color:#F80307; color:#F3EBEB;"><td></td><td></td><td></td><td><p>You have no Jobs, Add Some Jobs.</p></td></tr>';
}
				

echo '<div class="form-group col-md-12" style="font-size:18px;">'.$rowcount.' jobs found.</div>';

?>
</div>

 <div class="form-group col-md-2" style="margin-left:-80px;">
 <label>Job Status</label>
	 <select name="job_status" id="job_status" class="form-control">
			       	   	 <option style="padding:10px; background-color:#E7D91E; color:#F9F0F1; cursor:pointer;" value="">Select Status</option>
                               <?php
							   
							        $customers_sqlj="select * from job_status";
									$t_resultj=mysqli_query($con,$customers_sqlj);
									while($status=mysqli_fetch_assoc($t_resultj))
									{
									
									?>
	<option style="padding:20px; background-color:#2977C9; color:#F9F0F1; cursor:pointer;" value="<?php echo $status['id']; ?>">
	   <?php echo $status['name']; ?>
    </option>
						<?php
						
						}
						?>
			       	   </select>
					   </div>
			<div class="col-md-1" style="margin-left:-20px;">
    
    <input style="margin-top:20px;" type="submit" name="confirm_job_status" class="btn btn-sm btn-success" value="Set Status"/>
    
	</div>		   		
		<div class="form-group col-md-4">
        <label>Allocate Driver</label>
			       	   <select name="driver_id" id="driver_id" class="form-control">
			       	   	 <option style="padding:10px; background-color:#E7D91E; color:#F9F0F1; cursor:pointer;" value="">Select a Driver </option>
						 
                               <?php
							   
							   

							   
							        $customers_sql="select employees.id,employees.phone,employees.first_name,employees.email_status,employees.email_status1,employees.email_status2,employees.email_status3,vehicle_make.make,vehicles.color,vehicles.reg
from vehicles
left join employees on vehicles.driver_id=employees.id
left join vehicle_make on vehicles.make=vehicle_make.id WHERE employees.first_name IS NOT NULL ORDER BY first_name";
									$t_result=mysqli_query($con,$customers_sql);
									while($customer=mysqli_fetch_assoc($t_result))
									{
									
									 if($customer['email_status']=='1' || $customer['email_status1']=='1' || $customer['email_status2']=='1' ||$customer['email_status3']=='1')
		 {
									?>
								
	<option  style="padding:20px; background-color:#990000; color:#CC66CC; cursor:pointer;" id="expire_<?php echo $customer['id']; ?>" value="<?php echo $customer['id']; ?>">
	  <?php echo $customer["first_name"]." ".$customer["reg"]." ".$customer["phone"]." ".$customer["make"]." ".$customer["color"]; ?> 
    </option>
						<?php
						}
						else
						{
						?>
									
	<option style="padding:20px; background-color:#2977C9; color:#F9F0F1; cursor:pointer;" id="alive_<?php echo $customer['id']; ?>" value="<?php echo $customer['id']; ?>">
	   <?php echo $customer["first_name"]." ".$customer["reg"]." ".$customer["phone"]." ".$customer["make"]." ".$customer["color"]; ?>
    </option>
						<?php
						
						}
						}
						?>
			       	   </select>
			       	   </div>
    <div class="col-md-2">
    
    <input style="margin-top:20px;" type="submit" name="confirm_booking" class="btn btn-sm btn-success" value="Allocate Driver"/>
    
	</div>
	
    <div class="col-md-1" style="float:left; margin-left:-100px;">
    
    <input style="margin-top:20px;" name="delete_booking" type="submit" class="btn btn-sm btn-danger" value="Delete"/>
    
	</div>
    
    <div class="col-md-1" style="float:left; margin-left:-30px;">
    
    <input style="margin-top:20px;" name="email_passenger" type="submit" class="btn btn-sm btn-primary" value="Email Passenger"/>
    
	</div>
     <div class="col-md-1 pull-right" style="margin-top:20px;">
    
    <a href="list_bookings.php" class="btn btn-sm btn-warning">Clear Filter</a>
    
	</div>
          
		  
		  
		  
		  
    </div>

<table  id="bookings" class="table list_jobs table-bordered table-striped table-info" cellspacing="0" border="1">

        <thead>
			
            <tr class="btn-primary" style="padding:10px;">

                           <th style="max-width:10px;">Job ID</th>
						   <th style="max-width:20px;">Job Type</th>
                           <th style="max-width:50px;">Change Driver</th>
                           <th style="max-width:20px;">Pickup Time</th>
                           <th style="min-width:250px;">Vehicle/Booking Details</th>
                           <th style="max-width:100px;">Client Name</th>
                           <!--th>Pickup Address</th>
                           
                           <th>Drop To</th-->
                          <th style="min-width:300px;">Pickup/Drop Address</th>
                            <!--th>Start Date</th>
                            <th>End Date</th-->
							<!--th>Booking Details</th-->
                            <th style="max-width:50px;">Days</th>
							<th style="max-width:50px;">Rate</th>
							<th style="max-width:50px;">Driver Rate</th>
                           <th style="min-width:135px;">Comments</th>
                           <th style="max-width:20px;">Edit</th>
                            <th style="max-width:20px;"><input type="checkbox" id="select_all" /></th>
                           
            </tr>

        </thead>

        <tfoot>

            <tr class="btn-primary">
                          <th>Job ID</th>
						  <th>Job Type</th>
                           <th>Change Driver</th>
                           <th>Pickup Time</th>
                           <th>Vehicle/Booking Details</th>
                           <th>Client Name</th>
                            <!--th>Pickup Address</th> 
                           <th>Drop To</th-->
                          <th>Pickup/Drop Address</th>
                           
                            <!--th>Start Date</th>
                            <th>End Date</th-->
							<!--th>Booking Details</th-->
                            <th>Days</th>
                           <th>Rate</th>
							<th>Driver Rate</th>
                           <th>Comments</th>
                           <th>Edit</th>
                           <th><input type="checkbox" id="select_all" /></th>
                           
            </tr>

        </tfoot>

        <tbody>
        
        <?php
				$today=date("Y-m-d");
				$std="";
				$etd="";
				$dtd="";
				$nt=0;
                while($job=mysqli_fetch_assoc($res))

                  {
				
				if ($job['job_status']=='2'){?>
                     <!--tr style="background-color:#88F487;" data-field="comments" class="confirmed"-->
                    
                            <tr>
							 <td style="background-color:#88F487;" >
                         
                                
						    <?php echo $job['booking_id']; 
							
						   }
						   elseif($job['job_status']=='3'){?>
						    
                         <!--tr style="background-color:#CC0000;"  data-field="comments" class="cancelled"-->  
						 <tr>
                                <td  style="background-color:#CC0000;">
						    <?php echo $job['booking_id']; 
							
						   }
						   elseif($job['job_status']=='5'){?>
						    
                         <!--tr style="background-color:#FF6600;"  data-field="comments" class="onhold"-->  
						 <tr>
                                <td  style="background-color:#FF6600;">
						    <?php echo $job['booking_id']; 
							
						   }
				
						   else{
								echo '<tr data-field="comments" class="pending">';
								echo '<td style="background-color:#F1070B; color:#FFF8F8;">'.$job['booking_id'];
								
								}
							?>
                            </td>
							<td>
							<?php echo $job['job_type'];?>
							</td>
                          <input type="hidden" name="booking_id[]" value=<?php echo $job['booking_id'];?>>
                           <td>
						   <?php $start2 = date("d/m/y", strtotime($job['pickup_date']));?>
                           <?php $start1 = date("l", strtotime($job['pickup_date']));?>
						    <?php $startd2 = date("d/m/y", strtotime($job['start_date']));?>
                           <?php $startd1 = date("l", strtotime($job['start_date']));?>
						    <?php $endd2 = date("d/m/y", strtotime($job['end_date']));?>
                           <?php $endd1 = date("l", strtotime($job['end_date']));?>
                           <a href="change_driver.php?driver_id=<?php echo $job['driver_id'];?>&booking_id=<?php echo $job['booking_id'];?>&" onclick="this.href+=new Date().getTime();return true;">Change</a>
						   <br /><br />
						   <a href="unallocate_driver.php?driver_id=<?php echo $job['driver_id'];?>&booking_id=<?php echo $job['booking_id'];?>&"  onclick="return confirm('Are you sure you want to Unallocate a driver?')">Unallocate a Driver</a>
						   <br />
						   <br />
						    
   
<!--a data-toggle="modal" data-id="<?php echo $job['booking_id'];?>" title="Add this item" class="open-AddBookDialog btn btn-primary" href="#myModal">Details</a-->
						   		 <?php //echo $start1.' '.$start2;
								 
								 ?>  
						  </td>
                          <?php $mins=str_replace('&#39;','0',$job['mins']);?>
                          <td><p><b style='font-size:13px'><?php echo date("d/m", strtotime($job['start_date']))."</b> <b style='font-size:18px'>".$job['hours'].":".$mins;?></b></p></td>
                           <input type="hidden" name="pickup_date[]" value=<?php echo $start2;?>>
						   <input type="hidden" name="start_date[]" value=<?php echo $startd2;?>>
						   <input type="hidden" name="end_date[]" value=<?php echo $endd2;?>>
                           
                            <input type="hidden" name="hours[]" value=<?php echo $job['hours'];?>>
                            
                            <input type="hidden" name="mins[]" value=<?php echo $mins;?>>
                            <input type="hidden" name="passengers[]" value=<?php echo $job['passengers'];?>>
							<input type="hidden" name="bags[]" value=<?php echo $job['bags'];?>>
                           <?php 
						   if($job['driver']=='' || $job['driver']=='0'){;?>
						   <td>
                           <!--td style="background-color:#F4080C; color:#F8F5F5; font-size:12px;"-->Allocate Driver <?php
						    echo "<p>".$job["reg"]." ".$job["make"]." ".$job["color"]."<br/> <b>Start Date:</b> ".date("d/m/y", strtotime($job['start_date']))."<br/> <b>End Date:</b> ".date("d/m/y", strtotime($job['end_date']))."</p>";
							?>
                           </td>
                           <?php }else
						   {
						    echo '<td>';
							    //if($job['substitute']=='')
								{
							//   echo "<p>".$job['driver']." ".$job["reg"]." ".$job["make"]." ".$job["color"]." Start ".date("d/m/y", strtotime($job['start_date']))." ";
							 
							   
							
							   }
							   //else
							  // if($job['substitute']!='')
							   {
							   //$sid=$job['substitute'];
							  $bid=$job['booking_id']; 
							   //$sub_sql="select * from driver_substitute WHERE booking_id='$bid'";
							   $sub_sql="select * from driver_bookings WHERE booking_id='$bid'";
									$sub_result=mysqli_query($con,$sub_sql);
							  	while($sub_driver=mysqli_fetch_assoc($sub_result))
									{
									//$sid=$sub_driver['substitute_id'];
                                    $sid=$sub_driver['driver_id'];
							    $customers_sql1="select * from employees WHERE employees.id='$sid'";
									$t_result1=mysqli_query($con,$customers_sql1);
									$subname=mysqli_fetch_assoc($t_result1);
									$nt++;
									//$sub_n=$subname['first_name'];
								//	while($sub=mysqli_fetch_assoc($t_result1))
									//{
									// echo "<hr>";
							 //  echo "New Driver : ".$sub['first_name']." ".$sub['phone'];
							
							  echo "<p>".$subname['first_name']." ".$job["reg"]." ".$job["make"]." ".$job["color"]." <br/> <b>Start Date:</b> ".date("d/m/y", strtotime($sub_driver['start_date']))."<br/> <b>End Date:</b>  ".date("d/m/y", strtotime($sub_driver['end_date']))."</p>";
							  }
							 
							   }
							  
							   ?></td>
                            
                             <?php ;}?>
							<?php ?> 
                            
                            </td>
                            
                            <td style="min-width:150px;"><?php echo $job['company_contact']."<br>".$job['customer_name']." ".$job['passenger_phone'];
							if($job['client_reference']!='')
							{
							echo "<br/><b style='color:#FF0000;'>";
							echo "Ref : ".$job['client_reference'];
							echo "</b>"; 
							}
							?></td>
                           
                            <td style="min-width:150px;"><b>Pickup:</b><?php echo $job['pickup_address']." ".$job['pickup_post_code'];?><!--/td>
                            <td style="min-width:150px;"--><br /><b>Drop:</b> <?php echo $job['drop_address']." ".$job['drop_post_code'];?><br />
							<b>Passengers:</b><?php echo $job['passengers'];?>&nbsp;
							<b>Bags:</b><?php echo $job['bags'];?><br />
							<b style='font-size:13px'>
							<?php if($job['flight_no']!=""){echo "Flight No. : ";?><!--a href="https://uk.flightaware.com/live/flight/<?php //echo $job['flight_no'];?>" target="_blank"><?php //echo $job['flight_no']."  "; }?></a> </b-->
							<a href="https://www.google.co.in/search?gl=in&q=<?php echo $job['flight_no'];?>&btnG=" target="_blank"><?php echo $job['flight_no']."  "; }?></a></b>
							</td>
                           
                           <input type="hidden" name="company_contact[]" value="<?php echo $job['company_contact'];?>">
                           <input type="hidden" name="passenger_phone[]" value="<?php echo $job['passenger_phone'];?>">
                           <input type="hidden" name="make[]" value="<?php echo $job['make'];?>">
						    <input type="hidden" name="flight_no[]" value="<?php echo $job['flight_no'];?>">
                           <input type="hidden" name="email[]" value="<?php echo $job['email'];?>">
                           <input type="hidden" name="pickup_address[]" value="<?php echo $job['pickup_address'];?>">
                           <input type="hidden" name="pickup_post_code[]" value="<?php echo $job['pickup_post_code'];?>">
                           <input type="hidden" name="drop_address[]" value="<?php echo $job['drop_address'];?>">
                           <input type="hidden" name="drop_post_code[]" value="<?php echo $job['drop_post_code'];?>">
                           <!-- check if driver is allocated or not -->
                           
                          
                          <input name="id[]" type="hidden" id="id" value="<?php echo $job['booking_id']; ?>">
                          
                        <?php $id=$job['booking_id'];?>
                        
                        
                          
                          <td>
						  <?php
							
							   ?>
                             <?php echo "<p>".$job['days']."</p>";?>
							 
                             <input name="days[]" type="hidden" id="days" value=<?php echo "'".$job['days']."'"; ?>>
                              <?php
							 
							
							   ?>
                          </td>
                          <td>
						    &pound;<?php echo $job['rate'];?>
                             <input name="rate[]" type="hidden" id="rate" value=<?php echo "'".$job['rate']."'"; ?>>
                             
						  </td>
						  <td>
						   &pound;<?php echo $job['supp_cost'];?>
                             <input name="supp_cost[]" type="hidden" id="supp_cost" value=<?php echo "'".$job['supp_cost']."'"; ?>>
                             
						  </td>
                            <td class="input" style="margin-top:10px;">
							
							<?php echo $job['comments'];?></td>
                            <input name="comments[]" type="hidden" id="comments" value=<?php echo "'".$job['comments']."'"; ?>>
                       <td><a href="edit_booking.php?booking_id=<?php echo $job['booking_id'];?>&" onclick="this.href+=new Date().getTime();return true;"><img src="edit--file-icon-69715.png" width="25px" /></a><br /><br />
					   <a href="print_booking.php?booking_id=<?php echo $job['booking_id'];?>&" onclick="this.href+=new Date().getTime();return true;"><img src="job_card1.png" width="25px" /></a></td> 						 
       <td style="text-align:right; font-size:20px;"><input name="selected_booking[]" type="checkbox" class="checkbox selected_booking" value="<?php echo $job['booking_id'];?>"></td>
                        
                           
                 
              </tr>
   <?php } ?>
   		 </tbody>
			   </table>
</table>
</form>
<?php
	function send_driver_email($to,$message,$driver_name)
		 {
		   $driver_email=$to;
		   $driver_message=$message;
		  
		$mail2 = new PHPMailer;
		$mail->SMTPAuth   = true;
		$mail2->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->Subject  = 'Your Booking Sheet';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()) {
		   
		   
			  echo '<script>alert("Email Was not Sent To Driver");</script>';
		   }else {
			   echo '<script>alert("Email Sent To Driver");</script>';
		   }
		  
			
		}

function send_passenger_email($to,$message,$passenger)
		 {
		$to=$to;
		$message=$message;   
		$passenger=$passenger;
		
		$mail = new PHPMailer;
		$mail->SMTPAuth   = true;
		$mail->IsHTML(true);  
		$mail->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail->addAddress($to, $passenger);
		$mail->Subject  = 'Passenger Booking Confirmation';
		$mail->Body     =$message;
		
		if(!$mail->send()) {
		  echo 'Message was not sent.';
		  echo 'Mailer error: ' . $mail->ErrorInfo;
		} else {
			//echo '<script>alert("A Confirmation Email has been sent to Passenger"); var url11 = "list_bookings.php?"+new Date().getTime(); window.location.replace(url11);<script>';
			echo '<script>alert("A Confirmation Email has been sent to Passenger");</script>';
		  } 
		}


function send_driver_name_plate($file_name,$name_plate,$driver_email,$driver_name,$driver_message)
{

		$path='';
		$file_name=$file_name;
		$driver_email=$driver_email;
		$driver_name=$driver_name;
		$name_plate=$name_plate;
		$driver_message=$driver_message;
		
		
		$path="bookings/";
		  
		$mail = new PHPMailer;
		$mail->IsHTML(true);  
		$mail->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail->addAddress($driver_email, $driver_name);
		$mail->Subject  = 'Driver Booking Confirmation';
		$mail->Body     =$driver_message;
		$mail->addAttachment($file_name);
		$mail->addAttachment($name_plate);
		if(!$mail->send()) {
		  echo 'Message was not sent.';
		  echo 'Mailer error: ' . $mail->ErrorInfo;
		} else {
		//	echo '<script>alert("A Confirmation Email has been sent to Driver"); var url11 = "list_bookings.php?"+new Date().getTime(); window.location.replace(url11);<script>';
			echo '<script>alert("A Confirmation Email has been sent to Driver");</script>';
		}
		

}



?>
<!-- Delete Booking Button Code -->

<?php /////////// if Delete is Pressed //

 if(isset($_POST['delete_booking']))
			{
		
		/*	
			echo "<pre>";
  				 print_r($_POST);
			echo "</pre>";
		exit;
		*/	
		$bookingIds = $_POST;
		$count=count($_POST['selected_booking']);
		for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_booking'][$i] ,$bookingIds['booking_id']);
			//echo "index=".$index;
		$booking_id=$con->real_escape_string($_POST['selected_booking'][$i]);
		
		
		
		$sqlc="SELECT * FROM driver_bookings
where bookings.id='$booking_id'";
		//echo $sql;
		if (!mysqli_query($con,$sqlc)) {mysqli_error($con);}
		$result=$con->query($sqlc);
		$driver=mysqli_fetch_assoc($result);
		
		$did=$driver['driver_id'];
		$sqlcd="SELECT * FROM employees
where employees.id='$did'";
		//echo $sql;
		if (!mysqli_query($con,$sqlcd)) {mysqli_error($con);}
		$resultd=$con->query($sqlcd);
		$driverd=mysqli_fetch_assoc($resultd);
	//	$driver_phone=$driver['phone'];
		$driver_name=$driverd['first_name'];
		$driver_email=$driverd['email'];
		//$pco_number=$driver['pco_number'];
		//$pco_expiry=$driver['pco_expiry'];
		//$driver_address=$driver['address'];
		//$driver_post_code=$driver['post_code'];
		//$driver_photo=$driver['driver_photo'];
		//$color=$driver['color'];
		//$reg=$driver['reg'];
		/* $start3=date("d/m/y", strtotime($driver['start_date']));
							  $start4 = date("l", strtotime($driver['start_date']));
							  $startdate= $start4.' '.$start3;*/
		
		//echo $driver_email;
		//exit;
		//Customer details for sending email
		
		//$passenger_email=$con->real_escape_string($_POST['email'][$index]);
		//$passenger_phone=$con->real_escape_string($_POST['passenger_phone'][$index]);
		//$pickup_address=$driver['pickup_address'];
		//$pickup_post_code=$driver['pickup_post_code'];
		//$pickup_date=$con->real_escape_string($_POST['pickup_date'][$index]);
		//$hours=$con->real_escape_string($_POST['hours'][$index]);
		//$mins=$con->real_escape_string($_POST['mins'][$index]);
		//$make=$con->real_escape_string($_POST['make'][$index]);
		//$comments=$driver['comments'];
		//////// Now Select the Registration and Car Color of this Selectd Driver 
		//$pickup_time=$hours.":".$mins;
		//exit;
		//$drop_address=$driver['drop_address'];
		//$drop_post_code=$driver['drop_post_code'];
		//echo "Customer".$passenger;
		//$name=$passenger;
		// Now send email to Passenger///////////////////////////////////////////////////////////////
		// $passenger_message ='';
		// $driver_message1='';
         //$to = "dashraja65@gmail.com";//$passenger_email;
		 //$No=$No+1; 
					  
			
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	 
		  
		 //  $driver_email="dashraja65@gmail.com";//$to;
		  $message="hello Your Booking ".$booking_id." has been Cancelled. Please call the office now to confirm again.";
		   $driver_message=$message;
		 // $driver_name=$current_driver;
		$mail2 = new PHPMailer;
		$mail2->SMTPAuth   = true;
		$mail2->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->Subject  = 'Booking Cancelled';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()) {
		   
		   
			  /*echo '<script>alert("Email Was not Sent To Driver");</script>';*/
		   }else {
			  /* echo '<script>alert("Email Sent To Driver");</script>';*/
		   }	
				 
		$update_booking="DELETE FROM bookings WHERE
					id=$booking_id";
					 // echo $update_booking;
					  if (!mysqli_query($con,$update_booking)) {
							echo $update_booking;
							die('update 3 INTO Bookings -Error: ' . mysqli_error($con));
							exit;
						 }
		$sql_sub="Delete from driver_bookings where booking_id=".$booking_id;
 if (!mysqli_query($con,$sql_sub)) {//echo $sql_check;die('Update 3 INTO ORDER_Details -Error: ' . mysqli_error($con));
			}
						  
		}
		echo '<script>alert("Record Deleted"); var url11 = "list_bookings.php?"+new Date().getTime();window.location.replace(url11);</script>';
		}
?>
<!-- email selected passengers -->
<?php
if(isset($_POST['email_passenger']))
			{
		
			/*	
			echo "<pre>";
  				 print_r($_POST);
			echo "</pre>";
		    exit;
		  */
		$bookingIds = $_POST;
		$count=count($_POST['selected_booking']);
		$driver_message='';
		$passenger_message='';
		$driver_message .= "<h1>WINGS CHAUFFEURS LTD. - Driver Booking Sheet</h3><br><hr>";
		$passenger_message .= "<h1>WINGS CHAUFFEURS LTD. - Booking Confirmation</h3>";
		$driver_message .='<table>';
        $counter=0;
	

 $No = 0;
 $color='';
 $additional_details='';
 $footer='';
 $terms='';;
		
		for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_booking'][$i] ,$bookingIds['booking_id']);
			//echo "index=".$index;
		$driver=$con->real_escape_string($_POST['driver_id']);
		
		$booking_id=$con->real_escape_string($_POST['selected_booking'][$i]);
		$passengers=$con->real_escape_string($_POST['passengers'][$i]);
		
		
		
		// reterive email of this driver
		$sql="SELECT employees.pco_number,employees.pco_expiry,employees.address,employees.post_code,employees.phone,employees.first_name,employees.email,employees.phone,employees.driver_photo,vehicles.reg,vehicles.color,driver_bookings.driver_id
FROM vehicles
LEFT JOIN employees on vehicles.driver_id=employees.id
LEFT JOIN driver_bookings on driver_bookings.driver_id=employees.id where driver_bookings.booking_id=$booking_id";
		//echo $sql;
		if (!mysqli_query($con,$sql)) {mysqli_error($con);}
		$result=$con->query($sql);
		$driver=mysqli_fetch_assoc($result);
		$driver_email=$driver['email'];
		$driver_phone=$driver['phone'];
		$driver_name=$driver['first_name'];
		$pco_number=$driver['pco_number'];
		$pco_expiry=$driver['pco_expiry'];
		$driver_address=$driver['address'];
		$driver_post_code=$driver['post_code'];
		$driver_photo=$driver['driver_photo'];
		$color=$driver['color'];
		$reg=$driver['reg'];
		//echo $driver_email;
		//exit;
		//Customer details for sending email
		$passenger=$con->real_escape_string($_POST['company_contact'][$index]);
		$passenger_email=$con->real_escape_string($_POST['email'][$index]);
		$passenger_phone=$con->real_escape_string($_POST['passenger_phone'][$index]);
		$pickup_address=$con->real_escape_string($_POST['pickup_address'][$index]);
		$pickup_post_code=$con->real_escape_string($_POST['pickup_post_code'][$index]);
		$pickup_date=$con->real_escape_string($_POST['pickup_date'][$index]);
		$hours=$con->real_escape_string($_POST['hours'][$index]);
		$mins=$con->real_escape_string($_POST['mins'][$index]);
		$make=$con->real_escape_string($_POST['make'][$index]);
		$start_date=$con->real_escape_string($_POST['start_date'][$index]);
		$end_date=$con->real_escape_string($_POST['end_date'][$index]);
		if(isset($_POST['flight_no'][$index]))
		{
        $flight_no=$_POST['flight_no'][$index];	
		}
		else
		{
		$flight_no="";
		}	
		//////// Now Select the Registration and Car Color of this Selectd Driver 
		$pickup_time=$hours.":".$mins;
		//exit;
		$drop_address=$con->real_escape_string($_POST['drop_address'][$index]);
		$drop_post_code=$con->real_escape_string($_POST['drop_post_code'][$index]);
		//echo "Customer".$passenger;
		$name=$passenger;
		// Now send email to Passenger///////////////////////////////////////////////////////////////
		 $passenger_message ='';
         $to = $passenger_email;
		 $No=$No+1; 
		 $passenger_message .= '    
		 <h4>
		 <hr>
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.$booking_id.'</p>
		 <hr>
		 <p>Time: '.$pickup_time.'</p>
	     <p><strong>Start Date: </strong>'.$start_date.'</p>
		 
		  <p><strong>End Date: </strong>'.$end_date.'</p>
         <p>Driver: </b>'.strtoupper($driver_name).'</p>
		 <p style="color:#E3060A">Driver Phone: '.$driver_phone.'</p>
		 <p background-color: rgb(255, 0, 0);><strong>Pickup From: </strong>'.strtoupper($pickup_address).','.strtoupper($pickup_post_code).'</p>
         <p><strong>Drop To: </strong>'.strtoupper($drop_address).','.strtoupper($drop_post_code).'</p>
		 
		 
		 </h4>
        <hr>
		 <p><b>Additional Details of Driver:</b></p>
		 <img class="img-circle" width="80" height="80" src=http://webdynamicslondon.co.uk/cabezy/drivers/'.$driver_photo.'>
		  <p>Name: '.$driver_name.'</p>
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <!--p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p-->
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		 
		 <hr>
		 <p>Thanks for booking at WINGS CHAUFFEURS LTD. Contact Number - +442036333706 M:- +447779623706</p>
		<b><p>Terms and Conditions:</p></b>
		<p style="font-size:8px;">Terms and Conditions<br>
Payment and Deposits<br>
<br>
Credit card payments are subject to a 3% surcharge.<br>
All prices are exclusive of VAT charged at 20%.<br>
Your booking may be subject to additional waiting time and car park charges.<br>
The charge on your credit card statement will be shown as Wings Chauffeurs Ltd<br>
We do not store credit card details nor do we share customer details with any 3rd parties<br>
<br>
Cancellation and Refund Policy<br>
<br>
If a booking is cancelled by the Client within 48 hours from the start of the period of hire, 25% of all monies paid will be non-refundable.<br>
<br>
If a booking is cancelled by the Client within 24 hours from the start of the period of hire, 100% of the booking fee will be chargeable.<br>
<br>
If the customer does not appear at the time and place designated as the pickup point, all monies paid will be non-refundable.<br>
<br>
<br>
Terms and Conditions<br>
<br>
Wings Chauffeurs requests a minimum of 24 hours� notice for any online bookings.<br>
<br>
Whilst we do our utmost to ensure our drivers are punctual, please understand that we cannot accept responsibility for delays caused by circumstances out of our control.<br>
<br>
The driver will drive at safe and sensible speeds in accordance with road conditions, traffic and the legal speed limits.<br>
<br>
Clients are responsible for any damage they cause to the interior/exterior of a vehicle on hire to them and will be billed accordingly for any repair or valeting that is required in order to reinstate a vehicle to full working order.<br>
<br>
We may provide subcontracted vehicles occasionally.<br>
<br>
If there are any changes or variations including extra mileage to the journeys other than what were agreed at the time of booking, the client will be charged extra in accordance with the pricing structure on our website.<br>
<br>
We reserve the right to change your vehicle or chauffeur at any time if necessary.<br>
<br>
Every effort will be made by Wings Chauffeurs to ensure that our vehicle(s) or Sub-Contractors vehicle(s) arrive on time.<br>
<br>
Our Chauffeur(s) will travel by the most appropriate route on the day, unless instructed otherwise by the Customer at the time of booking.<br>
<br>
Wings Chauffeurs vehicle(s) and sub-contracted vehicles are fully insured for passenger and third party claims. However, customers properties are carried entirely at their own risk and Wings Chauffeurs  shall not be held responsible/liable for any loss/damage to such property.<br>
<br>
Wings Chauffeurs  keep all lost property book at their office, and endeavour to return any lost goods left in our vehicle(s) or subcontracted vehicle(s) to the customer.<br>
<br>
Wings Chauffeurs and its chauffeurs have the right to refuse to carry any passenger who is thought to be under the influence of alcohol or drugs and whose behaviour poses a threat either to the Chauffeur, the vehicle or any other passenger(s).<br>
<br>
Wings Chauffeurs maintains a strict non-smoking policy in all its vehicles</p>
		
		 ';
		 //echo $passenger_message;
		// exit;
		send_passenger_email($to,$passenger_message,$passenger);
		
		
		}//for loop
		echo "<script>var url11 = 'list_bookings.php?'+new Date().getTime();window.location.replace(url11);</script>";  
		 exit;
	
	}//if($_POST

 
?>
<?php
 if(!empty($_POST['confirm_job_status']))
			{
		$job_status=$_POST['job_status'];	
		$bookingIds = $_POST;
		$count=count($_POST['selected_booking']);
		$counter=0;
		for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_booking'][$i] ,$bookingIds['booking_id']);
			//echo "index=".$index;
			$booking_id=$con->real_escape_string($_POST['selected_booking'][$i]);
		 $update_booking="UPDATE bookings SET
					  job_status='$job_status' WHERE id='$booking_id'";
					 // echo $update_booking;
					  //exit;
					  if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}	
					  
				////////////////////////////////////////////////////
				
					$sql="SELECT employees.pco_number,employees.pco_expiry,employees.address,employees.post_code,employees.phone,employees.first_name,employees.email,employees.phone,employees.driver_photo,vehicles.reg,vehicles.color,driver_bookings.driver_id
FROM vehicles
LEFT JOIN employees on vehicles.driver_id=employees.id
LEFT JOIN driver_bookings on driver_bookings.driver_id=employees.id where driver_bookings.booking_id='$booking_id'";
		//echo $sql;
		if (!mysqli_query($con,$sql)) {mysqli_error($con);}
		$result=$con->query($sql);
		$driver=mysqli_fetch_assoc($result);
		$driver_email=$driver['email'];
		$driver_phone=$driver['phone'];
		$driver_name=$driver['first_name'];
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



$sqls="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.job_type,bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,bookings.job_status,bookings.passengers,bookings.bags, 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";
$ress=$con->query($sqls);

$booking_data= mysqli_fetch_assoc($ress);


 $start_date = str_replace('/', '-', $booking_data['start_date']);
		 $start_date= date("d/m/Y", strtotime($start_date));
		 $sday=date("l",strtotime($booking_data['start_date']));
		 
		  $end_date = str_replace('/', '-', $booking_data['end_date']);
		 $end_date= date("d/m/Y", strtotime($end_date));
		 $eday=date("l",strtotime($booking_data['end_date']));
		 $bags=$booking_data['bags'];
		 $passengers=$booking_data['passengers'];
		
		
		$pco_number=$driver['pco_number'];
		$pco_expiry=$driver['pco_expiry'];
		$driver_address=$driver['address'];
		$driver_post_code=$driver['post_code'];
		$driver_photo=$driver['driver_photo'];
		$color=$driver['color'];
		$reg=$driver['reg'];
		//echo $driver_email;
		//exit;
		//Customer details for sending email
		$passenger=$con->real_escape_string($_POST['company_contact'][$index]);
		$pieces = explode(" ", $passenger);
		$first_name=$pieces[0];
		$last_name=$pieces[1]; 
		$first_name=strtoupper($first_name);
		$last_name=strtoupper($last_name);
		
		$passenger_email=$con->real_escape_string($_POST['email'][$index]);
		$passenger_phone=$con->real_escape_string($_POST['passenger_phone'][$index]);
		$pickup_address=$con->real_escape_string($_POST['pickup_address'][$index]);
		$pickup_post_code=$con->real_escape_string($_POST['pickup_post_code'][$index]);
		$pickup_date=$con->real_escape_string($_POST['pickup_date'][$index]);
		$hours=$con->real_escape_string($_POST['hours'][$index]);
		$mins=$con->real_escape_string($_POST['mins'][$index]);
		$make=$con->real_escape_string($_POST['make'][$index]);
		$comments=$con->real_escape_string($_POST['comments'][$index]);
		//////// Now Select the Registration and Car Color of this Selectd Driver 
		$pickup_time=$hours.":".$mins;
		//exit;
		$drop_address=$con->real_escape_string($_POST['drop_address'][$index]);
		$drop_post_code=$con->real_escape_string($_POST['drop_post_code'][$index]);
		if(isset($_POST['flight_no'][$index]))
		{
        $flight_no=$_POST['flight_no'][$index];	
		}
		else
		{
		$flight_no="";
		}	
		//echo "Customer".$passenger;
		$name=$passenger;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////				
					  
					  if($job_status=='3'){
					  
		 //  $driver_email="dashraja65@gmail.com";//$to;
		 $driver_message='';
		  $message="<h1  style='color:#E3060A'>Hello ".$driver_name."<br/>Your Job ".$booking_id." has been Cancelled, for more information please call the office.</h1><br><hr>";
		   $driver_message=$message;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		   
		   
		   
		//$passenger_message='';
		//$driver_message .= "<h1>WINGS CHAUFFEURS LTD. - Driver Booking Sheet</h1><br><hr>";
		//$passenger_message .= "<h1>WINGS CHAUFFEURS LTD. - Booking Confirmation</h3>";
		$driver_message .='<table>';
        $counter=1;
		 $driver_message .= '    
		 
		 <p><strong>Job No: </strong>'.$counter.'</p>
		 
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.$booking_id.'</p>
		 <p><strong>Time: </strong>'.$pickup_time.'</p>
	     <p><strong>Start Date: </strong>'.$sday.' '.$start_date.'</p>
		 
		 
		 <p><strong>End Date: </strong>'.$eday.' '.$end_date.'</p>
		 
		 
         <p><strong>Passenger:</strong> </b>'.$passenger.'</p>
		 <p><strong>Passenger Phone:</strong> '.$passenger_phone.'</p>
		 <p><strong>No. of Passengers:</strong> '.$passengers.'</p>
		 <p><strong>No. of Bags:</strong> '.$bags.'</p>';
		 if($flight_no!="")
		 {
		  $driver_message .= '<p>Flight No. : '.$flight_no.'</p>';  
		 }
		  $driver_message .= '  
		 <p><strong>Pickup From: </strong>'.$booking_data['pickup_address'].' , '.$booking_data['pickup_post_code'].'</p>
         <p><strong>Drop To: </strong>'.$booking_data['drop_address'].','.$booking_data['drop_post_code'].'</p>
		 <p>Operater Notes : '.$booking_data['comments'].'</p>
		 <p>................................................................................................................</p>
		 <!--p><strong>Passengers: </strong>'.$passengers.'</p-->
		 
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <!--p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p-->
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		
		 <hr>
		<b><p><strong>Terms and Conditions:</strong></p></b>
		

<b> 
Driver are responsible for the safety of vehicles.</b> 
<hr>
</p>
		
		 ';
		   
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		   
		   
		 // $driver_name=$current_driver;
		$mail2 = new PHPMailer;
		$mail2->SMTPAuth   = true;
		$mail2->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->Subject  = 'Job Cancelled';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()) {
		   
		   
			  /*echo '<script>alert("Email Was not Sent To Driver");</script>';*/
		   }else {
			  /* echo '<script>alert("Email Sent To Driver");</script>';*/
		   }	
				 
		  $update_booking="UPDATE bookings SET
					  driver_id='' WHERE id='$booking_id'";
					 // echo $update_booking;
					  //exit;
					  if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}
		$sql_sub="Delete from driver_bookings where booking_id=".$booking_id;
 if (!mysqli_query($con,$sql_sub)) {//echo $sql_check;die('Update 3 INTO ORDER_Details -Error: ' . mysqli_error($con));
			}
			  
					  
					  
			echo '<script>alert("Job Cancelled, Cancellation Email sent to Driver");</script>';
		}
		if($job_status=='2'){
		
		 //  $driver_email="dashraja65@gmail.com";//$to;
		  $driver_message='';
		  $message="<h1 style='color:#E3060A'>Hello ".$driver_name."<br/> Your Job ".$booking_id." has been Confirmed, for more information please call the office.</h1><br><hr>";
		   $driver_message=$message;
		 // $driver_name=$current_driver;
	///////////////////////////////////////////////////////////////////////////////	 
		 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		   
		   
		   
		//$passenger_message='';
		//$driver_message .= "<h1>WINGS CHAUFFEURS LTD. - Driver Booking Sheet</h1><br><hr>";
		//$passenger_message .= "<h1>WINGS CHAUFFEURS LTD. - Booking Confirmation</h3>";
		$driver_message .='<table>';
        $counter=1;
		 $driver_message .= '    
		 
		 <p><strong>Job No: </strong>'.$counter.'</p>
		 
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.$booking_id.'</p>
		 <p><strong>Time: </strong>'.$pickup_time.'</p>
	     <p><strong>Start Date: </strong>'.$sday.' '.$start_date.'</p>
		 
		 
		 <p><strong>End Date: </strong>'.$eday.' '.$end_date.'</p>
		 
		 
         <p><strong>Passenger:</strong> </b>'.$passenger.'</p>
		 <p><strong>Passenger Phone:</strong> '.$passenger_phone.'</p>
		 <p><strong>No. of Passengers:</strong> '.$passengers.'</p>
		 <p><strong>No. of Bags:</strong> '.$bags.'</p>';
		 if($flight_no!="")
		 {
		  $driver_message .= '<p>Flight No. : '.$flight_no.'</p>';  
		 }
		  $driver_message .= '  
		 <p><strong>Pickup From: </strong>'.$booking_data['pickup_address'].' , '.$booking_data['pickup_post_code'].'</p>
         <p><strong>Drop To: </strong>'.$booking_data['drop_address'].','.$booking_data['drop_post_code'].'</p>
		 <p>Operater Notes : '.$booking_data['comments'].'</p>
		 <p>................................................................................................................</p>
		 <!--p><strong>Passengers: </strong>'.$passengers.'</p-->
		 
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <!--p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p-->
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		
		 <hr>
		<b><p><strong>Terms and Conditions:</strong></p></b>
		

<b> 
Driver are responsible for the safety of vehicles.</b> 
<hr>
</p>
		
		 ';
//////////////////////////////////////////////////////////////////////////////////////		 
		 
		$mail2 = new PHPMailer;
		$mail2->SMTPAuth   = true;
		$mail2->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->Subject  = 'Job Confirmed';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()) {
		   
		   
			  /*echo '<script>alert("Email Was not Sent To Driver");</script>';*/
		   }else {
			  /* echo '<script>alert("Email Sent To Driver");</script>';*/
		   }	
		
		
			echo '<script>alert("Job Confirmed, Confirmed Email sent to Driver");</script>';
		}
		if($job_status=='5'){
		
		 //  $driver_email="dashraja65@gmail.com";//$to;
		 $driver_message='';
		  $message="<h1 style='color:#E3060A'>Hello ".$driver_name."<br/> Your Job ".$booking_id." is on hold now, please call the office to find out what to do next.</h1><br><hr>";
		   $driver_message=$message;
		 // $driver_name=$current_driver;
		 
		 //$passenger_message='';
		//$driver_message .= "<h1>WINGS CHAUFFEURS LTD. - Driver Booking Sheet</h1><br><hr>";
		//$passenger_message .= "<h1>WINGS CHAUFFEURS LTD. - Booking Confirmation</h3>";
		$driver_message .='<table>';
        $counter=1;
		 $driver_message .= '    
		 
		 <p><strong>Job No: </strong>'.$counter.'</p>
		 
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.$booking_id.'</p>
		 <p><strong>Time: </strong>'.$pickup_time.'</p>
	     <p><strong>Start Date: </strong>'.$sday.' '.$start_date.'</p>
		 
		 
		 <p><strong>End Date: </strong>'.$eday.' '.$end_date.'</p>
		 
		 
         <p><strong>Passenger:</strong> </b>'.$passenger.'</p>
		 <p><strong>Passenger Phone:</strong> '.$passenger_phone.'</p>
		 <p><strong>No. of Passengers:</strong> '.$passengers.'</p>
		 <p><strong>No. of Bags:</strong> '.$bags.'</p>';
		 if($flight_no!="")
		 {
		  $driver_message .= '<p>Flight No. : '.$flight_no.'</p>';  
		 }
		  $driver_message .= '  
		 <p><strong>Pickup From: </strong>'.$booking_data['pickup_address'].' , '.$booking_data['pickup_post_code'].'</p>
         <p><strong>Drop To: </strong>'.$booking_data['drop_address'].','.$booking_data['drop_post_code'].'</p>
		 <p>Operater Notes : '.$booking_data['comments'].'</p>
		 <p>................................................................................................................</p>
		 <!--p><strong>Passengers: </strong>'.$passengers.'</p-->
		 
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <!--p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p-->
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		
		 <hr>
		<b><p><strong>Terms and Conditions:</strong></p></b>
		

<b> 
Driver are responsible for the safety of vehicles.</b> 
<hr>
</p>
		
		 ';
		   
/////////
		 
		 
		$mail2 = new PHPMailer;
		$mail2->SMTPAuth   = true;
		$mail2->setFrom('info@wingschauffeurs.com', 'Wings Chauffeurs Ltd.');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->Subject  = 'Job On Hold';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()) {
		   
		   
			  /*echo '<script>alert("Email Was not Sent To Driver");</script>';*/
		   }else {
			  /* echo '<script>alert("Email Sent To Driver");</script>';*/
		   }	
		
		
		
			echo '<script>alert("Job On Hold, Email sent to Driver");</script>';
		}
		
		
	/////////////////////////////////////////////////////////////////////////	
			
		}
		
		echo "<script>var url11 = 'list_bookings.php?'+new Date().getTime();window.location.replace(url11);</script>";  
		 exit;
		
		}
?>		
<?php
 if(!empty($_POST['allocate_invoice'])&&!empty($_POST['invoice_id']))
			{
			$invoice_id=$con->real_escape_string($_POST['invoice_id']);

 
   

		$bookingIds = $_POST;
		$count=count($_POST['selected_booking']);
		
		  $counter=0;
	$vat=0;
		$nett=0;
		$vat_p=0;
 $total_gross=0;
 $No = 0;

 
 for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_booking'][$i] ,$bookingIds['booking_id']);
			//echo "index=".$index;
		
		
		$booking_id=$con->real_escape_string($_POST['selected_booking'][$i]);
		$passengers=$con->real_escape_string($_POST['passengers'][$i]);
		
		
		// check if this booking already exist if yes then update otherwise insert record
		$sql="Select * from bookings where invoice_status=1 AND id=".$booking_id;
		//echo $sql;
		$res=mysqli_query($con,$sql);
		$rowcount=mysqli_num_rows($res);
		$update_booking='';
		if($rowcount>0){
			
		//echo "Booking Found";
			$update_booking="UPDATE bookings SET
					  invoice_status=2 WHERE id=$booking_id";
					//  echo $update_booking;
					  if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}
					 // $update_booking="UPDATE bookings SET
					 // driver_id=$driver,job_status=2 WHERE id=$booking_id";
					 // if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}
					  $update_invoice_booking="INSERT INTO invoice_details 
		(invoice_no,booking_id)
		VALUES ('$invoice_id','$booking_id')";
		// echo $update_invoice_booking;
		if (!mysqli_query($con,$update_invoice_booking)) {mysqli_error($con);}
		
		$sqlin="Select * from invoices where invoice_no=".$invoice_id;
		$resin=mysqli_query($con,$sqlin);
		$rowin=mysqli_fetch_assoc($resin);
		$vat=$rowin['vat'];
		$nett=$rowin['nett'];
		$vat_p=($vat / $nett)*100;
		
	$sqlind="Select * from invoice_details where invoice_no=".$invoice_id;
		$resind=mysqli_query($con,$sqlind);
		while($rowind=mysqli_fetch_assoc($resind))
		{
		$inv_bid=$rowind['booking_id'];
		$sqlindb="Select * from bookings where id=".$inv_bid;
		$resindb=mysqli_query($con,$sqlindb);
		$rowb=mysqli_fetch_assoc($resindb);
		 $total_gross=$total_gross+$rowb['total_fare'];
		
		}
		
		$nett=$total_gross;
		$vat=($total_gross * $vat_p)/100;
		$gross=$total_gross + $vat;
		
		
			$update_invoices="UPDATE invoices SET
					  nett='$nett',vat='$vat',gross='$gross' WHERE invoice_no='$invoice_id'";
					//  echo $update_booking;
					  if (!mysqli_query($con,$update_invoices)) {echo "Error. ".mysqli_error($con);}
		
		
		echo '<script>alert("Invoiced Done");</script>';
					
			}
			else
			{
			echo '<script>alert("You selected Job is already Invoiced");</script>';
			}
			
			
	}
		
}
			
?>			
<?php
 if(!empty($_POST['confirm_booking'])&&!empty($_POST['driver_id']))
			{
		
		/*		
			echo "<pre>";
  				 print_r($_POST);
			echo "</pre>";
		exit;
*/

$driver=$con->real_escape_string($_POST['driver_id']);

 
    

		$bookingIds = $_POST;
		$count=count($_POST['selected_booking']);
		$driver_message='';
		$passenger_message='';
		$driver_message .= "<h1>WINGS CHAUFFEURS LTD. - Driver Booking Sheet</h3><br><hr>";
		$passenger_message .= "<h1>WINGS CHAUFFEURS LTD. - Booking Confirmation</h3>";
		$driver_message .='<table>';
        $counter=0;
	

 $No = 0;
 $color='';
 $additional_details='';
 $footer='';
 $terms='';
		 $pdf1=new FPDF();
		for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_booking'][$i] ,$bookingIds['booking_id']);
			//echo "index=".$index;
		
		if($driver==''){
			echo '<script>alert("You did not selected any Driver");return false;</script>';
		}
		$booking_id=$con->real_escape_string($_POST['selected_booking'][$i]);
		$passengers=$con->real_escape_string($_POST['passengers'][$i]);
		
		$sqlb="Select * from bookings where id=".$booking_id;
		//echo $sql;
		$resb=mysqli_query($con,$sqlb);
		$book=mysqli_fetch_assoc($resb);
		
		$supp_cost=$book['supp_cost'];
		$parking=$book['parking'];
		$days=$book['days'];
		$transfer=$book['transfer'];
		$start_date=$book['start_date'];
		$end_date=$book['end_date'];
		$total_fare=$supp_cost*$days+$parking+$transfer;
		// check if this booking already exist if yes then update otherwise insert record
		$sql="Select booking_id from driver_bookings where booking_id=".$booking_id;
		//echo $sql;
		$res=mysqli_query($con,$sql);
		$rowcount=mysqli_num_rows($res);
		$update_booking='';
		if($rowcount>0){
			
		//echo "Booking Found";
			$update_driver_booking="UPDATE driver_bookings SET
					  driver_id=$driver,status=2,parking=$parking,total_fare=$total_fare WHERE booking_id=$booking_id";
					  if (!mysqli_query($con,$update_driver_booking)) {echo "Error. ".mysqli_error($con);}
					  $update_booking="UPDATE bookings SET
					  driver_id=$driver,job_status=2 WHERE id=$booking_id";
					 // echo $update_booking;
					  //exit;
					  if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}
					  
					 // $update_driver_substitute="UPDATE driver_substitute SET
					  //driver_id=$driver WHERE booking_id=$booking_id";
					  //if (!mysqli_query($con,$update_driver_substitute)) {echo "Error. ".mysqli_error($con);}
			
			}else{
				
		//echo "nothing found";
				$update_driver_booking="INSERT INTO driver_bookings 
		(booking_id,driver_id,start_date,end_date,days,supp_cost,parking,total_fare)
		VALUES ('$booking_id','$driver','$start_date','$end_date','$days','$supp_cost','$parking','$total_fare')";
		if (!mysqli_query($con,$update_driver_booking)) {mysqli_error($con);}
		$update_booking="UPDATE bookings SET
					  driver_id=$driver,job_status=2 WHERE id=$booking_id";
					  //echo $update_booking;
					  if (!mysqli_query($con,$update_booking)) {echo "Error. ".mysqli_error($con);}
		}
		
	    // reterive email of this driver
		$sql="SELECT employees.pco_number,employees.pco_expiry,employees.address,employees.post_code,employees.phone,employees.first_name,employees.email,employees.phone,employees.driver_photo,vehicles.reg,vehicles.color
FROM vehicles
LEFT JOIN employees on vehicles.driver_id=employees.id
where employees.id=$driver";
		//echo $sql;
		if (!mysqli_query($con,$sql)) {mysqli_error($con);}
		$result=$con->query($sql);
		$driver=mysqli_fetch_assoc($result);
		$driver_email=$driver['email'];
		$driver_phone=$driver['phone'];
		$driver_name=$driver['first_name'];
		$pco_number=$driver['pco_number'];
		$pco_expiry=$driver['pco_expiry'];
		$driver_address=$driver['address'];
		$driver_post_code=$driver['post_code'];
		$driver_photo=$driver['driver_photo'];
		$color=$driver['color'];
		$reg=$driver['reg'];
		//echo $driver_email;
		//exit;
		//Customer details for sending email
		$passenger=$con->real_escape_string($_POST['company_contact'][$index]);
		$pieces = explode(" ", $passenger);
		$first_name=$pieces[0];
		$last_name=$pieces[1]; 
		$first_name=strtoupper($first_name);
		$last_name=strtoupper($last_name);
		
		$passenger_email=$con->real_escape_string($_POST['email'][$index]);
		$passenger_phone=$con->real_escape_string($_POST['passenger_phone'][$index]);
		$pickup_address=$con->real_escape_string($_POST['pickup_address'][$index]);
		$pickup_post_code=$con->real_escape_string($_POST['pickup_post_code'][$index]);
		$pickup_date=$con->real_escape_string($_POST['pickup_date'][$index]);
		$hours=$con->real_escape_string($_POST['hours'][$index]);
		$mins=$con->real_escape_string($_POST['mins'][$index]);
		$make=$con->real_escape_string($_POST['make'][$index]);
		$comments=$con->real_escape_string($_POST['comments'][$index]);
		//////// Now Select the Registration and Car Color of this Selectd Driver 
		$pickup_time=$hours.":".$mins;
		//exit;
		$drop_address=$con->real_escape_string($_POST['drop_address'][$index]);
		$drop_post_code=$con->real_escape_string($_POST['drop_post_code'][$index]);
		if(isset($_POST['flight_no'][$index]))
		{
        $flight_no=$_POST['flight_no'][$index];	
		}
		else
		{
		$flight_no="";
		}	
		//echo "Customer".$passenger;
		$name=$passenger;
		// Now send email to Passenger///////////////////////////////////////////////////////////////
		 $passenger_message ='';
         $to = $passenger_email;
		 $No=$No+1; 
		 $passenger_message .= '    
		 
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.strtoupper($booking_id).'</p>
		 <hr>
		 
	     <p><strong>Date: </strong>'.date("l", strtotime($job['start_date'])).' '.$pickup_date.'</p>
		 <p>Time: '.$pickup_time.'</p>
		 
         <p>Driver: </b>'.strtoupper($driver_name).'</p>
		 <p style="color:#E3060A">Driver Phone: '.$driver_phone.'</p>
		 <p background-color: rgb(255, 0, 0);><strong>Pickup From: </strong>'.strtoupper($pickup_address).','.strtoupper($pickup_post_code).'</p>
         <p><strong>Drop To: </strong>'.strtoupper($drop_address).','.strtoupper($drop_post_code).'</p>
		 
		 
		 
         <hr>
		 <p><b>Additional Details of Driver:</b></p>
		 <img width="120" height="120" src="http://webdynamicslondon.co.uk/cabezy/drivers"'.$driver_photo.'>
		  <p>Name: '.$driver_name.'</p>
		  
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p>
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		 
		 <hr>
		 <p>Thanks for booking at WINGS CHAUFFEURS LTD. Contact Number - +442036333706 M:- +447779623706</p>
		<b><p>Terms and Conditions:</p></b>
		<p style="font-size:8px;">Terms and Conditions</p>
		
		 ';
		 $driver_image="http://webezy.co.uk/cabezy/drivers".$driver_photo;
		
		//send_passenger_email($to,$passenger_message,$passenger);
		//echo $passenger_message;
		
		 /////////////////////// Email Customer Ends///////////////////////////////////////
		$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.job_type,bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,bookings.job_status,bookings.passengers,bookings.bags, 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";
$res=$con->query($sql);

$booking_data= mysqli_fetch_assoc($res);


		 ////////////////////////////  Make Name Plates ///////////////////////////////////////
		 
		 $pdf1->AddPage('L','A4');
		 $pdf1->SetFont('Arial','B',15);
         $pdf1->setXY(50,50);
		 //$pdf1->Cell(50, 6, "Passenger Name Plate for Booking Ref:".$booking_id, 0, 1);
		 $pdf1->setXY(50,100);
		 $pdf1->SetFont('Arial','B',80);
		 $pdf1->Cell(50, 10,$first_name, 0, 1);
		 $pdf1->setXY(50,150);
		 $pdf1->Cell(30, 20,$last_name, 0, 1);
		 //////////////////////////  Name Plate Done ///////////////////////////////////////
		 $start_date = str_replace('/', '-', $booking_data['start_date']);
		 $start_date= date("d/m/Y", strtotime($start_date));
		 $sday=date("l",strtotime($booking_data['start_date']));
		 
		  $end_date = str_replace('/', '-', $booking_data['end_date']);
		 $end_date= date("d/m/Y", strtotime($end_date));
		 $eday=date("l",strtotime($booking_data['end_date']));
		 
		 $passengers=$booking_data['passengers'];
		 $bags=$booking_data['bags'];
		 
		 $driver_message .= '    
		 
		 <p><strong>Job No: </strong>'.$counter.'</p>
		 
		 <p style="color:#E3060A"><strong>Booking Ref: </strong>'.$booking_id.'</p>
		 <p><strong>Time: </strong>'.$pickup_time.'</p>
	     <p><strong>Start Date: </strong>'.$sday.' '.$start_date.'</p>
		 
		 
		 <p><strong>End Date: </strong>'.$eday.' '.$end_date.'</p>
		 
		 
         <p><strong>Passenger:</strong> </b>'.$passenger.'</p>
		 <p><strong>Passenger Phone:</strong> '.$passenger_phone.'</p>
		 <p><strong>No. of Passengers:</strong> '.$passengers.'</p>
		 <p><strong>No. of Bags:</strong> '.$bags.'</p>';
		 if($flight_no!="")
		 {
		  $driver_message .= '<p>Flight No. : '.$flight_no.'</p>';  
		 }
		  $driver_message .= '  
		 <p><strong>Pickup From: </strong>'.$booking_data['pickup_address'].' , '.$booking_data['pickup_post_code'].'</p>
         <p><strong>Drop To: </strong>'.$booking_data['drop_address'].','.$booking_data['drop_post_code'].'</p>
		 <p>Operater Notes : '.$booking_data['comments'].'</p>
		 <p>................................................................................................................</p>
		 <!--p><strong>Passengers: </strong>'.$passengers.'</p-->
		 
		 <p><strong>Driver PCO Number: </strong>'.$pco_number.'</p>
		  <!--p><strong>PCO Expiry Date: </strong>'.date("d/m/Y",strtotime($pco_expiry)).'</p-->
		 <p><strong>Car: </strong>'.strtoupper($make).'</p>
		 <p><strong>Car Color: </strong>'.strtoupper($color).'</p>
		 <p><strong>Car Reg: </strong>'.strtoupper($reg).'</p>
		
		 <hr>
		<b><p><strong>Terms and Conditions:</strong></p></b>
		

<b> 
Driver are responsible for the safety of vehicles.</b> 
<hr>
</p>
		
		 ';
		// echo $driver_message;
		}
		 //////////////////////////  Now Create PDF Of Name Plates Selected ///////////////////////////////////////
		 $name_plate='bookings/'.$booking_id.'_name_plate.pdf';
		//
		
		 $pdf1->Output($name_plate,'F');
		 //////////////////////////  Now Create PDF FIle for Bookings to Send to Driver ///////////////////////////////////////
	     $rand=mt_rand(99, 99999);
		 $booking_file ='bookings/'.$rand.'_driver_booking.pdf';
		 //$pdf->Output($booking_file,'F');
		 
	//////////////////////////////////////////////////////////job card//////////////////////////////////////////////////////////
	       $sql="SELECT bookings.start_date,bookings.id AS booking_id,bookings.days,bookings.comments,bookings.flight_no,bookings.parking,bookings.driver_id, bookings.drop_address,bookings.drop_post_code,bookings.pickup_address,bookings.pickup_post_code, bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time, bookings.hours,bookings.mins,bookings.other,bookings.job_status,bookings.passengers,bookings.bags,job_status.name,bookings.comments,
bookings.start_date,bookings.end_date,bookings.days,bookings.rate AS rate,bookings.supp_cost AS supp_cost,bookings.substitute,
customers.id AS customer_id, customers.name AS customer_name,customers.address1,customers.post_code,customers.city, customers.phone as customer_phone, 
employees.first_name AS driver,employees.email AS driver_email,employees.phone as driver_phone,employees.pco_number,vehicles.color as color,vehicles.reg as reg, vehicle_make.make as make,
company_contact.name as company_contact,company_contact.email,company_contact.mobile as passenger_phone

FROM bookings 
LEFT JOIN customers ON bookings.customer_id = customers.id 
LEFT JOIN payment_type ON bookings.payment_type = payment_type.id 
LEFT JOIN employees ON bookings.driver_id = employees.id 
LEFT JOIN company_contact ON bookings.passenger_id = company_contact.id 
LEFT JOIN vehicle_make ON bookings.vehicle_id = vehicle_make.id 
LEFT JOIN vehicles on vehicles.driver_id=employees.id
LEFT JOIN job_status ON bookings.job_status = job_status.id 

 WHERE bookings.id=".$booking_id." ORDER BY bookings.id DESC";

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

$booking_data= mysqli_fetch_assoc($res);
		   
		      $invoice_html=
					 '   
					 <!doctype html>
					  <html>
					  
					  <meta charset="utf-8">
					  <head><style>
					/*  
					  .full{
		width:100%;
		
		}
		.half{
		width:50%;
		
		}
		 .full1{
		width:60%;
		
		}
		.half1{
		width:30%;
		margin-right:10px;
	
		
		}
		.half2{
		width:45.5%;
		margin-right:10px;
	min-height:120px;
		
		}
		.half3{
		width:92%;
		margin-right:10px;
	min-height:100px;
		
		}
		
h2 {
	
	 style="padding:10px; color:#000000; background-color:#68B0EC;"
	 }
*{
	font-size:14px;
	font-family:arial;
	color:#000000;}
	 */
</style></head>
					  <body>
					  <div id="invoice">';
					 
                             $mins=str_replace('&#39;','0',$booking_data['mins']);
                         
						    $start_date = date("d/m/y", strtotime($booking_data['start_date']));
                            $start1 = date("l", strtotime($booking_data['start_date']));
						     $end_date = date("d/m/y", strtotime($booking_data['end_date']));
                            $end1 = date("l", strtotime($booking_data['end_date']));
							$driver_name=@$booking_data['driver'];
							$driver_email=@$booking_data['driver_email'];
							$driver_phone=@$booking_data['driver_phone'];
					 $invoice_html.=' 	<h3 style="color:#FF0000;">For Better View Turn Screen Horizontal</h3>
                     <div class="full" style="width:100%;">
					 <div class="half" style="float:left; width:70%;">
						
						
						<!--h3 align="left" style=" float:left;">
						<img src="wings_logo.JPG" style="margin-left:0%;"></h3--> 
							 <h3 align="left" style=" float:left;"><font face="Times New Roman, Times, serif"><b style="font-size:25px;">Wings Chauffeurs Ltd.</b></font>
							 <b style="font-size:12px;"><br>Office 2.25, 450 Bath Rd,<br>
							 West Drayton,Middlesex,London,<br>
							 UB7 0EB<br></b></h3>
						</div>
						
						
						
						 <div class="half" style="float:right; width:30%;">
						 <br>
						  	<h1>JOB CARD</h1>	
							</div>
					</div>
					<br><br><br><br><br>		
							';
			

					        
                  $invoice_html.=
				  
					 '
		 
		<div class="full" style="width:100%;">
		 <br><br>
		 <p style="color:#E3060A; font-size:20px;"><strong style="font-size:20px;">Booking Ref : </strong>'.$booking_id.'</p>
		 </div>
		 <div class="full1" style="float:left; width:100%;">
		 <div class="half1" style="float:left; width:18%; margin-right:10px; border:solid 1px #000000;" align="left">
		  <div class="full" style="float:left; width:100%; background:#FF0000; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Start Date</strong>
		  </div>
	     '.$start1.' '.$start_date.'<br>
		 <strong>Time : </strong>'.$booking_data['hours'].":".$mins.'
		 </div>
		  <div class="half1" style="float:left; width:18%; margin-right:10px; border:solid 1px #000000;" align="left">
		  <div class="full" style="float:left; width:100%; background:#00CC00; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">End Date</strong>
		  </div>
		 '.$end1.' '.$end_date.'
		 <br><br>
		 </div>
		 <div class="half1" style="float:left; width:18%; margin-right:10px; border:solid 1px #000000;" align="center">
		  <div class="full" style="float:left; width:100%; background:#0099FF; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">No. of Days</strong>
		  </div>
		  '.$booking_data['days'].'
		  <br><br>
		 </div>
		 </div>
		 
		 <div class="full" style="width:100%; float:left; margin-top:10px;">
		 
		 <div class="half1" style="float:left; width:30%; margin-right:10px; border:solid 1px #000000;" align="left">
		  <div class="full" style="width:100%; float:left; background:#0099FF; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Driver</strong>
		  </div>
	     <p><strong>Driver :</strong>'.$driver_name.'</p>
		 <p><strong>Phone : </strong>'.$driver_phone.'</p>
		 <p><strong>Driver PCO No : </strong>'.$booking_data['pco_number'].'</p>
		 </div>
		 
		 <div class="half1" style="float:left; width:30%; margin-right:10px; border:solid 1px #000000;" align="left">
		  <div class="full" style="float:left; width:100%; background:#FF6600; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Client</strong>
		  </div>
	      <p><strong>Passenger :</strong> </b>'.$booking_data['company_contact'].'</p>
		 <p><strong>Phone :</strong><a href="tel:'.$booking_data['passenger_phone'].'"><b>'.$booking_data['passenger_phone'].'</b></a></p>
		  <p><strong>Passengers :</strong> '.$booking_data['passengers'].' , <strong>Bags :</strong> '.$booking_data['bags'].'</p>
		 </div>
		 
		 <div class="half1" style="float:left; width:30%; margin-right:10px; border:solid 1px #000000;" align="center">
		  <div class="full" style="float:left; width:100%; background:#0099FF; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:left;">Vehical</strong>
		  </div>
	     <p style="text-align:left;"><strong>Car : </strong>'.strtoupper($booking_data['make']).'</p>
		 <p style="text-align:left;"><strong>Car Color : </strong>'.strtoupper($booking_data['color']).'</p>
		 <p style="text-align:left;"><strong>Car Reg : </strong>'.strtoupper($booking_data['reg']).'</p>
		 </div>
		 </div>
		 
		  <div class="full" style="width:100%; float:left; margin-top:10px;">
		 
		 <div class="half2" style="width:45.5%; margin-right:10px; min-height:120px; float:left; border:solid 1px #000000;" align="left">
		  <div class="full" style="width:100%; float:left; background:#FF0000; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Pickup From</strong>
		  </div>
	     <p>';
		 $flight_no=$booking_data['flight_no'];
		 if($flight_no!="")
		 {
		  $invoice_html .= '<strong>Flight No. </strong>: <a href="https://www.google.co.in/search?gl=in&q='.$flight_no.'&btnG=" target="_blank">'.$flight_no.'</a>';
		 }
		 $invoice_html .='</p>
		 <p>'.$booking_data['pickup_address'].' , '.$booking_data['pickup_post_code'].'</p>
		 
		 </div>
		 
		 <div class="half2" style="width:45.5%; margin-right:10px; min-height:120px; float:left; border:solid 1px #000000;" align="left">
		  <div class="full" style="width:100%; float:left; background:#00CC00; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Drop To</strong>
		  </div>
	     
		 <p>'.$booking_data['drop_address'].','.$booking_data['drop_post_code'].'s</p>
		 </div>
		 
		
		 </div>
		  <div class="half3" style="width:92%; margin-right:10px; min-height:100px; float:left; margin-top:10px; border:solid 1px #000000;" align="left">
		  <div class="full" style=" width:100%; float:left; background:#0099FF; border:solid 1px #000000;">
		  <strong style="color:#FFFFFF; text-align:center;">Operator Notes</strong>
		  </div>
	      <p>Driver cost : &pound;'.$booking_data['supp_cost']*$booking_data['days']."<br/>".$booking_data['comments'].'</p>
		 
		 </div>
		 
		 
		 ';
        
		  
		   
		 $invoice_html .= '  
		 
		
		
		 <p>&nbsp;</p>
		 <p>&nbsp;</p>
		 <p>&nbsp;</p>
		 <p>&nbsp;</p>
		  <p>&nbsp;</p>
		<p>&nbsp;</p>
		
		<br/>
		<b><p><strong>Terms and Conditions :</strong></p></b>
		

<b> 
Driver are responsible for the safety of vehicles.</b> 
</p>
	
		
		 ';
	$driver_message=$invoice_html;
	//$driver_message=file_get_contents("print_booking1.php");
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	 
		 
	     //////////////////////////  All Ready Now Send Mail to driver ///////////////////////////////////////
		 //echo $driver_message;
		 //exit;
		// send_passenger_email($to,$passenger_message,$passenger);
		send_driver_email($driver_email,$driver_message,$driver_name);
		// send_driver_name_plate($booking_file,$name_plate,$driver_email,$driver_name,$driver_message);
		 //echo $first_name;
		 //echo $last_name;
		echo "<script>var url11 = 'list_bookings.php?'+new Date().getTime();window.location.replace(url11);</script>";  
		 exit;
		 
		 //////////////////////////  Disco ///////////////////////////////////////
		
		
		
		
		
		///////////////////////////////////////////////////////////////////////////////
		
	}
?>	

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Details</h4>
      </div>
      <div class="modal-body">
        <!--p>Records Updated Succesfully.</p-->
		<div id="bookId">
		</div>
		      
      </div>
      <div class="modal-footer">
        <button id="close_me" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

	 
	<script type="text/javascript">
	
	
$(document).ready(function(){

    $('#select_all').on('click',function(){
        if(this.checked){
            $('.checkbox').each(function(){
                this.checked = true;
            });
        }else{
             $('.checkbox').each(function(){
                this.checked = false;
            });
        }
    });
    
    $('.checkbox').on('click',function(){
        if($('.checkbox:checked').length == $('.checkbox').length){
            $('#select_all').prop('checked',true);
        }else{
            $('#select_all').prop('checked',false);
        }
    });
});
/////////////////////// Selecting a Driver on key up in driver box/////////////////
$("#driver_name").keyup(function(){
		$('#contact_id').val('');
		//$("#delivery_address").hide();
		//if any other div are open close them or hide them
		var url11 = "ajax/find_driver.php?"+new Date().getTime();
		$.ajax({
		type: "POST",
		url: url11,
		data:'keyword='+$(this).val(),
		beforeSend: function(){
			$("#contact_name").css("background","#F5C211");
		},
		success: function(data){
			$("#suggesstion-box").show();
			$("#suggesstion-box").html(data);
			$("#contact_name").css("background","#green");
		}
		});
});
	
	function selectDriver(val) {
	var data=val;
	 var data = data.split('-');
	var id=data[0];
	var name=data[1];
	
	$("#driver_id").val(id);
	$("#driver_name").val(name);
	
	$("#suggesstion-box").hide();
	}
	
	
$("#driver_id").change(function(){	
var t=$("#driver_id").val();
var t1=$("#expire_"+t).val();
if(t1!=undefined)
{
 //alert("Driver MOT or somethings are expired. Do you want to allocate this Driver");   
 
  var retVal = confirm("Driver MOT or somethings are expired. Do you want to allocate this Driver?");
               if( retVal == true ){
                 // document.write ("User wants to continue!");
                  return true;
               }
               else{
                 // document.write ("User does not want to continue!");
				 $("#driver_id").val("");
                 // return false;
               }
 
 }
});
///////////////////////////////////////////////////////////////////////////////////
</script>