$oProduct->price = $_POST["productPrice"]; $oProduct->ingredients = $_POST["ingredients"]; $oProduct->stockLevel = $_POST["stockLevel"]; $oProduct->save(); header("Location: addProduct.php?message=added"); exit; } } //html markup $oProductForm->makeInput("productName", "Product Name *", "eight columns floatLeft marginBottom10"); $oProductForm->makeInput("productDescription", "Product Description *", "eight columns floatLeft marginBottom10"); $oProductForm->makeImageUpload("imageUpload", "Image Upload *"); $oProductForm->makeInput("productSize", "Product Size *", "eight columns floatLeft marginBottom10"); $oProductForm->makeInput("productPrice", "Product Price *", "eight columns floatLeft marginBottom10"); $oProductForm->makeTextArea("ingredients", "Ingredients *", "eight columns floatLeft marginBottom10 selfClear"); $oProductForm->quantityInput("stockLevel", "Stock Level *", "addStockLevel"); $oProductForm->makeSubmit("add", "Add Product", "clearBoth blueButton bgBlue marginBottom30"); ?> <h1 class="textAlignCenter marginBottom30">Add a Product</h1> <span class="displayBlock positionRelative recipeCaption captionLine textAlignCenter marginBottom10">* Required Fields </span> <!-- add product form starts here --> <div class="otherForms addProductForm"> <?php echo $oProductForm->HTML; if (isset($_GET["message"]) == true) { if ($_GET["message"] == "added") { echo '<div class="formSuccess">New Product added succesfully!</div>'; } } ?> </div>
<?php require_once "includes/header.php"; require_once "includes/product.php"; require_once "includes/productManager.php"; require_once "includes/form.php"; $iProductID = 1; if (isset($_GET["ProductID"])) { $iProductID = $_GET["ProductID"]; } $oProduct = new Product(); $oProduct->load($iProductID); $oBasketForm = new Form("addToBasket.php"); // form markup: $oBasketForm->makeHiddenField("ProductID", $iProductID); $oBasketForm->quantityInput("quantity", "Quantity", "addQuantity"); $oBasketForm->makeSubmit("addToBasket", "Add to Basket", "displayBlock clearBoth blueButton2 bgBlue marginTop10 marginBottom10"); // main product info: echo View::renderShopItem($oProduct, $oBasketForm); if (isset($_GET["message"]) == true) { if ($_GET["message"] == "itemAdded") { echo '<div class="addToBasket formSuccess">Item has been added to basket.</div>'; } if ($_GET["message"] == "noQuantity") { echo '<div class="addToBasket formError">* Must select quantity.</div>'; } } $aAllProducts = ProductManager::getAllProducts(); ?>