-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewbookings.php
210 lines (155 loc) · 6.53 KB
/
viewbookings.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
<?php
include "config.php";
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Bookings</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body style="background-color: #fafafa">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">STUD</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item">
<a class="nav-link" href="profile.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="book.php">Become Stud</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Bookings</a>
</li>
</ul>
<a style="color: #fff">Logged In: <b> <?php
$uid=$_SESSION["user_id"];
$query="SELECT name from users where user_id='$uid'";
$result=mysqli_query($db,$query);
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
echo $row["name"];
?></b></a>   
<div class="btn-group">
<button type="button" class="btn btn-outline-success my-2 my-sm-0 dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" type="submit">
settings
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button" onclick="window.location.href='user_profile.php'">Your profile</button>
<button class="dropdown-item" type="button">Settings</button>
<hr>
<button class="dropdown-item" type="button">Help</button>
<hr>
<button class="dropdown-item" type="button" onclick="window.location.href='signout.php'">Sign Out</button>
</div>
</div>
</div>
</nav>
<?php
$uid=$_SESSION["user_id"];
$pending=2;
$query="SELECT * FROM booking_record where bud_id='$uid' AND booking_status='$pending' AND dob>=CURDATE() ORDER BY dob ASC;";
$rt=mysqli_query($db,$query);
if ($rt->num_rows <= 0)
{
?><img align="center" style="width: 400px;display: block;
margin-top: 50px;
margin-left: auto;
margin-right: auto;
width: 35%;" src="nobooking.svg"><p align="center"><b>
<?php
echo "No Bookings";?></p></b>
<div style="text-align: center;">
<button type="button" class="btn btn-dark" style=" position: relative;align-self: center;" align="center" onclick="location.href ='book.php'">Book Now</button>
</div>
<?php
}
else
{
while ($row=mysqli_fetch_array($rt,MYSQLI_ASSOC))
{
?>
<div style="padding-left: 15px;padding-right: 15px;padding-top: 10px; align-self: center;display: inline-block;" align="center">
<?php
$tid=$row['topic_id'];
$sid=$row['stud_id'];
$q="SELECT name from topics where id='$tid';";
$result=mysqli_query($db,$q);
if (!$result) {
printf("Error: %s\n", mysqli_error($db));
exit();
}
$r=mysqli_fetch_array($result,MYSQLI_ASSOC);
$stud_query="SELECT * from users where user_id='$sid';";
$stud_result=mysqli_query($db,$stud_query);
$stud_row=mysqli_fetch_array($stud_result,MYSQLI_ASSOC);
?>
<div class="card" style="background-color: #fff;max-width: 18rem;width:16rem;box-shadow: 0 8px 6px -5px #BDBDBD;">
<div class="card-body" style="display: inline-block;">
<h5 class="card-title" align="center" style="align-self: center;" ><?php echo $r["name"]; ?></h5>
<class="card-text" align="center"><?php echo date("g:i a", strtotime($row["from_time"]));?> - <?php echo date("g:i a", strtotime($row["to_time"]));
?><br></class="card-text">
<?php
$date_now = date("Y-m-d");
if ($date_now == $row["dob"]) {
?><b><class="card-text"><span class="badge badge-pill badge-danger" align="center" ><?php echo 'Today'; ?></span></b><?php
}else{
?>
<class="card-text"><span class="badge badge-pill badge-warning" align="center" ><?php
echo $row["dob"];
}?></class="card-text"></span>
<small class="form-text text-muted">#SB<?php echo $row['id']; ?></small>
<span style="margin-top: -12px;" class="badge badge-pill badge-warning">Request Pending...</span>
</div><hr style="margin-top: -10px">
<class="card-text" style="text-transform: uppercase;"><?php echo $stud_row["name"]; ?></class="card-text">
<small class="form-text text-muted">username: <?php echo $stud_row['username']; ?></small>
<class="card-text" >Stud Rating: <b><?php echo $stud_row["stud_rating"]; ?></class="card-text"></b>
<div style="display: inline-block; padding: 10px" align="center">
<button name="delbtn" class="btn btn-success delbtn" id="<?php echo $row["id"];?>" value="Delete">Delete</button>
<?php
}?>
</div>
</div>
</div>
</div>
<?php }
?>
<script type="text/javascript">
$(document).ready(function(){
$('.delbtn').click(function(){
var id=$(this).attr("id");
console.log(id);
$.ajax({
url:"delitem.php",
dataType:"text",
method:"GET",
data:{
id:id
},success:function(data){
var result=$.trim(data);
console.log(result);
if(result=='Y')
{
alert("Item Deleted");
header('Location: http://localhost/stud/viewbookings.php');
}
else
{
alert('Not deleted');
}
}
});
});
});
</script>
</div>
</body>
</html>