diff options
Diffstat (limited to 'public/admin-order.php')
-rw-r--r-- | public/admin-order.php | 76 |
1 files changed, 76 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> |