<?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>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 #7CB9E8 !important; background:white; color: #7CB9E8; 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 { margin-right: 3%; height: 60%; width: 95%; margin: auto; overflow-x: auto;scrollbar-width: thin; }

</style>
</head>
<body>
<div class='table'>
<?php  require_once "inc/config.php";
 $sql = "SELECT * FROM product_sales where time >= CURDATE() AND YEAR(time) = YEAR(CURRENT_DATE) order by time DESC";
   if($result = $mysqli->query($sql)){
   if($result->num_rows > 0){
   echo "<table >";
   echo "<thead>";
   echo "<tr class='t1'>";
   echo "<th>Customer Name</th>";
   echo "<th>items released</th>";
  echo "<th>Item Size</th>";
   echo "<th>Quantity</th>";
    echo "<th>Unit price</th>";
  echo "<th>Total Price</th>";
    // echo "<th>Served by</th>";
   echo "<th>Time</th>";
     echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
    while($row = $result->fetch_array()){
   echo "<tr>";
  echo "<td>" . $row['customer'] . "</td>";
   echo "<td>" . $row['name'] . "</td>";
   echo "<td>" . $row['size'] . "</td>";
   echo "<td>" . $row['quantity'] . "</td>";
       echo "<td>" . $row['price'] . "</td>";
         echo "<td>" . $row['unit_totalprice'] . "</td>";
      //     echo "<td>" . $row['session'] . "</td>";
  echo "<td style = 'color:orange; font-weight:bold;'>" . date_format( new DateTime ($row['time'] ),"d M, Y H: m: s"). "</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>