
<meta charset="utf-8">

<title>List of Orders</title>
<!doctype html>

<html>

<head>




 </head>
  <?php

include "../dbconfig.php";
 $today= date('Y-m-d');
//Get the order data for this order.
if(isset($_POST['filter_search'])){
	$condition='';
	$drop_post_code='';
	$driver='';
	$passenger='';
	$name='';
	$pickup_date="";
	$from="";
	$to="";
	$pickup_post_code="";
	$pickup_post_code="";
	if (!empty($_POST['pickup_date']))
	{
	  $pickup_date=$con->real_escape_string($_POST['pickup_date']);
	  $pickup_date = str_replace("/","-",$pickup_date);
	  $pickup_date = date("Y-m-d", strtotime($pickup_date));
	}else
	{
		
	$pickup_date="";
	}
	if (!empty($_POST['from']))
	{
	  $from=$con->real_escape_string($_POST['from']);
	  $from = str_replace("/","-",$from);
	  $from = date("Y-m-d", strtotime($from));
	}else
	{
	$from=date('Y-m-d', strtotime("-15 days"));
	}
	if (!empty($_POST['to']))
	{
	  $to=$con->real_escape_string($_POST['to']);
	  $to = str_replace("/","-",$to);
	  $to = date("Y-m-d", strtotime($to));
	}else
	{
    $to=date('Y-m-d', strtotime("+15 days"));
	
	}
	if (!empty($_POST['pickup_post_code']))
	{
	  $pickup_post_code=$con->real_escape_string($_POST['pickup_post_code']);
	  
	}
	if (!empty($_POST['drop_post_code']))
	{
	  $drop_post_code=$con->real_escape_string($_POST['drop_post_code']);
	  
	}
	if (!empty($_POST['name']))
	{
	  $name=$con->real_escape_string($_POST['name']);
	  
	 
	}
	
	if (!empty($_POST['driver']))
	{
	  $driver=$con->real_escape_string($_POST['driver']);
	  
	}
	if (!empty($_POST['passenger']))
	{
	  $passenger=$con->real_escape_string($_POST['passenger']);
	  
	}
	
$sql="SELECT bookings.pickup_date,bookings.id AS booking_id,bookings.comments, 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,
customers.id AS customer_id, customers.name AS customer_name,customers.address1,customers.post_code,customers.city, customers.mobile, employees.first_name AS driver,employees.id as driver_id, vehicles.make as vehicle, company_contact.name as company_contact,company_contact.email
FROM bookings 
LEFT JOIN customers ON bookings.customer_id = customers.id 
LEFT JOIN employees ON bookings.driver_id = employees.id 
LEFT JOIN vehicles ON bookings.vehicle_id = vehicles.id 
LEFT JOIN company_contact ON bookings.passenger_id = company_contact.id 

WHERE 
bookings.job_status=2
AND bookings.pickup_date BETWEEN '$from' AND '$to' 
AND bookings.pickup_post_code LIKE '$pickup_post_code%' 
AND bookings.drop_post_code LIKE '$drop_post_code%' 
AND company_contact.name LIKE '$passenger%'
AND customers.name LIKE '$name%' 
AND employees.first_name LIKE '$driver%'
GROUP BY  bookings.id
ORDER BY bookings.id DESC";

//echo $sql;
  if (!mysqli_query($con,$sql)) 
				  { 	
					  
					  die('SELECT 1 SQL SAID -Error: ' . mysqli_error($con));
				  }
	else
	{
$res=mysqli_query($con,$sql);
	}

}

?>
<body style="font-family:Montserrat; font-size:16px;">


   <?php include "list_jobs_data.php";?>
   
<style type="text/css">
    @media screen and (min-width: 768px) {
        .modal-dialog {
          width: 700px; /* New width for default modal */
        }
        .modal-sm {
          width: 350px; /* New width for small modal */
        }
    }
    @media screen and (min-width: 992px) {
        .modal-lg {
          width: 1050px; /* New width for large modal */
        }
    }
</style>

<!-- Delete Modal -->
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Confirm Cancellation?</h4>
                </div>
            
                <div class="modal-body">
                    <p style="background-color:#EF0E12; color:white; font-size:20px;">Are you 100% Sure and Manager has Authorised?<img width="100" height="100" src="images/delete.png" class="img-thumbnail responsive">
                    </p>
                    
                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-dismiss="modal">I am not Sure</button>
                    <a class="btn btn-danger btn-ok">I am sure - Cancel Job </a>
                </div>
            </div>
        </div>
    </div>
<!-- Delete Modal Ends -->

<!-- Delete Modal -->
<div class="modal fade" id="job_done" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">You Sure ?</h4>
                </div>
            
                <div class="modal-body">
                    <p style="background-color:#EF0E12; color:white; font-size:20px;">This Job is Aleady Updated. Please check Job Again.
                    </p>
                    
                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-dismiss="modal">close This Screen</button>
                </div>
            </div>
        </div>
    </div>
<!-- Delete Modal Ends -->
</body>
</html>