-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmindash.php
181 lines (149 loc) · 6.42 KB
/
admindash.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
<?php
session_start();
error_reporting(0);
include('includes/dbconnection.php');
if (strlen($_SESSION['damsid']==0)) {
header('location:logout.php');
} else
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 50px auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
.form-container {
margin-bottom: 30px;
}
label {
display: block;
margin: 10px 0 5px;
}
input, select, button {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table th, table td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
table th {
background-color: #4CAF50;
color: white;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<!-- Login Form -->
<div class="container" id="loginContainer">
<h1>Admin Login</h1>
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username" placeholder="Enter username" required>
<label for="password">Password:</label>
<input type="password" id="password" placeholder="Enter password" required>
<button type="submit">Login</button>
</form>
</div>
<!-- Admin Dashboard -->
<div class="container hidden" id="adminDashboard">
<h1>Admin Dashboard</h1>
<table>
<thead>
<tr>
<th>Hospital Name</th>
<th>Patients</th>
<th>Accepted Patients</th>
<th>Rejected Patients</th>
</tr>
</thead>
<tbody id="hospitalTableBody">
<!-- Table rows will be dynamically added here -->
</tbody>
</table>
</div>
<script>
// Hardcoded Admin Credentials
const ADMIN_CREDENTIALS = {
username: "admin",
password: "password123"
};
// Login Form and Dashboard Elements
const loginForm = document.getElementById('loginForm');
const loginContainer = document.getElementById('loginContainer');
const adminDashboard = document.getElementById('adminDashboard');
const hospitalTableBody = document.getElementById('hospitalTableBody');
// Example Data for Hospitals
const hospitals = [
{ name: "City Hospital", patients: 100, accepted: 80, rejected: 20 },
{ name: "Green Valley Hospital", patients: 50, accepted: 40, rejected: 10 },
{ name: "Sunrise Hospital", patients: 120, accepted: 100, rejected: 20 }
];
// Function to Populate the Table
function populateTable() {
hospitalTableBody.innerHTML = ''; // Clear existing rows
hospitals.forEach(hospital => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${hospital.name}</td>
<td>${hospital.patients}</td>
<td>${hospital.accepted}</td>
<td>${hospital.rejected}</td>
`;
hospitalTableBody.appendChild(row);
});
}
// Login Form Submission
loginForm.addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username === ADMIN_CREDENTIALS.username && password === ADMIN_CREDENTIALS.password) {
alert("Login Successful!");
loginContainer.classList.add('hidden'); // Hide login form
adminDashboard.classList.remove('hidden'); // Show dashboard
populateTable();
} else {
alert("Invalid Username or Password");
}
});
</script>
</body>
</html>