PluginProbe
The Innovative Form Builder – IvyForms / 1.4
The Innovative Form Builder – IvyForms v1.4
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 1.4, at backend/src/Services/Template/KitchenUpgradeChangeFormTemplate.php

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