PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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.9, at backend/src/Services/Template/VacationLeaveRequestFormTemplate.php

454 lines 16.2 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' => 1,
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' => 2,
69 'type' => 'text',
70 'label' => BackendStrings::getNewFormStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
72 'required' => true,
73 'parentId' => 1,
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' => 3,
84 'type' => 'text',
85 'label' => BackendStrings::getNewFormStrings()['last_name'],
86 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
87 'required' => true,
88 'parentId' => 1,
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' => 4,
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' => 12,
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' => 5,
122 'label' => BackendStrings::getTemplateStrings()['hr'],
123 'value' => 'hr',
124 'isDefault' => false,
125 'position' => 1
126 ],
127 [
128 'id' => 6,
129 'label' => BackendStrings::getTemplateStrings()['it'],
130 'value' => 'it',
131 'isDefault' => false,
132 'position' => 2
133 ],
134 [
135 'id' => 7,
136 'label' => BackendStrings::getTemplateStrings()['marketing'],
137 'value' => 'marketing',
138 'isDefault' => false,
139 'position' => 3
140 ],
141 [
142 'id' => 8,
143 'label' => BackendStrings::getTemplateStrings()['finance'],
144 'value' => 'finance',
145 'isDefault' => false,
146 'position' => 4
147 ],
148 [
149 'id' => 9,
150 'label' => BackendStrings::getTemplateStrings()['sales'],
151 'value' => 'sales',
152 'isDefault' => false,
153 'position' => 5
154 ],
155 [
156 'id' => 10,
157 'label' => BackendStrings::getTemplateStrings()['operations'],
158 'value' => 'operations',
159 'isDefault' => false,
160 'position' => 6
161 ],
162 [
163 'id' => 11,
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' => 13,
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' => self::getLeaveTypeOptions(8)
194 ],
195 // Leave Start Date
196 [
197 'id' => 14,
198 'fieldIndex' => 5,
199 'type' => 'date',
200 'label' => BackendStrings::getTemplateStrings()['leave_start_date'],
201 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
202 'required' => true,
203 'parentId' => null,
204 'defaultValue' => '',
205 'position' => 5,
206 'dateFieldType' => 'picker',
207 'dateFormat' => 'MM/DD/YYYY',
208 ],
209 // Leave End Date
210 [
211 'id' => 15,
212 'fieldIndex' => 6,
213 'type' => 'date',
214 'label' => BackendStrings::getTemplateStrings()['leave_end_date'],
215 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
216 'required' => true,
217 'parentId' => null,
218 'defaultValue' => '',
219 'position' => 6,
220 'dateFieldType' => 'picker',
221 'dateFormat' => 'MM/DD/YYYY',
222 ],
223 // Total Number of Days
224 [
225 'id' => 16,
226 'fieldIndex' => 7,
227 'type' => 'number',
228 'label' => BackendStrings::getTemplateStrings()['total_number_of_days'],
229 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'],
230 'required' => false,
231 'parentId' => null,
232 'defaultValue' => '',
233 'position' => 7,
234 'minValue' => 1,
235 'maxValue' => 365,
236 ],
237 // Partial / Full Day
238 [
239 'id' => 17,
240 'fieldIndex' => 8,
241 'type' => 'select',
242 'label' => BackendStrings::getTemplateStrings()['partial_full_day'],
243 'placeholder' => BackendStrings::getTemplateStrings()['select_day_type'],
244 'required' => false,
245 'parentId' => null,
246 'defaultValue' => '',
247 'position' => 7,
248 'fieldOptions' => self::getDayTypeOptions(17)
249 ],
250 // Reason / Comments
251 [
252 'id' => 18,
253 'fieldIndex' => 9,
254 'type' => 'textarea',
255 'label' => BackendStrings::getTemplateStrings()['reason_comments'],
256 'placeholder' => BackendStrings::getTemplateStrings()['provide_any_context_or_notes'],
257 'required' => false,
258 'parentId' => null,
259 'defaultValue' => '',
260 'position' => 8,
261 ],
262 ];
263 }
264
265 /**
266 * Get leave type options
267 *
268 * @param int $startId Starting ID for the options
269 *
270 * @return array<int, array<string, mixed>>
271 */
272 private static function getLeaveTypeOptions(int $startId): array
273 {
274 return [
275 [
276 'id' => $startId,
277 'label' => BackendStrings::getTemplateStrings()['annual_leave'],
278 'value' => 'annual_leave',
279 'isDefault' => false,
280 'position' => 1
281 ],
282 [
283 'id' => $startId + 1,
284 'label' => BackendStrings::getTemplateStrings()['sick_leave'],
285 'value' => 'sick_leave',
286 'isDefault' => false,
287 'position' => 2
288 ],
289 [
290 'id' => $startId + 2,
291 'label' => BackendStrings::getTemplateStrings()['personal_day'],
292 'value' => 'personal_day',
293 'isDefault' => false,
294 'position' => 3
295 ],
296 [
297 'id' => $startId + 3,
298 'label' => BackendStrings::getTemplateStrings()['maternity_leave'],
299 'value' => 'maternity_leave',
300 'isDefault' => false,
301 'position' => 4
302 ],
303 [
304 'id' => $startId + 4,
305 'label' => BackendStrings::getTemplateStrings()['paternity_leave'],
306 'value' => 'paternity_leave',
307 'isDefault' => false,
308 'position' => 5
309 ],
310 [
311 'id' => $startId + 5,
312 'label' => BackendStrings::getTemplateStrings()['study_leave'],
313 'value' => 'study_leave',
314 'isDefault' => false,
315 'position' => 6
316 ],
317 [
318 'id' => $startId + 6,
319 'label' => BackendStrings::getTemplateStrings()['family_care_leave'],
320 'value' => 'family_care_leave',
321 'isDefault' => false,
322 'position' => 7
323 ],
324 [
325 'id' => $startId + 7,
326 'label' => BackendStrings::getTemplateStrings()['unpaid_leave'],
327 'value' => 'unpaid_leave',
328 'isDefault' => false,
329 'position' => 8
330 ],
331 [
332 'id' => $startId + 8,
333 'label' => BackendStrings::getTemplateStrings()['other'],
334 'value' => 'other',
335 'isDefault' => false,
336 'position' => 9
337 ],
338 ];
339 }
340
341 /**
342 * Get day type options
343 *
344 * @param int $startId Starting ID for the options
345 *
346 * @return array<int, array<string, mixed>>
347 */
348 private static function getDayTypeOptions(int $startId): array
349 {
350 return [
351 [
352 'id' => $startId,
353 'label' => BackendStrings::getTemplateStrings()['full_day'],
354 'value' => 'full_day',
355 'isDefault' => false,
356 'position' => 1
357 ],
358 [
359 'id' => $startId + 1,
360 'label' => BackendStrings::getTemplateStrings()['half_day_morning'],
361 'value' => 'half_day_morning',
362 'isDefault' => false,
363 'position' => 2
364 ],
365 [
366 'id' => $startId + 2,
367 'label' => BackendStrings::getTemplateStrings()['half_day_afternoon'],
368 'value' => 'half_day_afternoon',
369 'isDefault' => false,
370 'position' => 3
371 ],
372 ];
373 }
374
375 /**
376 * Get approval fields
377 *
378 * @return array<int, array<string, mixed>>
379 */
380 private static function getApprovalFields(): array
381 {
382 return [
383 // Supervisor Approval Required?
384 [
385 'id' => 33,
386 'fieldIndex' => 10,
387 'type' => 'radio',
388 'label' => BackendStrings::getTemplateStrings()['supervisor_approval_required'],
389 'placeholder' => '',
390 'required' => true,
391 'parentId' => null,
392 'defaultValue' => '',
393 'position' => 9,
394 'fieldOptions' => [
395 [
396 'id' => 31,
397 'label' => BackendStrings::getTemplateStrings()['yes'],
398 'value' => 'yes',
399 'isDefault' => false,
400 'position' => 1
401 ],
402 [
403 'id' => 32,
404 'label' => BackendStrings::getTemplateStrings()['no'],
405 'value' => 'no',
406 'isDefault' => false,
407 'position' => 2
408 ],
409 ]
410 ],
411 // Backup / Coverage Plan
412 [
413 'id' => 36,
414 'fieldIndex' => 11,
415 'type' => 'select',
416 'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'],
417 'placeholder' => BackendStrings::getTemplateStrings()['name_of_colleague_covering_duties'],
418 'required' => false,
419 'parentId' => null,
420 'defaultValue' => '',
421 'position' => 10,
422 'fieldOptions' => [
423 [
424 'id' => 34,
425 'label' => BackendStrings::getComponentsStrings()['option_1'],
426 'value' => 'option1',
427 'isDefault' => false,
428 'position' => 1,
429 ],
430 [
431 'id' => 35,
432 'label' => BackendStrings::getComponentsStrings()['option_2'],
433 'value' => 'option2',
434 'isDefault' => false,
435 'position' => 2,
436 ],
437 ]
438 ],
439 // Additional Notes
440 [
441 'id' => 37,
442 'fieldIndex' => 12,
443 'type' => 'textarea',
444 'label' => BackendStrings::getTemplateStrings()['additional_notes'],
445 'placeholder' => BackendStrings::getTemplateStrings()['any_extra_information'],
446 'required' => false,
447 'parentId' => null,
448 'defaultValue' => '',
449 'position' => 11,
450 ],
451 ];
452 }
453 }
454