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