require_once 'includes/form.php';
require_once 'includes/posts.php';
require_once 'includes/topics.php';
$oForm = new Form();
if (isset($_SESSION["MemberID"]) == false) {
    //member not allowed
} else {
    if (isset($_POST["submit"])) {
        $oForm->data = $_POST;
        $oForm->checkRequired("PostContent");
        if ($oForm->valid == true) {
            $oNewPost = new Post();
            $oNewPost->PostContent = $_POST["PostContent"];
            $oNewPost->TopicID = $_GET["TopicID"];
            $oNewPost->MemberID = $_SESSION["MemberID"];
            $oNewPost->save();
            header("Location:viewCategories?CategoryID=6");
        }
    }
    $oForm->makeTextArea("Post Content", "PostContent");
    $oForm->makeSubmit("Post");
}
?>
<div class="mainBackground">
	<h3>New Post</h3>
	<?php 
echo $oForm->html;
?>
</div>
<?php 
require_once 'includes/footer.php';
        $oRecipe->ingredients = $_POST["ingredients"];
        $oRecipe->directions = $_POST["directions"];
        //            $sImageName = "recipeImage".$oRecipe -> title.".jpg";
        //            $oRecipe -> imagePath = $sImageName;
        //            $oRecipe -> userID = $oCustomer -> userID;
        //            $oRecipe -> recipeTypeID = $_POST["recipeCategory"];
        $oRecipe->save();
        header("Location: editRecipe.php?message=updated&RecipeID=" . $oRecipe->recipeID);
        exit;
    }
}
//html markup:
$oEditForm->makeInput("recipeTitle", "Recipe Title *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeSelect("recipeCategory", "Recipe Category *", RecipeTypeManager::listAllTypes(), "eight columns floatLeft editRecipe marginBottom10");
$oEditForm->makeImageUpload("imageUpload", "Image Upload *");
$oEditForm->makeTextArea("authorNotes", "Author Notes *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeTextArea("ingredients", "Ingredients *", "eight columns editRecipe floatLeft marginBottom10");
$oEditForm->makeTextArea("directions", "Directions *", "clearBoth editRecipe marginRight10 marginBottom30 marginLeft10");
$oEditForm->makeSubmit("update", "update", "blueButton2 bgBlue marginBottom10");
?>
       <h1 class="textAlignCenter marginBottom30">Edit Recipe</h1>
       <span class="displayBlock positionRelative recipeCaption captionLine textAlignCenter marginBottom10">* Required Fields </span>
       <!-- submit recipe form starts here -->
       <div class="otherForms">
           <?php 
echo $oEditForm->HTML;
if (isset($_GET["message"]) == true) {
    if ($_GET["message"] == "updated") {
        echo '<div class="recipeUpdate formSuccess">Recipe Update Successful!</div>';
    }
}
        $oProduct->size = $_POST["productSize"];
        $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>';
    }
}
?>