-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminhome.php
251 lines (226 loc) · 5.87 KB
/
adminhome.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
<?php
session_start();
include ("database/connection.php");
include ("_admin.php");
// database/connection.php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "travel";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Function to execute a query and return the count
function getCount($conn, $sql)
{
$result = $conn->query($sql);
if ($result) {
$row = $result->fetch_assoc();
return $row['total'];
} else {
return 0;
}
}
// SQL queries to count rows for each category
$sqlPlaces = "SELECT COUNT(*) AS total FROM place";
$sqlTransportation = "SELECT COUNT(*) AS total FROM bus_details";
$sqlBlogs = "SELECT COUNT(*) AS total FROM blog_table";
$sqlResidence = "SELECT COUNT(*) AS total FROM hotel";
$sqlUsers = "SELECT COUNT(*) AS total FROM users";
// Execute the queries and store the counts
$totalPlaces = getCount($conn, $sqlPlaces);
$totalTransportation = getCount($conn, $sqlTransportation);
$totalBlogs = getCount($conn, $sqlBlogs);
$totalResidence = getCount($conn, $sqlResidence);
$totalUsers = getCount($conn, $sqlUsers);
// Close the connection
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<style>
.navs {
background-color: #333;
color: #fff;
padding: 1rem 2rem;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
position: fixed;
width: 100%;
top: 0;
left: 0;
}
.navs h1 {
margin: 0;
font-size: 2rem;
letter-spacing: 1.5px;
}
.container {
display: flex;
justify-content: center;
flex-wrap: wrap;
padding: 4rem 1rem 3rem;
gap: 2rem;
}
.card {
background-color: #fff;
border: none;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
width: 260px;
text-align: center;
padding: 2rem 1rem;
transition: transform 0.3s, box-shadow 0.3s;
cursor: pointer;
position: relative;
overflow: hidden;
}
.card:hover {
transform: translateY(-10px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}
.card h2 {
margin: 0;
font-size: 1.7rem;
color: #333;
transition: color 0.3s;
}
.card a {
text-decoration: none;
display: block;
margin-top: 1.5rem;
font-weight: bold;
font-size: 1.1rem;
transition: color 0.3s;
}
.card a:hover {
color: #9eb3be;
}
.card::before {
content: '';
position: absolute;
top: 0;
left: -50%;
width: 100%;
height: 100%;
background: #a0beda;
z-index: 0;
transform: skewX(-30deg);
transition: transform 0.5s;
}
.card:hover::before {
transform: skewX(-30deg) translateX(200%);
}
.card-content {
position: relative;
z-index: 1;
}
#chartContainer {
width: 20%;
margin: 0 auto;
padding: 2rem 0;
}
canvas {
display: block;
width: 100%;
height: 300px;
}
</style>
</head>
<body>
<div class="text-center">
<h1>Admin Dashboard</h1>
</div>
<div class="container">
<div class="card">
<div class="card-content">
<h2>Tour Places</h2>
<p>Total Places: <?php echo $totalPlaces; ?></p>
<a href="adminPlace.php">Manage Places</a>
</div>
</div>
<div class="card">
<div class="card-content">
<h2>Transportation</h2>
<p>Total Buses: <?php echo $totalTransportation; ?></p>
<a href="adminBus.php">Manage Transportation</a>
</div>
</div>
<div class="card">
<div class="card-content">
<h2>Blog & Reviews</h2>
<p>Total Blogs: <?php echo $totalBlogs; ?></p>
<a href="adminBlog.php">Manage Blogs</a>
</div>
</div>
<div class="card">
<div class="card-content">
<h2>Residence</h2>
<p>Total Residences: <?php echo $totalResidence; ?></p>
<a href="adminHotel.php">Manage Residence</a>
</div>
</div>
<div class="card">
<div class="card-content">
<h2>User</h2>
<p>Total Users: <?php echo $totalUsers; ?></p>
<a href="userAdmin.php">Manage Users</a>
</div>
</div>
</div>
<div id="chartContainer">
<canvas id="myChart"></canvas>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['Tour Places', 'Transportation', 'Blog & Reviews', 'Residence', 'User'],
datasets: [{
label: 'Total Count',
data: [<?php echo $totalPlaces; ?>, <?php echo $totalTransportation; ?>, <?php echo $totalBlogs; ?>, <?php echo $totalResidence; ?>, <?php echo $totalUsers; ?>],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
tooltip: {
callbacks: {
label: function(tooltipItem) {
return tooltipItem.label + ': ' + tooltipItem.raw;
}
}
}
}
}
});
</script>
</body>
</html>