forked from ABHRADEEP800/PHP-E_Commerce_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_orders.php
147 lines (135 loc) · 5.99 KB
/
all_orders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
session_start();
// checking if user is logged in or not
if(!isset($_SESSION['customer'])){
header("Location: login.php");
}
// including database connection
include('database.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Home</title>
<link rel="icon" type="image/x-icon" href="assets/svg-logo/logo1.svg">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
/>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>
<script
src="https://kit.fontawesome.com/db79afedbd.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/main.css" />
</head>
<body>
<!-- including header -->
<?php
// including header
include 'header.php';
?>
<!----------------------------------------------Body---------------------------------------------------------->
<?php
// getting user details from database
$user_email = $_SESSION['customer'];
$sql = "SELECT * FROM user WHERE user_email = '$user_email'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$user_name = $row['user_name'];
$user_id = $row['user_id'];
?>
<section style="background-color: #eee;">
<!------------------ order Details --------------------->
<div class="container" >
<div class="card mb-4">
<div class="card-body">
<div class="mb-4">
<div class="section-title">
<p class="h3">All Orders</p>
</div>
<hr>
<?php
// getting orders of user from database
$sql = "SELECT * FROM orders WHERE order_user = '$user_id' ORDER BY order_id DESC";
$result = mysqli_query($conn, $sql);
// displaying orders of user
while($row = mysqli_fetch_assoc($result)){
$order_id = $row['order_id'];
$order_date = date("d M Y ", strtotime($row['order_date']));
$order_status = $row['order_status'];
// getting order items of user from database
$sql1="SELECT product.product_name, order_p.order_qu, product.product_img ,product.product_id
FROM order_p
INNER JOIN product ON product.product_id=order_p.order_item
WHERE order_p.order_id=$order_id ";
$result1=mysqli_query($conn,$sql1);
// displaying order items of user
while($row1=mysqli_fetch_assoc($result1)){
$product_name=$row1['product_name'];
$product_quantity=$row1['order_qu'];
$product_img=$row1['product_img'];
$product_id=$row1['product_id'];
?>
<div class="row mb-3 bb-1 pt-0">
<div class="col-md-4 col-lg-4 col-sm-12 col-xs-12">
<img class="thumb_img" src="<?php echo "app/".$product_img; ?>">
</div>
<div class="col-md-8 col-lg-8 col-sm-12 col-xs-12">
<a class="d-flex" href="order_view.php?order_id=<?php echo $order_id;?>">
<div class="col-6 me-3">
<p class="h4"><?php echo $product_name; ?></p>
</div>
<div class="col-4">
<small><?php echo $product_quantity." Pcs"; ?></small>
</div>
<div class="col-2">
<i class="fa fa-angle-right"></i>
</div>
</a>
<div class="d-flex">
<div class="col-6">
<small class="text-muted "><?php echo $order_status." on ".$order_date; ?></small>
</div>
<?php
// checking if order is delivered or not
if($order_status == "Delivered" ){
// getting review of product from database
$sql3= "SELECT * FROM review WHERE product_id = '$product_id' AND order_id = '$order_id'";
$result22 = mysqli_query($conn, $sql3);
$row_count= mysqli_num_rows($result22);
// checking if user has already rated the product or not
if($row_count==0){
?>
<div class='col-6 text-end'>
<a class='text-end' href='rating.php?order_id=<?php echo $order_id;?>&product_id=<?=$product_id?>'>Rate This product >></a>
</div>
<?php
}
}
?>
</div>
</div>
</div>
<!-- bottom seperator line -->
<hr>
<?php
}
}
?>
</div>
</div>
</div>
</div>
</section>
<!----------------------------------- footer -------------------------------------------->
<?php
// including footer
include 'footer.php';
?>
</body>
</html>