<?php

error_reporting(0);
include('header.php');
include("db_con.php");
// include("login_check_admin.php");
session_start();

$equipment_id = $_GET["equipment_id"];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>





<div class="container">

<form action="customer_list.php" method="post">
<div class="input-group mb-3">
  <input type="text" class="form-control" name="email" placeholder="xyz@gmail.com" aria-label="Recipient's username" aria-describedby="basic-addon2">
  <div class="input-group-append">
  <!-- <button class="btn btn-primary" type="button" id="button-addon2">Search</button> -->
  <input class="btn btn-primary" type="submit" value="Search" name="search">
  </div>
  </form>
</div>

<br>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block">Reports</button> -->



<table class="table table-hover">
  <thead class="thead-success">
    <tr>
      <th scope="col">First Name</th>
      <th scope="col">Last Name</th>
      <th scope="col">Address</th>
      <th scope="col">Phone</th>
      <th scope="col">Email</th>
      <th scope="col">Birthdate</th>
    </tr>
  </thead>
 
  <?php
 

   $Qry3="SELECT * FROM `log`  WHERE equipment_id = '$equipment_id'";


   if(isset($_POST["search"]))
    {
      $email = $_POST["email"];
      $Qry3="SELECT * FROM `customer` WHERE `email`='$email'";
      ?>
        <script>      
          if ( window.history.replaceState ) 
            {
              window.history.replaceState( null, null, window.location.href );
            }
        </script>
        <?php
        unset($_POST["search"]);     
    }


    $Run3=mysqli_query($con,$Qry3);
    if(mysqli_num_rows($Run3)<1)
    {
        echo"query failed";
        echo"<tr><td colspan='3'> No Record</td></tr>";
    }
    else
    {
      // echo"query run";
        $count=0;
        // $Data3=mysqli_fetch_assoc($Run3);
        while($Data3=mysqli_fetch_assoc($Run3))
        {
            $count++;
            ?>
           
            <tr <?php if($_GET["customer_id"] == $Data3["customer_id"]){echo 'class = "table-success"';}?> onclick="location.href = 'customer_detail.php?customer_id=<?php echo $Data3['customer_id']; ?>'">      
                <td><?php echo $Data3["first_name"]; ?></td>
                <td><?php echo $Data3["last_name"]; ?></td>
                <td><?php echo $Data3["address"]; ?></td>
                <td><?php echo $Data3["phone"]; ?></td>
                <td><?php echo $Data3["email"]; ?></td>
                <td><?php echo $Data3["birthdate"]; ?></td>   
                
            </tr>  
              
            
           
        <?php
        }
    }
    ?>

  </tbody>
</table>

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