<?php
include("db.php");
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>Driver Logbook</title>
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/Registration-Form-with-Photo.css">
    <link rel="stylesheet" href="assets/css/styles.css">
</head>
<div class="login-clean" style="height: 660px;background-image: url(&quot;assets/img/star-sky.jpg&quot;);">
  <div class="form-container" style="padding-top:60px">
  <div class="card" style=" max-width:900px; width:80%; margin:auto; border-radius:20px;">

  <div class="card-header">
    <h5 class="mb-0" style="text-align:left;">Start Trips</h5>
    <input type="hidden" name="date" value="<?php echo date("Y-m-d")?>"></h5>
  </div>
  <div class="card-body">
      <?php
      $result = mysqli_query($conn, "SELECT car FROM cars WHERE car='$_POST[car]'");
      $car = mysqli_fetch_array($result);
?>
  <form action="trips2.php" method="POST">
  <h3 class="mb-0" style="text-align:left"><span style="margin-left:250px"></span>You are using <?php echo $car['car']?></h3>
  <div class="form-group"><input type="date" name="date" class="form-control" style="margin: 0 auto;width:50%;"></div>
    <?php
    $name2 = mysqli_query($conn, "SELECT * FROM users");
    $row2 = mysqli_fetch_array($name2);
    $name = mysqli_query($conn, "SELECT * FROM users");?>
    <div class="form-group"><select name="username" class="form-control" >
      <option>--Select username--</option>
      <?php while($row = mysqli_fetch_array($name)){?>
        <option><?php echo $row['username']?><option>

        <?php }?>
        </select>
    </div>

      <div class="form-group"><input class="form-control" type="text"  required name="client" placeholder="Client Name"></div>
      <?php
        $get = mysqli_query($conn, "SELECT * FROM users");
        $getid = mysqli_fetch_array($get);
      ?>
      <div class="form-group"><input class="form-control" type="number"  required maxlength="6" name="job" placeholder="Job Number"></div>
      <div class="form-group"><textarea class="form-control" type="text" required name="description" placeholder="Description"></textarea></div>
      <div class="form-group"><input class="form-control" required type="text" name="destination" placeholder="Destination"></div>
      <h3 style="margin-top:5px;">Fueling</h3><br>
      <div class="input-group" style="margin-top:-20px; border:2px solid red; padding:5px">
      <input type="number" class="form-control"  name="station_mileage" placeholder="Mileage"/>
        <span class="input-group-addon">-</span>
        <input type="text" class="form-control" name="amount" placeholder="Amount"/>
        <span class="input-group-addon">-</span>
        <input type="text" class="form-control" name="litres" placeholder="Litres"/>
      </div>
      <p class="mb-0">First leg time</p><br>
      <div class="input-group" style="margin-top:-20px;">
      <input type="time" class="form-control" name="start_time"  placeholder="Start-Time"/>
        <span class="input-group-addon">-</span>
        <input type="time" class="form-control" name="end_time"  placeholder="End-Time"/>
      </div>
      <p class="mb-0">Second leg time</p><br>
      <div class="input-group" style="margin-top:-20px;">
        <?php

          $miles = mysqli_query($conn, "SELECT end_mileage FROM trips WHERE car='$_POST[car]' ORDER BY id DESC LIMIT 1");
          $get = mysqli_fetch_array($miles);
        ?>
      <input type="time" class="form-control" name="start_time2" value="00:00" placeholder="Start-Time"/>
        <span class="input-group-addon">-</span>
        <input type="time" class="form-control" name="end_time2" value="00:00" placeholder="End-Time"/>
      </div><br>
      <div class="input-group">
        <input type="number" class="form-control" required name="start_mileage" value="<?php

        echo $get['end_mileage']?>"/>
        <span class="input-group-addon">-</span>
        <input type="number" class="form-control" name="end_mileage" required placeholder="End-Mileage"/>
      </div>
        <input type="hidden" name="car" value="<?php echo $car['car']?>">
    <input type="submit" name="submit" value="Start" class="btn btn-primary btn-block"  style="background-color: rgb(7,166,128); margin-left:250px; margin-top:30px; width:40%">

  </form>


  </div>
</div>
</body>

</html>
