source: Innova/DeliveredOrders.php@ 057badc

Last change on this file since 057badc was 057badc, checked in by Vlado 222039 <vlado.popovski@…>, 2 months ago

Adding code

  • Property mode set to 100644
File size: 2.5 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 = 'd'; ");
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>Delivered 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>Shipped Date</th>
28 <th>Delivered Date</th>
29 <th>Price</th>
30 <th>City</th>
31 <th>Postal Code</th>
32 <th>Address</th>
33 <th></th>
34 </tr>
35 <?php
36
37 foreach($orders_res as $order) {
38 $order_price = 0;
39 $order_items = mysqli_query($conn, "SELECT * FROM order_item WHERE order_id={$order['id']};");
40
41 foreach($order_items as $item) {
42 $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'];
43 $order_price = $order_price + ($item['quantity']*$item['price']);
44 }
45 ?>
46 <tr>
47 <td><?php echo $order['id'] ?></td>
48 <td><?php echo $order['user_id'] ?></td>
49 <td><?php echo $order['order_date'] ?></td>
50 <td><?php echo $order['shipped_date'] ?></td>
51 <td><?php echo $order['arrived_date'] ?></td>
52 <td>$<?php echo $order_price ?></td>
53 <td><?php echo $order['city'] ?></td>
54 <td><?php echo $order['postal_code'] ?></td>
55 <td><?php echo $order['address'] ?></td>
56 <td>
57 <a href='./ViewOrder.php?order_id=<?php echo $order['id'] ?>'>View</a>
58 </td>
59 </tr>
60 <?php
61 }
62
63 ?>
64 </table>
65 </body>
66</html>
Note: See TracBrowser for help on using the repository browser.