<?php 
  if (!isset($_SESSION['username'])) {
    $_SESSION['msg'] = "To access this page, Login is required";
    header('location: login.php');
  }  ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
 <title>daris Admin</title>
<style type="text/css">
* {  box-sizing: border-box;}
body {  margin: 0;}
td {  padding:8px;border-bottom: 1px solid #ddd !important; font-size: xx-small; }

th {  padding:10px;border: 1px solid #ddd !important; background:#7CB9E8; color: white; opacity: .8;text-align: left;  font-size: x-small;
 border-spacing: 1;}

table { margin: auto; border-spacing: 1; width: 100%; float: left;  }

.no-results{float: left; margin-left: 5%; color: red; font-size: small;}

table i { margin-right: 3%; }

.btn-delete {background: white; border:  1px solid red; color: red; padding: 4px;}
.btn-delete a { color: red; text-decoration: none; font-size: x-small;}

.btn-edit {background: white; border:  1px solid forestgreen;  padding: 4px;}
.btn-edit a { color:black; text-decoration: none; font-size: x-small;}


.btn-edit:hover{background:#dde; border:  1px solid none;  padding: 5px; ;opacity: .6}
.btn-delete:hover{background:#dde; border:  1px solid red;  padding: 5px; opacity: .6;}
.btn-reset:hover{background:#dde; border:  1px solid red;  padding: 5px; opacity: .6;}


</style>
</head>
<body>
<div style="" >
<?php  require_once "inc/config.php";
 $sql = "SELECT * FROM categories order by Id DESC";
   if($result = $mysqli->query($sql)){
   if($result->num_rows > 0){
   echo "<table class='table'>";
   echo "<thead>";
   echo "<tr class='t1'>";
   echo "<th>Category Id</th>";
   echo "<th>Category Code</th>";
   echo "<th>Category Name</th>";
    echo "<th>Date Added </th>";
  echo "<th>Stock Status </th>";
    echo "<th>Edit Record</th>";
   echo "<th>Remove</th>";
     echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
    while($row = $result->fetch_array()){
   echo "<tr>";
  echo "<td><i class='fa fa-shopping-basket bs'</i>      " . $row['Id'] . "</td>";
   echo "<td>" . $row['Category_code'] . "</td>";
   echo "<td>" . $row['Category_name'] . "</td>";
  echo "<td>" . date_format( new DateTime ($row['Time'] ),"d M, Y H: m: s"). "</td>";

 echo "<td>SUFFICIENT</td>";

echo "<td><button class='btn-edit'><a href='edit-product-categories.php?edit=". $row['Id'] ."' title='Edit record' data-toggle='tooltip'>Edit Record</a></button>"."</td>";

echo "<td><button class='btn-delete'><a href='del-categories.php?id=". $row['Id'] ."' title='delete Record' data-toggle='tooltip'>Remove</a></button>" ."</td>";



  echo "</tr>";
         }
    echo "</tbody>";                            
    echo "</table>";
   // Free result set
       $result->free();
            } else{ echo "<p class='no-results'><em>Opps! no records.</em></p>";}
  
   } else{ echo "ERROR: Could not able to execute $sql. " . $mysqli->error;}
   // Close connection
       $mysqli->close();?>
</div>
 </body>
</html>