<?php
include("models/res_menu.class.php");
if (isset($_POST['name']) && isset($_POST['categories_id']) && isset($_POST['price'])) {
    $result = "";
    if (isset($_POST['name'])) {
        $name = $_POST['name'];
        $price = $_POST['price'];
        $category = $_POST['categories_id'];
        // $photo = $_POST['photo'];
        $menu = new ResMenu(null, $name, $price, $category, null);
        $result = $menu->create();
    }
}


?>

<h4 style="text-align: center; color: aquamarine;">Add New Menu</h4>
<form method="post">
    <div style="margin: 10px;">
        <label>Menu Item Name</label>
        <input type="text" name="name" class="form-control" required>
    </div>
    <div style="margin: 10px;">
        <label>Category</label>
        <?php
        $category = ResMenu::readCategories(); ?>


        <select name="categories_id" class="form-control ">
            <?php foreach ( $category as $item) { ?>
                <option value="<?php echo $item["id"]; ?>">
                    <?php echo $item["name"] ?>
                </option>

            <?php } ?>
        </select>
    </div>

    <div style="margin: 10px;">
        <label>Price</label>
        <input type="number" name="price" class="form-control" min="0" required>
    </div>

    <input type="submit" value="Add Menu Item" class="form-control btn btn-success">
    </div>
</form>