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

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

391 lines 13.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 // 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' => 1,
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' => 2,
90 'type' => 'text',
91 'label' => BackendStrings::getNewFormStrings()['first_name'],
92 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
93 'required' => true,
94 'parentId' => 1,
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' => 3,
113 'type' => 'text',
114 'label' => BackendStrings::getNewFormStrings()['last_name'],
115 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
116 'required' => true,
117 'parentId' => 1,
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' => 4,
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' => 5,
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' => 13,
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' => 6,
173 'label' => BackendStrings::getTemplateStrings()['hr'],
174 'value' => 'hr',
175 'isDefault' => false,
176 'position' => 1
177 ],
178 [
179 'id' => 7,
180 'label' => BackendStrings::getTemplateStrings()['it'],
181 'value' => 'it',
182 'isDefault' => false,
183 'position' => 2
184 ],
185 [
186 'id' => 8,
187 'label' => BackendStrings::getTemplateStrings()['marketing'],
188 'value' => 'marketing',
189 'isDefault' => false,
190 'position' => 3
191 ],
192 [
193 'id' => 9,
194 'label' => BackendStrings::getTemplateStrings()['finance'],
195 'value' => 'finance',
196 'isDefault' => false,
197 'position' => 4
198 ],
199 [
200 'id' => 10,
201 'label' => BackendStrings::getTemplateStrings()['sales'],
202 'value' => 'sales',
203 'isDefault' => false,
204 'position' => 5
205 ],
206 [
207 'id' => 11,
208 'label' => BackendStrings::getTemplateStrings()['operations'],
209 'value' => 'operations',
210 'isDefault' => false,
211 'position' => 6
212 ],
213 [
214 'id' => 12,
215 'label' => BackendStrings::getTemplateStrings()['other'],
216 'value' => 'other',
217 'isDefault' => false,
218 'position' => 7
219 ],
220 ]
221 ],
222 // Job Title/Position
223 [
224 'id' => 14,
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' => 15,
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 'dateFieldType' => 'picker',
257 'dateFormat' => 'MM/DD/YYYY',
258 ],
259 // Leave End Date
260 [
261 'id' => 16,
262 'fieldIndex' => 7,
263 'type' => 'date',
264 'label' => BackendStrings::getTemplateStrings()['leave_end_date'],
265 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
266 'required' => true,
267 'parentId' => null,
268 'defaultValue' => '',
269 'position' => 7,
270 'dateFieldType' => 'picker',
271 'dateFormat' => 'MM/DD/YYYY',
272 ],
273 // Total Number of Days
274 [
275 'id' => 17,
276 'fieldIndex' => 8,
277 'type' => 'number',
278 'label' => BackendStrings::getTemplateStrings()['total_number_of_days'],
279 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'],
280 'required' => true,
281 'parentId' => null,
282 'defaultValue' => '',
283 'position' => 8,
284 'minValue' => 1,
285 'maxValue' => 365,
286 ],
287 // Annual Leave Balance
288 [
289 'id' => 18,
290 'fieldIndex' => 9,
291 'type' => 'number',
292 'label' => BackendStrings::getTemplateStrings()['annual_leave_balance'],
293 'placeholder' => BackendStrings::getTemplateStrings()['remaining_leave_days'],
294 'required' => false,
295 'parentId' => null,
296 'defaultValue' => '',
297 'position' => 9,
298 'minValue' => 0,
299 'maxValue' => 365,
300 ],
301 // Reason for Leave
302 [
303 'id' => 19,
304 'fieldIndex' => 10,
305 'type' => 'textarea',
306 'label' => BackendStrings::getTemplateStrings()['reason_for_leave'],
307 'placeholder' => BackendStrings::getTemplateStrings()['briefly_describe_reason'],
308 'required' => false,
309 'parentId' => null,
310 'defaultValue' => '',
311 'position' => 10,
312 ],
313 ];
314 }
315
316 /**
317 * Get approval fields
318 *
319 * @return array<int, array<string, mixed>>
320 */
321 private static function getApprovalFields(): array
322 {
323 return [
324 // Contact During Leave
325 [
326 'id' => 22,
327 'fieldIndex' => 11,
328 'type' => 'radio',
329 'label' => BackendStrings::getTemplateStrings()['contact_during_leave'],
330 'placeholder' => '',
331 'required' => true,
332 'parentId' => null,
333 'defaultValue' => '',
334 'position' => 11,
335 'fieldOptions' => [
336 [
337 'id' => 20,
338 'label' => BackendStrings::getTemplateStrings()['yes'],
339 'value' => 'yes',
340 'isDefault' => false,
341 'position' => 1
342 ],
343 [
344 'id' => 21,
345 'label' => BackendStrings::getTemplateStrings()['no'],
346 'value' => 'no',
347 'isDefault' => false,
348 'position' => 2
349 ],
350 ]
351 ],
352 // Emergency Contact
353 [
354 'id' => 23,
355 'fieldIndex' => 12,
356 'type' => 'text',
357 'label' => BackendStrings::getTemplateStrings()['emergency_contact'],
358 'placeholder' => BackendStrings::getTemplateStrings()['emergency_contact_phone'],
359 'required' => false,
360 'parentId' => null,
361 'defaultValue' => '',
362 'position' => 12,
363 ],
364 // Supervisor Name
365 [
366 'id' => 24,
367 'fieldIndex' => 13,
368 'type' => 'text',
369 'label' => BackendStrings::getTemplateStrings()['supervisor_name'],
370 'placeholder' => BackendStrings::getTemplateStrings()['enter_supervisor_name'],
371 'required' => true,
372 'parentId' => null,
373 'defaultValue' => '',
374 'position' => 13,
375 ],
376 // Backup / Coverage Plan
377 [
378 'id' => 25,
379 'fieldIndex' => 14,
380 'type' => 'textarea',
381 'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'],
382 'placeholder' => BackendStrings::getTemplateStrings()['describe_coverage_arrangements'],
383 'required' => false,
384 'parentId' => null,
385 'defaultValue' => '',
386 'position' => 14,
387 ],
388 ];
389 }
390 }
391