diff options
Diffstat (limited to 'productedit.php')
| -rw-r--r-- | productedit.php | 108 |
1 files changed, 14 insertions, 94 deletions
diff --git a/productedit.php b/productedit.php index 2005444..0fd33e6 100644 --- a/productedit.php +++ b/productedit.php @@ -1,5 +1,7 @@ <?php session_start(); + require_once('vendor.inc.php'); + if(isset($_GET['catid'])) { $catid = $_GET['catid']; @@ -13,8 +15,6 @@ header("Location: product.php?id={$catid}"); } - require_once('vendor.inc.php'); - if(isset($_GET['delete'])) { $product = ProductQuery::create()->findOneById($_GET['delete']); @@ -58,95 +58,15 @@ $product->save(); header("Location: products.php?id={$catid}"); } -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Production</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1><?php echo $product->getName(); ?></h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href=".">Home</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <dt><a href="products.php?id=<?php echo $catid; ?>">Back</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - $username = $_SESSION['username']; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <form action="productedit.php?<?php echo "{$type}={$product->getId()}" ?>&catid=<?php echo $catid; ?>" method="post"> - <h1>Product</h1> - <div class="row"> - <label for="name"><u>N</u>ame:</label> - <input class="formw" type="text" - placeholder="Name" id="name" name="name" accesskey="n" - maxlength="100" value="<?php echo $product->getName(); ?>"> - </div> - <div class="row"> - <label for="price"><u>P</u>rice (Euro):</label> - <input class="formw" type="number" step="0.01" min="0" - placeholder="Price (Euro)" id="price" name="price" accesskey="p" - maxlength="13" value="<?php echo $product->getPrice(); ?>"> - </div> - <div class="row"> - <label for="width"><u>W</u>idth (mm):</label> - <input class="formw" type="number" - placeholder="Width (mm)" id="width" name="width" accesskey="w" - maxlength="11" value="<?php echo $product->getWidth(); ?>"> - </div> - <div class="row"> - <label for="height"><u>H</u>eight (mm):</label> - <input class="formw" type="number" - placeholder="Height (mm)" id="height" name="height" accesskey="h" - maxlength="11" value="<?php echo $product->getHeight(); ?>"> - </div> - <div class="row"> - <label for="desc"><u>D</u>escription:</label> - <textarea class="formw" placeholder="Description" id="desc" name="desc" - accesskey="d" maxlength="1000"><?php echo $product->getDescription(); ?></textarea> - </div> - <div class="row"> - <label for="cat"><u>C</u>ategories:</label> - <select multiple class="formw" id="cat" name="cat[]" accesskey="c"> - <?php - foreach (CategoryQuery::create()->find() as $category) - { - echo "<option value=\"{$category->getId()}\" "; - if($product->getCategories()->contains($category)) - { - echo "selected"; - } - echo ">{$category->getName()}</option>"; - } - ?> - </select> - </div> - <div class="spacer"> </div> - <button type="submit"> - <?php - echo ucfirst($type); - ?> - </button> - <button type="reset"> - Reset - </button> - </form> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + + $smarty = new Smarty; + + $smarty->assign('loggedin', isset($_SESSION['username'])); + $smarty->assign('catid', $catid); + $smarty->assign('product', $product); + $smarty->assign('allCategories', CategoryQuery::create()->find()); + $smarty->assign('type', $type); + + $smarty->display('productedit.tpl'); + +?>
\ No newline at end of file |
