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

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

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