<?php include 'db.php'; include 'layout.php'; ?>
<body>
<div class="main-wrapper">
  <div class="page-wrapper">
    <div class="content">
      <div class="page-header">
        <div class="page-title"><h4>Floors</h4><h6>Manage dining sections/floors</h6></div>
        <div class="page-btn">
          <a href="#" class="btn btn-added" data-bs-toggle="modal" data-bs-target="#addFloorModal">+ Add Floor</a>
        </div>
      </div>

      <div class="card"><div class="card-body">
        <table class="table table-bordered">
          <thead><tr><th>Name</th><th>Description</th></tr></thead>
          <tbody>
<?php
$res = $conn->query("SELECT * FROM dinein_floors ORDER BY id DESC");
while ($row = $res->fetch_assoc()) {
  echo "<tr><td>{$row['name']}</td><td>{$row['description']}</td></tr>";
}
?>
          </tbody>
        </table>
      </div></div>

      <!-- Add Floor Modal -->
      <div class="modal fade" id="addFloorModal"><div class="modal-dialog">
        <form method="POST" action="add_floor.php" class="modal-content">
          <div class="modal-header"><h5>Add Floor</h5><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div>
          <div class="modal-body">
            <input type="text" name="name" class="form-control mb-2" placeholder="Floor Name" required>
            <textarea name="description" class="form-control mb-2" placeholder="Description"></textarea>
          </div>
          <div class="modal-footer"><button class="btn btn-primary" type="submit">Save Floor</button></div>
        </form>
      </div></div>

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