PluginProbe
The Innovative Form Builder – IvyForms / 0.8.1
The Innovative Form Builder – IvyForms v0.8.1
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 / MaintenanceWorkOrderFormTemplate.php

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

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