<?php
error_reporting(0);
session_start();
// include("LoginCheckSuperAdmin.php");

include('header.php');
include("db_con.php");
$equipment_id = $_GET["equipment_id"];

if(!isset($_GET["equipment_id"]))
{
  echo"<tr class='alert alert-danger text-center'><td colspan='3'>Please scane QR code to access this page</td></tr>";
}
else
{
  $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>User view equipment</title>
    

</head>
<body>
<table class="table table-hover">

<!-- <div class="alert alert-success my-0" role="alert">
<a href="main.php" class="alert-link text-decoration-none">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
  <path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"/>
</svg></a>&emsp;
            <a href="" class="alert-link text-decoration-none"> Image Upload Queue</a>
</div> -->
    
    <!-- <tr style="background-color:#d1e7dd; color:#000;">
    
    
        <th>Image Upload Queue</th>
       
        <th class="text-center"></th>
       
        
    </tr> -->

    <?php
    $Qry3="SELECT * FROM `equipment` WHERE equipment_id='$equipment_id'"; 

    $Run3=mysqli_query($con,$Qry3);
    if(mysqli_num_rows($Run3)<1)
    {
        echo"<tr><td colspan='3'> No Record</td></tr>";
    }
    else
    {
      ?>
      <br>
      <div class="container">
      <div class="row row-cols-1 row-cols-md-4">
      <?php
        while($Data3=mysqli_fetch_assoc($Run3))
        {
            
            ?>


  

  <div class="col mb-4">
    <div class="card">
    <div class="card-header">
    Record ID: <?php echo $Data3["record_id"]; ?>
        
    </div>
    <img src="images\equipment\<?php echo $Data3['equipment_id'].'/'.$Data3['image']; ?>" onerror="if (this.src != 'images/default/equipment_image_not_found.jpg') this.src = 'images/default/equipment_image_not_found.jpg';" class="card-img-top" alt="...">

      <!-- <img class="card-img-top" src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=<?php echo $qr_code_url."?equipment_id=".$Data3["equipment_id"];?>&choe=UTF-8"> -->
      <div class="card-body">
        <h5 class="card-title">Title: <?php echo $Data3["title"]; ?></h5>

        <p class="card-text"><small class="text-muted">Location: <?php echo $Data3["location"]; ?><br>Type: <?php echo $Data3["equipment_type"]; ?><br>Notes: <?php echo $Data3["notes"]; ?><br>Service interval: <?php echo $Data3["service_interval"]; ?></small></p>
        <p class="card-text">Description: <?php echo $Data3["equipment_description"]; ?></p>
        
                <!-- <div class="text-right my-0" >
            <a align="right"class="btn btn-sm btn-primary text-right my-0 py-1"href="admin_view_log.php?equipment_id=<?php echo $Data3["equipment_id"]; ?>">logs</a>
        </div> -->
        <!-- <p class="card-text"><small class="text-muted">Notes: <?php echo $Data3["notes"]; ?></small></p> -->
      </div>
            <a class="btn btn-sm btn-primary m-1 py-1"href="user_view_log.php?equipment_id=<?php echo $Data3["equipment_id"]; ?>">View Logs</a>
             <a class="btn btn-sm btn-primary m-1 py-1"href="user_add_report_issue.php?equipment_id=<?php echo $Data3["equipment_id"]; ?>">Report Issue ?</a>
            <a class="btn btn-sm btn-primary m-1 py-1"href="user_add_service.php?equipment_id=<?php echo $Data3["equipment_id"]; ?>">Service ?</a>
            <a class="btn btn-sm btn-primary m-1 py-1"href="user_add_repair.php?equipment_id=<?php echo $Data3["equipment_id"]; ?>">Repair ?</a>

      <!-- <div class="card-footer">

    </div> -->
    <?php
   
?>
    </div>
  </div>


            <!-- <tr>
                
                <td rowspan=""><a class="text-decoration-none text-dark" href="images\<?php echo $Data3['equipment_id'].'/'.$Data3['image']; ?>"><img width="200px" height="150px" src="images\<?php echo $Data3['equipment_id'].'/'.$Data3['image']; ?>" alt="NOT_FOUND" style="max-width:50px"></a></td>
                <td><?php echo "Title: ".$Data3["title"]."<br>Location: ".$Data3["location"]."<br>Equipment Type: ".$Data3["equipment_type"]."<br>Equipment Description: ".$Data3["equipment_description"]."<br>Notes: ".$Data3["notes"]."<br>Service Interval: ".$Data3["service_interval"]; ?></td>
              
               
              
               
                <td rowspan="" class="text-center align-middle"><a href="DeleteOrder.php?OrderNumber=<?php echo $Data3["OrderNumber"]?>&OrderID=<?php echo $Data3["OrderID"]?>&Image=<?php echo $Data3["Image"]?>" class="btn btn-danger"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
  <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
  <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg></a></td>    
            </tr>   -->
            
           
        <?php
        }
        ?>
        </div>
        </div>
        </table>
        <?php
    }



  }
    ?>



</body>
</html>