<?php
session_start();
if(isset($_SESSION['User'])){
include ("db.php");
$selectedUsername = $_POST['username'] ?? $_GET['username'] ?? '';
$selectedCar = $_POST['car'] ?? $_GET['car'] ?? '';
$tripCreated = false;

if(isset($_POST['newtrip'])){
  $username = $_POST['username'];
  $car = $_POST['car'];
  $selectedUsername = $username;
  $selectedCar = $car;
  $client = $_POST['client'];
    if(empty($_POST['job'])){
      $job = $_POST['employeecode'];
  }else{
  $job = $_POST['job'];
  }
  $description = $_POST['description'];
  $destination = $_POST['destination'];
  $starttime = $_POST['start_time'];
  $endtime = $_POST['end_time'];
  $starttime2 = $_POST['start_time2'];
  $endtime2 = $_POST['end_time2'];
  $startmileage = $_POST['start_mileage'];
  $endmileage = $_POST['end_mileage'];
  $station = $_POST['station_mileage'];
  $stationmileage = $_POST['station_mileage'];
  $amount = $_POST['amount'];
  $litres = $_POST['litres'];
  $expense = $_POST['expense_account'];
  $date = $_POST['date'];
  $empty = '';
  $empty2 = ' 0 ';
  $empty3 = '';
  $empty4 = '';
  $empty5 = '';

  if($stationmileage > 0){
    $result = "INSERT INTO trips(username,car,client,job,description,destination,date,start_time,end_time,start_time2,end_time2,start_mileage,end_mileage,station_mileage,amount,litres,expense_account)
    VALUES('$username','$car','$client','$job','$description','$destination','$date','$starttime','$endtime','$starttime2','$endtime2','$startmileage','$stationmileage','$station','$amount','$litres','$empty');";
    $result2= "INSERT INTO trips(username,car,client,job,description,destination,date,start_time,end_time,start_time2,end_time2,start_mileage,end_mileage,station_mileage,amount,litres,expense_account)
    VALUES('$username','$car','$client','$job','$description','$destination','$date','$starttime','$endtime','$starttime2','$endtime2','$stationmileage','$endmileage','$empty2','$empty3','$empty4','$empty5');";
    $tripCreated = $conn->query($result) === TRUE && $conn->query($result2) === TRUE;

  }else{
    $result3 = "INSERT INTO trips(username,car,client,job,description,destination,date,start_time,end_time,start_time2,end_time2,start_mileage,end_mileage,station_mileage,amount,litres,expense_account)
    VALUES('$username','$car','$client','$job','$description','$destination','$date','$starttime','$endtime','$starttime2','$endtime2','$startmileage','$endmileage','$empty2','$empty3','$empty4','$empty5');";
    $tripCreated = $conn->query($result3) === TRUE;
  }

}


?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png">
  <link rel="icon" type="image/png" href="./assets/img/favicon.png">
  <title>
   Dicomm Driver Logbook
  </title>
  <!--     Fonts and icons     -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
  <!-- Nucleo Icons -->
  <link href="./assets/css/nucleo-icons.css" rel="stylesheet" />
  <link href="./assets/css/nucleo-svg.css" rel="stylesheet" />
  <!-- Font Awesome Icons -->
  <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
  <link href="./assets/css/nucleo-svg.css" rel="stylesheet" />
  <!-- CSS Files -->
  <link id="pagestyle" href="./assets/css/soft-ui-dashboard.css?v=1.0.1" rel="stylesheet" />
  <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css"/>
<link href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap5.min.css"/>

  <script src="https://kit.fontawesome.com/06d73363bc.js" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
<script>
    $(document).ready(function () {
    $('#example').DataTable({
    "ordering": false
});
});
</script>
</head>

<body class="g-sidenav-show  bg-gray-100">
<aside class="sidenav navbar navbar-vertical navbar-expand-xs border-0 border-radius-xl my-3 fixed-left ms-3" id="sidenav-main">
    <div class="sidenav-header">
      <i class="fas fa-times p-3 cursor-pointer text-secondary opacity-5 position-absolute right-0 top-0 d-none d-xl-none" aria-hidden="true" id="iconSidenav"></i>
      <a class="navbar-brand m-0" href="dashboard.php">
       
        <h6 class="ms-1 font-weight-bold text-info">Dicomm Driver Logbook</h6>
      </a>
    </div>
    <hr class="horizontal dark mt-0">
    <div class="collapse navbar-collapse  w-auto" id="sidenav-collapse-main">
      <ul class="navbar-nav">
        <li class="nav-item ">
          <a class="nav-link" href="dashboard.php">
            <div class="icon icon-shape  icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
              <svg width="12px" height="12px" viewBox="0 0 45 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                <title>shop </title>
                <g id="Basic-Elements" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                  <g id="Rounded-Icons" transform="translate(-1716.000000, -439.000000)" fill="#FFFFFF" fill-rule="nonzero">
                    <g id="Icons-with-opacity" transform="translate(1716.000000, 291.000000)">
                      <g id="shop-" transform="translate(0.000000, 148.000000)">
                        <path class="color-background" d="M46.7199583,10.7414583 L40.8449583,0.949791667 C40.4909749,0.360605034 39.8540131,0 39.1666667,0 L7.83333333,0 C7.1459869,0 6.50902508,0.360605034 6.15504167,0.949791667 L0.280041667,10.7414583 C0.0969176761,11.0460037 -1.23209662e-05,11.3946378 -1.23209662e-05,11.75 C-0.00758042603,16.0663731 3.48367543,19.5725301 7.80004167,19.5833333 L7.81570833,19.5833333 C9.75003686,19.5882688 11.6168794,18.8726691 13.0522917,17.5760417 C16.0171492,20.2556967 20.5292675,20.2556967 23.494125,17.5760417 C26.4604562,20.2616016 30.9794188,20.2616016 33.94575,17.5760417 C36.2421905,19.6477597 39.5441143,20.1708521 42.3684437,18.9103691 C45.1927731,17.649886 47.0084685,14.8428276 47.0000295,11.75 C47.0000295,11.3946378 46.9030823,11.0460037 46.7199583,10.7414583 Z" id="Path" opacity="0.598981585"></path>
                        <path class="color-background" d="M39.198,22.4912623 C37.3776246,22.4928106 35.5817531,22.0149171 33.951625,21.0951667 L33.92225,21.1107282 C31.1430221,22.6838032 27.9255001,22.9318916 24.9844167,21.7998837 C24.4750389,21.605469 23.9777983,21.3722567 23.4960833,21.1018359 L23.4745417,21.1129513 C20.6961809,22.6871153 17.4786145,22.9344611 14.5386667,21.7998837 C14.029926,21.6054643 13.533337,21.3722507 13.0522917,21.1018359 C11.4250962,22.0190609 9.63246555,22.4947009 7.81570833,22.4912623 C7.16510551,22.4842162 6.51607673,22.4173045 5.875,22.2911849 L5.875,44.7220845 C5.875,45.9498589 6.7517757,46.9451667 7.83333333,46.9451667 L19.5833333,46.9451667 L19.5833333,33.6066734 L27.4166667,33.6066734 L27.4166667,46.9451667 L39.1666667,46.9451667 C40.2482243,46.9451667 41.125,45.9498589 41.125,44.7220845 L41.125,22.2822926 C40.4887822,22.4116582 39.8442868,22.4815492 39.198,22.4912623 Z" id="Path"></path>
                      </g>
                    </g>
                  </g>
                </g>
              </svg>
            </div>
            <span class="nav-link-text ms-1">Dashboard</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link  " href="driver-list.php">
            <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
              <svg width="12px" height="12px" viewBox="0 0 42 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                <title>office</title>
                <g id="Basic-Elements" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                  <g id="Rounded-Icons" transform="translate(-1869.000000, -293.000000)" fill="#FFFFFF" fill-rule="nonzero">
                    <g id="Icons-with-opacity" transform="translate(1716.000000, 291.000000)">
                      <g id="office" transform="translate(153.000000, 2.000000)">
                        <path class="color-background" d="M12.25,17.5 L8.75,17.5 L8.75,1.75 C8.75,0.78225 9.53225,0 10.5,0 L31.5,0 C32.46775,0 33.25,0.78225 33.25,1.75 L33.25,12.25 L29.75,12.25 L29.75,3.5 L12.25,3.5 L12.25,17.5 Z" id="Path" opacity="0.6"></path>
                        <path class="color-background" d="M40.25,14 L24.5,14 C23.53225,14 22.75,14.78225 22.75,15.75 L22.75,38.5 L19.25,38.5 L19.25,22.75 C19.25,21.78225 18.46775,21 17.5,21 L1.75,21 C0.78225,21 0,21.78225 0,22.75 L0,40.25 C0,41.21775 0.78225,42 1.75,42 L40.25,42 C41.21775,42 42,41.21775 42,40.25 L42,15.75 C42,14.78225 41.21775,14 40.25,14 Z M12.25,36.75 L7,36.75 L7,33.25 L12.25,33.25 L12.25,36.75 Z M12.25,29.75 L7,29.75 L7,26.25 L12.25,26.25 L12.25,29.75 Z M35,36.75 L29.75,36.75 L29.75,33.25 L35,33.25 L35,36.75 Z M35,29.75 L29.75,29.75 L29.75,26.25 L35,26.25 L35,29.75 Z M35,22.75 L29.75,22.75 L29.75,19.25 L35,19.25 L35,22.75 Z" id="Shape"></path>
                      </g>
                    </g>
                  </g>
                </g>
              </svg>
            </div>
            <span class="nav-link-text ms-1">All drivers</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link  " href="car-list.php">
            <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
              <svg width="12px" height="12px" viewBox="0 0 43 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                <title>credit-card</title>
                <g id="Basic-Elements" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                  <g id="Rounded-Icons" transform="translate(-2169.000000, -745.000000)" fill="#FFFFFF" fill-rule="nonzero">
                    <g id="Icons-with-opacity" transform="translate(1716.000000, 291.000000)">
                      <g id="credit-card" transform="translate(453.000000, 454.000000)">
                        <path class="color-background" d="M43,10.7482083 L43,3.58333333 C43,1.60354167 41.3964583,0 39.4166667,0 L3.58333333,0 C1.60354167,0 0,1.60354167 0,3.58333333 L0,10.7482083 L43,10.7482083 Z" id="Path" opacity="0.593633743"></path>
                        <path class="color-background" d="M0,16.125 L0,32.25 C0,34.2297917 1.60354167,35.8333333 3.58333333,35.8333333 L39.4166667,35.8333333 C41.3964583,35.8333333 43,34.2297917 43,32.25 L43,16.125 L0,16.125 Z M19.7083333,26.875 L7.16666667,26.875 L7.16666667,23.2916667 L19.7083333,23.2916667 L19.7083333,26.875 Z M35.8333333,26.875 L28.6666667,26.875 L28.6666667,23.2916667 L35.8333333,23.2916667 L35.8333333,26.875 Z" id="Shape"></path>
                      </g>
                    </g>
                  </g>
                </g>
              </svg>
            </div>
            <span class="nav-link-text ms-1">All cars</span>
          </a>
        </li>
        

        <li class="nav-item">
          <a class="nav-link  " href="driver-list.php">
            <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
              <svg width="12px" height="12px" viewBox="0 0 42 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                <title>office</title>
                <g id="Basic-Elements" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                  <g id="Rounded-Icons" transform="translate(-1869.000000, -293.000000)" fill="#FFFFFF" fill-rule="nonzero">
                    <g id="Icons-with-opacity" transform="translate(1716.000000, 291.000000)">
                      <g id="office" transform="translate(153.000000, 2.000000)">
                        <path class="color-background" d="M12.25,17.5 L8.75,17.5 L8.75,1.75 C8.75,0.78225 9.53225,0 10.5,0 L31.5,0 C32.46775,0 33.25,0.78225 33.25,1.75 L33.25,12.25 L29.75,12.25 L29.75,3.5 L12.25,3.5 L12.25,17.5 Z" id="Path" opacity="0.6"></path>
                        <path class="color-background" d="M40.25,14 L24.5,14 C23.53225,14 22.75,14.78225 22.75,15.75 L22.75,38.5 L19.25,38.5 L19.25,22.75 C19.25,21.78225 18.46775,21 17.5,21 L1.75,21 C0.78225,21 0,21.78225 0,22.75 L0,40.25 C0,41.21775 0.78225,42 1.75,42 L40.25,42 C41.21775,42 42,41.21775 42,40.25 L42,15.75 C42,14.78225 41.21775,14 40.25,14 Z M12.25,36.75 L7,36.75 L7,33.25 L12.25,33.25 L12.25,36.75 Z M12.25,29.75 L7,29.75 L7,26.25 L12.25,26.25 L12.25,29.75 Z M35,36.75 L29.75,36.75 L29.75,33.25 L35,33.25 L35,36.75 Z M35,29.75 L29.75,29.75 L29.75,26.25 L35,26.25 L35,29.75 Z M35,22.75 L29.75,22.75 L29.75,19.25 L35,19.25 L35,22.75 Z" id="Shape"></path>
                      </g>
                    </g>
                  </g>
                </g>
              </svg>
            </div>
            <span class="nav-link-text ms-1">All drivers</span>
          </a>
        </li>
        
        
        
      </ul>
    </div>
    
  </aside>
  <main class="main-content mt-1 border-radius-lg">
    <!-- Navbar -->
   
        
      </div>
    </nav>
    <!-- End Navbar -->
   <div class="container-fluid "> 
   <div class="page-header min-height-200 border-radius-xl mt-4" style="background-image: url('./img/background.jpg'); background-size:cover; ">
       
      </div>
      <div class="card card-body blur shadow-blur mx-4 mt-n6">
        <div class="row gx-4">
          <div class="col-auto">
            
          </div>

    <?php
        if($selectedUsername === '' || $selectedCar === ''){
          header("Location: driver-list.php");
          exit;
        }
        $query = mysqli_query($conn, "SELECT * FROM users WHERE username = '$selectedUsername' ");
        $details = mysqli_fetch_array($query);
        $displayUsername = $details['username'] ?? $selectedUsername;
        $employeeCode = $details['code'] ?? '';
    ?>


          <div class="col-auto my-auto">
            <div class="h-150">
              <h5 class="mb-1">
               <?php echo $displayUsername?>
              </h5>
              <p class="mb-0 font-weight-bold text-sm">
               Trips for
                <span class="ms-1"><?php echo $selectedCar?></span>
              </p>
            </div>
          </div>
          <div class="col-sm-4 col-8 my-sm-auto ms-sm-auto me-sm-0 mx-auto mt-3">
            <div class="nav-wrapper position-relative end-0">
              <ul class="nav nav-pills nav-fill p-1 bg-transparent justify-content-between" role="tablist">
                <li class="nav-item">
                <button type="button" class="btn btn-info" data-bs-toggle="modal" data-bs-target="#exampleModal">
                     Record Trip
                </button>

                  
                  </a>
                </li>
                <li class="nav-item">
                   <form action="driver-profile.php" method="POST">
                       <input type="hidden" name="username" value="<?php echo $selectedUsername?>">
                       <input type="submit" value="Back to profile" class="btn btn-dark">
                   </form>
                </li>
                
              </ul>
            </div>
          </div>
        </div>
      </div>
      </div>
  
    </div><br><br>
    <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Recording trip for <?php echo $selectedUsername?><br>Car used: <?php echo $selectedCar?></h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <form action="driver-profile-trips.php" method="post">
      <div class="modal-body">
        <label class="text-xxs">Client</label>
        <select name="client" class="form-control" id="">
          <option value="">Select Client</option>
          <?php
            $getclients = mysqli_query($conn, "SELECT * FROM clients");
            while($client = mysqli_fetch_array($getclients)){
                $getstartmileage = mysqli_query($conn, "SELECT end_mileage FROM trips WHERE car = '$selectedCar' ORDER BY end_mileage DESC LIMIT 1");
                    $startmileage = mysqli_fetch_array($getstartmileage);
              ?>
              <option value="<?php echo $client['name']?>"><?php echo $client['name']?></option>
            <?php
            }
          ?>
        </select>
          <label class="text-xxs">Job number</label>
           <input type="number" class="form-control" name="job" >
           <label class="text-xxs">Expense account</label>
           <input type="text" class="form-control" name="expense_account" >
           <label class="text-xxs">Description</label>
            <input type="text" class="form-control" name="description" >
            <label class="text-xxs">Destination</label>
             <input type="text" class="form-control" name="destination" >
             <label class="text-xxs">Date</label>
              <input type="date" class="form-control" name="date" >
              <label class="text-xxs">1st leg start time</label>
               <input type="time" class="form-control" name="start_time" >
               <label class="text-xxs">1st leg end time</label>
                <input type="time" class="form-control" name="end_time" >
                <label class="text-xxs">2nd leg start time</label>
                 <input type="time" class="form-control" name="start_time2" >
                 <label class="text-xxs">2nd leg end time</label>
                  <input type="time" class="form-control" name="end_time2" >
                  <label class="text-xxs">Start mileage</label>
                   <input type="number" class="form-control" name="start_mileage" value="<?php echo $startmileage['end_mileage']?>" >
                   <label class="text-xxs">End mileage</label>
                    <input type="number" class="form-control" name="end_mileage" >
                    <label class="text-xxs">Station mileage</label>
                     <input type="number" class="form-control" name="station_mileage" >
                     <label class="text-xxs">Amount</label>
                      <input type="number" step="any" class="form-control" name="amount" >
                      <label class="text-xxs">Litres</label>
                       <input type="number" step="any" class="form-control" name="litres" >
      
      </div>
      
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <input type="hidden" name="employeecode" value="<?php echo $employeeCode?>">
        <input type="hidden" name="car" value="<?php echo $selectedCar?>">
        <input type="hidden" name="username" value="<?php echo $selectedUsername?>">
        <input type="submit" name="newtrip" class="btn btn-primary" value="Save trip">
        </form>
      </div>
    </div>
  </div>
</div>






    <div class="card-body px-0 pt-0 pb-2">
       <?php 
       if(isset($_POST['delete'])){
    $id = $_POST['id'];
    $delete = mysqli_query($conn, "DELETE FROM trips WHERE id = '$id'");
     if ($delete) {?>
   <div class="alert alert-success col-5 mx-auto justify-space-between" role="alert">
  Trip with id (#<?php echo $_POST['id']?>) deleted successfully
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php }
}

  if ($tripCreated) {
 ?>
 <div class="alert alert-success col-3 mx-auto justify-space-between" role="alert">
  Trip created successfully
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
 <?php
} 
?>
              <div class="table-responsive p-0 w-90 mx-auto">
                <table id="example" class="table align-items-center mb-0">
                  <thead>
                    <tr>
                      <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Date</th>
                      <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">Client</th>                 
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Job/Employee No.</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Start Mileage</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">End Mileage</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Distance</th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7"></th>
                      <th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7"></th>

                    </tr>
                  </thead>
                  <tbody>
                  <?php  $result = mysqli_query($conn, "SELECT * FROM trips WHERE username='$selectedUsername' and car = '$selectedCar' ORDER BY id DESC");
    while($row = mysqli_fetch_array($result)){
    $mileage = $row['end_mileage'] - $row['start_mileage'];?>
                    <tr>
                      <td>
                        <div class="d-flex px-2 py-1">
                         
                          <div class="d-flex flex-column justify-content-center">
                            <h6 class="mb-0 text-sm"><?php echo $row['date']?></h6>
                            
                          </div>
                        </div>
                      </td>
                      <td>
                        <p class="text-xs font-weight-bold mb-0 " ><?php echo $row['client']?></p>
                        
                      </td>
                      <td>
                        <p class="text-xs font-weight-bold mb-0" style="text-align:center"><?php echo $row['job']?></p>
                        
                      </td>
                      <td>
                        <p class="text-xs font-weight-bold mb-0" style="text-align:center"><?php echo $row['start_mileage']?></p>
                        
                      </td>
                      <td>
                        <p class="text-xs font-weight-bold mb-0" style="text-align:center"><?php echo $row['end_mileage']?></p>
                        
                      </td>
                      <td>
                        <p class="text-xs font-weight-bold mb-0" style="text-align:center"><?php echo $mileage?></p>
                        
                      </td>
                      <td class="d-flex justify-space-between">
                     <form action="update-trip.php" method="POST">
                      <input type="hidden" name="id" value="<?php echo $row['id']?>">
                        <input type="submit" name="view-trip" value="View trip" class="btn btn-info">
                     </form>
                     </td>
                     <td>
                     <form action="driver-profile-trips.php" method="POST">
                      <input type="hidden" name="id" value="<?php echo $row['id']?>">
                      <input type="hidden" name="username" value="<?php echo $selectedUsername?>">
                      <input type="hidden" name="car" value="<?php echo $row['car']?>">
                        <input type="submit" name="delete" value="X" class="btn btn-danger col-2 text-center">
                     </form>
                      </td>
                    </tr>
                        <?php } ?>

        </div>
  </main>
  

</body>
<?php
  }else{
    header("Location: index.php");
  }
    

?>
