PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.3
Booking for Appointments and Events Calendar – Amelia v2.3
2.4.5 2.4.4 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 4 months ago BookingApplicationService.php 2 months ago BookingFallbackService.php 5 months ago EventApplicationService.php 2 months ago IcsApplicationService.php 1 year ago
BookingFallbackService.php
238 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 ];
86 }
87
88 /**
89 * Generate HTML page
90 */
91 private static function generateHtml(string $title, string $description, string $color, string $iconType): string
92 {
93 $siteUrl = home_url();
94 $siteName = get_bloginfo('name');
95 $returnHomeText = BackendStrings::get('fallback_return_to_home');
96
97 // Get the appropriate SVG icon based on type
98 $iconSvg = self::getIconSvg($iconType);
99
100 return <<<HTML
101 <!DOCTYPE html>
102 <html lang="en">
103 <head>
104 <meta charset="UTF-8">
105 <meta name="viewport" content="width=device-width, initial-scale=1.0">
106 <title>{$title} - {$siteName}</title>
107 <style>
108 * {
109 margin: 0;
110 padding: 0;
111 box-sizing: border-box;
112 }
113 body {
114 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
115 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
116 min-height: 100vh;
117 display: flex;
118 align-items: center;
119 justify-content: center;
120 padding: 20px;
121 }
122 .container {
123 background: white;
124 border-radius: 12px;
125 box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
126 max-width: 500px;
127 width: 100%;
128 padding: 40px 30px;
129 text-align: center;
130 }
131 .icon {
132 width: 80px;
133 height: 80px;
134 margin: 0 auto 20px;
135 border-radius: 50%;
136 display: flex;
137 align-items: center;
138 justify-content: center;
139 background-color: {$color};
140 opacity: 0.9;
141 }
142 .icon svg {
143 width: 45px;
144 height: 45px;
145 fill: white;
146 }
147 h1 {
148 color: #333;
149 font-size: 28px;
150 font-weight: 600;
151 margin-bottom: 15px;
152 }
153 p {
154 color: #666;
155 font-size: 16px;
156 line-height: 1.6;
157 margin-bottom: 30px;
158 }
159 .btn {
160 display: inline-block;
161 background-color: {$color};
162 color: white;
163 text-decoration: none;
164 padding: 12px 30px;
165 border-radius: 6px;
166 font-weight: 500;
167 transition: all 0.3s ease;
168 }
169 .btn:hover {
170 opacity: 0.9;
171 transform: translateY(-2px);
172 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
173 }
174 @media (max-width: 600px) {
175 .container {
176 padding: 30px 20px;
177 }
178 h1 {
179 font-size: 24px;
180 }
181 p {
182 font-size: 14px;
183 }
184 }
185 </style>
186 </head>
187 <body>
188 <div class="container">
189 <div class="icon">
190 {$iconSvg}
191 </div>
192 <h1>{$title}</h1>
193 <p>{$description}</p>
194 <a href="{$siteUrl}" class="btn">{$returnHomeText}</a>
195 </div>
196 </body>
197 </html>
198 HTML;
199 }
200
201 /**
202 * Get SVG icon based on type
203 */
204 private static function getIconSvg(string $iconType): string
205 {
206 $checkIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
207 '<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 ' .
208 '1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>';
209
210 $errorIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
211 '<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 ' .
212 '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>';
213
214 $warningIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
215 '<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>';
216
217 $infoIcon = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' .
218 '<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>';
219
220 $icons = [
221 'check' => $checkIcon,
222 'error' => $errorIcon,
223 'warning' => $warningIcon,
224 'info' => $infoIcon
225 ];
226
227 return $icons[$iconType] ?? $icons['info'];
228 }
229
230 /**
231 * Get fallback page HTML
232 */
233 public static function getFallbackHtml(string $statusType): string
234 {
235 return self::getFallbackPage($statusType);
236 }
237 }
238