<?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: 760px;background-image: url(&quot;assets/img/star-sky.jpg&quot;);">
  <div class="form-container" style="padding-top:60px">
  <div class="card" style=" max-width:100%; width:100%; margin:auto; border-radius:20px;">
  <div class="card-header">
    <?php
    $name = mysqli_query($conn, "SELECT car from cars where car='$_POST[car]'");
    $get = mysqli_fetch_array($name);
    ?>
    <h5 class="mb-0" style="float:left;"><?php echo $get['car']?>'Profile</h5>
  </div>
  <div class="card-body" style="overflow-y:scroll; overflow-x:hidden;">
    <table class="table table-striped" >


      <tr>
        <th>Date</th><th>Username</th><th>Client</th><th>Job/Employee Number</th><th>Start Mileage</th><th>End Mileage</th><th>Fueling</th><th>Expense Account</th>
      </tr>
      <tr>
      <?php  $result = mysqli_query($conn, "SELECT * FROM trips WHERE car='$_POST[car]'ORDER BY id DESC");
       while($row = mysqli_fetch_array($result)){?>
      <tr>
        <td><?php echo $row['date'];?></td>
        <td><?php echo $row['username'];?></td>
        <td><?php echo $row['client'];?></td>
        <td><?php echo $row['job'];?></td>
        <td><?php echo $row['start_mileage'];?></td>
        <td><?php echo $row['end_mileage'];?></td>
        <td><span style="font-weight:bold; color:red;">
          <?php
            if($row['station_mileage'] > 0){
              echo $row['station_mileage'];
            }
          ?>
        </span></td>
        <form action="car-profile.php" method="POST">
        <td><?php
        if(!empty($row['expense_account'])){
          echo $row['expense_account'];
        }else{?><input type="text" name="expense_account" placeholder="Expense Account"><?php } ?></td>
        <?php } ?>
      </tr>
</div>
<input type="hidden" name="car" value="<?php echo $get['car']?>">
<input type="submit" name="update" value="Car Profile" class="btn btn-success">
</form>
    </table>


  </div>

</div>
</body>

</html>
