Repository navigation
Expand file tree
/
Copy pathscanTicket.php
More file actions
353 lines (327 loc) · 24.3 KB
/
Copy pathscanTicket.php
File metadata and controls
353 lines (327 loc) · 24.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
353
<script src="popper/html5-qrcode.min_.js"></script>
<div class="modal fade modal-lg" id="ScanModal" data-bs-backdrop="static" role="dialog">
<!-- Event pop-up -->
<div class="top modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-light text-dark">
<h1 class="modal-title fs-5 fw-bold" id="exampleModalToggleLabel">SCAN TICKET</h1>
<button type="button" class="btn-close text-dark" data-bs-dismiss="modal" aria-label="Close">
<span style="display: flex; align-items: center; justify-content: center; height: 100%;">
×
</span>
</button>
</div>
<div class="modal-body bg-dark text-light overflow-auto">
<div class="row gy-3 row-cols-1 row-cols-md-1 row-cols-sm-1">
<div class=" P-3 col col-md-6 col-sm-12">
<!-- <h4>SCAN RESULT</h4> -->
<form action="" id="panda">
<select class="form-select" id="ScanValue" required name="eventId">
<option disabled selected value="">Select Event Name</option>
<!-- fetching the event that were created by the user -->
<?php include_once 'conn.php';
$UserId = $_SESSION['user']['id']; //getting the user id
$sql = "SELECT * FROM event WHERE UserId = '$UserId'";
$result = mysqli_query($con, $sql); //excuting the query
while ($row = mysqli_fetch_assoc($result)) {
$eId = $row["id"];
$sqlSeat = "SELECT * FROM seat WHERE eventId = '$eId'";
$result_sqlSeat = mysqli_query($con, $sqlSeat); //excuting the query
$count = mysqli_num_rows($result_sqlSeat);
$row_sqlSeat = mysqli_fetch_assoc($result_sqlSeat);
echo "<option class='fw-bold text-center' value=" . $row_sqlSeat["eventId"] . ">" . $row["Name"] . "</option>";
} ?>
</select>
<label for="" class="fs-4" id="qrGuestName"><span>Guest Name:</span></label>
<input id="result" type="text" placeholder="Guest Name Here" readonly
class="mb-3 mt-1 form-control">
<input type="text" hidden id="qrCode" class="my-3 form-control">
<!-- display qr code -->
</form>
<div>
<span class="fs-4">STATUS: </span>
<!-- <span id="name1"></span> -->
<span id="status1"></span>
<!-- <span id="time1"></span> -->
</div>
<div>
<span class="fs-4">SEAT-AREA: </span>
<!-- <span id="name1"></span> -->
<span id="area"></span>
<!-- <span id="time1"></span> -->
</div>
</div>
<div class="col col-md-6 col-sm-12 ">
<div style="width:100%;" id="reader"></div>
</div>
</div>
<script type="text/javascript">
function onScanSuccess(qrCodeMessage) { // on scan success
//alert the select values
document.getElementById('qrCode').value = qrCodeMessage;
var ScanValue = document.getElementById('ScanValue').value; //event id
var ScanValue1 = document.getElementById('ScanValue'); //event id
//alert(ScanValue+'ScanValue');
// document.forms[0].submit();
//alert(ScanValue)
if (ScanValue == "") {
// if the event is not selected
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 fw-bold text-dark bg-warning p-3 text-center'>Warning <i class='fa-solid fa-triangle-exclamation'></i> <br>Please select an EVENT</i></p>";
} else {
// if the event is selected
$.ajax({
type: "POST",
url: "scanTicketAction.php",
data: {
qrCodeMessage: qrCodeMessage,
ScanValue: ScanValue
},
cache: false,
success: function (data) {
// /document.getElementById('result').value = data;
//alert(data);
var name1 = JSON.parse(data).name;
var status1 = JSON.parse(data).status;
var time1 = JSON.parse(data).time;
var SeatArea = JSON.parse(data).SeatArea;
// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// checkinh if the guest exists in the database
if (name1 == null) {
document.getElementById('qrGuestName').innerHTML =
"<span>Qr Message Is</span>";
document.getElementById('result').value = qrCodeMessage;
} else {
document.getElementById('result').value = name1;
document.getElementById('qrGuestName').innerHTML =
"<span>Guest Name:</span>";
}
// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
if (status1 == "PAID" && time1 != null) { //if paid and already entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-danger border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-dark fw-bold bg-danger rounded p-3 text-center'><i>Already Been Used And Verified By</i> " +
name1 + " <i>At</i> <br>" + time1 +
" !! <br> <small class='p-1 m-1 text-danger bg-dark'>PLEASE SHOW YOUR PASS TO PROCEED</small></p>";
} else if (status1 == "PAID" && time1 == null) { //if paid and not entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 fw-bold text-dark bg-success p-3 text-center'><i class='fa-solid fa-check-double'></i> <br>Already Paid <br> Successfully Verified</p>";
$.ajax({
type: "POST",
url: "insertScanTime.php",
data: {
qrCodeMessage: qrCodeMessage
},
cache: false,
success: function (qrCode) {
// document.getElementById('status1').innerHTML = "<p class='fs-5 text-dark fw-bold bg-success p-3 text-center'>Successfully Verified !!</p>";
//alert('VERIFIED');
},
error: function (xhr, status, error) {
console.error(xhr);
}
});
} else if (status1 == "NOT PAID" && time1 ==
null) { //if not paid and not entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-danger p-3 text-center'>NOT PAID !! <br> <i>Pay Now to Verify Ticket</i> <button class='verifyBtn animate__animated animate__shakeX animate__infinite animate__delay-2s animate__slow btn p-1 m-1 fw-bold fs-4 text-danger bg-dark'>Verify Payment</button></p>";
// on click on the verify buutton above
$(document).ready(function () {
$(document).on('click', '.verifyBtn', function () {
// alert('verified button clicked');
$.ajax({
url: "verifyScannedTicket.php",
type: "POST",
data: {
qrCodeMessage: qrCodeMessage
},
success: function (result) {
document.getElementById(
'area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById(
'status1')
.innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-success p-3 text-center'>Successfully Verified !!</p>";
//alert('successfully Verified');
}
});
})
})
} else {
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-danger p-3 text-center'><i class='fa-solid fa-xmark'></i><br>ERROR<br><i>GUEST NOT INVITED</i> !!</p>";
}
// alert("the name is " + name1 + " he has " + status1 + " Time entered " + time1);
},
error: function (xhr, status, error) {
console.error(xhr);
}
});
}
ScanValue1.onclick = function () {
var ScanValue = document.getElementById('ScanValue').value; //event id
if (ScanValue != "") {
$.ajax({
type: "POST",
url: "scanTicketAction.php",
data: {
qrCodeMessage: qrCodeMessage,
ScanValue: ScanValue
},
cache: false,
success: function (data) {
ScanValue = ""; //event id
// /document.getElementById('result').value = data;
//alert(data);
var name1 = JSON.parse(data).name;
var status1 = JSON.parse(data).status;
var time1 = JSON.parse(data).time;
// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// checking if the guest exists in the database
if (name1 == null) {
document.getElementById('qrGuestName').innerHTML =
"<span>Qr Message Is</span>";
document.getElementById('result').value = qrCodeMessage;
} else {
document.getElementById('result').value = name1;
document.getElementById('qrGuestName').innerHTML =
"<span>Guest Name:</span>";
}
// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
if (status1 == "PAID" && time1 !=
null) { //if paid and already entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-dark fw-bold bg-danger p-3 text-center'><i>Already Been Used And Verified By</i> " +
name1 + " <i>At</i> <br>" + time1 +
" !! <br> <small class='p-1 m-1 text-danger bg-dark'>PLEASE SHOW YOUR PASS TO PROCEED</small></p>";
} else if (status1 == "PAID" && time1 ==
null) { //if paid and not entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 fw-bold text-dark bg-success p-3 text-center'><i class='fa-solid fa-check-double'></i> <br>Already Paid <br> Successfully Verified</p>";
$.ajax({
type: "POST",
url: "insertScanTime.php",
data: {
qrCodeMessage: qrCodeMessage
},
cache: false,
success: function (qrCode) {
// document.getElementById('status1').innerHTML = "<p class='fs-5 text-dark fw-bold bg-success p-3 text-center'>Successfully Verified !!</p>";
//alert('VERIFIED');
},
error: function (xhr, status, error) {
console.error(xhr);
}
});
} else if (status1 == "NOT PAID" && time1 ==
null) { //if not paid and not entered
document.getElementById('area').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea + "</p>";
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-danger p-3 text-center'>NOT PAID !! <br> <i>Pay Now to Verify Ticket</i> <button class='verifyBtn animate__animated animate__shakeX animate__infinite animate__delay-2s animate__slow btn p-1 m-1 fw-bold fs-4 text-danger bg-dark'>Verify Payment</button></p>";
// on click on the verify buutton above
$(document).ready(function () {
$(document).on('click', '.verifyBtn', function () {
// alert('verified button clicked');
$.ajax({
url: "verifyScannedTicket.php",
type: "POST",
data: {
qrCodeMessage: qrCodeMessage
},
success: function (result) {
document
.getElementById(
'area')
.innerHTML =
"<p class='animate__animated animate__zoomInDown fs-4 text-light fw-bold bg-dark border-success border rounded p-3 text-center'> " +
SeatArea +
"</p>";
document
.getElementById(
'status1')
.innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-success p-3 text-center'>Successfully Verified !!</p>";
//alert('successfully Verified');
}
});
})
})
} else {
document.getElementById('status1').innerHTML =
"<p class='animate__animated animate__zoomInDown fs-5 text-dark fw-bold bg-danger p-3 text-center'><i class='fa-solid fa-xmark'></i><br>ERROR<br><i>GUEST NOT INVITED</i> !!</p>";
}
// alert("the name is " + name1 + " he has " + status1 + " Time entered " + time1);
},
error: function (xhr, status, error) {
console.error(xhr);
}
});
}
}
// $(document).ready(function () {
/*
* 'post_receiver.php' - where you will be passing the form data
* $(this).serialize() - for reading form data quickly
* function(data){... - data includes the response from post_receiver.php
*/
// $.ajax({
// type: 'POST',
// url: 'scanTicketAction.php',
// data: $(this).serialize()
// })
// .done(function (data) {
// // demonstrate the response
// $('#response').html(data);
// })
// .fail(function () {
// // if posting your form failed
// alert("Posting failed.");
// });
// });
// alert('working');
// var xmlhttp = new XMLHttpRequest();
// xmlhttp.onreadystatechange = function () {
// if (this.readyState == 4 && this.status == 200) {
// document.getElementById("txtHint").innerHTML = this.responseText;
// }
// };
// xmlhttp.open("GET", "gethint.php?q=" + str, true);
// xmlhttp.send();
}
function onScanError(errorMessage) {
//handle scan error
// alert('Image Cannot be Scanned. Change Image.')
}
var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", {
fps: 10,
qrbox: 250
});
html5QrcodeScanner.render(onScanSuccess, onScanError);
</script>
</div>
<div class="modal-footer justify-content-center">
<P class="fs-5">Customer satisfaction is our GOAL!</P>
<!-- <button class="btn btn-dark text-light" data-bs-target="#AddEventModal" data-bs-toggle="modal">ADD EVENT</button> -->
</div>
</div>
</div>
</div>