PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/Services/Template/VacationLeaveRequestFormTemplate.php +162 -124 0.7 → 1.5 View file →
@@ -1,23 +1,18 @@
1 1 <?php
2 2
3 3 namespace IvyForms\Services\Template;
4 4
5 -// phpcs:disable PSR1.Files.SideEffects
6 -if (!defined('ABSPATH')) {
7 - exit; // Exit if accessed directly
8 -}
9 -
10 5 use IvyForms\Services\Translations\BackendStrings;
11 6
12 7 class VacationLeaveRequestFormTemplate
13 8 {
14 9 /**
15 - * Get the vacation leave request form template
10 + * Get template metadata (without form_data)
16 11 *
17 12 * @return array<string, mixed>
18 13 */
19 - public static function getTemplate(): array
14 + public static function getTemplateMeta(): array
20 15 {
21 16 return [
22 17 'id' => 'vacation_leave_request_form',
23 18 'name' => BackendStrings::getTemplateStrings()['vacation_leave_request_form'],
@@ -22,10 +17,24 @@
22 17 'id' => 'vacation_leave_request_form',
23 18 'name' => BackendStrings::getTemplateStrings()['vacation_leave_request_form'],
24 19 'description' => BackendStrings::getTemplateStrings()['vacation_leave_request_form_desc'],
25 20 'category' => 'leave-request',
21 + 'subcategory' => 'leave-request-forms',
26 22 'is_pro' => false,
27 - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'vacation-leave-request-form.svg',
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 + [
28 37 'form_data' => [
29 38 'name' => BackendStrings::getTemplateStrings()['vacation_leave_request_form'],
30 39 'published' => 1,
31 40 'showTitle' => 1,
@@ -37,9 +46,10 @@
37 46 self::getApprovalFields()
38 47 ),
39 48 'settings' => []
40 49 ]
41 - ];
50 + ]
51 + );
42 52 }
43 53
44 54 /**
45 55 * Get employee information fields
@@ -50,9 +60,9 @@
50 60 {
51 61 return [
52 62 // Name Field - Parent
53 63 [
54 - 'id' => 0,
64 + 'id' => 1,
55 65 'fieldIndex' => 1,
56 66 'type' => 'name',
57 67 'label' => BackendStrings::getTemplateStrings()['full_name'],
58 68 'parentId' => null,
@@ -63,14 +73,14 @@
63 73 'position' => 1,
64 74 ],
65 75 // First Name - Child of Name Field
66 76 [
67 - 'id' => 0,
77 + 'id' => 2,
68 78 'type' => 'text',
69 79 'label' => BackendStrings::getNewFormStrings()['first_name'],
70 80 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
71 81 'required' => true,
72 - 'parentId' => 0,
82 + 'parentId' => 1,
73 83 'fieldIndex' => 1,
74 84 'defaultValue' => '',
75 85 'position' => 1,
76 86 'optionHide' => false,
@@ -78,14 +88,14 @@
78 88 'settings' => json_encode(['nameFieldType' => 'nameField1']),
79 89 ],
80 90 // Last Name - Child of Name Field
81 91 [
82 - 'id' => 0,
92 + 'id' => 3,
83 93 'type' => 'text',
84 94 'label' => BackendStrings::getNewFormStrings()['last_name'],
85 95 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
86 96 'required' => true,
87 - 'parentId' => 0,
97 + 'parentId' => 1,
88 98 'fieldIndex' => 1,
89 99 'defaultValue' => '',
90 100 'position' => 2,
91 101 'optionHide' => false,
@@ -93,9 +103,9 @@
93 103 'settings' => json_encode(['nameFieldType' => 'nameField2']),
94 104 ],
95 105 // Email Address
96 106 [
97 - 'id' => 0,
107 + 'id' => 4,
98 108 'fieldIndex' => 2,
99 109 'type' => 'email',
100 110 'label' => BackendStrings::getTemplateStrings()['email_address'],
101 111 'placeholder' => '[email protected]',
@@ -105,9 +115,9 @@
105 115 'position' => 2,
106 116 ],
107 117 // Department
108 118 [
109 - 'id' => 0,
119 + 'id' => 12,
110 120 'fieldIndex' => 3,
111 121 'type' => 'select',
112 122 'label' => BackendStrings::getTemplateStrings()['department'],
113 123 'placeholder' => BackendStrings::getTemplateStrings()['select_department'],
@@ -116,9 +126,9 @@
116 126 'defaultValue' => '',
117 127 'position' => 3,
118 128 'fieldOptions' => [
119 129 [
120 - 'id' => 0,
130 + 'id' => 5,
121 131 'label' => BackendStrings::getTemplateStrings()['hr'],
122 132 'value' => 'hr',
123 133 'isDefault' => false,
124 134 'position' => 1
@@ -123,9 +133,9 @@
123 133 'isDefault' => false,
124 134 'position' => 1
125 135 ],
126 136 [
127 - 'id' => 0,
137 + 'id' => 6,
128 138 'label' => BackendStrings::getTemplateStrings()['it'],
129 139 'value' => 'it',
130 140 'isDefault' => false,
131 141 'position' => 2
@@ -130,9 +140,9 @@
130 140 'isDefault' => false,
131 141 'position' => 2
132 142 ],
133 143 [
134 - 'id' => 0,
144 + 'id' => 7,
135 145 'label' => BackendStrings::getTemplateStrings()['marketing'],
136 146 'value' => 'marketing',
137 147 'isDefault' => false,
138 148 'position' => 3
@@ -137,9 +147,9 @@
137 147 'isDefault' => false,
138 148 'position' => 3
139 149 ],
140 150 [
141 - 'id' => 0,
151 + 'id' => 8,
142 152 'label' => BackendStrings::getTemplateStrings()['finance'],
143 153 'value' => 'finance',
144 154 'isDefault' => false,
145 155 'position' => 4
@@ -144,9 +154,9 @@
144 154 'isDefault' => false,
145 155 'position' => 4
146 156 ],
147 157 [
148 - 'id' => 0,
158 + 'id' => 9,
149 159 'label' => BackendStrings::getTemplateStrings()['sales'],
150 160 'value' => 'sales',
151 161 'isDefault' => false,
152 162 'position' => 5
@@ -151,9 +161,9 @@
151 161 'isDefault' => false,
152 162 'position' => 5
153 163 ],
154 164 [
155 - 'id' => 0,
165 + 'id' => 10,
156 166 'label' => BackendStrings::getTemplateStrings()['operations'],
157 167 'value' => 'operations',
158 168 'isDefault' => false,
159 169 'position' => 6
@@ -158,9 +168,9 @@
158 168 'isDefault' => false,
159 169 'position' => 6
160 170 ],
161 171 [
162 - 'id' => 0,
172 + 'id' => 11,
163 173 'label' => BackendStrings::getTemplateStrings()['other'],
164 174 'value' => 'other',
165 175 'isDefault' => false,
166 176 'position' => 7
@@ -179,9 +189,9 @@
179 189 {
180 190 return [
181 191 // Type of Leave
182 192 [
183 - 'id' => 0,
193 + 'id' => 13,
184 194 'fieldIndex' => 4,
185 195 'type' => 'select',
186 196 'label' => BackendStrings::getTemplateStrings()['type_of_leave'],
187 197 'placeholder' => BackendStrings::getTemplateStrings()['select_type_of_leave'],
@@ -188,77 +198,13 @@
188 198 'required' => true,
189 199 'parentId' => null,
190 200 'defaultValue' => '',
191 201 '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 - ]
202 + 'fieldOptions' => self::getLeaveTypeOptions(8)
257 203 ],
258 204 // Leave Start Date
259 205 [
260 - 'id' => 0,
206 + 'id' => 14,
261 207 'fieldIndex' => 5,
262 208 'type' => 'date',
263 209 'label' => BackendStrings::getTemplateStrings()['leave_start_date'],
264 210 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
@@ -265,12 +211,14 @@
265 211 'required' => true,
266 212 'parentId' => null,
267 213 'defaultValue' => '',
268 214 'position' => 5,
215 + 'dateFieldType' => 'picker',
216 + 'dateFormat' => 'MM/DD/YYYY',
269 217 ],
270 218 // Leave End Date
271 219 [
272 - 'id' => 0,
220 + 'id' => 15,
273 221 'fieldIndex' => 6,
274 222 'type' => 'date',
275 223 'label' => BackendStrings::getTemplateStrings()['leave_end_date'],
276 224 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
@@ -277,12 +225,14 @@
277 225 'required' => true,
278 226 'parentId' => null,
279 227 'defaultValue' => '',
280 228 'position' => 6,
229 + 'dateFieldType' => 'picker',
230 + 'dateFormat' => 'MM/DD/YYYY',
281 231 ],
282 232 // Total Number of Days
283 233 [
284 - 'id' => 0,
234 + 'id' => 16,
285 235 'fieldIndex' => 7,
286 236 'type' => 'number',
287 237 'label' => BackendStrings::getTemplateStrings()['total_number_of_days'],
288 238 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'],
@@ -294,9 +244,9 @@
294 244 'maxValue' => 365,
295 245 ],
296 246 // Partial / Full Day
297 247 [
298 - 'id' => 0,
248 + 'id' => 17,
299 249 'fieldIndex' => 8,
300 250 'type' => 'select',
301 251 'label' => BackendStrings::getTemplateStrings()['partial_full_day'],
302 252 'placeholder' => BackendStrings::getTemplateStrings()['select_day_type'],
@@ -303,35 +253,13 @@
303 253 'required' => false,
304 254 'parentId' => null,
305 255 'defaultValue' => '',
306 256 '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 - ]
257 + 'fieldOptions' => self::getDayTypeOptions(17)
330 258 ],
331 259 // Reason / Comments
332 260 [
333 - 'id' => 0,
261 + 'id' => 18,
334 262 'fieldIndex' => 9,
335 263 'type' => 'textarea',
336 264 'label' => BackendStrings::getTemplateStrings()['reason_comments'],
337 265 'placeholder' => BackendStrings::getTemplateStrings()['provide_any_context_or_notes'],
@@ -343,8 +271,118 @@
343 271 ];
344 272 }
345 273
346 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 + /**
347 385 * Get approval fields
348 386 *
349 387 * @return array<int, array<string, mixed>>
350 388 */
@@ -352,9 +390,9 @@
352 390 {
353 391 return [
354 392 // Supervisor Approval Required?
355 393 [
356 - 'id' => 0,
394 + 'id' => 33,
357 395 'fieldIndex' => 10,
358 396 'type' => 'radio',
359 397 'label' => BackendStrings::getTemplateStrings()['supervisor_approval_required'],
360 398 'placeholder' => '',
@@ -363,9 +401,9 @@
363 401 'defaultValue' => '',
364 402 'position' => 9,
365 403 'fieldOptions' => [
366 404 [
367 - 'id' => 0,
405 + 'id' => 31,
368 406 'label' => BackendStrings::getTemplateStrings()['yes'],
369 407 'value' => 'yes',
370 408 'isDefault' => false,
371 409 'position' => 1
@@ -370,9 +408,9 @@
370 408 'isDefault' => false,
371 409 'position' => 1
372 410 ],
373 411 [
374 - 'id' => 0,
412 + 'id' => 32,
375 413 'label' => BackendStrings::getTemplateStrings()['no'],
376 414 'value' => 'no',
377 415 'isDefault' => false,
378 416 'position' => 2
@@ -380,9 +418,9 @@
380 418 ]
381 419 ],
382 420 // Backup / Coverage Plan
383 421 [
384 - 'id' => 0,
422 + 'id' => 36,
385 423 'fieldIndex' => 11,
386 424 'type' => 'select',
387 425 'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'],
388 426 'placeholder' => BackendStrings::getTemplateStrings()['name_of_colleague_covering_duties'],
@@ -391,9 +429,9 @@
391 429 'defaultValue' => '',
392 430 'position' => 10,
393 431 'fieldOptions' => [
394 432 [
395 - 'id' => 0,
433 + 'id' => 34,
396 434 'label' => BackendStrings::getComponentsStrings()['option_1'],
397 435 'value' => 'option1',
398 436 'isDefault' => false,
399 437 'position' => 1,
@@ -398,9 +436,9 @@
398 436 'isDefault' => false,
399 437 'position' => 1,
400 438 ],
401 439 [
402 - 'id' => 0,
440 + 'id' => 35,
403 441 'label' => BackendStrings::getComponentsStrings()['option_2'],
404 442 'value' => 'option2',
405 443 'isDefault' => false,
406 444 'position' => 2,
@@ -408,9 +446,9 @@
408 446 ]
409 447 ],
410 448 // Additional Notes
411 449 [
412 - 'id' => 0,
450 + 'id' => 37,
413 451 'fieldIndex' => 12,
414 452 'type' => 'textarea',
415 453 'label' => BackendStrings::getTemplateStrings()['additional_notes'],
416 454 'placeholder' => BackendStrings::getTemplateStrings()['any_extra_information'],