} if (isset($_GET['success']) && $_GET['success'] == 'edit') { $alert['success'] = "The menu item was successfully updated."; } ?> <div class="row" style="margin-right: 0"> <div class="col-md-6 col-md-offset-3 page-wrapper"> <h2>View Menu Item(s)</h2> <hr> <form action="menu.view.php" method="post"> <h3>Today's Menu<a class="btn btn-default btn-sm pull-right" onclick="toggleAll('today-menu',this)">Expand All</a></h3> <hr> <?php bootstrap_alert($alert); $all_categories = MenuItemCategory::select(); if (is_object($all_categories)) { $all_categories = array($all_categories); } if ($all_categories) { foreach ($all_categories as $category) { $menu_items = MenuItem::select(array('category_id' => $category->id, 'available' => '1')); if (is_object($menu_items)) { $menu_items = array($menu_items); } ?> <div class="panel panel-primary"> <div class="panel-heading" role="tab" id="collapseDivHead-<?php echo $category->id; ?> ">
?> "> </div> <div class="form-group col-md-6"> <label for="txtCost">Cost:</label> <input type="number" class="form-control" id="txtCost" name="cost" placeholder="E.g. 80" tabindex="1" min="0" step="0.01" required value="<?php echo $menu_item->cost; ?> "> </div> </div> <div class="form-group"> <label for="selectCategory">Menu Item Category</label> <select class="form-control" id="selectCategory" name="category_id" tabindex="4" required> <?php $allMenuCat = MenuItemCategory::select(); if (is_object($allMenuCat)) { $allMenuCat = array($allMenuCat); } foreach ($allMenuCat as $menuCat) { echo "<option value='{$menuCat->id}'>" . ucwords($menuCat->name) . "</option>"; } ?> </select> </div> <div class="form-group hidden" id="newCatDiv"> <label for="txtCategory">Category Name</label> <input type="text" class="form-control" id="txtCategory" name="menuCategory" placeholder="Enter the new category" tabindex="5"> </div> <div class="checkbox"> <label>
<?php require '../includes/functions.php'; require 'templates/header.php'; if (isset($_POST['delete'])) { if (strtolower($_POST['delete']) == 'yes') { $menuItem = MenuItem::select(array('id' => $_POST['menu_item_id'])); if (is_object($menuItem)) { $menuItem->delete(); // IF THE CATEGORY HAS NO MORE ITEMS DELETE THE CATEGORY AS WELL if (MenuItem::count("category_id ='" . $menuItem->category_id . "'") == 0) { $menuCat = new MenuItemCategory(); $menuCat->id = $menuItem->category_id; $menuCat->delete(); } } else { redirect_to("menu.view.php?error=1"); } } } if (!isset($_GET['id'])) { redirect_to('menu.view.php'); } if (isset($_GET['error']) && $_GET['error'] == 'delete') { $alertArray = array('error' => 'The menu item could not be deleted!'); } $menuItem = MenuItem::select(array('id' => $_GET['id'])); // DISPLAY THE USER DETAILS AND THEN ASK FOR CONFIRMATION if (is_object($menuItem)) { $header = "menu"; $page = "delete";
require_once '../includes/functions.php'; require 'templates/header.php'; $header = "menu"; $page = "add"; require 'templates/navbar.php'; require 'templates/sidebar.php'; $alert = array(); if (isset($_POST['submit'])) { $menu = new MenuItem(); $menu->instantiate($_POST); if (!empty($menu->halfs)) { $menu->halfs = '1'; } if ($menu->category_id == "#add") { $menuCat = new MenuItemCategory(); $menuCat->name = $_POST['menuCategory']; $menuCat->insert(); $menu->category_id = $menuCat->id; } if ($menu->insert()) { $alert['success'] = "The menu item has been added!"; } else { $alert['error'] = "The menu item could not be added!"; } } ?> <div class="row" style="margin-right: 0"> <div class="col-md-6 col-md-offset-3 page-wrapper"> <h2>Add New Menu Item</h2>