PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / KitchenUpgradeChangeFormTemplate.php

KitchenUpgradeChangeFormTemplate.php in The Innovative Form Builder – IvyForms 0.9, at backend/src/Services/Template/KitchenUpgradeChangeFormTemplate.php

466 lines 17.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Translations\BackendStrings;
11
12 class KitchenUpgradeChangeFormTemplate
13 {
14 /**
15 * Get the kitchen upgrade change form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'kitchen_upgrade_change_form',
23 'name' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form'],
24 'description' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form_desc'],
25 'category' => 'order-forms',
26 'subcategory' => 'change-order-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'kitchen-upgrade-change-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['kitchen_upgrade_change_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getContactInformationFields(),
37 self::getChangeRequestFields(),
38 self::getAdditionalInformationFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Get contact information fields
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getContactInformationFields(): array
51 {
52 return array_merge(
53 self::getNameAndContactFields(),
54 self::getProjectAddressFields()
55 );
56 }
57
58 /**
59 * Get name and contact fields
60 *
61 * @return array<int, array<string, mixed>>
62 */
63 private static function getNameAndContactFields(): array
64 {
65 return [
66 // Homeowner Name
67 [
68 'id' => 1,
69 'fieldIndex' => 1,
70 'type' => 'name',
71 'label' => BackendStrings::getTemplateStrings()['homeowner_name'],
72 'parentId' => null,
73 'defaultValue' => '',
74 'placeholder' => '',
75 'required' => true,
76 'readonly' => false,
77 'position' => 1,
78 ],
79 // First Name - Child of Name Field
80 [
81 'id' => 2,
82 'type' => 'text',
83 'label' => BackendStrings::getNewFormStrings()['first_name'],
84 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_name'],
85 'required' => true,
86 'parentId' => 1,
87 'fieldIndex' => 1,
88 'defaultValue' => '',
89 'position' => 1,
90 'optionHide' => false,
91 'description' => '',
92 'settings' => json_encode(['nameFieldType' => 'nameField1']),
93 ],
94 // Last Name - Child of Name Field
95 [
96 'id' => 3,
97 'type' => 'text',
98 'label' => BackendStrings::getNewFormStrings()['last_name'],
99 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
100 'required' => true,
101 'parentId' => 1,
102 'fieldIndex' => 1,
103 'defaultValue' => '',
104 'position' => 2,
105 'optionHide' => false,
106 'description' => '',
107 'settings' => json_encode(['nameFieldType' => 'nameField2']),
108 ],
109 // Email Address
110 [
111 'id' => 4,
112 'fieldIndex' => 2,
113 'type' => 'email',
114 'label' => BackendStrings::getTemplateStrings()['email_address'],
115 'placeholder' => '[email protected]',
116 'required' => true,
117 'parentId' => null,
118 'defaultValue' => '',
119 'position' => 2,
120 'validation' => [
121 'required' => true,
122 'email' => true
123 ],
124 ],
125 // Contact Number
126 [
127 'id' => 5,
128 'fieldIndex' => 3,
129 'type' => 'phone',
130 'label' => BackendStrings::getTemplateStrings()['contact_number'],
131 'placeholder' => '+1 (_) _-_',
132 'required' => false,
133 'parentId' => null,
134 'defaultValue' => '',
135 'position' => 3,
136 'phoneAutoDetect' => true,
137 ],
138 ];
139 }
140
141 /**
142 * Get project address fields
143 *
144 * @return array<int, array<string, mixed>>
145 */
146 private static function getProjectAddressFields(): array
147 {
148 return [
149 // Project Address - Parent
150 [
151 'id' => 6,
152 'fieldIndex' => 4,
153 'type' => 'address',
154 'label' => BackendStrings::getTemplateStrings()['project_address'],
155 'placeholder' => '',
156 'required' => true,
157 'parentId' => null,
158 'defaultValue' => '',
159 'readonly' => false,
160 'position' => 4,
161 ],
162 // Address Line 1 - Child of Address Field
163 [
164 'id' => 8,
165 'type' => 'text',
166 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
167 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
168 'required' => true,
169 'parentId' => 4,
170 'fieldIndex' => 4,
171 'defaultValue' => '',
172 'position' => 1,
173 'hideLabel' => false,
174 'description' => '',
175 'addressType' => 'streetAddress',
176 'settings' => json_encode([
177 'type' => 'streetAddress',
178 'hideLabel' => false,
179 'description' => '',
180 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
181 'requiredMessage' => '',
182 'visible' => true,
183 ]),
184 ],
185 // Address Line 2 - Child of Address Field
186 [
187 'id' => 10,
188 'type' => 'text',
189 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
190 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
191 'required' => false,
192 'parentId' => 4,
193 'fieldIndex' => 4,
194 'defaultValue' => '',
195 'position' => 2,
196 'hideLabel' => false,
197 'description' => '',
198 'addressType' => 'addressLine2',
199 'settings' => json_encode([
200 'type' => 'addressLine2',
201 'hideLabel' => false,
202 'description' => '',
203 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
204 'requiredMessage' => '',
205 'visible' => true,
206 ]),
207 ],
208 // City - Child of Address Field
209 [
210 'id' => 12,
211 'type' => 'text',
212 'label' => BackendStrings::getTemplateStrings()['city'],
213 'placeholder' => '',
214 'required' => true,
215 'parentId' => 4,
216 'fieldIndex' => 4,
217 'defaultValue' => '',
218 'position' => 3,
219 'hideLabel' => false,
220 'description' => '',
221 'addressType' => 'city',
222 'settings' => json_encode([
223 'type' => 'city',
224 'hideLabel' => false,
225 'description' => '',
226 'placeholder' => BackendStrings::getTemplateStrings()['city'],
227 'requiredMessage' => '',
228 'visible' => true,
229 ]),
230 ],
231 // State/Province - Child of Address Field
232 [
233 'id' => 14,
234 'type' => 'text',
235 'label' => BackendStrings::getTemplateStrings()['state_province'],
236 'placeholder' => '',
237 'required' => true,
238 'parentId' => 4,
239 'fieldIndex' => 4,
240 'defaultValue' => '',
241 'position' => 4,
242 'hideLabel' => false,
243 'description' => '',
244 'addressType' => 'state',
245 'settings' => json_encode([
246 'type' => 'state',
247 'hideLabel' => false,
248 'description' => '',
249 'placeholder' => BackendStrings::getTemplateStrings()['state'],
250 'requiredMessage' => '',
251 'visible' => true,
252 ]),
253 ],
254 // Zip/Postal Code - Child of Address Field
255 [
256 'id' => 16,
257 'type' => 'text',
258 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
259 'placeholder' => '',
260 'required' => true,
261 'parentId' => 4,
262 'fieldIndex' => 4,
263 'defaultValue' => '',
264 'position' => 5,
265 'hideLabel' => false,
266 'description' => '',
267 'addressType' => 'zip',
268 'settings' => json_encode([
269 'type' => 'zip',
270 'hideLabel' => false,
271 'description' => '',
272 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
273 'requiredMessage' => '',
274 'visible' => true,
275 ]),
276 ],
277 // Country - Child of Address Field
278 [
279 'id' => 18,
280 'type' => 'text',
281 'label' => BackendStrings::getTemplateStrings()['country'],
282 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
283 'required' => true,
284 'parentId' => 4,
285 'fieldIndex' => 4,
286 'defaultValue' => '',
287 'position' => 6,
288 'hideLabel' => false,
289 'description' => '',
290 'addressType' => 'country',
291 'settings' => json_encode([
292 'type' => 'country',
293 'hideLabel' => false,
294 'description' => '',
295 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
296 'requiredMessage' => '',
297 'visible' => true,
298 ]),
299 ],
300 ];
301 }
302
303 /**
304 * Get change request fields
305 *
306 * @return array<int, array<string, mixed>>
307 */
308 private static function getChangeRequestFields(): array
309 {
310 return [
311 // Change Request Date
312 [
313 'id' => 19,
314 'fieldIndex' => 5,
315 'type' => 'date',
316 'label' => BackendStrings::getTemplateStrings()['change_request_date'],
317 'placeholder' => BackendStrings::getTemplateStrings()['select_change_request_date'],
318 'required' => true,
319 'parentId' => null,
320 'defaultValue' => '',
321 'position' => 5,
322 ],
323 // Upgrade Type Dropdown
324 [
325 'id' => 27,
326 'fieldIndex' => 6,
327 'type' => 'select',
328 'label' => BackendStrings::getTemplateStrings()['upgrade_type'],
329 'placeholder' => BackendStrings::getTemplateStrings()['select_upgrade_type'],
330 'required' => true,
331 'parentId' => null,
332 'defaultValue' => '',
333 'position' => 6,
334 'fieldOptions' => [
335 [
336 'id' => 20,
337 'label' => BackendStrings::getTemplateStrings()['cabinets'],
338 'value' => 'cabinets',
339 'isDefault' => false,
340 'position' => 1,
341 ],
342 [
343 'id' => 21,
344 'label' => BackendStrings::getTemplateStrings()['countertops'],
345 'value' => 'countertops',
346 'isDefault' => false,
347 'position' => 2,
348 ],
349 [
350 'id' => 22,
351 'label' => BackendStrings::getTemplateStrings()['appliances'],
352 'value' => 'appliances',
353 'isDefault' => false,
354 'position' => 3,
355 ],
356 [
357 'id' => 23,
358 'label' => BackendStrings::getTemplateStrings()['flooring'],
359 'value' => 'flooring',
360 'isDefault' => false,
361 'position' => 4,
362 ],
363 [
364 'id' => 24,
365 'label' => BackendStrings::getTemplateStrings()['lighting'],
366 'value' => 'lighting',
367 'isDefault' => false,
368 'position' => 5,
369 ],
370 [
371 'id' => 25,
372 'label' => BackendStrings::getTemplateStrings()['plumbing'],
373 'value' => 'plumbing',
374 'isDefault' => false,
375 'position' => 6,
376 ],
377 [
378 'id' => 26,
379 'label' => BackendStrings::getTemplateStrings()['other'],
380 'value' => 'other',
381 'isDefault' => false,
382 'position' => 7,
383 ],
384 ],
385 ],
386 // Description of Change
387 [
388 'id' => 28,
389 'fieldIndex' => 7,
390 'type' => 'textarea',
391 'label' => BackendStrings::getTemplateStrings()['description_of_change'],
392 'placeholder' => BackendStrings::getTemplateStrings()['describe_the_change_requested'],
393 'required' => true,
394 'parentId' => null,
395 'defaultValue' => '',
396 'position' => 7,
397 'rows' => 4,
398 ],
399 // Estimated Cost
400 [
401 'id' => 29,
402 'fieldIndex' => 8,
403 'type' => 'number',
404 'label' => BackendStrings::getTemplateStrings()['estimated_cost'],
405 'placeholder' => BackendStrings::getTemplateStrings()['enter_estimated_cost'],
406 'required' => false,
407 'parentId' => null,
408 'defaultValue' => '',
409 'position' => 8,
410 ],
411 ];
412 }
413
414 /**
415 * Get additional information fields
416 *
417 * @return array<int, array<string, mixed>>
418 */
419 private static function getAdditionalInformationFields(): array
420 {
421 return [
422 // Requires Designer Approval? Radio
423 [
424 'id' => 32,
425 'fieldIndex' => 9,
426 'type' => 'radio',
427 'label' => BackendStrings::getTemplateStrings()['requires_designer_approval'],
428 'placeholder' => '',
429 'required' => false,
430 'parentId' => null,
431 'defaultValue' => '',
432 'position' => 9,
433 'fieldOptions' => [
434 [
435 'id' => 30,
436 'label' => BackendStrings::getTemplateStrings()['yes'],
437 'value' => 'yes',
438 'isDefault' => false,
439 'position' => 1,
440 ],
441 [
442 'id' => 31,
443 'label' => BackendStrings::getTemplateStrings()['no'],
444 'value' => 'no',
445 'isDefault' => false,
446 'position' => 2,
447 ],
448 ],
449 ],
450 // Additional Notes / Instructions
451 [
452 'id' => 33,
453 'fieldIndex' => 10,
454 'type' => 'textarea',
455 'label' => BackendStrings::getTemplateStrings()['additional_notes_instructions'],
456 'placeholder' => BackendStrings::getTemplateStrings()['enter_additional_notes_instructions'],
457 'required' => false,
458 'parentId' => null,
459 'defaultValue' => '',
460 'position' => 10,
461 'rows' => 4,
462 ],
463 ];
464 }
465 }
466