source: PendingOrders.php

Last change on this file was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 6 days ago

Upload project files

  • Property mode set to 100644
File size: 3.0 KB
Line 
1<?php
2 session_start();
3
4 if(!isset($_SESSION['user_ID']) || !isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
5 header("Location: ./Log In.php");
6 }
7
8 require './connect.php';
9
10 $orders_res = mysqli_query($conn, "SELECT * FROM orders WHERE status = 'p'; ");
11?>
12
13<!DOCTYPE html>
14<html lang="en">
15 <head>
16 <meta charset="UTF-8">
17 <meta name="viewport" content="width=device-width, initial-scale=1.0">
18 <link rel="stylesheet" href="./CSS/AdminOrders.css">
19 <title>Pending Orders</title>
20 </head>
21 <body>
22 <table class="container">
23 <tr class="header">
24 <th>Order Number</th>
25 <th>User ID</th>
26 <th>Order Date</th>
27 <th>Price</th>
28 <th>City</th>
29 <th>Postal Code</th>
30 <th>Address</th>
31 <th></th>
32 <th></th>
33 </tr>
34 <?php
35
36 foreach($orders_res as $order) {
37 $order_price = 0;
38 $order_items = mysqli_query($conn, "SELECT * FROM order_item WHERE order_id={$order['id']};");
39
40 foreach($order_items as $item) {
41 $product_name = mysqli_query($conn, "SELECT name FROM products INNER JOIN order_item ON products.product_id = order_item.product_id WHERE order_item.id={$item['id']};")->fetch_assoc()['name'];
42 $order_price = $order_price + ($item['quantity']*$item['price']);
43 }
44 ?>
45 <tr>
46 <td><?php echo $order['id'] ?></td>
47 <td><?php echo $order['user_id'] ?></td>
48 <td><?php echo $order['order_date'] ?></td>
49 <td>$<?php echo $order_price ?></td>
50 <td><?php echo $order['city'] ?></td>
51 <td><?php echo $order['postal_code'] ?></td>
52 <td><?php echo $order['address'] ?></td>
53 <td>
54 <a href='./ViewOrder.php?order_id=<?php echo $order['id'] ?>'>View</a>
55 </td>
56 <td>
57 <form action="./ApproveOrder.php" method="POST">
58 <input type="hidden" name="order_id" value="<?php echo $order['id'] ?>">
59 <button>Approve And Ship</button>
60 </form>
61 <form action="./DiscardOrder.php" method="POST" style="margin-top: 4px;">
62 <input type="hidden" name="order_id" value="<?php echo $order['id'] ?>">
63 <button>Discard</button>
64 </form>
65 </td>
66 </tr>
67 <?php
68 }
69
70 ?>
71 </table>
72 </body>
73</html>
Note: See TracBrowser for help on using the repository browser.