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

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