PluginProbe
The Innovative Form Builder – IvyForms / 0.8.2
The Innovative Form Builder – IvyForms v0.8.2
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 / AnnualLeaveRequestFormTemplate.php

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

387 lines 13.1 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 AnnualLeaveRequestFormTemplate
13 {
14 /**
15 * Get the annual leave request form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'annual_leave_request_form',
23 'name' => BackendStrings::getTemplateStrings()['annual_leave_request_form'],
24 'description' => BackendStrings::getTemplateStrings()['annual_leave_request_form_desc'],
25 'category' => 'leave-request',
26 'subcategory' => 'leave-request-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'annual-leave-request-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['annual_leave_request_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => self::getFormFields(),
36 'settings' => []
37 ]
38 ];
39 }
40
41 /**
42 * Get all form fields
43 *
44 * @return array<int, array<string, mixed>>
45 */
46 private static function getFormFields(): array
47 {
48 return array_merge(
49 [
50 self::getNameField(),
51 self::getFirstNameField(),
52 self::getLastNameField(),
53 ],
54 self::getEmployeeDetailsFields(),
55 self::getLeaveDetailsFields(),
56 self::getApprovalFields()
57 );
58 }
59
60 /**
61 * Get name field (parent)
62 *
63 * @return array<string, mixed>
64 */
65 private static function getNameField(): array
66 {
67 return [
68 'id' => 0,
69 'fieldIndex' => 1,
70 'type' => 'name',
71 'label' => BackendStrings::getTemplateStrings()['full_name'],
72 'parentId' => null,
73 'defaultValue' => '',
74 'placeholder' => '',
75 'required' => true,
76 'readonly' => false,
77 'position' => 1,
78 ];
79 }
80
81 /**
82 * Get first name field (child of name field)
83 *
84 * @return array<string, mixed>
85 */
86 private static function getFirstNameField(): array
87 {
88 return [
89 'id' => 0,
90 'type' => 'text',
91 'label' => BackendStrings::getNewFormStrings()['first_name'],
92 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
93 'required' => true,
94 'parentId' => 0,
95 'fieldIndex' => 1,
96 'defaultValue' => '',
97 'position' => 1,
98 'optionHide' => false,
99 'description' => '',
100 'settings' => json_encode(['nameFieldType' => 'nameField1']),
101 ];
102 }
103
104 /**
105 * Get last name field (child of name field)
106 *
107 * @return array<string, mixed>
108 */
109 private static function getLastNameField(): array
110 {
111 return [
112 'id' => 0,
113 'type' => 'text',
114 'label' => BackendStrings::getNewFormStrings()['last_name'],
115 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
116 'required' => true,
117 'parentId' => 0,
118 'fieldIndex' => 1,
119 'defaultValue' => '',
120 'position' => 2,
121 'optionHide' => false,
122 'description' => '',
123 'settings' => json_encode(['nameFieldType' => 'nameField2']),
124 ];
125 }
126
127 /**
128 * Get employee details fields
129 *
130 * @return array<int, array<string, mixed>>
131 */
132 private static function getEmployeeDetailsFields(): array
133 {
134 return [
135 // Email Address
136 [
137 'id' => 0,
138 'fieldIndex' => 2,
139 'type' => 'email',
140 'label' => BackendStrings::getTemplateStrings()['email_address'],
141 'placeholder' => '[email protected]',
142 'required' => true,
143 'parentId' => null,
144 'defaultValue' => '',
145 'position' => 2,
146 ],
147 // Employee ID
148 [
149 'id' => 0,
150 'fieldIndex' => 3,
151 'type' => 'text',
152 'label' => BackendStrings::getTemplateStrings()['employee_id'],
153 'placeholder' => BackendStrings::getTemplateStrings()['enter_employee_id'],
154 'required' => true,
155 'parentId' => null,
156 'defaultValue' => '',
157 'position' => 3,
158 ],
159 // Department
160 [
161 'id' => 0,
162 'fieldIndex' => 4,
163 'type' => 'select',
164 'label' => BackendStrings::getTemplateStrings()['department'],
165 'placeholder' => BackendStrings::getTemplateStrings()['select_department'],
166 'required' => true,
167 'parentId' => null,
168 'defaultValue' => '',
169 'position' => 4,
170 'fieldOptions' => [
171 [
172 'id' => 0,
173 'label' => BackendStrings::getTemplateStrings()['hr'],
174 'value' => 'hr',
175 'isDefault' => false,
176 'position' => 1
177 ],
178 [
179 'id' => 0,
180 'label' => BackendStrings::getTemplateStrings()['it'],
181 'value' => 'it',
182 'isDefault' => false,
183 'position' => 2
184 ],
185 [
186 'id' => 0,
187 'label' => BackendStrings::getTemplateStrings()['marketing'],
188 'value' => 'marketing',
189 'isDefault' => false,
190 'position' => 3
191 ],
192 [
193 'id' => 0,
194 'label' => BackendStrings::getTemplateStrings()['finance'],
195 'value' => 'finance',
196 'isDefault' => false,
197 'position' => 4
198 ],
199 [
200 'id' => 0,
201 'label' => BackendStrings::getTemplateStrings()['sales'],
202 'value' => 'sales',
203 'isDefault' => false,
204 'position' => 5
205 ],
206 [
207 'id' => 0,
208 'label' => BackendStrings::getTemplateStrings()['operations'],
209 'value' => 'operations',
210 'isDefault' => false,
211 'position' => 6
212 ],
213 [
214 'id' => 0,
215 'label' => BackendStrings::getTemplateStrings()['other'],
216 'value' => 'other',
217 'isDefault' => false,
218 'position' => 7
219 ],
220 ]
221 ],
222 // Job Title/Position
223 [
224 'id' => 0,
225 'fieldIndex' => 5,
226 'type' => 'text',
227 'label' => BackendStrings::getTemplateStrings()['job_title_position'],
228 'placeholder' => BackendStrings::getTemplateStrings()['enter_job_title'],
229 'required' => false,
230 'parentId' => null,
231 'defaultValue' => '',
232 'position' => 5,
233 ],
234 ];
235 }
236
237 /**
238 * Get leave details fields
239 *
240 * @return array<int, array<string, mixed>>
241 */
242 private static function getLeaveDetailsFields(): array
243 {
244 return [
245 // Leave Start Date
246 [
247 'id' => 0,
248 'fieldIndex' => 6,
249 'type' => 'date',
250 'label' => BackendStrings::getTemplateStrings()['leave_start_date'],
251 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
252 'required' => true,
253 'parentId' => null,
254 'defaultValue' => '',
255 'position' => 6,
256 ],
257 // Leave End Date
258 [
259 'id' => 0,
260 'fieldIndex' => 7,
261 'type' => 'date',
262 'label' => BackendStrings::getTemplateStrings()['leave_end_date'],
263 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
264 'required' => true,
265 'parentId' => null,
266 'defaultValue' => '',
267 'position' => 7,
268 ],
269 // Total Number of Days
270 [
271 'id' => 0,
272 'fieldIndex' => 8,
273 'type' => 'number',
274 'label' => BackendStrings::getTemplateStrings()['total_number_of_days'],
275 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'],
276 'required' => true,
277 'parentId' => null,
278 'defaultValue' => '',
279 'position' => 8,
280 'minValue' => 1,
281 'maxValue' => 365,
282 ],
283 // Annual Leave Balance
284 [
285 'id' => 0,
286 'fieldIndex' => 9,
287 'type' => 'number',
288 'label' => BackendStrings::getTemplateStrings()['annual_leave_balance'],
289 'placeholder' => BackendStrings::getTemplateStrings()['remaining_leave_days'],
290 'required' => false,
291 'parentId' => null,
292 'defaultValue' => '',
293 'position' => 9,
294 'minValue' => 0,
295 'maxValue' => 365,
296 ],
297 // Reason for Leave
298 [
299 'id' => 0,
300 'fieldIndex' => 10,
301 'type' => 'textarea',
302 'label' => BackendStrings::getTemplateStrings()['reason_for_leave'],
303 'placeholder' => BackendStrings::getTemplateStrings()['briefly_describe_reason'],
304 'required' => false,
305 'parentId' => null,
306 'defaultValue' => '',
307 'position' => 10,
308 ],
309 ];
310 }
311
312 /**
313 * Get approval fields
314 *
315 * @return array<int, array<string, mixed>>
316 */
317 private static function getApprovalFields(): array
318 {
319 return [
320 // Contact During Leave
321 [
322 'id' => 0,
323 'fieldIndex' => 11,
324 'type' => 'radio',
325 'label' => BackendStrings::getTemplateStrings()['contact_during_leave'],
326 'placeholder' => '',
327 'required' => true,
328 'parentId' => null,
329 'defaultValue' => '',
330 'position' => 11,
331 'fieldOptions' => [
332 [
333 'id' => 0,
334 'label' => BackendStrings::getTemplateStrings()['yes'],
335 'value' => 'yes',
336 'isDefault' => false,
337 'position' => 1
338 ],
339 [
340 'id' => 0,
341 'label' => BackendStrings::getTemplateStrings()['no'],
342 'value' => 'no',
343 'isDefault' => false,
344 'position' => 2
345 ],
346 ]
347 ],
348 // Emergency Contact
349 [
350 'id' => 0,
351 'fieldIndex' => 12,
352 'type' => 'text',
353 'label' => BackendStrings::getTemplateStrings()['emergency_contact'],
354 'placeholder' => BackendStrings::getTemplateStrings()['emergency_contact_phone'],
355 'required' => false,
356 'parentId' => null,
357 'defaultValue' => '',
358 'position' => 12,
359 ],
360 // Supervisor Name
361 [
362 'id' => 0,
363 'fieldIndex' => 13,
364 'type' => 'text',
365 'label' => BackendStrings::getTemplateStrings()['supervisor_name'],
366 'placeholder' => BackendStrings::getTemplateStrings()['enter_supervisor_name'],
367 'required' => true,
368 'parentId' => null,
369 'defaultValue' => '',
370 'position' => 13,
371 ],
372 // Backup / Coverage Plan
373 [
374 'id' => 0,
375 'fieldIndex' => 14,
376 'type' => 'textarea',
377 'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'],
378 'placeholder' => BackendStrings::getTemplateStrings()['describe_coverage_arrangements'],
379 'required' => false,
380 'parentId' => null,
381 'defaultValue' => '',
382 'position' => 14,
383 ],
384 ];
385 }
386 }
387