-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.php
204 lines (192 loc) · 8.67 KB
/
order.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php session_start();
include('data-base/constant.php');
$customer_id = (isset($_SESSION['customer-id'])) ? $_SESSION['customer-id'] : 0;
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customer</title>
<link rel="stylesheet" type="text/CSS" href="css/ORDER.css">
<script src="popup-notification/popup-notification.js"></script>
<?php include('loader/loading-div.html'); ?>
<script src="jquery/jquery.js"></script>
<script src="js/responsiveNavigation.js" defer></script>
</head>
<body>
<script>
window.history.replaceState({}, '', 'order.php')
</script>
<!-- menu start -->
<nav class="nav-bar" responsiveNavigation=false>
<ul>
<a href="index.php" class="no-text-decoration">
<li class="index ">home</li>
</a>
<a href="search.php" class="no-text-decoration">
<li class="category ">search</li>
</a>
<a href="order.php" class="no-text-decoration order-link">
<li class="order highlight">orders</li>
</a>
<a href="profile.php" class="no-text-decoration">
<li class="profile">profile</li>
</a>
<?php
$user = (!isset($_SESSION['customer-id'])) ? "<a href='log-in.php' class='no-text-decoration'><li class='login'>log in</li></a>" :
"<a href='log-out.php' class='no-text-decoration'><li class='login'>log out</li></a>";
echo $user;
?>
<?php
if (isset($_SESSION['customer-id'])) {
$id = $_SESSION['customer-id'];
$sql1 = "select profile_image from customer where id=$id";
$res = mysqli_query($conn, $sql1);
while ($row = $res->fetch_assoc()) {
echo "
<li class='sre-icon-list'>
<a href='profile.php' class='sre-icon-link'>
<div class='sre-main-small-image-container'>
<div class='sre-profile-image-small-container'>
<img src='" . $row['profile_image'] . "' class='sre-img'>
</div>
</div>
</a></li>
";
}
}
?>
</ul>
<button class="nav-button"></button>
</nav>
<!-- menu end -->
<!--body-->
<div class="body1 main-height">
<?php
if (!isset($_SESSION['customer-id'])) {
echo "<div class='user-not-found'>
<div class='user-not-logged-in-container'>
";
include('animated/user-not-logged-in.html');
echo "
<div class='question'>Please login to see the orders...!</div>
<a href='log-in.php' class='p-t-l-link'>
<div class='profile-to-log-in-page-link-container'>log in</div>
</a>
</div>
</div>";
}
?>
<!-- main body -->
<div class="order-main-body">
<!-- // -js comes here -->
<script defer>
//*DECLARATIONS
let j, fullVal, starChildren
//*OTHER things
let responsive = false
window.addEventListener("resize", () => {
if (document.body.clientWidth <= 800) makeResponsive()
else notMakeResponsive()
})
if (document.body.clientWidth <= 800) makeResponsive()
else notMakeResponsive()
function notMakeResponsive() {
// -ajax to call the list of orders from the server
$.ajax({
url: 'php/orderList.php',
type: 'POST',
data: {
customer_id: <?php echo $customer_id ?>
},
success: (data) => {
$("#listContainer").html(data)
}
})
}
function makeResponsive() {
// -responsive ajax call to get all orders from the server
$.ajax({
url: 'php/orderList.php',
type: 'POST',
data: {
customer_id: <?php echo $customer_id ?>,
responsive: true
},
success: (data) => {
$("#listContainer").html(data)
}
})
}
function getCode(item) {
let allButtons = document.querySelector(".options").children
Array.prototype.forEach.call(allButtons, button => {
button.setAttribute("selected", "false")
})
item.setAttribute("selected", "true")
window.addEventListener("resize", () => {
if (document.body.clientWidth <= 800) ajax2(item)
else ajax1(item)
})
if (document.body.clientWidth <= 800) ajax2(item)
else ajax1(item)
}
function ajax1(item) {
$.ajax({
url: 'php/orderList.php',
type: 'POST',
data: {
button: item.value,
customer_id: <?php echo $customer_id ?>
},
success: (data, status) => {
$("#listContainer").html(data)
}
})
}
function ajax2(item) {
$.ajax({
url: 'php/orderList.php',
type: 'POST',
data: {
button: item.value,
responsive: true,
customer_id: <?php echo $customer_id ?>
},
success: (data, status) => {
$("#listContainer").html(data)
}
})
}
// -function that will call when an order is selected
function selectedList(item) {
Array.prototype.forEach.call(document.querySelector(".list-container").children, (s) => s.setAttribute("selected", "false"))
item.setAttribute("selected", "true");
}
</script>
<!-- this container contains all the orders placed by the customer -->
<div class="list-container-wrapper">
<div class="options">
<button class="all" id="allButton" value="all" onclick="getCode(this)" selected="true">All</button>
<button class="waiting" id="waitingButton" value="wait" onclick="getCode(this)" selected="false">Waiting</button>
<button class="processing" id="processingButton" value="process" onclick="getCode(this)" selected="false">Processing</button>
<button class="packed" id="packedButton" value="pack" onclick="getCode(this)" selected="false">Packed</button>
<button class="out-for-delivery" id="ofdButton" value="ofd" onclick="getCode(this)" selected="false">Out for delivery</button>
<button class="completed" id="completedButton" value="complete" onclick="getCode(this)" selected="false">Completed</button>
</div>
<div class="line"></div> <!-- it is a line between the two div's on the left side -->
<div class="list-container" id="listContainer">
<!-- incoming code will be here -->
</div>
</div>
<!-- this container contains the options and selected purchase list and some other details -->
<div class="option-container">
<div class="order-list" id="orderList">
<!-- <div class="no-product-is-selected"></div> //todo 🤔 -->
<div class="not-selected-message">Select an order to see the details...!</div>
</div>
</div>
</div>
</div>
<!--footer-->
<?php include('elements/footer.html') ?>