← All changes
|
backend/src/Services/Template/SpaAppointmentBookingFormTemplate.php
+39
-29
0.7
→
1.5
View file →
| @@ -1,23 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Template; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\Services\Translations\BackendStrings; |
| 11 | 6 | |
| 12 | 7 | class SpaAppointmentBookingFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the spa appointment booking form template | |
| 10 | + * Get template metadata (without form_data) | |
| 16 | 11 | * |
| 17 | 12 | * @return array<string, mixed> |
| 18 | 13 | */ |
| 19 | - public static function getTemplate(): array | |
| 14 | + public static function getTemplateMeta(): array | |
| 20 | 15 | { |
| 21 | 16 | return [ |
| 22 | 17 | 'id' => 'spa_appointment_booking_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['spa_appointment_booking_form'], |
| @@ -22,10 +17,24 @@ | ||
| 22 | 17 | 'id' => 'spa_appointment_booking_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['spa_appointment_booking_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['spa_appointment_booking_form_desc'], |
| 25 | 20 | 'category' => 'booking-forms', |
| 21 | + 'subcategory' => 'appointment-booking-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'spa-appointment-booking-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'spa-appointment-booking-form.svg' | |
| 24 | + ]; | |
| 25 | + } | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * Get the full template including form data | |
| 29 | + * | |
| 30 | + * @return array<string, mixed> | |
| 31 | + */ | |
| 32 | + public static function getTemplate(): array | |
| 33 | + { | |
| 34 | + return array_merge( | |
| 35 | + self::getTemplateMeta(), | |
| 36 | + [ | |
| 28 | 37 | 'form_data' => [ |
| 29 | 38 | 'name' => BackendStrings::getTemplateStrings()['spa_appointment_booking_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -37,9 +46,10 @@ | ||
| 37 | 46 | self::getAdditionalPreferencesFields() |
| 38 | 47 | ), |
| 39 | 48 | 'settings' => [] |
| 40 | 49 | ] |
| 41 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 42 | 52 | } |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Get client information fields |
| @@ -50,9 +60,9 @@ | ||
| 50 | 60 | { |
| 51 | 61 | return [ |
| 52 | 62 | // Name Field - Parent |
| 53 | 63 | [ |
| 54 | - 'id' => 0, | |
| 64 | + 'id' => 1, | |
| 55 | 65 | 'fieldIndex' => 1, |
| 56 | 66 | 'type' => 'name', |
| 57 | 67 | 'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 58 | 68 | 'parentId' => null, |
| @@ -63,14 +73,14 @@ | ||
| 63 | 73 | 'position' => 1, |
| 64 | 74 | ], |
| 65 | 75 | // First Name - Child of Name Field |
| 66 | 76 | [ |
| 67 | - 'id' => 0, | |
| 77 | + 'id' => 2, | |
| 68 | 78 | 'type' => 'text', |
| 69 | 79 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 70 | 80 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 71 | 81 | 'required' => true, |
| 72 | - 'parentId' => 0, | |
| 82 | + 'parentId' => 1, | |
| 73 | 83 | 'fieldIndex' => 1, |
| 74 | 84 | 'defaultValue' => '', |
| 75 | 85 | 'position' => 1, |
| 76 | 86 | 'optionHide' => false, |
| @@ -78,14 +88,14 @@ | ||
| 78 | 88 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 79 | 89 | ], |
| 80 | 90 | // Last Name - Child of Name Field |
| 81 | 91 | [ |
| 82 | - 'id' => 0, | |
| 92 | + 'id' => 3, | |
| 83 | 93 | 'type' => 'text', |
| 84 | 94 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 85 | 95 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 86 | 96 | 'required' => true, |
| 87 | - 'parentId' => 0, | |
| 97 | + 'parentId' => 1, | |
| 88 | 98 | 'fieldIndex' => 1, |
| 89 | 99 | 'defaultValue' => '', |
| 90 | 100 | 'position' => 2, |
| 91 | 101 | 'optionHide' => false, |
| @@ -93,9 +103,9 @@ | ||
| 93 | 103 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 94 | 104 | ], |
| 95 | 105 | // Email Address |
| 96 | 106 | [ |
| 97 | - 'id' => 0, | |
| 107 | + 'id' => 4, | |
| 98 | 108 | 'fieldIndex' => 2, |
| 99 | 109 | 'type' => 'email', |
| 100 | 110 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 101 | 111 | 'placeholder' => '[email protected]', |
| @@ -105,9 +115,9 @@ | ||
| 105 | 115 | 'position' => 2, |
| 106 | 116 | ], |
| 107 | 117 | // Phone Number |
| 108 | 118 | [ |
| 109 | - 'id' => 0, | |
| 119 | + 'id' => 5, | |
| 110 | 120 | 'fieldIndex' => 3, |
| 111 | 121 | 'type' => 'phone', |
| 112 | 122 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 113 | 123 | 'placeholder' => '+1 (_) _-_', |
| @@ -143,9 +153,9 @@ | ||
| 143 | 153 | private static function getServiceTypeField(): array |
| 144 | 154 | { |
| 145 | 155 | return [ |
| 146 | 156 | [ |
| 147 | - 'id' => 0, | |
| 157 | + 'id' => 11, | |
| 148 | 158 | 'fieldIndex' => 4, |
| 149 | 159 | 'type' => 'select', |
| 150 | 160 | 'label' => BackendStrings::getTemplateStrings()['service_type'], |
| 151 | 161 | 'placeholder' => BackendStrings::getTemplateStrings()['select_service_type'], |
| @@ -154,9 +164,9 @@ | ||
| 154 | 164 | 'defaultValue' => '', |
| 155 | 165 | 'position' => 4, |
| 156 | 166 | 'fieldOptions' => [ |
| 157 | 167 | [ |
| 158 | - 'id' => 0, | |
| 168 | + 'id' => 6, | |
| 159 | 169 | 'label' => BackendStrings::getTemplateStrings()['massage'], |
| 160 | 170 | 'value' => 'massage', |
| 161 | 171 | 'isDefault' => false, |
| 162 | 172 | 'position' => 1 |
| @@ -161,9 +171,9 @@ | ||
| 161 | 171 | 'isDefault' => false, |
| 162 | 172 | 'position' => 1 |
| 163 | 173 | ], |
| 164 | 174 | [ |
| 165 | - 'id' => 0, | |
| 175 | + 'id' => 7, | |
| 166 | 176 | 'label' => BackendStrings::getTemplateStrings()['facial'], |
| 167 | 177 | 'value' => 'facial', |
| 168 | 178 | 'isDefault' => false, |
| 169 | 179 | 'position' => 2 |
| @@ -168,9 +178,9 @@ | ||
| 168 | 178 | 'isDefault' => false, |
| 169 | 179 | 'position' => 2 |
| 170 | 180 | ], |
| 171 | 181 | [ |
| 172 | - 'id' => 0, | |
| 182 | + 'id' => 8, | |
| 173 | 183 | 'label' => BackendStrings::getTemplateStrings()['body_treatment'], |
| 174 | 184 | 'value' => 'body_treatment', |
| 175 | 185 | 'isDefault' => false, |
| 176 | 186 | 'position' => 3 |
| @@ -175,9 +185,9 @@ | ||
| 175 | 185 | 'isDefault' => false, |
| 176 | 186 | 'position' => 3 |
| 177 | 187 | ], |
| 178 | 188 | [ |
| 179 | - 'id' => 0, | |
| 189 | + 'id' => 9, | |
| 180 | 190 | 'label' => BackendStrings::getTemplateStrings()['aromatherapy'], |
| 181 | 191 | 'value' => 'aromatherapy', |
| 182 | 192 | 'isDefault' => false, |
| 183 | 193 | 'position' => 4 |
| @@ -182,9 +192,9 @@ | ||
| 182 | 192 | 'isDefault' => false, |
| 183 | 193 | 'position' => 4 |
| 184 | 194 | ], |
| 185 | 195 | [ |
| 186 | - 'id' => 0, | |
| 196 | + 'id' => 10, | |
| 187 | 197 | 'label' => BackendStrings::getTemplateStrings()['other'], |
| 188 | 198 | 'value' => 'other', |
| 189 | 199 | 'isDefault' => false, |
| 190 | 200 | 'position' => 5 |
| @@ -202,9 +212,9 @@ | ||
| 202 | 212 | private static function getTherapistPreferenceField(): array |
| 203 | 213 | { |
| 204 | 214 | return [ |
| 205 | 215 | [ |
| 206 | - 'id' => 0, | |
| 216 | + 'id' => 15, | |
| 207 | 217 | 'fieldIndex' => 5, |
| 208 | 218 | 'type' => 'select', |
| 209 | 219 | 'label' => BackendStrings::getTemplateStrings()['preferred_therapist'], |
| 210 | 220 | 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_therapist'], |
| @@ -213,9 +223,9 @@ | ||
| 213 | 223 | 'defaultValue' => '', |
| 214 | 224 | 'position' => 5, |
| 215 | 225 | 'fieldOptions' => [ |
| 216 | 226 | [ |
| 217 | - 'id' => 0, | |
| 227 | + 'id' => 12, | |
| 218 | 228 | 'label' => BackendStrings::getTemplateStrings()['therapist_a'], |
| 219 | 229 | 'value' => 'therapist_a', |
| 220 | 230 | 'isDefault' => false, |
| 221 | 231 | 'position' => 1 |
| @@ -220,9 +230,9 @@ | ||
| 220 | 230 | 'isDefault' => false, |
| 221 | 231 | 'position' => 1 |
| 222 | 232 | ], |
| 223 | 233 | [ |
| 224 | - 'id' => 0, | |
| 234 | + 'id' => 13, | |
| 225 | 235 | 'label' => BackendStrings::getTemplateStrings()['therapist_b'], |
| 226 | 236 | 'value' => 'therapist_b', |
| 227 | 237 | 'isDefault' => false, |
| 228 | 238 | 'position' => 2 |
| @@ -227,9 +237,9 @@ | ||
| 227 | 237 | 'isDefault' => false, |
| 228 | 238 | 'position' => 2 |
| 229 | 239 | ], |
| 230 | 240 | [ |
| 231 | - 'id' => 0, | |
| 241 | + 'id' => 14, | |
| 232 | 242 | 'label' => BackendStrings::getTemplateStrings()['no_preference'], |
| 233 | 243 | 'value' => 'no_preference', |
| 234 | 244 | 'isDefault' => true, |
| 235 | 245 | 'position' => 3 |
| @@ -247,9 +257,9 @@ | ||
| 247 | 257 | private static function getPreferredDateField(): array |
| 248 | 258 | { |
| 249 | 259 | return [ |
| 250 | 260 | [ |
| 251 | - 'id' => 0, | |
| 261 | + 'id' => 16, | |
| 252 | 262 | 'fieldIndex' => 6, |
| 253 | 263 | 'type' => 'date', |
| 254 | 264 | 'label' => BackendStrings::getTemplateStrings()['preferred_appointment_date'], |
| 255 | 265 | 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_date'], |
| @@ -271,9 +281,9 @@ | ||
| 271 | 281 | private static function getPreferredTimeField(): array |
| 272 | 282 | { |
| 273 | 283 | return [ |
| 274 | 284 | [ |
| 275 | - 'id' => 0, | |
| 285 | + 'id' => 17, | |
| 276 | 286 | 'fieldIndex' => 7, |
| 277 | 287 | 'type' => 'time', |
| 278 | 288 | 'label' => BackendStrings::getTemplateStrings()['preferred_time_slot'], |
| 279 | 289 | 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_time'], |
| @@ -295,9 +305,9 @@ | ||
| 295 | 305 | private static function getAdditionalPreferencesFields(): array |
| 296 | 306 | { |
| 297 | 307 | return [ |
| 298 | 308 | [ |
| 299 | - 'id' => 0, | |
| 309 | + 'id' => 18, | |
| 300 | 310 | 'fieldIndex' => 8, |
| 301 | 311 | 'type' => 'textarea', |
| 302 | 312 | 'label' => BackendStrings::getTemplateStrings()['special_instructions_notes'], |
| 303 | 313 | 'placeholder' => BackendStrings::getTemplateStrings()['specify_preferences_health_conditions'], |