From fba23ca163517597b67f4674f721d919470f3697 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 18 May 2015 12:36:04 +0200 Subject: Add functionality for changing, deleting and adding data --- productedit.php | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 productedit.php (limited to 'productedit.php') diff --git a/productedit.php b/productedit.php new file mode 100644 index 0000000..c2b33fa --- /dev/null +++ b/productedit.php @@ -0,0 +1,129 @@ +findOneById($_GET['delete']); + } + if(isset($_GET['modify'])) + { + $type = 'modify'; + $product = ProductQuery::create()->findOneById($_GET['modify']); + } + if(isset($_GET['add'])) + { + $type = "add"; + $product = new Product(); + } + if(!is_object($product)) + { + header("Location: products.php?id={$catid}"); + } + if(isset($_GET['delete'])) + { + $product->delete(); + header("Location: products.php?id={$catid}"); + } + if(isset($_POST['name']) && isset($_POST['price']) && isset($_POST['width']) && isset($_POST['height']) && isset($_POST['desc']) && isset($_POST['cat'])) + { + $product->setName($_POST['name']); + $product->setPrice($_POST['price']); + $product->setWidth($_POST['width']); + $product->setHeight($_POST['height']); + $product->setDescription($_POST['desc']); + + if(is_array($_POST['cat'])) + { + $catCollect = new Propel\Runtime\Collection\Collection(); + foreach ($_POST['cat'] as $categoryID) + { + $catCollect->set($categoryID, CategoryQuery::create()->findOneById($categoryID)); + } + $product->setCategories($catCollect); + } + $product->save(); + header("Location: products.php?id={$catid}"); + } +?> + + + + +Production + + + + Back +
getId()}" ?>&catid=" method="post"> +

Product

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
 
+ + +
+ + \ No newline at end of file -- cgit v1.2.3-70-g09d2