Combine wishlist create and view
This commit is contained in:
parent
4f45bc84f1
commit
932e42edc0
4 changed files with 50 additions and 64 deletions
|
@ -208,11 +208,7 @@ class Page
|
|||
Wishlist
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="/?page=wishlist-create">
|
||||
<i class="list icon"></i>
|
||||
Create
|
||||
</a>
|
||||
<a class="item" href="/?page=wishlist-view">
|
||||
<a class="item" href="/?page=wishlists">
|
||||
<i class="list icon"></i>
|
||||
View
|
||||
</a>
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* wishlist.php
|
||||
*
|
||||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
use wishthis\Page;
|
||||
|
||||
$page = new page(__FILE__, 'Create a wishlist');
|
||||
|
||||
if (isset($_POST['name'])) {
|
||||
$database->query('INSERT INTO `wishlists`
|
||||
(
|
||||
`user`,
|
||||
`name`,
|
||||
`hash`
|
||||
) VALUES (
|
||||
' . $_SESSION['user']['id'] . ',
|
||||
"' . $_POST['name'] . '",
|
||||
"' . sha1(time() . $_SESSION['user']['id'] . $_POST['name']) . '"
|
||||
)
|
||||
;');
|
||||
|
||||
header('Location: /?page=wishlist-product-add');
|
||||
die();
|
||||
}
|
||||
|
||||
$page->header();
|
||||
$page->navigation();
|
||||
?>
|
||||
<main>
|
||||
<div class="ui container">
|
||||
<h1 class="ui header"><?= $page->title ?></h1>
|
||||
|
||||
<div class="ui segment">
|
||||
<form class="ui form" method="post">
|
||||
<div class="field">
|
||||
<label>Name</label>
|
||||
<input type="text"
|
||||
name="name"
|
||||
placeholder="<?= getCurrentSeason() ?>"
|
||||
value="<?= getCurrentSeason() ?>"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<input class="ui primary button" type="submit" value="Create" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
$page->footer();
|
|
@ -1,19 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Template for viewing wishlists.
|
||||
* Template for wishlists.
|
||||
*
|
||||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
use wishthis\{Page, User, Wishlist};
|
||||
|
||||
$page = new page(__FILE__, 'View wishlist');
|
||||
$page = new page(__FILE__, 'Wishlists');
|
||||
$page->header();
|
||||
$page->navigation();
|
||||
|
||||
/**
|
||||
* Delete wishlist
|
||||
* Create
|
||||
*/
|
||||
if (isset($_POST['wishlist-create'], $_POST['name'])) {
|
||||
$database->query('INSERT INTO `wishlists`
|
||||
(
|
||||
`user`,
|
||||
`name`,
|
||||
`hash`
|
||||
) VALUES (
|
||||
' . $_SESSION['user']['id'] . ',
|
||||
"' . $_POST['name'] . '",
|
||||
"' . sha1(time() . $_SESSION['user']['id'] . $_POST['name']) . '"
|
||||
)
|
||||
;');
|
||||
|
||||
header('Location: /?page=wishlist-product-add');
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*/
|
||||
if (isset($_POST['wishlist_delete_id'])) {
|
||||
$database->query('DELETE FROM `wishlists`
|
||||
|
@ -25,9 +45,34 @@ if (isset($_POST['wishlist_delete_id'])) {
|
|||
<div class="ui container">
|
||||
<h1 class="ui header"><?= $page->title ?></h1>
|
||||
|
||||
<div class="ui segment">
|
||||
<h2 class="ui header">Create</h2>
|
||||
<p>
|
||||
Choose a new name for your wishlist.
|
||||
Here's a suggestion to get you started!
|
||||
</p>
|
||||
|
||||
<form class="ui form" method="post">
|
||||
<div class="field">
|
||||
<label>Name</label>
|
||||
<input type="text"
|
||||
name="name"
|
||||
placeholder="<?= getCurrentSeason() ?>"
|
||||
value="<?= getCurrentSeason() ?>"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<input class="ui primary button"
|
||||
type="submit"
|
||||
name="wishlist-create"
|
||||
value="Create"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="ui horizontal stackable segments">
|
||||
<div class="ui segment">
|
||||
<h2 class="ui header">Wishlists</h2>
|
||||
<h2 class="ui header">View</h2>
|
||||
<p>Please select a wishlist to view.</p>
|
||||
|
||||
<div class="field">
|
Loading…
Reference in a new issue