<?php //require_once('./config.php'); ?>
<?php require_once('config_courier.php'); 
include "dbconfig.php";



$cop=$_GET['cop'];
 $invoice_no =$_GET['invoice_no'];
  if($cop=="wings")
  {
  $sql="SELECT DISTINCT 
invoices.invoice_no,invoices.date as invoice_date,

bookings.pickup_date,bookings.id as booking_id,bookings.hours,bookings.mins,bookings.pickup_address,bookings.pickup_post_code,bookings.drop_address,bookings.drop_post_code,
bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time,bookings.other,bookings.parking,bookings.transfer,
bookings.start_date,bookings.end_date,bookings.days,bookings.rate,
customers.name as company,customers.email as email,customers.address1,customers.post_code,customers.email,customers.id as company_id,

company_contact.name as passenger,

employees.first_name AS driver,vehicles.reg as reg, vehicle_make.make as make,
invoices.*
FROM `invoice_details` 
INNER JOIN bookings on invoice_details.booking_id=bookings.id
INNER JOIN customers on bookings.customer_id=customers.id
INNER JOIN company_contact on bookings.passenger_id=company_contact.id
INNER JOIN employees ON bookings.driver_id=employees.id
INNER JOIN vehicles ON vehicles.driver_id=employees.id
LEFT JOIN vehicle_make ON vehicle_make.id=bookings.vehicle_id
INNER JOIN invoices on invoice_details.invoice_no=invoices.invoice_no
WHERE invoices.invoice_no='$invoice_no'

ORDER BY bookings.pickup_date ASC, bookings.hours ASC, bookings.mins ASC
";
}
elseif($cop=="courier")
{

 $sql="SELECT DISTINCT 
invoices_wings_courier.invoice_no,invoices_wings_courier.date as invoice_date,

bookings.pickup_date,bookings.id as booking_id,bookings.hours,bookings.mins,bookings.pickup_address,bookings.pickup_post_code,bookings.drop_address,bookings.drop_post_code,
bookings.waiting_charges,bookings.fare,bookings.total_fare,bookings.waiting_time,bookings.other,bookings.parking,bookings.transfer,
bookings.start_date,bookings.end_date,bookings.days,bookings.rate,
customers.name as company,customers.address1,customers.post_code,customers.email,customers.id as company_id,

company_contact.name as passenger,

employees.first_name AS driver,vehicles.reg as reg, vehicle_make.make as make,
invoices_wings_courier.*
FROM `invoice_details_wings_courier` 
INNER JOIN bookings on invoice_details_wings_courier.booking_id=bookings.id
INNER JOIN customers on bookings.customer_id=customers.id
INNER JOIN company_contact on bookings.passenger_id=company_contact.id
INNER JOIN employees ON bookings.driver_id=employees.id
INNER JOIN vehicles ON vehicles.driver_id=employees.id
LEFT JOIN vehicle_make ON vehicle_make.id=bookings.vehicle_id
INNER JOIN invoices_wings_courier on invoice_details_wings_courier.invoice_no=invoices_wings_courier.invoice_no
WHERE invoices_wings_courier.invoice_no=$invoice_no

ORDER BY bookings.pickup_date ASC, bookings.hours ASC, bookings.mins ASC
";

}
$res=mysqli_query($con,$sql);
$rowcount=mysqli_num_rows($res);
$client=mysqli_query($con,$sql);
$invoice=mysqli_fetch_assoc($client);
//echo $invoice['gross'];
$total=0;
				$id=1;
				$total_gross=0;
				$vat=0;
				$gross=0;
				$nett=0;
				$count=0;
                while($job=mysqli_fetch_assoc($res))
				
                  {
					 
					 $booking_id = $job['booking_id'];
					 $pickup_date = date("d/m/Y",strtotime($job['pickup_date']));
					 $time = $job['hours'].":".$job['mins'];
	 				 $passenger=$job['passenger'];
					 $company=$job['company'];
					 $reg=$job['reg'];
					 
					 $make=$job['make'];
					 
					 $driver=$job['driver'];
					 $start_date=$job['start_date'];
					  $end_date=$job['end_date'];
					 $parking=$job['parking'];
					  $transfer=$job['transfer'];
					 $rate=$job['rate'];
			    	 $days=$job['days'];
					 $total_fare=$job['total_fare']; 
					 $total_gross=$total_gross+$job['total_fare'];
					 $company_id = $job['company_id'];
					 $total=$total+$job['nett'];
					 $nett=$job['nett'];
					 $vat=$job['vat'];
					 $gross=$job['gross'];
					 $count++;

               

                  }
				 // echo $gross;
				  //echo $invoice_no;
//$gross=number_format((float)$gross,2);
//$gross="1000";

?>

<!DOCTYPE html>
<html lang="en">
<head>
      <meta charset="utf-8">

      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="description" content="">
      <meta name="author" content="ThemeBucket">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
      <link rel="shortcut icon" href="images/cancrete.png">

      <title>Blank page</title>

      <!--Core CSS -->
      <link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
      <link rel="stylesheet" href="css/bootstrap.css">
      <link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
      <link href="css/style-responsive.css" rel="stylesheet" />
      
      <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Coda+Caption:800|Pacifico|Hind|Anton|Chewy|Bangers|Montserrat:400,700' rel='stylesheet' type='text/css'>
</head>
  <body class="login-body">

    <div class="container" id="login_box">

      <div class="form-signin" >
      <div id="message">
        <h2 class="form-signin-heading">Wings Couriers Ltd.</h2>
      </div>  
        <div class="login-wrap">
            <!--div class="user-login-info">
            	Enter Your User Name
                <input id="user_name" type="text" class="form-control" name="user_name" placeholder="User ID" autofocus onKeyPress="return textonly(event);">
                Enter Your PIN (Numeric Only)
                <input id="pin" maxlength="5" type="password" class="input_text form-control" name="pin" placeholder="Enter Your 5 Numbers PIN" onKeyPress="return numericonly(event);">
            </div-->
          <!--
            <label class="checkbox">
                <input type="checkbox" value="remember-me"> Remember me
                <span class="pull-right">
                    <a data-toggle="modal" href="#myModal"> </a>

                </span>
            </label>
           -->
           <label><h2>Total : &pound;<?php echo $gross; ?></h2></label>
			<form action="charge_courier.php" method="post">
			<input type="hidden" name="invoice_no" id="invoice_no"  value="<?php echo $invoice_no; ?>" />
			<input type="hidden" name="cop" id="cop"  value="<?php echo $cop; ?>" /> 
			<input type="hidden" name="stripe_amount" id="stripe_amount"  value="<?php echo $gross; ?>" /> 
			<div align="center">
  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<?php echo $stripe['publishable_key']; ?>"
          data-amount="<?php echo $gross*100; ?>" data-description="Wings Chauffeurs Ltd."
		   data-currency="GBP"></script>
		  </div>
</form>
<!--
            <div class="registration">
                Don't have an account yet?
                <a class="" href="registration.html">
                    Create an account
                </a>
            </div>
-->
        </div>

         

      </div>

    </div>
	
	


</body>
</html>