PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Application / Services / Booking / BookingFallbackService.php
ameliabooking / src / Application / Services / Booking Last commit date
AppointmentApplicationService.php 2 weeks ago BookingApplicationService.php 1 month ago BookingFallbackService.php 1 month ago EventApplicationService.php 1 month ago IcsApplicationService.php 2 weeks ago
BookingFallbackService.php
250 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Services\Booking;
4
5 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
6
7 /**
8 * Class BookingFallbackService
9 *
10 * Provides fallback HTML pages when redirect URLs are not defined
11 *
12 * @package AmeliaBooking\Application\Services\Booking
13 */
14 class BookingFallbackService
15 {
16 /**
17 * Generates HTML for booking confirmation fallback page
18 */
19 private static function getFallbackPage(string $statusType): string
20 {
21 $messages = self::getMessages();
22
23 if (!isset($messages[$statusType])) {
24 $statusType = 'failed';
25 }
26
27 $message = $messages[$statusType];
28
29 return self::generateHtml(
30 $message['title'],
31 $message['description'],
32 $message['color'],
33 $message['icon']
34 );
35 }
36
37 /**
38 * Get all message configurations
39 */
40 private static function getMessages(): array
41 {
42 return [
43 'approved' => [
44 'title' => BackendStrings::get('fallback_booking_confirmed_title'),
45 'description' => BackendStrings::get('fallback_booking_confirmed_desc'),
46 'color' => '#28a745',
47 'icon' => 'check'
48 ],
49 'processed' => [
50 'title' => BackendStrings::get('fallback_booking_processed_title'),
51 'description' => BackendStrings::get('fallback_booking_processed_desc'),
52 'color' => '#ffc107',
53 'icon' => 'warning'
54 ],
55 'approved_with_issues' => [
56 'title' => BackendStrings::get('fallback_booking_approved_issues_title'),
57 'description' => BackendStrings::get('fallback_booking_approved_issues_desc'),
58 'color' => '#ff9800',
59 'icon' => 'warning'
60 ],
61 'failed' => [
62 'title' => BackendStrings::get('fallback_booking_failed_title'),
63 'description' => BackendStrings::get('fallback_booking_failed_desc'),
64 'color' => '#dc3545',
65 'icon' => 'error'
66 ],
67 'canceled' => [
68 'title' => BackendStrings::get('fallback_booking_canceled_title'),
69 'description' => BackendStrings::get('fallback_booking_canceled_desc'),
70 'color' => '#6c757d',
71 'icon' => 'info'
72 ],
73 'cancel_error' => [
74 'title' => BackendStrings::get('fallback_cancellation_failed_title'),
75 'description' => BackendStrings::get('fallback_cancellation_failed_desc'),
76 'color' => '#dc3545',
77 'icon' => 'error'
78 ],
79 'rejected' => [
80 'title' => BackendStrings::get('fallback_booking_rejected_title'),
81 'description' => BackendStrings::get('fallback_booking_rejected_desc'),
82 'color' => '#6c757d',
83 'icon' => 'info'
84 ],
85 'payment_done' => [
86 'title' => BackendStrings::get('fallback_payment_done_title'),
87 'description' => BackendStrings::get('fallback_payment_desc'),
88 'color' => '#dc3545',
89 'icon' => 'error'
90 ],
91 'payment_failed' => [
92 'title' => BackendStrings::get('fallback_payment_failed_title'),
93 'description' => BackendStrings::get('fallback_payment_desc'),
94 'color' => '#dc3545',
95 'icon' => 'error'
96 ],
97 ];
98 }
99
100 /**
101 * Generate HTML page
102 */
103 private static function generateHtml(string $title, string $description, string $color, string $iconType): string
104 {
105 $siteUrl = home_url();
106 $siteName = get_bloginfo('name');
107 $returnHomeText = BackendStrings::get('fallback_return_to_home');
108
109 // Get the appropriate SVG icon based on type
110 $iconSvg = self::getIconSvg($iconType);
111
112 return <<<HTML
113 <!DOCTYPE html>
114 <html lang="en">
115 <head>
116 <meta charset="UTF-8">
117 <meta name="viewport" content="width=device-width, initial-scale=1.0">
118 <title>{$title} - {$siteName}</title>
119 <style>
120 * {
121 margin: 0;
122 padding: 0;
123 box-sizing: border-box;
124 }
125 body {
126 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
127 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
128 min-height: 100vh;
129 display: flex;
130 align-items: center;
131 justify-content: center;
132 padding: 20px;
133 }
134 .container {
135 background: white;
136 border-radius: 12px;
137 box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
138 max-width: 500px;
139 width: 100%;
140 padding: 40px 30px;
141 text-align: center;
142 }
143 .icon {
144 width: 80px;
145 height: 80px;
146 margin: 0 auto 20px;
147 border-radius: 50%;
148 display: flex;
149 align-items: center;
150 justify-content: center;
151 background-color: {$color};
152 opacity: 0.9;
153 }
154 .icon svg {
155 width: 45px;
156 height: 45px;
157 fill: white;
158 }
159 h1 {
160 color: #333;
161 font-size: 28px;
162 font-weight: 600;
163 margin-bottom: 15px;
164 }
165 p {
166 color: #666;
167 font-size: 16px;
168 line-height: 1.6;
169 margin-bottom: 30px;
170 }
171 .btn {
172 display: inline-block;
173 background-color: {$color};
174 color: white;
175 text-decoration: none;
176 padding: 12px 30px;
177 border-radius: 6px;
178 font-weight: 500;
179 transition: all 0.3s ease;
180 }
181 .btn:hover {
182 opacity: 0.9;
183 transform: translateY(-2px);
184 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
185 }
186 @media (max-width: 600px) {
187 .container {
188 padding: 30px 20px;
189 }
190 h1 {
191 font-size: 24px;
192 }
193 p {
194 font-size: 14px;
195 }
196 }
197 </style>
198 </head>
199 <body>
200 <div class="container">
201 <div class="icon">
202 {$iconSvg}
203 </div>
204 <h1>{$title}</h1>
205 <p>{$description}</p>
206 <a href="{$siteUrl}" class="btn">{$returnHomeText}</a>
207 </div>
208 </body>
209 </html>
210 HTML;
211 }
212
213 /**
214 * Get SVG icon based on type
215 */
216 private static function getIconSvg(string $iconType): string
217 {
218 $checkIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
219 '<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 ' .
220 '1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>';
221
222 $errorIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
223 '<path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 ' .
224 '12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>';
225
226 $warningIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
227 '<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>';
228
229 $infoIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
230 '<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';
231
232 $icons = [
233 'check' => $checkIcon,
234 'error' => $errorIcon,
235 'warning' => $warningIcon,
236 'info' => $infoIcon
237 ];
238
239 return $icons[$iconType] ?? $icons['info'];
240 }
241
242 /**
243 * Get fallback page HTML
244 */
245 public static function getFallbackHtml(string $statusType): string
246 {
247 return self::getFallbackPage($statusType);
248 }
249 }
250