diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-05-21 17:23:54 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-05-21 17:23:54 +0200 |
commit | 05d4f801fa8a519e257993cfa5bf1d72cdb7646f (patch) | |
tree | 8414b1dd2bc891839abca26234a9c1a6f7fa4c15 /public | |
parent | 690516d932e6894938622472222cdfcb06740a83 (diff) |
admin order editing page added
Diffstat (limited to 'public')
-rw-r--r-- | public/admin-order.php | 76 | ||||
-rw-r--r-- | public/admin.css | 17 | ||||
-rw-r--r-- | public/cart.php | 10 |
3 files changed, 103 insertions, 0 deletions
diff --git a/public/admin-order.php b/public/admin-order.php new file mode 100644 index 0000000..debde66 --- /dev/null +++ b/public/admin-order.php @@ -0,0 +1,76 @@ +<!DOCTYPE html> +<?php require "../lib/login.php"; ?> +<?php if_privileged(PRIVILEGE_ADMIN, "/") ?> +<?php do { + if ($_SERVER['REQUEST_METHOD'] !== 'POST') break; + $order_id = $_POST['id']; + $new_status = $_POST['status']; + if (!$order_id) break; + if (!$new_status) break; + + $statement = $cursor->prepare("update `order` set status = ? where id = ?"); + $statement->bind_param("ii", $new_status, $order_id); + $statement->execute(); +} while (false); ?> +<?php +function order_template($order) { + echo <<<"EOF" + <form method="post"> + <input type="hidden" name="id" value="$order->id"> + <tr> + <td>$order->id</td> + <td>$order->user_name</td> + <td>$order->product_count</td> + <td> + <select name="status"> + EOF; + $stages = array( + 1 => "in winkelwagen", + "besteld", + "onderweg", + "afgeleverd", + ); + foreach ($stages as $id => $name) { + $selected = $id == $order->status ? ' selected' : ''; + echo "<option value=\"{$id}\"{$selected}>{$name}</option>"; + } + echo <<<"EOF" + </select> + </td> + <td> + <input type="submit" value="bijwerken"> + </td> + </tr> + </form> + EOF; +} +?> + +<html> +<head> + <?php include 'head.php' ?> + <title>orders</title> + <link rel="stylesheet" href="admin.css"> +</head> +<body> + <?php include 'navbar.php' ?> + <div class="main limwidth"> + <h2>bestellingen</h2> + <p>hier kun je bestellingen zien en de status aanpassen. wijzigingen kunnen doorgevoegd worden door op de 'bijwerken'-knop te drukken na het aanpassen van de status. maar één bestellingen kan aangepast worden per update!!</p> + <table> + <tr> + <th>ID</th> + <th>besteller</th> + <th>aantal producten</th> + <th>status</th> + <th>update</th> + </tr> + <?php + $res = $cursor->query("select `order`.id as id, sum(orderproduct.count) as product_count, user.name as user_name, `order`.status from orderproduct join `order` on `order`.id = orderproduct.`order` join user on user.id = `order`.user where status > 1 group by orderproduct.`order` order by status asc"); + while ($order = $res->fetch_object()) order_template($order); + ?> + </table> + </div> + <?php include 'footer.php' ?> +</body> +</html> diff --git a/public/admin.css b/public/admin.css index 0892cf1..991bb2d 100644 --- a/public/admin.css +++ b/public/admin.css @@ -22,3 +22,20 @@ form textarea { font-family: sans-serif; resize: vertical; } + +table { + width: 100%; + border-collapse: collapse; +} + +table th, +table td { + padding: 4px; + border: 2px solid var(--bg-alt); +} + +table td:nth-child(1) { text-align: center; } +table td:nth-child(3) { text-align: right; } +table td select, +table td input { width: 100%; } + diff --git a/public/cart.php b/public/cart.php index f3b9b5e..60f4c63 100644 --- a/public/cart.php +++ b/public/cart.php @@ -53,6 +53,16 @@ EOF; <body> <?php include 'navbar.php' ?> <div class="main limwidth"> + <?php do { + if (($user_privileges & PRIVILEGE_ADMIN) == 0) break; + echo <<<"EOF" + <div class="center"> + <form action="/admin-order.php" method="get" class="d-ib"> + <input type="submit" value="Bestellingen beheren" class="button filled"> + </form> + </div> + EOF; + } while (false); ?> <h2>dingen in de mand van <?php echo $username ?></h2> <?php do { global $username; |