-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooking_success.html
More file actions
173 lines (155 loc) · 6.57 KB
/
booking_success.html
File metadata and controls
173 lines (155 loc) · 6.57 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Booking Success</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"></script>
<style>
/* Global Styles */
body {
font-family: 'Inter', sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #34d399, #059669); /* Green gradient */
color: #fff;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
/* Success Container */
.success-container {
background: #fff; /* Solid white background */
padding: 30px;
border-radius: 15px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
width: 400px;
text-align: center;
animation: fadeIn 1s ease-in-out;
color: #333; /* Dark text for better contrast */
}
.success-container h2 {
margin-bottom: 20px;
font-size: 28px;
font-weight: 600;
color: #059669; /* Green color for the heading */
}
.success-container p {
margin: 10px 0;
font-size: 16px;
color: #555; /* Darker text for better readability */
}
.success-container span {
font-weight: 500;
color: #000; /* Black text for better contrast */
}
/* Success Icon */
.success-icon {
font-size: 48px;
color: #059669; /* Green color for the icon */
margin-bottom: 20px;
animation: bounce 1.5s infinite;
}
/* Download Button */
.download-button {
margin-top: 20px;
padding: 12px 24px;
background: #059669; /* Green color for the button */
color: #fff;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background 0.3s ease, transform 0.3s ease;
}
.download-button:hover {
background: #047857; /* Darker green on hover */
transform: translateY(-2px);
}
.download-button:active {
transform: translateY(0);
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
40% { transform: translateY(-20px); }
60% { transform: translateY(-10px); }
}
</style>
</head>
<body>
<div class="success-container" id="ticket">
<!-- Success Icon -->
<div class="success-icon">
<i class="fas fa-check-circle"></i>
</div>
<h2>Booking Successful!</h2>
<p>Thank you for booking with us. Here are your booking details:</p>
<!-- Booking Details -->
<p>Bus: <span id="busName"></span></p>
<p>From: <span id="source"></span></p>
<p>To: <span id="destination"></span></p>
<p>Total Fare: ₹<span id="fare"></span></p>
<p>Selected Seats: <span id="seats"></span></p>
<p>Pickup: <span id="pickup"></span></p>
<p>Drop-off: <span id="dropoff"></span></p>
<p>Mobile: <span id="mobile"></span></p>
<p>Email: <span id="email"></span></p>
<p>ID Card: <span id="idCard"></span></p>
<!-- Download Ticket Button -->
<button class="download-button" onclick="downloadTicket()">
<i class="fas fa-download"></i> Download Ticket
</button>
</div>
<script>
// Get query parameters from URL
const urlParams = new URLSearchParams(window.location.search);
const farePerSeat = parseFloat(urlParams.get('fare')); // Fare per seat
const selectedSeats = urlParams.get('seats').split(','); // Array of selected seats
const totalFare = farePerSeat * selectedSeats.length; // Calculate total fare
// Display booking details
document.getElementById('busName').textContent = decodeURIComponent(urlParams.get('bus_name'));
document.getElementById('source').textContent = decodeURIComponent(urlParams.get('source'));
document.getElementById('destination').textContent = decodeURIComponent(urlParams.get('destination'));
document.getElementById('fare').textContent = totalFare.toFixed(2); // Display total fare
document.getElementById('seats').textContent = urlParams.get('seats');
document.getElementById('pickup').textContent = decodeURIComponent(urlParams.get('pickup'));
document.getElementById('dropoff').textContent = decodeURIComponent(urlParams.get('dropoff'));
document.getElementById('mobile').textContent = urlParams.get('mobile');
document.getElementById('email').textContent = decodeURIComponent(urlParams.get('email'));
document.getElementById('idCard').textContent = decodeURIComponent(urlParams.get('idCard'));
// Function to download the ticket as a JPG
function downloadTicket() {
const ticketElement = document.getElementById('ticket');
// Add a small delay to ensure everything is rendered
setTimeout(() => {
domtoimage.toJpeg(ticketElement, {
quality: 1.0, // Highest quality
bgcolor: '#fff', // Set background color to white
})
.then((dataUrl) => {
// Create a temporary link to trigger the download
const link = document.createElement('a');
link.href = dataUrl;
link.download = 'ticket.jpg'; // File name for the downloaded image
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
alert("Your ticket has been downloaded as ticket.jpg!");
})
.catch((error) => {
console.error("Error generating ticket image:", error);
alert("Failed to generate the ticket. Please try again.");
});
}, 500); // 500ms delay to ensure rendering
}
</script>
</body>
</html>