PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.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 / RepairWorkOrderFormTemplate.php

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

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