-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_delete.php
151 lines (139 loc) · 4.33 KB
/
admin_delete.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
<?php
session_start();
if(session_id()=='' || isset($_SESSION['user'])){
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "1234";
$dbname = "coffeecorner";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$user = $_SESSION['user'];
$sql = "SELECT * FROM add_reservation";
$result = mysqli_query($connection, $sql);
if(!$result)
{
die("database query fail!" . mysqli_error($connection) . mysqli_errno($connection));
}
if(isset($_POST['delete']))
{
header("location: user_view.php");
}
?>
<!doctype html>
<html>
<head>
<link href="admin_delete.css?v={random number/string}" rel="stylesheet" type="text/css">
<meta charset="utf-8">
<title>Admin | Delete Reservation</title>
</head>
<body class="ggwp">
<h2 class="h2">Coffee Corner</h2>
<nav class="navbar">
<ul class="ul">
<li class="dashboard"><a class="dashboard2" href="admin.php">Dashboard</a></li>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Notification</button>
<div id="myDropdown" class="dropdown-content">
<a href="notification.php">Add Notification</a>
<a href="notification1.php">View Notification</a>
</div>
</div>
<li class="view"><a class="view2" href="admin_view.php">View Reservation</a></li>
<li class="update"><a class="update2" href="reservation_status.php">Reservation Status</a></li>
<li class="delete"><a class="a_delete" href="admin_delete.php">Delete Reservation</a></li>
<li class="border-bottom"><a></a></li>
</ul>
</nav>
<p class="credential">Logged in as : <?php echo $_SESSION['user']; ?></p>
<a class="button_logout" href="admin_logout.php" name="logout">Log out</a>
<div class="delete1">
<h2>Delete Reservation</h2>
<?php
// table reservation details
echo "<table width=\"1200\" border=\"1\" cellspacing=\"0px\" cellpadding=\"50px\">";
echo "<tr>";
echo "<th>Customer</th>";
echo "<th>Reservation ID</th>";
echo "<th>Total Person</th>";
echo "<th>Date</th>";
echo "<th>Time</th>";
echo "<th>Status</th>";
echo "</tr>";
echo "<tr>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row['username']; ?></td>
<td><?php echo $row['reserve_id']; ?></td>
<td><?php echo $row['no_of_people']; ?></td>
<td><?php echo date('d/m/Y', strtotime($row['date'])); ?></td>
<td><?php echo date('h:i a', strtotime($row['time'])); ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php
}
}else{
echo "<script type='text/javascript'>alert('No reservation to be deleted. No customer yet!'); window.location.href = \"admin.php\";</script>";
}
echo "</tr>";
echo "</table>";
// end table reservation details
?>
</div>
<div class="select">
<?php
$sql = "SELECT * FROM add_reservation";
$result = mysqli_query($connection, $sql);
?>
<h3>Select Reservation ID to delete:</h3>
<form id="form" action="admin_deletedetail.php" method="get">
<?php
echo "<select name=\"Reservation_ID\" form=\"form\">";
while ($row = mysqli_fetch_array($result))
{
$gg = $row['reserve_id'];
echo "<option value='" . $gg . "' name=\"reserve_id\">" . $gg . "</option>";
}
echo "</select>";
?>
<input type="submit" name="form" value="Submit">
</form>
</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
<script language="JavaScript" type="text/javascript">
function login(showhide){
if(showhide == "show"){
document.getElementById('popupbox').style.visibility="visible";
}else if(showhide == "hide"){
document.getElementById('popupbox').style.visibility="hidden";
}
}
</script>
</body>
<?php
}
else
{
header("location: admin_login.php");
}
?>
</html>