 <form action="" method="post">

<div class="col-md-12 well" style="margin-bottom:10pz;">
            <div class="col-md-3">
			<?php
            $rowcount=mysqli_num_rows($res);

if($rowcount==0)
{
	echo '<label>No Driver Record Found</label>';
}
				
$today = date("d/m/y", strtotime($today));
echo '<label>Total '.$rowcount.' Drivers Registered</label>';

?>
</div>
            
             
				<!--div class="col-md-3">
                	<a href="reports/drivers_data_print.php" class="btn btn-warning btn-sm>">Print TFL Data</a>
                </div-->
                <div class="col-md-3">
                <a href="new_driver.php" class="btn btn-info btn-sm>">Add New Driver</a>
                </div> 
                <div class="col-md-3">
   
    <input name="delete_driver" type="submit" class="btn btn-sm btn-danger" value="Delete"/>
  
	</div>
                </div>
<table style="font-size:16px; color:#000000;" id="drivers" class="table table list_jobs table-hover table-bordered table-striped table-info" cellspacing="0" border="1">

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

                           <th>Sr No.</th>
                           <th>Driver Name</th>
                           <th>Phone</th>
                           <th>Address</th>
                           <th>Car Make/Reg</th>
                           <th>MOT Date</th>
                           <th>Ins. Exp</th>
                           <th>TFL Exp</th>
                           <th>Badge Exp.</th>
                           <th>PCO Number</th>
                           <th>PCO Expiry</th>
						   <th>Reg Plate</th>
						   <th>N. I. Number</th>
                           <th>Edit</th>
                           <th><input type="checkbox" id="select_all" /></th>
                           
          </tr>

        </thead>

        <tfoot>

            <tr class="btn-primary">
                          <th>Sr No.</th>
                           <th>Driver Name</th>
                           <th>Phone</th>
                           <th>Address</th>
                           <th>Car Make/Reg</th>
                           <th>MOT Date</th>
                           <th>Ins. Exp</th>
                           <th>TFL Exp</th>
                           <th>Badge Exp.</th>
                           <th>PCO Number</th>
                           <th>PCO Expiry</th>
						   <th>Reg Plate</th>
						   <th>N. I. Number</th>
                            <th>Edit</th>
                            <th></th>
                            
                          
            </tr>

        </tfoot>

        <tbody>
        
        <?php
				$i=1;
                while($job=mysqli_fetch_assoc($res))
   					{?>      
                  <tr class="update_job" row-id="<?php echo $job['id'];?>">
                   
                     <input type="hidden" name="id[]" value=<?php echo $job['id'];?>>
					   <td><?php echo $i;?></td>
                          <td><?php echo strtoupper($job['first_name']);?>
                            <?php if($job['driver_photo']==''){
							  $path='images/dummy.jpg';
						  }else{
						   $path="drivers/".$job['driver_photo'];
						  }?>
                          <img style="border-radius: 50%;height: 50px;width: 50px;" src="<?php echo $path;?>">
                          </td>
                           <td><?php echo $job['phone'];?></td>
                           <td><?php echo $job['address']."<br>".$job['post_code'];?></td>
                           <td><?php echo strtoupper($job['reg'])."<br>".strtoupper($job['make']);?></td>
                           <td><?php echo date("d/m/y",strtotime($job['mot_date']));?></td>
                           <td><?php echo date("d/m/y",strtotime($job['insurance_date']));?></td>
                           <td><?php echo date("d/m/y",strtotime($job['tfl_expiry']));?></td>
                           <!--td><?php //echo $job['badge_number'];?></td-->
                           <td><?php echo date("d/m/y",strtotime($job['badge_expiry']));?></td>
                           <td><?php echo $job['pco_number'];?></td>
                           <td><?php echo date("d/m/y",strtotime($job['pco_expiry']));?></td>
						   <td><?php echo $job['reg_plate'];?></td>
						   <td><?php echo $job['n_i_number'];?></td>
                           <td><a href="edit_driver.php?driver_id=<?php echo $job['driver_id'];?>&" onclick="this.href+=new Date().getTime();return true;">edit<i class="fa fa-pencil-square-o"></i></a></td>
                           <td style="text-align:right;"><input name="selected_driver[]" type="checkbox" class="checkbox selected_driver" value=<?php echo $job['driver_id'];?>></td>
                        </tr>
             
   <?php 
   $i++;
   } ?>
   		 </tbody>
			   </table>
               </form>

<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">Success</h4>
      </div>
      <div class="modal-body">
        <p>Records Updated Succesfully.</p>
      </div>
      <div class="modal-footer">
        <button id="close_me" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

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

 if(isset($_POST['delete_driver']))
			{
		
		/*	
			echo "<pre>";
  				 print_r($_POST);
			echo "</pre>";
		exit;
		*/	
		$bookingIds = $_POST;
		$count=count($_POST['selected_driver']);
		for ($i=0;$i<$count;$i++){
			$counter=1+$i;
			$index = array_search($_POST['selected_driver'][$i] ,$bookingIds['id']);
			//echo "index=".$index;
		$driver_id=$con->real_escape_string($_POST['selected_driver'][$i]);
		
		
		$DELETE_booking="DELETE FROM employees,vehicles USING employees
JOIN vehicles on vehicles.driver_id=employees.id
WHERE employees.id=$driver_id";
					  //echo $DELETE_booking;
					  if (!mysqli_query($con,$DELETE_booking)) {
							echo $update_booking;
							die('DELETE 3 INTO Bookings -Error: ' . mysqli_error($con));
							exit;
						 }
					  
		  }
		  echo '<script>alert("Record Deleted");var url11 = "list_drivers.php?"+new Date().getTime(); window.location.replace(url11)</script>';
		}
?>

	<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);
        }
    });
});
</script>