-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
161 lines (145 loc) · 6.54 KB
/
dashboard.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Customer Dashboard</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Bootstrap JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="./css/mainpage.css" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script src="./js/server/view_order.js"> </script>
</head>
<body>
<video autoplay muted loop plays-inline class='backvid'>
<source src='./assests/video/cms_vid.mp4' type='video/mp4' />
</video>
<div class="container">
<h1>Welcome</h1>
</div>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="./dashboard.php">Customer Dashboard</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="./index.php">Home</a></li>
<li><a href="./php/server/get_orders.php">Orders</a></li>
<li><a href="#">Profile</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li class="nav-item" id="login-nav-item">
<li><a href="log_in.php"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</li>
<li class="nav-item" id="logout-nav-item" style="display:none;">
<a class="nav-link js-scroll-trigger" href="#" onclick="log_out()">Log out</a>
</li>
</ul>
</div>
<script>
// Check if user is logged in
update_navbar();
if (sessionStorage.getItem('currentloggedin')) {
// User is logged in, retrieve user ID and name from session storage
let user = JSON.parse(sessionStorage.getItem('currentloggedin'));
let user_id = user.id;
let username_logged_in = user.name;
// Hide the Login button and show the Logout button
$('#login-nav-item').hide();
$('#logout-nav-item').show();
// Display the user's name next to the "Welcome" greeting
$('h1').append(', ' + username_logged_in);
} else {
// User is not logged in, hide the Logout button and show the Login button
$('#logout-nav-item').hide();
$('#login-nav-item').show();
}
function update_navbar() {
let login_nav_item = document.getElementById("login-nav-item");
let logout_nav_item = document.getElementById("logout-nav-item");
// Check if there is a logged in user in the session storage
let logged_in_user = sessionStorage.getItem('currentloggedin');
if (logged_in_user) {
// Show the "Log out" button and hide the "Login" button
login_nav_item.style.display = "none";
logout_nav_item.style.display = "block";
} else {
// Show the "Login" button and hide the "Log out" button
login_nav_item.style.display = "block";
logout_nav_item.style.display = "none";
}
}
function log_out() {
// Remove the current logged-in user from the session storage
sessionStorage.removeItem('currentloggedin');
// Show a SweetAlert to confirm that the user has been logged out
Swal.fire({
icon: 'success',
title: 'Logged out',
text: 'You have been logged out.',
timer: 3000, // 3 seconds
timerProgressBar: true,
showConfirmButton: false
}).then(() => {
// Redirect the user to the dashboard page
window.location.href = 'dashboard.php';
});
}
</script>
</nav>
<div class="container">
<div class="row">
<div class="col-sm-4">
<h2>Orders</h2>
<p>View and manage your orders here.</p>
<a id="view_order_btn" class="btn btn-primary" onclick=display_orders()>View Orders</a>
</div>
<div class="col-sm-4">
<h2>Profile</h2>
<p>Update your profile information.</p>
<a href="#" class="btn btn-primary">Edit Profile</a>
</div>
<div class="col-sm-4">
<h2>Support</h2>
<p>Get help with your account.</p>
<a href="#" class="btn btn-primary">Contact Support</a>
</div>
</div>
</div>
<!-- Order Modal -->
<div class="modal fade" id="orderModal" tabindex="-1" role="dialog" aria-labelledby="orderModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="orderModalLabel">Orders</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table class="table table-hover">
<thead>
<tr>
<th>Order ID</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody id="orders-table-body">
<!-- Order rows will be added dynamically by JavaScript -->
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>