PluginProbe
The Innovative Form Builder – IvyForms / 0.8.2
The Innovative Form Builder – IvyForms v0.8.2
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 / RepairWorkOrderFormTemplate.php

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

304 lines 10.8 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 RepairWorkOrderFormTemplate
13 {
14 /**
15 * Get the repair work order form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'repair_work_order_form',
23 'name' => BackendStrings::getTemplateStrings()['repair_work_order_form'],
24 'description' => BackendStrings::getTemplateStrings()['repair_work_order_form_desc'],
25 'category' => 'order-forms',
26 'subcategory' => 'work-order-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'repair-work-order-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['repair_work_order_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getContactInformationFields(),
37 self::getRepairDetailsFields(),
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 [
53 // Employee Name
54 [
55 'id' => 0,
56 'fieldIndex' => 1,
57 'type' => 'name',
58 'label' => BackendStrings::getTemplateStrings()['employee_name'],
59 'parentId' => null,
60 'defaultValue' => '',
61 'placeholder' => '',
62 'required' => true,
63 'readonly' => false,
64 'position' => 1,
65 ],
66 // First Name - Child of Name Field
67 [
68 'id' => 0,
69 'type' => 'text',
70 'label' => BackendStrings::getNewFormStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_name'],
72 'required' => true,
73 'parentId' => 0,
74 'fieldIndex' => 1,
75 'defaultValue' => '',
76 'position' => 1,
77 'optionHide' => false,
78 'description' => '',
79 'settings' => json_encode(['nameFieldType' => 'nameField1']),
80 ],
81 // Last Name - Child of Name Field
82 [
83 'id' => 0,
84 'type' => 'text',
85 'label' => BackendStrings::getNewFormStrings()['last_name'],
86 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
87 'required' => true,
88 'parentId' => 0,
89 'fieldIndex' => 1,
90 'defaultValue' => '',
91 'position' => 2,
92 'optionHide' => false,
93 'description' => '',
94 'settings' => json_encode(['nameFieldType' => 'nameField2']),
95 ],
96 // Email Address
97 [
98 'id' => 0,
99 'fieldIndex' => 2,
100 'type' => 'email',
101 'label' => BackendStrings::getTemplateStrings()['email_address'],
102 'placeholder' => '[email protected]',
103 'required' => true,
104 'parentId' => null,
105 'defaultValue' => '',
106 'position' => 2,
107 'validation' => [
108 'required' => true,
109 'email' => true
110 ],
111 ],
112 // Phone Number
113 [
114 'id' => 0,
115 'fieldIndex' => 3,
116 'type' => 'phone',
117 'label' => BackendStrings::getTemplateStrings()['contact_number'],
118 'placeholder' => '+1 (_) _-_',
119 'required' => true,
120 'parentId' => null,
121 'defaultValue' => '',
122 'position' => 3,
123 'phoneAutoDetect' => true,
124 ],
125 ];
126 }
127
128 /**
129 * Get repair details fields
130 *
131 * @return array<int, array<string, mixed>>
132 */
133 private static function getRepairDetailsFields(): array
134 {
135 return [
136 // Location
137 [
138 'id' => 0,
139 'fieldIndex' => 4,
140 'type' => 'text',
141 'label' => BackendStrings::getTemplateStrings()['location'],
142 'placeholder' => BackendStrings::getTemplateStrings()['exact_location_of_issue'],
143 'required' => true,
144 'parentId' => null,
145 'defaultValue' => '',
146 'position' => 4,
147 ],
148 // Equipment/Item to Repair
149 [
150 'id' => 0,
151 'fieldIndex' => 5,
152 'type' => 'text',
153 'label' => BackendStrings::getTemplateStrings()['equipment_item_to_repair'],
154 'placeholder' => BackendStrings::getTemplateStrings()['device_or_item_name'],
155 'required' => true,
156 'parentId' => null,
157 'defaultValue' => '',
158 'position' => 5,
159 ],
160 // Repair Type Dropdown
161 [
162 'id' => 0,
163 'fieldIndex' => 6,
164 'type' => 'select',
165 'label' => BackendStrings::getTemplateStrings()['repair_type'],
166 'placeholder' => BackendStrings::getTemplateStrings()['select_repair_type'],
167 'required' => true,
168 'parentId' => null,
169 'defaultValue' => '',
170 'position' => 6,
171 'fieldOptions' => [
172 [
173 'id' => 0,
174 'label' => BackendStrings::getTemplateStrings()['mechanical'],
175 'value' => 'mechanical',
176 'isDefault' => false,
177 'position' => 1,
178 ],
179 [
180 'id' => 0,
181 'label' => BackendStrings::getTemplateStrings()['electrical'],
182 'value' => 'electrical',
183 'isDefault' => false,
184 'position' => 2,
185 ],
186 [
187 'id' => 0,
188 'label' => BackendStrings::getTemplateStrings()['software'],
189 'value' => 'software',
190 'isDefault' => false,
191 'position' => 3,
192 ],
193 [
194 'id' => 0,
195 'label' => BackendStrings::getTemplateStrings()['other'],
196 'value' => 'other',
197 'isDefault' => false,
198 'position' => 4,
199 ],
200 ],
201 ],
202 // Severity Dropdown
203 [
204 'id' => 0,
205 'fieldIndex' => 7,
206 'type' => 'select',
207 'label' => BackendStrings::getTemplateStrings()['severity'],
208 'placeholder' => BackendStrings::getTemplateStrings()['select_severity'],
209 'required' => true,
210 'parentId' => null,
211 'defaultValue' => '',
212 'position' => 7,
213 'fieldOptions' => [
214 [
215 'id' => 0,
216 'label' => BackendStrings::getTemplateStrings()['minor'],
217 'value' => 'minor',
218 'isDefault' => false,
219 'position' => 1,
220 ],
221 [
222 'id' => 0,
223 'label' => BackendStrings::getTemplateStrings()['major'],
224 'value' => 'major',
225 'isDefault' => false,
226 'position' => 2,
227 ],
228 [
229 'id' => 0,
230 'label' => BackendStrings::getTemplateStrings()['critical'],
231 'value' => 'critical',
232 'isDefault' => false,
233 'position' => 3,
234 ],
235 ],
236 ],
237 // Preferred Repair Date
238 [
239 'id' => 0,
240 'fieldIndex' => 8,
241 'type' => 'date',
242 'label' => BackendStrings::getTemplateStrings()['preferred_repair_date'],
243 'placeholder' => BackendStrings::getTemplateStrings()['enter_preferred_repair_date'],
244 'required' => true,
245 'parentId' => null,
246 'defaultValue' => '',
247 'position' => 8,
248 ],
249 ];
250 }
251
252 /**
253 * Get additional information fields
254 *
255 * @return array<int, array<string, mixed>>
256 */
257 private static function getAdditionalInformationFields(): array
258 {
259 return [
260 // Steps Already Taken
261 [
262 'id' => 0,
263 'fieldIndex' => 9,
264 'type' => 'textarea',
265 'label' => BackendStrings::getTemplateStrings()['steps_already_taken'],
266 'placeholder' => BackendStrings::getTemplateStrings()['describe_troubleshooting_done'],
267 'required' => false,
268 'parentId' => null,
269 'defaultValue' => '',
270 'position' => 9,
271 'rows' => 4,
272 ],
273 // Notify Department Head
274 [
275 'id' => 0,
276 'fieldIndex' => 10,
277 'type' => 'checkbox',
278 'label' => BackendStrings::getTemplateStrings()['notify_department_head'],
279 'placeholder' => '',
280 'required' => false,
281 'parentId' => null,
282 'defaultValue' => '',
283 'position' => 10,
284 'fieldOptions' => [
285 [
286 'id' => 0,
287 'label' => BackendStrings::getTemplateStrings()['yes'],
288 'value' => 'yes',
289 'isDefault' => false,
290 'position' => 1,
291 ],
292 [
293 'id' => 0,
294 'label' => BackendStrings::getTemplateStrings()['no'],
295 'value' => 'no',
296 'isDefault' => false,
297 'position' => 2,
298 ],
299 ],
300 ],
301 ];
302 }
303 }
304