<?php
require_once("models/orders.class.php");
$msg = "";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = null; // Assuming auto-increment
    $order_id = $_POST['order_id'];
    $table_id = $_POST['table_id'];
    $total_amount = $_POST['total_amount'];
    $special_request = $_POST['special_request'];
    $order_status_id = $_POST['order_status_id'];
    $obj = new ResOrders(null, $order_id, $table_id, $total_amount, $special_request, $order_status_id);
    $msg = $obj->create();
}

?>
<h1>Create Orders</h1>
<a href="orders" class="btn btn-primary mb-3">Back to Manage</a>

<?php if($msg) { ?>
<div class="alert alert-info alert-dismissible fade show" role="alert">
  <?php echo $msg; ?>
  <button type="button" class="btn-close close" data-dismiss="alert" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php } ?>
<form method="post">
  <input type="hidden" name="id">
  <div class="card-body">
    <div class="form-group mb-3">
      <label for="order_id">Order Id</label>
      <input type="text" class="form-control" name="order_id" id="order_id">
    </div>
    <div class="form-group mb-3">
      <label for="table_id">Table Id</label>
      <input type="text" class="form-control" name="table_id" id="table_id">
    </div>
    <div class="form-group mb-3">
      <label for="total_amount">Total Amount</label>
      <input type="text" class="form-control" name="total_amount" id="total_amount">
    </div>
    <div class="form-group mb-3">
      <label for="special_request">Special Request</label>
      <input type="text" class="form-control" name="special_request" id="special_request">
    </div>
    <div class="form-group mb-3">
      <label for="order_status_id">Order Status Id</label>
      <input type="text" class="form-control" name="order_status_id" id="order_status_id">
    </div>
  </div>
  <div class="card-footer">
    <button type="submit" class="btn btn-success">Submit</button>
  </div>
</form>
