This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
369 lines (289 loc) · 12.3 KB
/
index.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: login.php');
exit();
}
include ('serverconnect.php');
?>
<!DOCTYPE html>
<html>
<?php
include('header.php')
?>
<body class="form-v8 loggedin" id="fade" onload="displayFromDatabase(0,1,1)">
<div id="loader">
<div class="loader"><div></div><div></div><div></div><div></div></div>
</div>
<?php
if ($_SESSION['username'] == 'administrator'){
include ('adminNavbar.php');
} else{
include ('navbar.php');
}
?>
<div style="height: 63px; opacity: 0; padding: 0; margin: 0" ></div>
<div class="content">
<?php if (isset($_GET['sent']) && $_GET['sent'] == 1){
echo '<p style="color: green" >Your request is sent</p>';
} ?>
<?php if (isset($_GET['verify']) && $_GET['verify'] == 1){
echo '<p style="color: green" >Successfully Verified</p>';
} ?>
<?php if (isset($_GET['return']) && $_GET['return'] == 1){
echo '<p style="color: green" >Successfully Returned</p>';
} ?>
<?php if (isset($_GET['return']) && $_GET['return'] == 0){
echo '<p style="color: red" >Error occurred, please login with the user you borrowed the equipment with</p>';
} ?>
<?php if (isset($_GET['adminonly']) && $_GET['adminonly'] == 1){
echo '<p style="color: red" >This page is only accessible by the admininistrator</p>';
} ?><?php if (isset($_GET['reset']) && $_GET['reset'] == 1){
echo '<p style="color: green" >Password successfully reset</p>';
} ?>
</div>
<?php $getCategory = mysqli_query($db, "SELECT * FROM EqManage.categories");
?>
<div class="features-boxed" style="height: 787px;">
<div class="container">
<div class="intro">
<h2 class="text-center">Availability Status</h2>
<p class="text-center">In this page, you can check whether the equipment is available or not</p>
<input id="input" type="text" placeholder="Search.." style="padding-top: 10px;margin-top: 10px">
<form action="#">
<div class="select-box">
<label for="select-box1" class="label select-box1"><span class="label-desc">Filter By Category</span> </label>
<select id="select-box1" class="select" name="filtercat" onchange="getIndex1()">
<option value="0" selected>--All--</option>
<?php while ($row = mysqli_fetch_array($getCategory)) { ?>
<?php echo "<option value=\"".$row['id']."\" name=\"filterCat\">".$row['categoryName']."</option>"; ?>
<?php } ?>
</select>
</div>
</form>
<form action="#">
<div class="select-box">
<label for="select-box2" class="label select-box1"><span class="label-desc">Sort By Category Name: </span> </label>
<select id="select-box2" class="select" onchange="getIndex1()">
<option value="1" selected>Category Name Ascending</option>
<option value="2" >Category Name Descending</option>
</select>
</div>
</form>
<form action="#">
<div class="select-box">
<label for="select-box3" class="label select-box1"><span class="label-desc">Sort By Equipment Name: </span> </label>
<select id="select-box3" class="select" onchange="getIndex1()">
<option value="1" >Equipment Name Ascending</option>
<option value="2" >Equipment Name Descending</option>
</select>
</div>
</form>
</div>
<div class="row justify-content-center features" id="box">
<!--<div class="col-sm-6 col-md-5 col-lg-4 item">
<div class="box">
<h3 class="name">Equipment Name</h3>
<p class="description">Details</p><a href="#" class="learn-more">Borrow This Equipment »</a></div>
</div>-->
<!---->
<!-- --><?php //$results = mysqli_query($db, "SELECT * FROM equipment");
// $results2 = mysqli_query($db, "SELECT C.categoryName, E.id, E.equipment, E.leftQuantity, E.availability, C.id
// FROM EqManage.categories C
// LEFT JOIN EqManage.equipment E ON C.id=E.category
// GROUP BY C.id,E.id, C.categoryName, E.equipment
// ORDER BY C.categoryName,E.equipment");
//
// ?>
<!---->
<!-- --><?php //while ($row = mysqli_fetch_array($results2)) { ?>
<!---->
<!---->
<!-- --><?php //echo "<div class=\"col-sm-6 col-md-5 col-lg-4 item\">"; ?>
<!---->
<!---->
<!---->
<!-- --><?php //if ($row['availability'] == 1) {
// echo "<div class=\"box\" id='box2'>";
// } elseif ($row['availability'] == 0){
// echo "<div class=\"box\" id='box2'>";
// } else echo "Error"; ?>
<!---->
<!---->
<!---->
<!---->
<!-- --><?php ///*echo "<h3 class=\"name\">".$row['Equipment']."</h3>"; */?>
<!---->
<!---->
<!---->
<!-- --><?php //if ($row['availability'] == 1) {
// echo "<a style='font-style: italic; text-decoration: underline'>".$row['categoryName']."<a/><h3 class=\"name\">".$row['equipment']."</h3>";
// } elseif ($row['availability'] == 0){
// echo "<h3 class=\"name\" style='color: orangered'>".$row['equipment']."</h3>";
// } else echo "Error"; ?>
<!---->
<!---->
<!---->
<!-- --><?php //if ($row['availability'] == 1) {
// echo "<p class=\"description\">".$row['leftQuantity']." Available";
// } elseif ($row['availability'] == 0){
// echo "<p class=\"description\" style='color: red'>Not Available";
// } else echo "Error"; ?>
<!---->
<!---->
<!-- --><?php //echo "</p>"; ?>
<!---->
<!---->
<!---->
<!-- --><?php //if ($row['availability'] == 1) {
// echo "<a href=\"direct-checkout.php?selected=".$row['id']."\" class=\"learn-more\">Borrow This Equipment »</a>";
// } elseif ($row['availability'] == 0){
// echo "";
// } else echo "Error"; ?>
<!---->
<!-- --><?php //echo "</div>"; ?>
<!-- --><?php //echo "</div>"; ?>
<!---->
<!-- --><?php //} ?>
<!---->
<!-- </div>-->
<!-- </div>-->
</div>
<script>
$(document).ready(function(){
$("#input").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#box div").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
// document.getElementById("add-cart").onclick(function() {
// $(".dropdown-toggle").dropdown("toggle");
// console.log("opened");
// });
// $('.trigger_button').click(function(e){
// // Kill click event:
// e.stopPropagation();
//
// console.log("pressed");
// $('.dropdown-toggle').dropdown('toggle');
// });
});
/* $(document).ready(function getIndex(){
$("#select-box1").onchange(function getIndex1(){
var e = document.getElementById("select-box1");
var cat = e.options[e.selectedIndex].value;
$.ajax({
url: "fetchindex.php",
type: "POST",
async: false,
data:{
"filterCat":cat
},
success: function(data){
displayFromDatabase();
}
});
});
});*/
function getIndex1(){
var e = document.getElementById("select-box1");
var cat = e.options[e.selectedIndex].value;
var e2 = document.getElementById("select-box2");
var sortC = e2.options[e2.selectedIndex].value;
var e3 = document.getElementById("select-box3");
var sortE = e3.options[e3.selectedIndex].value;
$.ajax({
url: "fetchIndex.php",
type: "POST",
async: false,
data: {
},
success:function(data){
displayFromDatabase(cat,sortC,sortE);
}
})
}
function displayFromDatabase(filter,sortC,sortE){
$.ajax({
url: "fetchIndex.php",
type: "POST",
async: false,
data: {
"display": 1,
"filterCat": filter,
"sortC":sortC,
"sortE":sortE
},
success:function (data) {
$("#box").html(data);
}
})
}
function addCart(eqID) {
console.log(eqID);
var idname = eqID + "_qty";
var qty = document.getElementById(idname).value;
console.log(qty);
$.ajax({
url:"navbarCart.php",
type:"POST",
data:{
"eqID":eqID,
"qty":qty
},
success:function (data) {
console.log("added to cart");
$("#cartDiv").html(data);
console.log(data);
}
})
}
function clearCart() {
$.ajax({
url:"navbarCart.php",
type:"POST",
data:{
"destroy_cart":"1",
},
success:function (data) {
console.log("cleared cart");
$("#cartDiv").html(data);
}
})
}
function deleteItem(eqID) {
console.log(eqID);
$.ajax({
url:"navbarCart.php",
type:"POST",
data:{
"delete":"1",
"eqID":eqID
},
success:function (data) {
console.log("deleted item");
$("#cartDiv").html(data);
console.log(data);
}
})
}
function updateQty(eqID, qty) {
console.log(qty);
console.log(eqID);
$.ajax({
url:"navbarCart.php",
type:"POST",
data:{
"update":"1",
"qty":qty,
"eqID":eqID
},
success:function (data) {
$("#cartDiv").html(data);
console.log(data);
}
})
}
</script>
</body>