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

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

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