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 / VacationLeaveRequestFormTemplate.php

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

426 lines 16.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 VacationLeaveRequestFormTemplate
13 {
14 /**
15 * Get the vacation leave request form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'vacation_leave_request_form',
23 'name' => BackendStrings::getTemplateStrings()['vacation_leave_request_form'],
24 'description' => BackendStrings::getTemplateStrings()['vacation_leave_request_form_desc'],
25 'category' => 'leave-request',
26 'subcategory' => 'leave-request-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'vacation-leave-request-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['vacation_leave_request_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getEmployeeInformationFields(),
37 self::getLeaveDetailsFields(),
38 self::getApprovalFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Get employee information fields
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getEmployeeInformationFields(): array
51 {
52 return [
53 // Name Field - Parent
54 [
55 'id' => 0,
56 'fieldIndex' => 1,
57 'type' => 'name',
58 'label' => BackendStrings::getTemplateStrings()['full_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_first_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 ],
108 // Department
109 [
110 'id' => 0,
111 'fieldIndex' => 3,
112 'type' => 'select',
113 'label' => BackendStrings::getTemplateStrings()['department'],
114 'placeholder' => BackendStrings::getTemplateStrings()['select_department'],
115 'required' => true,
116 'parentId' => null,
117 'defaultValue' => '',
118 'position' => 3,
119 'fieldOptions' => [
120 [
121 'id' => 0,
122 'label' => BackendStrings::getTemplateStrings()['hr'],
123 'value' => 'hr',
124 'isDefault' => false,
125 'position' => 1
126 ],
127 [
128 'id' => 0,
129 'label' => BackendStrings::getTemplateStrings()['it'],
130 'value' => 'it',
131 'isDefault' => false,
132 'position' => 2
133 ],
134 [
135 'id' => 0,
136 'label' => BackendStrings::getTemplateStrings()['marketing'],
137 'value' => 'marketing',
138 'isDefault' => false,
139 'position' => 3
140 ],
141 [
142 'id' => 0,
143 'label' => BackendStrings::getTemplateStrings()['finance'],
144 'value' => 'finance',
145 'isDefault' => false,
146 'position' => 4
147 ],
148 [
149 'id' => 0,
150 'label' => BackendStrings::getTemplateStrings()['sales'],
151 'value' => 'sales',
152 'isDefault' => false,
153 'position' => 5
154 ],
155 [
156 'id' => 0,
157 'label' => BackendStrings::getTemplateStrings()['operations'],
158 'value' => 'operations',
159 'isDefault' => false,
160 'position' => 6
161 ],
162 [
163 'id' => 0,
164 'label' => BackendStrings::getTemplateStrings()['other'],
165 'value' => 'other',
166 'isDefault' => false,
167 'position' => 7
168 ],
169 ]
170 ],
171 ];
172 }
173
174 /**
175 * Get leave details fields
176 *
177 * @return array<int, array<string, mixed>>
178 */
179 private static function getLeaveDetailsFields(): array
180 {
181 return [
182 // Type of Leave
183 [
184 'id' => 0,
185 'fieldIndex' => 4,
186 'type' => 'select',
187 'label' => BackendStrings::getTemplateStrings()['type_of_leave'],
188 'placeholder' => BackendStrings::getTemplateStrings()['select_type_of_leave'],
189 'required' => true,
190 'parentId' => null,
191 'defaultValue' => '',
192 'position' => 4,
193 'fieldOptions' => [
194 [
195 'id' => 0,
196 'label' => BackendStrings::getTemplateStrings()['annual_leave'],
197 'value' => 'annual_leave',
198 'isDefault' => false,
199 'position' => 1
200 ],
201 [
202 'id' => 0,
203 'label' => BackendStrings::getTemplateStrings()['sick_leave'],
204 'value' => 'sick_leave',
205 'isDefault' => false,
206 'position' => 2
207 ],
208 [
209 'id' => 0,
210 'label' => BackendStrings::getTemplateStrings()['personal_day'],
211 'value' => 'personal_day',
212 'isDefault' => false,
213 'position' => 3
214 ],
215 [
216 'id' => 0,
217 'label' => BackendStrings::getTemplateStrings()['maternity_leave'],
218 'value' => 'maternity_leave',
219 'isDefault' => false,
220 'position' => 4
221 ],
222 [
223 'id' => 0,
224 'label' => BackendStrings::getTemplateStrings()['paternity_leave'],
225 'value' => 'paternity_leave',
226 'isDefault' => false,
227 'position' => 5
228 ],
229 [
230 'id' => 0,
231 'label' => BackendStrings::getTemplateStrings()['study_leave'],
232 'value' => 'study_leave',
233 'isDefault' => false,
234 'position' => 6
235 ],
236 [
237 'id' => 0,
238 'label' => BackendStrings::getTemplateStrings()['family_care_leave'],
239 'value' => 'family_care_leave',
240 'isDefault' => false,
241 'position' => 7
242 ],
243 [
244 'id' => 0,
245 'label' => BackendStrings::getTemplateStrings()['unpaid_leave'],
246 'value' => 'unpaid_leave',
247 'isDefault' => false,
248 'position' => 8
249 ],
250 [
251 'id' => 0,
252 'label' => BackendStrings::getTemplateStrings()['other'],
253 'value' => 'other',
254 'isDefault' => false,
255 'position' => 9
256 ],
257 ]
258 ],
259 // Leave Start Date
260 [
261 'id' => 0,
262 'fieldIndex' => 5,
263 'type' => 'date',
264 'label' => BackendStrings::getTemplateStrings()['leave_start_date'],
265 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
266 'required' => true,
267 'parentId' => null,
268 'defaultValue' => '',
269 'position' => 5,
270 ],
271 // Leave End Date
272 [
273 'id' => 0,
274 'fieldIndex' => 6,
275 'type' => 'date',
276 'label' => BackendStrings::getTemplateStrings()['leave_end_date'],
277 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
278 'required' => true,
279 'parentId' => null,
280 'defaultValue' => '',
281 'position' => 6,
282 ],
283 // Total Number of Days
284 [
285 'id' => 0,
286 'fieldIndex' => 7,
287 'type' => 'number',
288 'label' => BackendStrings::getTemplateStrings()['total_number_of_days'],
289 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'],
290 'required' => false,
291 'parentId' => null,
292 'defaultValue' => '',
293 'position' => 7,
294 'minValue' => 1,
295 'maxValue' => 365,
296 ],
297 // Partial / Full Day
298 [
299 'id' => 0,
300 'fieldIndex' => 8,
301 'type' => 'select',
302 'label' => BackendStrings::getTemplateStrings()['partial_full_day'],
303 'placeholder' => BackendStrings::getTemplateStrings()['select_day_type'],
304 'required' => false,
305 'parentId' => null,
306 'defaultValue' => '',
307 'position' => 7,
308 'fieldOptions' => [
309 [
310 'id' => 0,
311 'label' => BackendStrings::getTemplateStrings()['full_day'],
312 'value' => 'full_day',
313 'isDefault' => false,
314 'position' => 1
315 ],
316 [
317 'id' => 0,
318 'label' => BackendStrings::getTemplateStrings()['half_day_morning'],
319 'value' => 'half_day_morning',
320 'isDefault' => false,
321 'position' => 2
322 ],
323 [
324 'id' => 0,
325 'label' => BackendStrings::getTemplateStrings()['half_day_afternoon'],
326 'value' => 'half_day_afternoon',
327 'isDefault' => false,
328 'position' => 3
329 ],
330 ]
331 ],
332 // Reason / Comments
333 [
334 'id' => 0,
335 'fieldIndex' => 9,
336 'type' => 'textarea',
337 'label' => BackendStrings::getTemplateStrings()['reason_comments'],
338 'placeholder' => BackendStrings::getTemplateStrings()['provide_any_context_or_notes'],
339 'required' => false,
340 'parentId' => null,
341 'defaultValue' => '',
342 'position' => 8,
343 ],
344 ];
345 }
346
347 /**
348 * Get approval fields
349 *
350 * @return array<int, array<string, mixed>>
351 */
352 private static function getApprovalFields(): array
353 {
354 return [
355 // Supervisor Approval Required?
356 [
357 'id' => 0,
358 'fieldIndex' => 10,
359 'type' => 'radio',
360 'label' => BackendStrings::getTemplateStrings()['supervisor_approval_required'],
361 'placeholder' => '',
362 'required' => true,
363 'parentId' => null,
364 'defaultValue' => '',
365 'position' => 9,
366 'fieldOptions' => [
367 [
368 'id' => 0,
369 'label' => BackendStrings::getTemplateStrings()['yes'],
370 'value' => 'yes',
371 'isDefault' => false,
372 'position' => 1
373 ],
374 [
375 'id' => 0,
376 'label' => BackendStrings::getTemplateStrings()['no'],
377 'value' => 'no',
378 'isDefault' => false,
379 'position' => 2
380 ],
381 ]
382 ],
383 // Backup / Coverage Plan
384 [
385 'id' => 0,
386 'fieldIndex' => 11,
387 'type' => 'select',
388 'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'],
389 'placeholder' => BackendStrings::getTemplateStrings()['name_of_colleague_covering_duties'],
390 'required' => false,
391 'parentId' => null,
392 'defaultValue' => '',
393 'position' => 10,
394 'fieldOptions' => [
395 [
396 'id' => 0,
397 'label' => BackendStrings::getComponentsStrings()['option_1'],
398 'value' => 'option1',
399 'isDefault' => false,
400 'position' => 1,
401 ],
402 [
403 'id' => 0,
404 'label' => BackendStrings::getComponentsStrings()['option_2'],
405 'value' => 'option2',
406 'isDefault' => false,
407 'position' => 2,
408 ],
409 ]
410 ],
411 // Additional Notes
412 [
413 'id' => 0,
414 'fieldIndex' => 12,
415 'type' => 'textarea',
416 'label' => BackendStrings::getTemplateStrings()['additional_notes'],
417 'placeholder' => BackendStrings::getTemplateStrings()['any_extra_information'],
418 'required' => false,
419 'parentId' => null,
420 'defaultValue' => '',
421 'position' => 11,
422 ],
423 ];
424 }
425 }
426