PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/Services/Template/MaintenanceWorkOrderFormTemplate.php +142 -95 0.8.2 → 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 MaintenanceWorkOrderFormTemplate
13 8 {
14 9 /**
15 - * Get the maintenance work order 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' => 'maintenance_work_order_form',
23 18 'name' => BackendStrings::getTemplateStrings()['maintenance_work_order_form'],
@@ -24,9 +19,22 @@
24 19 'description' => BackendStrings::getTemplateStrings()['maintenance_work_order_form_desc'],
25 20 'category' => 'order-forms',
26 21 'subcategory' => 'work-order-forms',
27 22 'is_pro' => false,
28 - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maintenance-work-order-form.svg',
23 + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maintenance-work-order-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 + [
29 37 'form_data' => [
30 38 'name' => BackendStrings::getTemplateStrings()['maintenance_work_order_form'],
31 39 'published' => 1,
32 40 'showTitle' => 1,
@@ -39,9 +47,10 @@
39 47 self::getSubmissionApprovalFields()
40 48 ),
41 49 'settings' => []
42 50 ]
43 - ];
51 + ]
52 + );
44 53 }
45 54
46 55 /**
47 56 * Get requester information fields
@@ -52,9 +61,9 @@
52 61 {
53 62 return [
54 63 // Name Field - Parent
55 64 [
56 - 'id' => 0,
65 + 'id' => 1,
57 66 'fieldIndex' => 1,
58 67 'type' => 'name',
59 68 'label' => BackendStrings::getTemplateStrings()['full_name'],
60 69 'parentId' => null,
@@ -65,14 +74,14 @@
65 74 'position' => 1,
66 75 ],
67 76 // First Name - Child of Name Field
68 77 [
69 - 'id' => 0,
78 + 'id' => 2,
70 79 'type' => 'text',
71 80 'label' => BackendStrings::getNewFormStrings()['first_name'],
72 81 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
73 82 'required' => true,
74 - 'parentId' => 0,
83 + 'parentId' => 1,
75 84 'fieldIndex' => 1,
76 85 'defaultValue' => '',
77 86 'position' => 1,
78 87 'optionHide' => false,
@@ -80,14 +89,14 @@
80 89 'settings' => json_encode(['nameFieldType' => 'nameField1']),
81 90 ],
82 91 // Last Name - Child of Name Field
83 92 [
84 - 'id' => 0,
93 + 'id' => 3,
85 94 'type' => 'text',
86 95 'label' => BackendStrings::getNewFormStrings()['last_name'],
87 96 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
88 97 'required' => true,
89 - 'parentId' => 0,
98 + 'parentId' => 1,
90 99 'fieldIndex' => 1,
91 100 'defaultValue' => '',
92 101 'position' => 2,
93 102 'optionHide' => false,
@@ -95,9 +104,9 @@
95 104 'settings' => json_encode(['nameFieldType' => 'nameField2']),
96 105 ],
97 106 // Email Address
98 107 [
99 - 'id' => 0,
108 + 'id' => 4,
100 109 'fieldIndex' => 2,
101 110 'type' => 'email',
102 111 'label' => BackendStrings::getTemplateStrings()['email_address'],
103 112 'placeholder' => '[email protected]',
@@ -107,9 +116,9 @@
107 116 'position' => 2,
108 117 ],
109 118 // Phone Number
110 119 [
111 - 'id' => 0,
120 + 'id' => 5,
112 121 'fieldIndex' => 3,
113 122 'type' => 'phone',
114 123 'label' => BackendStrings::getTemplateStrings()['phone_number'],
115 124 'placeholder' => '+1 (_) _-_',
@@ -128,12 +137,25 @@
128 137 * @return array<int, array<string, mixed>>
129 138 */
130 139 private static function getLocationFacilityFields(): array
131 140 {
141 + return array_merge(
142 + self::getLocationFields(),
143 + self::getFacilityAddressFields()
144 + );
145 + }
146 +
147 + /**
148 + * Building / department / room fields
149 + *
150 + * @return array<int, array<string, mixed>>
151 + */
152 + private static function getLocationFields(): array
153 + {
132 154 return [
133 155 // Building / Department / Room
134 156 [
135 - 'id' => 0,
157 + 'id' => 6,
136 158 'fieldIndex' => 4,
137 159 'type' => 'text',
138 160 'label' => BackendStrings::getTemplateStrings()['building_department_room'],
139 161 'placeholder' => BackendStrings::getTemplateStrings()['enter_building_department_room'],
@@ -141,11 +163,22 @@
141 163 'parentId' => null,
142 164 'defaultValue' => '',
143 165 'position' => 4,
144 166 ],
167 + ];
168 + }
169 +
170 + /**
171 + * Facility address fields
172 + *
173 + * @return array<int, array<string, mixed>>
174 + */
175 + private static function getFacilityAddressFields(): array
176 + {
177 + return [
145 178 // Address Field - Parent
146 179 [
147 - 'id' => 0,
180 + 'id' => 7,
148 181 'fieldIndex' => 5,
149 182 'type' => 'address',
150 183 'label' => BackendStrings::getTemplateStrings()['address_site_location'],
151 184 'parentId' => null,
@@ -156,14 +189,14 @@
156 189 'required' => false,
157 190 ],
158 191 // Address Line 1 - Child of Address Field
159 192 [
160 - 'id' => 0,
193 + 'id' => 9,
161 194 'type' => 'text',
162 195 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
163 196 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
164 197 'required' => false,
165 - 'parentId' => 0,
198 + 'parentId' => 5,
166 199 'fieldIndex' => 5,
167 200 'defaultValue' => '',
168 201 'position' => 1,
169 202 'hideLabel' => false,
@@ -168,25 +201,27 @@
168 201 'position' => 1,
169 202 'hideLabel' => false,
170 203 'description' => '',
171 204 'addressType' => 'streetAddress',
172 - 'settings' => json_encode([
173 - 'type' => 'streetAddress',
174 - 'hideLabel' => false,
175 - 'description' => '',
176 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
177 - 'requiredMessage' => '',
178 - 'visible' => true
179 - ]),
205 + 'settings' => json_encode(
206 + [
207 + 'type' => 'streetAddress',
208 + 'hideLabel' => false,
209 + 'description' => '',
210 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
211 + 'requiredMessage' => '',
212 + 'visible' => true
213 + ]
214 + ),
180 215 ],
181 216 // Address Line 2 - Child of Address Field
182 217 [
183 - 'id' => 0,
218 + 'id' => 11,
184 219 'type' => 'text',
185 220 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
186 221 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
187 222 'required' => false,
188 - 'parentId' => 0,
223 + 'parentId' => 5,
189 224 'fieldIndex' => 5,
190 225 'defaultValue' => '',
191 226 'position' => 2,
192 227 'hideLabel' => false,
@@ -191,25 +226,27 @@
191 226 'position' => 2,
192 227 'hideLabel' => false,
193 228 'description' => '',
194 229 'addressType' => 'addressLine2',
195 - 'settings' => json_encode([
196 - 'type' => 'addressLine2',
197 - 'hideLabel' => false,
198 - 'description' => '',
199 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
200 - 'requiredMessage' => '',
201 - 'visible' => true
202 - ]),
230 + 'settings' => json_encode(
231 + [
232 + 'type' => 'addressLine2',
233 + 'hideLabel' => false,
234 + 'description' => '',
235 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
236 + 'requiredMessage' => '',
237 + 'visible' => true
238 + ]
239 + ),
203 240 ],
204 241 // City - Child of Address Field
205 242 [
206 - 'id' => 0,
243 + 'id' => 13,
207 244 'type' => 'text',
208 245 'label' => BackendStrings::getTemplateStrings()['city'],
209 246 'placeholder' => BackendStrings::getTemplateStrings()['city'],
210 247 'required' => false,
211 - 'parentId' => 0,
248 + 'parentId' => 5,
212 249 'fieldIndex' => 5,
213 250 'defaultValue' => '',
214 251 'position' => 3,
215 252 'hideLabel' => false,
@@ -214,25 +251,27 @@
214 251 'position' => 3,
215 252 'hideLabel' => false,
216 253 'description' => '',
217 254 'addressType' => 'city',
218 - 'settings' => json_encode([
219 - 'type' => 'city',
220 - 'hideLabel' => false,
221 - 'description' => '',
222 - 'placeholder' => BackendStrings::getTemplateStrings()['city'],
223 - 'requiredMessage' => '',
224 - 'visible' => true
225 - ]),
255 + 'settings' => json_encode(
256 + [
257 + 'type' => 'city',
258 + 'hideLabel' => false,
259 + 'description' => '',
260 + 'placeholder' => BackendStrings::getTemplateStrings()['city'],
261 + 'requiredMessage' => '',
262 + 'visible' => true
263 + ]
264 + ),
226 265 ],
227 266 // State / Province - Child of Address Field
228 267 [
229 - 'id' => 0,
268 + 'id' => 15,
230 269 'type' => 'text',
231 270 'label' => BackendStrings::getTemplateStrings()['state_province'],
232 271 'placeholder' => BackendStrings::getTemplateStrings()['state'],
233 272 'required' => false,
234 - 'parentId' => 0,
273 + 'parentId' => 5,
235 274 'fieldIndex' => 5,
236 275 'defaultValue' => '',
237 276 'position' => 4,
238 277 'hideLabel' => false,
@@ -237,25 +276,27 @@
237 276 'position' => 4,
238 277 'hideLabel' => false,
239 278 'description' => '',
240 279 'addressType' => 'state',
241 - 'settings' => json_encode([
242 - 'type' => 'state',
243 - 'hideLabel' => false,
244 - 'description' => '',
245 - 'placeholder' => BackendStrings::getTemplateStrings()['state'],
246 - 'requiredMessage' => '',
247 - 'visible' => true
248 - ]),
280 + 'settings' => json_encode(
281 + [
282 + 'type' => 'state',
283 + 'hideLabel' => false,
284 + 'description' => '',
285 + 'placeholder' => BackendStrings::getTemplateStrings()['state'],
286 + 'requiredMessage' => '',
287 + 'visible' => true
288 + ]
289 + ),
249 290 ],
250 291 // Zip / Postal Code - Child of Address Field
251 292 [
252 - 'id' => 0,
293 + 'id' => 17,
253 294 'type' => 'text',
254 295 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
255 296 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
256 297 'required' => false,
257 - 'parentId' => 0,
298 + 'parentId' => 5,
258 299 'fieldIndex' => 5,
259 300 'defaultValue' => '',
260 301 'position' => 5,
261 302 'hideLabel' => false,
@@ -260,25 +301,27 @@
260 301 'position' => 5,
261 302 'hideLabel' => false,
262 303 'description' => '',
263 304 'addressType' => 'zip',
264 - 'settings' => json_encode([
265 - 'type' => 'zip',
266 - 'hideLabel' => false,
267 - 'description' => '',
268 - 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
269 - 'requiredMessage' => '',
270 - 'visible' => true
271 - ]),
305 + 'settings' => json_encode(
306 + [
307 + 'type' => 'zip',
308 + 'hideLabel' => false,
309 + 'description' => '',
310 + 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
311 + 'requiredMessage' => '',
312 + 'visible' => true
313 + ]
314 + ),
272 315 ],
273 316 // Country - Child of Address Field
274 317 [
275 - 'id' => 0,
318 + 'id' => 19,
276 319 'type' => 'text',
277 320 'label' => BackendStrings::getTemplateStrings()['country'],
278 321 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
279 322 'required' => false,
280 - 'parentId' => 0,
323 + 'parentId' => 5,
281 324 'fieldIndex' => 5,
282 325 'defaultValue' => '',
283 326 'position' => 6,
284 327 'hideLabel' => false,
@@ -283,16 +326,18 @@
283 326 'position' => 6,
284 327 'hideLabel' => false,
285 328 'description' => '',
286 329 'addressType' => 'country',
287 - 'settings' => json_encode([
288 - 'type' => 'country',
289 - 'hideLabel' => false,
290 - 'description' => '',
291 - 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
292 - 'requiredMessage' => '',
293 - 'visible' => true
294 - ]),
330 + 'settings' => json_encode(
331 + [
332 + 'type' => 'country',
333 + 'hideLabel' => false,
334 + 'description' => '',
335 + 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
336 + 'requiredMessage' => '',
337 + 'visible' => true
338 + ]
339 + ),
295 340 ],
296 341 ];
297 342 }
298 343
@@ -305,9 +350,9 @@
305 350 {
306 351 return [
307 352 // Type of Maintenance / Issue
308 353 [
309 - 'id' => 0,
354 + 'id' => 25,
310 355 'fieldIndex' => 6,
311 356 'type' => 'select',
312 357 'label' => BackendStrings::getTemplateStrings()['type_of_maintenance_issue'],
313 358 'placeholder' => BackendStrings::getTemplateStrings()['select_type_of_maintenance'],
@@ -316,9 +361,9 @@
316 361 'defaultValue' => '',
317 362 'position' => 6,
318 363 'fieldOptions' => [
319 364 [
320 - 'id' => 0,
365 + 'id' => 20,
321 366 'label' => BackendStrings::getTemplateStrings()['electrical'],
322 367 'value' => 'electrical',
323 368 'isDefault' => false,
324 369 'position' => 1
@@ -323,9 +368,9 @@
323 368 'isDefault' => false,
324 369 'position' => 1
325 370 ],
326 371 [
327 - 'id' => 0,
372 + 'id' => 21,
328 373 'label' => BackendStrings::getTemplateStrings()['plumbing'],
329 374 'value' => 'plumbing',
330 375 'isDefault' => false,
331 376 'position' => 2
@@ -330,9 +375,9 @@
330 375 'isDefault' => false,
331 376 'position' => 2
332 377 ],
333 378 [
334 - 'id' => 0,
379 + 'id' => 22,
335 380 'label' => BackendStrings::getTemplateStrings()['hvac'],
336 381 'value' => 'hvac',
337 382 'isDefault' => false,
338 383 'position' => 3
@@ -337,9 +382,9 @@
337 382 'isDefault' => false,
338 383 'position' => 3
339 384 ],
340 385 [
341 - 'id' => 0,
386 + 'id' => 23,
342 387 'label' => BackendStrings::getTemplateStrings()['general_repair'],
343 388 'value' => 'general_repair',
344 389 'isDefault' => false,
345 390 'position' => 4
@@ -344,9 +389,9 @@
344 389 'isDefault' => false,
345 390 'position' => 4
346 391 ],
347 392 [
348 - 'id' => 0,
393 + 'id' => 24,
349 394 'label' => BackendStrings::getTemplateStrings()['other'],
350 395 'value' => 'other',
351 396 'isDefault' => false,
352 397 'position' => 5
@@ -354,9 +399,9 @@
354 399 ]
355 400 ],
356 401 // Description of Problem
357 402 [
358 - 'id' => 0,
403 + 'id' => 26,
359 404 'fieldIndex' => 7,
360 405 'type' => 'textarea',
361 406 'label' => BackendStrings::getTemplateStrings()['description_of_problem'],
362 407 'placeholder' => BackendStrings::getTemplateStrings()['describe_the_maintenance_issue'],
@@ -366,9 +411,9 @@
366 411 'position' => 7,
367 412 ],
368 413 // Urgency / Priority
369 414 [
370 - 'id' => 0,
415 + 'id' => 30,
371 416 'fieldIndex' => 8,
372 417 'type' => 'select',
373 418 'label' => BackendStrings::getTemplateStrings()['urgency_priority'],
374 419 'placeholder' => BackendStrings::getTemplateStrings()['select_urgency_level'],
@@ -377,9 +422,9 @@
377 422 'defaultValue' => '',
378 423 'position' => 8,
379 424 'fieldOptions' => [
380 425 [
381 - 'id' => 0,
426 + 'id' => 27,
382 427 'label' => BackendStrings::getTemplateStrings()['low'],
383 428 'value' => 'low',
384 429 'isDefault' => false,
385 430 'position' => 1
@@ -384,9 +429,9 @@
384 429 'isDefault' => false,
385 430 'position' => 1
386 431 ],
387 432 [
388 - 'id' => 0,
433 + 'id' => 28,
389 434 'label' => BackendStrings::getTemplateStrings()['medium'],
390 435 'value' => 'medium',
391 436 'isDefault' => false,
392 437 'position' => 2
@@ -391,9 +436,9 @@
391 436 'isDefault' => false,
392 437 'position' => 2
393 438 ],
394 439 [
395 - 'id' => 0,
440 + 'id' => 29,
396 441 'label' => BackendStrings::getTemplateStrings()['high'],
397 442 'value' => 'high',
398 443 'isDefault' => false,
399 444 'position' => 3
@@ -400,9 +445,9 @@
400 445 ],
401 446 ]
402 447 ],
403 448 [
404 - 'id' => 0,
449 + 'id' => 31,
405 450 'fieldIndex' => 9,
406 451 'type' => 'time',
407 452 'label' => BackendStrings::getTemplateStrings()['preferred_date_time'],
408 453 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_date_time'],
@@ -414,9 +459,9 @@
414 459 'timeFormat' => 'ampm',
415 460 ],
416 461 // Additional Instructions / Notes
417 462 [
418 - 'id' => 0,
463 + 'id' => 32,
419 464 'fieldIndex' => 10,
420 465 'type' => 'textarea',
421 466 'label' => BackendStrings::getTemplateStrings()['additional_instructions_notes'],
422 467 'placeholder' => BackendStrings::getTemplateStrings()['add_any_additional_notes'],
@@ -437,9 +482,9 @@
437 482 {
438 483 return [
439 484 // Supervisor Approval Required?
440 485 [
441 - 'id' => 0,
486 + 'id' => 35,
442 487 'fieldIndex' => 11,
443 488 'type' => 'radio',
444 489 'label' => BackendStrings::getTemplateStrings()['supervisor_approval_required'],
445 490 'placeholder' => '',
@@ -448,9 +493,9 @@
448 493 'defaultValue' => '',
449 494 'position' => 11,
450 495 'fieldOptions' => [
451 496 [
452 - 'id' => 0,
497 + 'id' => 33,
453 498 'label' => BackendStrings::getTemplateStrings()['yes'],
454 499 'value' => 'yes',
455 500 'isDefault' => false,
456 501 'position' => 1
@@ -455,9 +500,9 @@
455 500 'isDefault' => false,
456 501 'position' => 1
457 502 ],
458 503 [
459 - 'id' => 0,
504 + 'id' => 34,
460 505 'label' => BackendStrings::getTemplateStrings()['no'],
461 506 'value' => 'no',
462 507 'isDefault' => false,
463 508 'position' => 2
@@ -465,9 +510,9 @@
465 510 ]
466 511 ],
467 512 // Date Submitted
468 513 [
469 - 'id' => 0,
514 + 'id' => 36,
470 515 'fieldIndex' => 12,
471 516 'type' => 'date',
472 517 'label' => BackendStrings::getTemplateStrings()['date_submitted'],
473 518 'placeholder' => '',
@@ -474,8 +519,10 @@
474 519 'required' => false,
475 520 'parentId' => null,
476 521 'defaultValue' => '',
477 522 'position' => 12,
523 + 'dateFieldType' => 'picker',
524 + 'dateFormat' => 'MM/DD/YYYY',
478 525 ],
479 526 ];
480 527 }
481 528 }