-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathticket.php
279 lines (271 loc) · 12.9 KB
/
ticket.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
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
<?php include_once 'helpers/helper.php'; ?><!-- log on to codeastro.com for more projects -->
<?php subview('header.php'); ?>
<style>
body {
background: #bdc3c7; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #2c3e50, #bdc3c7); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #2c3e50, #bdc3c7); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
@font-face {
font-family: 'product sans';
src: url('assets/css/Product Sans Bold.ttf');
}
h2.brand {
/* font-style: italic; */
font-size: 27px !important;
}
.vl {
border-left: 6px solid #424242;
height: 400px;
}
p.head {
text-transform: uppercase;
font-family: arial;
font-size: 17px;
margin-bottom: 10px ;
color: grey;
}
p.txt {
text-transform: uppercase;
font-family: arial;
font-size: 25px;
font-weight: bolder;
}
.out {
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: white;
padding-left: 25px;
padding-right: 0px;
padding-top: 20px;
}
h2 {
font-weight: lighter !important;
font-size: 35px !important;
margin-bottom: 20px;
font-family: 'Montserrat', sans-serif;
font-weight: bolder;
}
.text-light2 {
color: #d9d9d9;
}
h3 {
/* font-weight: lighter !important; */
font-size: 21px !important;
margin-bottom: 20px;
font-family: Tahoma, sans-serif;
font-weight: lighter;
}
h1 {
font-weight: lighter !important;
font-size: 45px !important;
margin-bottom: 20px;
font-family: 'Arial', sans-serif;
font-weight: bolder;
}
</style>
<main>
<?php if(isset($_SESSION['userId'])) {
require 'helpers/init_conn_db.php';
if(isset($_POST['cancel_but'])) {
$ticket_id = $_POST['ticket_id'];
$stmt = mysqli_stmt_init($conn);
$sql = 'SELECT * FROM Ticket WHERE ticket_id=?';
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt,'i',$ticket_id);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)) {
$sql_pas = 'DELETE FROM Passenger_profile WHERE passenger_id=?
';
$stmt_pas = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt_pas,$sql_pas)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt_pas,'i',$row['passenger_id']);
mysqli_stmt_execute($stmt_pas);
$sql_t = 'DELETE FROM Ticket WHERE ticket_id=?';
$stmt_t = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt_t,$sql_t)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt_t,'i',$row['ticket_id']);
mysqli_stmt_execute($stmt_t);
}
}
}
}
}
?>
<div class="container mb-5">
<h1 class="text-center text-light mt-4 mb-4">Vé Điện Tử</h1>
<?php
$stmt = mysqli_stmt_init($conn);
$sql = 'SELECT * FROM Ticket WHERE user_id=?';
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt,'i',$_SESSION['userId']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
$sql_p = 'SELECT * FROM Passenger_profile WHERE passenger_id=?';
$stmt_p = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt_p,$sql_p)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt_p,'i',$row['passenger_id']);
mysqli_stmt_execute($stmt_p);
$result_p = mysqli_stmt_get_result($stmt_p);
if($row_p = mysqli_fetch_assoc($result_p)) {
$sql_f = 'SELECT * FROM Flight WHERE flight_id=?';
$stmt_f = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt_f,$sql_f)) {
header('Location: ticket.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt_f,'i',$row['flight_id']);
mysqli_stmt_execute($stmt_f);
$result_f = mysqli_stmt_get_result($stmt_f);
if($row_f = mysqli_fetch_assoc($result_f)) {
$date_time_dep = $row_f['departure'];
$date_dep = substr($date_time_dep,0,10);
$time_dep = substr($date_time_dep,10,6) ;
$date_time_arr = $row_f['arrivale'];
$date_arr = substr($date_time_arr,0,10);
$time_arr = substr($date_time_arr,10,6) ;
if($row['class'] === 'E') {
$class_txt = 'ECONOMY';
} else if($row['class'] === 'B') {
$class_txt = 'BUSINESS';
}
echo '
<div class="row mb-5">
<div class="col-8 out">
<div class="row ">
<div class="col">
<h2 class="text-secondary mb-0 brand">
Flight Booking</h2>
</div>
<div class="col">
<h2 class="mb-0">'.$class_txt.'</h2>
</div>
</div>
<hr>
<div class="row mb-3">
<div class="col-4">
<p class="head">Máy Bay</p>
<p class="txt">'.$row_f['airline'].'</p>
</div>
<div class="col-4">
<p class="head">Từ</p>
<p class="txt">'.$row_f['source'].'</p>
</div>
<div class="col-4">
<p class="head">Đến</p>
<p class="txt">'.$row_f['Destination'].'</p>
</div>
</div>
<div class="row mb-3">
<div class="col-8">
<p class="head">Hành khách</p>
<p class=" h5 text-uppercase">
'.$row_p['f_name'].' '.$row_p['m_name'].' '.$row_p['l_name'].'
</p>
</div>
<div class="col-4">
<p class="head">giờ lên máy bay </p>
<p class="txt">12:45</p>
</div>
</div>
<div class="row">
<div class="col-3">
<p class="head">Ngày Khởi Hành</p>
<p class="txt mb-1">'.$date_dep.'</p>
<p class="h1 font-weight-bold mb-3">'.$time_dep.'</p>
</div>
<div class="col-3">
<p class="head">Ngày Đến</p>
<p class="txt mb-1">'.$date_arr.'</p>
<p class="h1 font-weight-bold mb-3">'.$time_arr.'</p>
</div>
<div class="col-3">
<p class="head">cổng</p>
<p class="txt">A22</p>
</div>
<div class="col-3">
<p class="head">ghế</p>
<p class="txt">'.$row['seat_no'].'</p>
</div>
</div>
</div>
<div class="col-3 pl-0" style="background-color:#376b8d !important;
padding:20px; border-top-right-radius: 25px; border-bottom-right-radius: 25px;">
<div class="row">
<div class="col">
<h2 class="text-light text-center brand">
Flight Booking</h2>
</div>
</div>
<div class="row justify-content-center">
<div class="col-12">
<img src="assets/images/airtic.png" class="mx-auto d-block"
height="200px" width="200px" alt="">
</div>
</div>
<div class="row">
<h3 class="text-light2 text-center mt-2 mb-0 pl-3">
  Cảm ơn bạn đã chọn chúng tôi. </br> </br>
Vui lòng có mặt tại cổng vào thời gian lên máy bay</h3>
</div>
</div>
<div class="col-1">
<div class="dropdown">
<button class="btn btn-danger dropdown-toggle" type="button"
id="dropdownMenuButton" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-v"></i> </td>
</button>
<div class="dropdown-menu">
<form class="px-4 py-3" action="ticket.php"
method="post">
<input type="hidden" name="ticket_id"
value='.$row['ticket_id'].'>
<button class="btn btn-danger btn-sm"
name="cancel_but">
<i class="fa fa-trash"></i> Cancel Ticket</button>
</form>
<form class="px-4 py-3" action="e_ticket.php" target="_blank"
method="post">
<input type="hidden" name="ticket_id"
value='.$row['ticket_id'].'>
<button class="btn w-100 mb-3 btn-primary btn-sm"
name="print_but">
<i class="fa fa-print"></i> Print Ticket</button>
</form>
</div>
</div>
</div>
</div>
' ;
}
}
}
}
}
}
?>
</div>
</main><!-- log on to codeastro.com for more projects -->
<?php } ?>
<?php subview('footer.php'); ?>