-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_view_bookings.php
162 lines (134 loc) · 5.16 KB
/
admin_view_bookings.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
<?php
ob_start();
session_start();
if(isset($_SESSION['admin_session_token']) && !empty($_SESSION['admin_session_token']))
{
include("connect.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>View & Manage Bookings</title>
<link rel="stylesheet" type="text/css" href="admin_mangage_routes.css" />
<link rel="stylesheet" type="text/css" href="usermenu.css" />
<!-- Link to your external CSS file -->
</head>
<body >
<?php include("adminmenu.php");?>
<?php
$per_page_record = 10; // Number of entries to show in a page.
// Look for a GET variable page if not found default is 1.
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else {
$page=1;
}
$start_from = ($page-1) * $per_page_record;
$query = "SELECT routes.source, routes.destination, routes.charge, orders.paid_amount, orders.txn_id, bookings.ticketid, bookings.payment, bookings.travel_date, bookings.booking_date from routes INNER JOIN bookings ON routes.busnum=bookings.busnum INNER JOIN orders ON orders.txn_id = bookings.payment_id order by bookings.booking_date DESC LIMIT $start_from, $per_page_record";
$rs_result = mysqli_query ($con, $query);
?>
<div class="form-container">
<h1>View Bookings</h1>
<?php
if(mysqli_num_rows($rs_result) > 0)
{
?>
<table id="routes">
<thead>
<tr>
<th>Travel Date</th>
<th>Booking Date</th>
<th>Ticket No</th>
<th>Source</th>
<th>Destination</th>
<th>Charge</th>
<th>Transaction Status</th>
<th>Pyament ID</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
while ($row = mysqli_fetch_array($rs_result)) {
// Display each field of the records.
?>
<tr>
<td><?php echo $row["travel_date"]; ?></td>
<td><?php echo $row["booking_date"]; ?></td>
<td><?php echo $row["ticketid"]; ?></td>
<td><?php echo $row["source"]; ?></td>
<td><?php echo $row["destination"]; ?></td>
<td>Rs. <?php echo $row["paid_amount"]; ?>/-</td>
<td><?php echo $row["payment"]; ?></td>
<td><?php echo $row["txn_id"]; ?></td>
</tr>
<?php
$i++;
};
?>
</tbody>
</table>
<?php
}
else
{
?>
<p>Bookings Not found</p>
<?php
}
?>
<!--Pagination-->
<div class="pagination">
<?php
$query = "SELECT COUNT(*) FROM routes";
$rs_result1 = mysqli_query($con, $query);
$row = mysqli_fetch_row($rs_result1);
$total_records = $row[0];
echo "</br>";
// Number of pages required.
$total_pages = ceil($total_records / $per_page_record);
$pagLink = "";
if($page>=2){
echo "<a href='admin_view_bookings.php?page=".($page-1)."'> Prev </a>";
}
for ($i=1; $i<=$total_pages; $i++) {
if ($i == $page) {
$pagLink .= "<a class = 'active' href='admin_view_bookings.php?page="
.$i."'>".$i." </a>";
}
else {
$pagLink .= "<a href='admin_view_bookings.php?page=".$i."'>
".$i." </a>";
}
};
echo $pagLink;
if($page<$total_pages){
echo "<a href='admin_view_bookings.php?page=".($page+1)."'> Next </a>";
}
?>
</div>
<div class="inline">
<input id="page" type="number" min="1" max="<?php echo $total_pages?>"
placeholder="<?php echo $page."/".$total_pages; ?>" required>
<button class="btn" onClick="go2Page();">Go</button>
</div>
<script>
function go2Page()
{
var page = document.getElementById("page").value;
page = ((page><?php echo $total_pages; ?>)?<?php echo $total_pages; ?>:((page<1)?1:page));
window.location.href = 'admin_view_bookings.php?page='+page;
}
</script>
</body>
</html>
<?php
mysqli_close($con);
}
else
{
header("location: login.php");
}
ob_end_flush();
?>