-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwelcome admin.php
More file actions
352 lines (288 loc) · 11.3 KB
/
Copy pathwelcome admin.php
File metadata and controls
352 lines (288 loc) · 11.3 KB
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
<!DOCTYPE html>
<?php
include_once 'C:\xampp\htdocs\CarRentalSystem\once.php';
session_start();
$email = $_SESSION['email'];
?>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link href="welcome admin.css" rel="stylesheet">
<link rel="icon" href="https://cdn-icons-png.flaticon.com/512/809/809998.png" type="image/x-icon">
<title>Car Rental - Home (admin)</title>
</head>
<body>
<nav class ="navbar">
<div class="logo"><a href="#">Car Rental <i class="fas fa-car"></i></a></div>
<div class="search-box">
<form method="POST" name="form2" action="advancedsearch.php">
<input class="search-txt" type="text" name="advanced" placeholder="Type to search">
<button class="search-btn" name="search" type="submit" formaction="advancedsearch.php" value="car">Car</button>
<button class="search-btn" name="search" type="submit" formaction="advancedsearch.php" value="customer">Customer</button>
<button class="search-btn" name="search3" type="submit" formaction="advancedreservation.php">Reservation</button>
</form>
</div>
<ul class="menu">
<li><a href="#">Home</a></li>
<li>
<a href="#">Account</a>
<ul class="dropdown">
<li><a href="index.php">Log out</a></li>
</ul>
</li>
<li><a href="#">About us</a></li>
</ul>
</nav>
<section class="content">
<div class="welcome">
<p> Welcome Back
<?php
$query=mysqli_query($connect,"select admin_name from admin where Email = '$email'");
$fetch = mysqli_fetch_assoc($query);
echo $fetch['admin_name'];
?>
</p>
</div>
<div class="action_btn">
<a href="#move1"><button>Edit Cars</button></a><br>
<a href="#move2"><button>Edit officies</button></a><br>
<a href="#move3"><button>Approve cars</button></a><br>
<a href="#move4"><button>Reject Cars That Not Paid</button></a>
<form method="get" name="form" action="payment.php">
<button>Show Payment</button>
</form>
<form method="get" name="form" action="show reservations.php">
<button>Show All Reservations</button>
</form>
<form method="get" name="form" action="carReservations.php">
<button>Show Reservation For Car</button>
</form>
<form method="get" name="form" action="customer reservation.php">
<button>Show Customer's Reservations</button>
</form>
<form method="get" name="form" action="show status.php">
<button>Show Status</button>
</form>
</div>
</section>
<h1 id="move1"></h1><br><br>
<h1 class="pheading">Cars in the officies</h1>
<section class="sec">
<div class="car">
<div class="card">
<div class="img"><img src="https://www.iconeasy.com/icon/png/System/Delikate/Add.png" alt=""></div>
<div class="box">
<a href="add car.php"><button class="btn0">Add car</button></a>
</div>
</div>
<?php
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM car NATURAL JOIN office";
if ($result=$conn->query($sql))
{
while($row = $result->fetch_assoc())
{
$picture = $row["Image"];
$Brand = $row["Brand"];
$Model = $row["Model"];
$Year = $row["Year"];
$office = $row["Office_name"];
$Price_per_day = $row["Price_per_day"];
?>
<div class="card">
<div class="img"><img src= <?= $picture ?> alt=""></div>
<br>
<div class="title"><span style="color:grey">Brand: </span> <?= $Brand ?></div>
<div class="title"><span style="color:grey">Model: </span><?= $Model ?></div>
<div class="title"><span style="color:grey">Year: </span><?= $Year ?></div>
<div class="title"><span style="color:grey">Office: </span><?= $office ?></div>
<div class="box">
<div class="price"><span style="color:green">$</span> <?= $Price_per_day ?></div>
<form method="get" name="form" action="edit car.php">
<button class="btn" name="plate" type="submit" value=<?= $row["Plate_id"] ?> > Edit Car </button>
</form>
</div>
</div>
<?php
}
$result->free();
}
?>
</div>
</section>
<h1 id="move2"></h1><br><br>
<h1 class="pheading">Officies in the countries</h1>
<section class="sec">
<div class="car">
<div class="card">
<div class="img"><img src="https://www.iconeasy.com/icon/png/System/Delikate/Add.png" alt=""></div>
<div class="box">
<a href="add office.php"><button class="btn0">Add office</button></a>
</div>
</div>
<?php
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = " SELECT * FROM office";
if ($result=$conn->query($sql))
{
while($row = $result->fetch_assoc())
{
$officeid = $row["Office_id"];
$officename = $row["Office_name"];
$officecountry = $row["Country"];
$officecity = $row["City"];
$officeaddress = $row["Address"];
?>
<div class="card">
<div class="img"><img src="https://images.olx.com.eg/thumbnails/43759412-800x600.webp" alt=""></div>
<div class="title"><span style="color:grey">Office ID: </span><?= $officeid ?></div>
<div class="title"><span style="color:grey">Office Name: </span><?= $officename ?></div>
<div class="title"><span style="color:grey">City: </span><?= $officecity ?></div>
<div class="title"><span style="color:grey">Address: </span><?= $officeaddress ?></div>
<div class="box">
<form method="get" name="form" action="edit office.php">
<button class="btn" name="office" type="submit" value=<?= $officeid ?> > Edit Office </button>
</form>
</div>
</div>
<?php
}
$result->free();
}
?>
</div>
</section>
<h1 id="move3"></h1><br><br>
<h1 class="pheading">Reserved Cars by users</h1>
<section class="sec">
<div class="car">
<?php
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM (reservation NATURAL JOIN car) NATURAL JOIN office WHERE reservation.Action = 'Pending' AND car.Office_id = office.Office_id;";
if ($res=$conn->query($sql))
{
while($row = $res->fetch_assoc())
{
$plate = $row["Plate_id"];
$respicture = $row["Image"];
$resBrand = $row["Brand"];
$resModel = $row["Model"];
$resYear = $row["Year"];
$resoffice = $row["Office_name"];
$resPrice_per_day = $row["Price_per_day"];
$pickupDate = $row["Start_date"];
$retuenDate = $row["End_date"];
$ID = $row["national_id"];
?>
<div class="card">
<div class="img"><img src= <?= $respicture ?> alt=""></div>
<div class="title"><span style="color:grey">Plate ID: </span><?= $plate ?></div>
<div class="title"><span style="color:grey">Brand: </span><?= $resBrand ?></div>
<div class="title"><span style="color:grey">Model: </span><?= $resModel ?></div>
<div class="title"><span style="color:grey">Year: </span><?= $resYear ?></div>
<div class="title"><span style="color:grey">Office: </span><?= $resoffice ?></div>
<div class="title"><span style="color:grey">Price/Day: </span><?= $resPrice_per_day ?></div>
<div class="title"><span style="color:grey">Pick Up Date: </span><?= $pickupDate ?></div>
<div class="title"><span style="color:grey">Return Date: </span><?= $retuenDate ?></div>
<div class="title"><span style="color:grey">Customer National ID: </span><?= $ID ?></div>
<div class="box">
</div>
<div class="box">
<form method="get" name="form">
<button class="btn2" name="approve" type="submit" value=<?= $row["Plate_id"] ?> > Approve </button>
<button class="btn3" name="reject" type="submit" value=<?= $row["Plate_id"] ?> > Reject </button>
</form>
</div>
</div>
<?php
}
$res->free();
}
?>
</div>
</section>
<h1 id="move4"></h1><br><br>
<h1 class="pheading">Reject Cars That Not Paid</h1>
<section class="sec">
<div class="car">
<?php
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM (reservation NATURAL JOIN car) NATURAL JOIN office WHERE reservation.Action = 'Approved' AND car.Office_id = office.Office_id;";
if ($res=$conn->query($sql))
{
while($row = $res->fetch_assoc())
{
$plate = $row["Plate_id"];
$respicture = $row["Image"];
$resBrand = $row["Brand"];
$resModel = $row["Model"];
$resYear = $row["Year"];
$resoffice = $row["Office_name"];
$resPrice_per_day = $row["Price_per_day"];
$entryDate = $row["Entry_date"];
$ID = $row["national_id"];
?>
<div class="card">
<div class="img"><img src= <?= $respicture ?> alt=""></div>
<div class="title"><span style="color:grey">Plate_id: </span><?= $plate ?></div>
<div class="title"><span style="color:grey">Brand: </span><?= $resBrand ?></div>
<div class="title"><span style="color:grey">Model: </span><?= $resModel ?></div>
<div class="title"><span style="color:grey">Year: </span><?= $resYear ?></div>
<div class="title"><span style="color:grey">Office: </span><?= $resoffice ?></div>
<div class="title"><span style="color:grey">Price/Day: </span><?= $resPrice_per_day ?></div>
<div class="title"><span style="color:grey">Reserved at: </span><?= $entryDate ?></div>
<div class="title"><span style="color:grey">Customer National ID: </span><?= $ID ?></div>
<div class="box">
</div>
<div class="box">
<form method="get" name="form">
<button class="btn3" name="paid" type="submit" value=<?= $row["Plate_id"] ?> > Reject due to not paid </button>
</form>
</div>
</div>
<?php
}
$res->free();
}
?>
</div>
</section>
<footer>
<p><a href="">Contact us</a></p>
</footer>
<?php
if (isset($_GET["approve"])) {
$plate = $_GET["approve"];
$temp = $connect->prepare("UPDATE reservation SET reservation.Action='Approved' WHERE Plate_id='$plate' AND reservation.Action='Pending'");
$temp->execute();
}
if (isset($_GET["reject"])) {
$plate = $_GET["reject"];
$temp = $connect->prepare("UPDATE reservation SET reservation.Action='Rejected' WHERE Plate_id='$plate' AND reservation.Action='Pending'");
$temp->execute();
}
if (isset($_GET["paid"])) {
$plate = $_GET["paid"];
$temp = $connect->prepare("UPDATE reservation SET reservation.Action='Rejected not paid' WHERE Plate_id='$plate' AND reservation.Action='Approved'");
$temp->execute();
}
?>
</body>
</html>